Wednesday, April 23, 2008

TUTOS - Blank Screen When You Add A New Bug

So I love TUTOS so far, except I encountered a bug when I entered a bug. I found the solution in their forum, but it was after searching google for a while with no luck I was about to post something for help when I noticed a post which had the answer.

Go into php/bugtracking/ folder.
edit bug.pinc

line 880 something...
$mail->resetBody();
change to
$mail->resetBodies();

delete all the echo or debugging information throughout the mess you have made trying to fix this.
Thats it!!

Labels: , , , , , , , , ,

Thursday, April 17, 2008

How to setup Mailman List Administration on a different Port

This is just a really quick set of commands that I needed to use in order to fix my mailman html administration to work on another port. My mailman installation is on ubuntu (debian), so your locations might be different.

I needed mine to work on port other than 80 so this is what I dug up after some research:
In your mailman config file (/etc/mailman/mm_cfg.py):
search and replace the port in the Default URL Pattern:


DEFAULT_URL_PATTERN = 'http://%s:8080/mailman/'
(the 8080 represents the port you would like to use,
so if you are using a different port, plug it in there)
Use a program like vi in your ssh connection or you use webmin, edit this file in the file editor.
I would also recommend checking these settings if they are not already there:
# Max recipients for each message
SMTP_MAX_RCPTS = 4
# Max messages sent in each SMTP connection
SMTP_MAX_SESSIONS_PER_CONNECTION = 30

I had to change these to work properly with my isp host as mailman was sending too many recipients per message and it ended up bouncing.

Ok, now save your file.

You will notice that this will not change any of your current administrative pages and it will unfortunately still end up giving you the old urls (without the port you need).

To fix this you can use this little session I saved to remind myself what I did (it took me a while to find the location, but)...
> cd /var/lib/mailman/bin
> /withlist -l -r fix_url mailman
bash: /withlist: No such file or directory
> ./withlist -l -r fix_url mailman
Importing fix_url...
Running fix_url.fix_url()...
Loading list mailman (locked)
Finalizing
Saving list
> /etc/init.d/mailman force-reload Mailman
* Restarting Mailman master qrunner mailmanctl
...done.
Voila! Now you should be able to reload those pages and see the changes: your urls should include the port that you need.

Labels: , , , , , , , , , , , , , , , , , , ,

Sunday, April 13, 2008

Sendmail SMTP Smarthost Authentication with Alternate Port

Wow, so this project took me almost all weekend to complete. I am trying to get a maillist server running to also power a mailman installation. I tried to use my virtual private server, it overwhelmed it and my server started having issues; although I have finally deduced a great optimization of those settings (which I still have to post at some point).


In any case I have to credit this page with helping me most of the way; but I think I might have missed something or perhaps it is missing a small be key entry. In any case, I will provide you with my exact files (Without the domains).

This installation was done on ubuntu.

Configuring a smarthost for sendmail

To configure a smarthost (with authentication) for sendmail, you'll have to create a file called /etc/mail/auth/client-info and modify the file /etc/mail/sendmail.mc.

Configure authentication

Create the directory /etc/mail/auth/ if it doesn't exist. Then create the file /etc/mail/auth/client-info. The content in of this file represents your login credentials for the smarthost. It should look like the example below:

AuthInfo: "U:username" "I:email" "P:password"

Where:

  • is the fully qualified domain name (fqdn) of your smarthost
  • is the userid used to login at the smarthost (often your email address)
  • is the account to be used for your smarthost (often your email address as well)
  • is the password that belongs to your smarthost username

Here is an Auth File example: client-info.zip

Next, you'll have to build the password hash database with this command:

sudo bash -c "cd /etc/mail/auth/ && makemap hash client-info <> 

Configure sendmail

Now you have prepared the authentication setup for the concerning smarthost,
let's go on and configure sendmail to use this smarthost. To do so, please edit the
file /etc/mail/sendmail.mc. Find the line starting with MAILER_DEFINITIONS in this
file and insert the lines before this line:

define(`SMART_HOST',`relay:smtp.yourisp.com')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo', `hash /etc/mail/auth/client-info')dnl
I also had to add these lines to get mine to work (not part of the original article).

# "Smart" relay host (may be null)
define(`RELAY_MAILER_ARGS',`TCP $h 587')dnl
DSsmtp.smarthost.net

The key addition that I made to the article is the DS entry. Without this entry, the actual
forwarding did now work.

Now use the M4 macro processor to translate the /etc/mail/sendmail.mc file into a format
sendmail understands (/etc/mail/sendmail.cf). This can be taken out by:

sudo bash -c "cd /etc/mail/ && m4 sendmail.mc > sendmail.cf"

This is an example of what mine looks like. I use it to effectively relay all sendmail delivery
via my isp's authenticated smarthost on port 587. You can use webmin to effectively copy and
paste this. I am also including a zip file, but you would have to search through it extensively
- I don't recommend it.

divert(-1)dnl
divert(0)dnl
define(`_USE_ETC_MAIL_')dnl
include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
VERSIONID(`$Id: sendmail.mc, v 8.14.1-8ubuntu1 2007-08-01 05:06:30 cowboy Exp $')dn1
OSTYPE(`debian')dnl
DOMAIN(`debian-mta')dnl
undefine(`confHOST_STATUS_DIRECTORY')dnl #DAEMON_HOSTSTATS=
FEATURE(`no_default_msa')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Name=MTAv4,Port=smtp,Family=inet')
DAEMON_OPTIONS(`Name=MSPv4,Port=submission,Family=inet')
define(`confPRIVACY_FLAGS', `authwarnings,needmailhelo,noexpn,novrfy')dnl
define(`confCONNECTION_RATE_THROTTLE', `15')dnl
define(`confCONNECTION_RATE_WINDOW_SIZE',`10m')dnl
FEATURE(`access_db', , `skip')dnl
FEATURE(`relay_hosts_only')dnl
FEATURE(`use_cw_file')dnl
FEATURE(`greet_pause', `1000')dnl
FEATURE(`delay_checks', `friend', `n')dnl
define(`confBAD_RCPT_THROTTLE',`3')dnl
FEATURE(`conncontrol', `nodelay', `terminate')dnl
FEATURE(`ratecontrol', `nodelay', `terminate')dnl
dnl define(`confCON_EXPENSIVE',`True')dnl
include(`/etc/mail/m4/dialup.m4')dnl
include(`/etc/mail/m4/provider.m4')dnl
FEATURE(`relay_hosts_only')dnl
define(`RELAY_MAILER_ARGS',`TCP $h 587')dnl
define(`SMART_HOST',`relay:smtp.smarthost.net')dnl
# "Smart" relay host (may be null)
DSsmtp.smarthost.net
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo', `hash /etc/mail/auth/client-info')dnl
FEATURE(`always_add_domain')dnl
MASQUERADE_AS(`yourdomain.net')dnl
GENERICS_DOMAIN(`yourdomain.net')dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl
MAILER(`local')dnl
MAILER(`smtp')dnl

here is an example config file


Note: What to do if no authentication needed?
In case no authentication is needed or necessary in your smarthost setup.
This how-to can be used as well. In that case, just simply skip the paragraph
Configure authentication
and only add the line define(`SMART_HOST', )dnl
to the /etc/mail/sendmail.mc file. All the rest of the how-to applies as well.




To prevent sendmail from sending messages for local recipients through the smarthost,
you'll have to tell sendmail which domains are locally processed. This can be done by
inserting all local domains in the file /etc/mail/local-host-names, like in the example below:

localhost
mylocaldomain.com
myotherlocaldomain.com

Of course, the domains mylocaldomain.com and myotherlocaldomain.com need
to be replaced by your actual local domains.

Now, again this file /etc/mail/local-host-names needs to be translated into a format
sendmail understands. Us the make command to do so, like shown below:

sudo bash -c "cd /etc/mail && make"

Restart sendmail and check the configuration

To make sure your configuration is all right, restart sendmail
To restart sendmail, use this command:

sudo /etc/init.d/sendmail restart

sudo bash -c "cd /etc/mail/auth/ && makemap hash client-info <>

sudo bash -c "cd /etc/mail/ && m4 sendmail.mc > sendmail.cf"


/etc/init.d/sendmail reload


this solved the following problems for me
Apr 13 23:20:07 ubu sendmail[8640]: m3E6K5Rq008640: from=, size=1221, class=0, nrcpts=1, msgid=<027201c89db4$0287afa0$6402a8c0@experience>, proto=SMTP, daemon=MTAv4, relay=[192.168.2.100]
Apr 13 23:20:07 ubu sendmail[8659]: m3E6K5Rq008640: to=, ctladdr= (1000/1000), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=121221, relay=64.202.165.58, dsn=5.1.2, stat=Host unknown (Name server: 64.202.165.58: host not found)

(reason: 550 Host unknown)

550 5.1.2
Host unknown (Name server: 64.202.165.58: host not found)
Host unknown (Name server: 64.202.165.58: host not found)



If you have gone through all of this and you still cannot figure out what is wrong, try going to your /etc folder and find nswitch.conf
this is what mine looks like:
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
#hosts: dns files mdns4_minimal mdns4 [NOTFOUND=return]

passwd: compat
group: compat
shadow: compat

hosts: dns [NOTFOUND=continue] files
ipnodes: dns [NOTFOUND=continue] fileshosts: dns [NOTFOUND=continue] files
networks: files

protocols: db files
services: db files
ethers: db files
rpc: db files

netgroup: nis


and your /etc/resolv.conf file should look like (with your own nameservers/dns servers)
nameserver 68.87.69.146
nameserver 68.87.85.98
nameserver 192.168.2.1
sendmail.zip

Labels: , , , , , , , , , , , ,

Thursday, April 3, 2008

Error: No space left on device - PHP, IIS, Win2K3

Today I went to upload on one of my client's sites and realized that the uploads were not working.

After looking at the directories and permissions to ensure that they were not deleted, I went back to see that the directories that were suppposed to be created with each upload where not being created.

I went to turn error reporting on the php script:

error_reporting(7);

this error appeared on the IIS 6, Windows 2k3 Box.

Warning: mkdir() [function.mkdir]: No space left on device in E:\Domains\www.domainname.com\html\upload_new.php on line 75

I checked and there was enough space left on the device. I moved the upload to different drive and that seemed to work. But no matter what I did on the upload directory permissions wise, I was still receiving the same error.

After going crazy for a while, I found a post online that could be very helpful in debugging if my post does not solve your problem.

It ended up being that the IUSER_XXXXX ran out of space for their disk quota and was not being allowed to write to the disk. There are a few ways that you can fix this, but I don't need quota's turned on for this machine and I don't care if they go over the quota, so I chose to just turn the enforcement off. You could easily delete files to go back under quota or raise the users quota.

You can change your quota rules by going to your volume or drive (e: in my case) and right clicking and selecting properties. There you can see a quota tab. There are a few options here (which I will not get into), but to fix the problem you can easily just click a checkbox which will stop the system from enforcing quota rules (it will stop disabling people if they go over the quota). Likewise, you can change your quota limitations on this screen.

If you find this useful, please digg me, link me, or click on a sponser for which you find legitimate interest.

Labels: , , , , , , , , ,

Wednesday, April 2, 2008

Zip Codes Database Table MySQL Export (2006 version with Latitude & Longitude)

As I had promised to myself and a few others. Here is a 2006 Zip Codes Database MySQL Export with latitude and longitude coordinates.

I had been looking for a zip radius solution for one of my projects and I ran into micah's zip code class online. The class is very nicely done; and I am very grateful for people like him who share their work with the world.

But I did notice that the database table for zip codes being used was a bit outdated; I tried to find a mysql export, or as I like to childishly snicker "dump", with the 2006 zip code public data I had found online. I could not find one readily, so I offered some time to transfer the data to a mysql friendly format that would work with micah's solution (If you would like examples on how I made a zip radius search with Micah's class just let me know!).

It is late and I still have much else to do. I have been able to transfer the data, but I do not have time to break it up into 5 mysql files. If you are kind enough to do so, please send me a zip and I will post it here. Thanks for reading. If you would like to support me, please link me, digg me, or perhaps click on one of the sponsors of which you find legitimate interest.

Without further ado, here is the zip code table export.
zip_codes_2006.zip

Labels: , , , , , , , , , ,

Sunday, March 30, 2008

Subtotal Not Adding Up Correctly in PHP (with Items over 1000)

I am on a few list serves and occasionally I am able to get a few of the questions answered. I will post some of them on my blog occassionally in case you run into the same issues. In this case, one of my fellow programmers ran into an issue where his subtotals where not adding up properly. I had run into the same issue myself. Just read below. It is simply a matter or recognizing that your variable might be formatted to display with a comma, such as 1,432.12


----- Original Message -----
From: Matt
To: List
Cc: Mauricio
Sent: Sunday, March 30, 2008 11:48 PM
Subject: Re: it it a php bug? or am i just slow?

That was it!!

apparently the ',' was settype()ing it on the fly as a string, so when it came to the += it was evaluating wrong..

Many thanks Mauricio!

Mauricio Zuniga - Systems Engineer wrote:
also,
even though you are giving us the values,
could it be possible that you have your number formatted with a comma?
such as 1,321.43.
I once ran into an issue where my subtotals were not correct because of this...
----- Original Message -----
From:
To:
Cc:
Sent: Sunday, March 30, 2008 10:29 PM
Subject: Re: it it a php bug? or am i just slow?

I set up the following loop:
$item_price = 0;
$items = array(50, 100, 1357);
foreach ($items as $v) {
$item_price += $v;
echo "
$item_price";
}
and it gave the following output:
50
150
1507
which is what was expected.

Could you post the actual loop code you are using? Perhaps there is something there we can help with?

Daniel

Mattwrote:
Not sure if this is a bug in PHP, or if I'm just especially slow...

I've got a script that's calculating the total order for items in a cart. To do this it's doing a simple += on the variable $subtotal as it prints each row on the cart page, then it prints $subtotal in the appropriate spot at the end. So on its way through the loop that prints each row, right at the end of the loop it does:

$subtotal += $item_price;

Simple, straight forward, not a problem.

It works perfectly fine. IF the value of $item_price <= 999.99 (?!??!!!?!?!?!?)

Anything >= 1000.00 and it adds 1 to subtotal, not the $itemprice. (?!?!?!?)

I've echoed $item_price and $subtotal while the loop is printing, I get results as below:

// first iteration
echo $item_price; // 50.00
echo $subtotal; // 50.00

// second iteration
echo $item_price; // 100.00
echo $subtotal; // 150.00

// so far, so good, right?

// third iteration
echo $item_price; // 1357.00
echo $subtotal; // 151.00

/// what??

// fourth iteration
echo $item_price; // 100.00
echo $subtotal; // 251.00


Any ideas? The only option I've considered so far is chucking every computer in the house out the damn window and becoming a carpenter, but I'm still on the fence about that.


-M.E.


--
_________________________________________



--
_________________________________________




Labels: , , , , , , , , , , , ,

Friday, March 28, 2008

How to Take a Video Screen Capture in Jing and Send it to Youtube.com

Wow, what a painstacking process this was!
It took me so long that I decided to write a blog entry about it while I am waiting for the conversion.

Here are the ingredients that I used to capture my screen and get it on youtube for sharing.

I went to jingproject.com by techsmith which is my favorite free screen capture tool (and I hope that it stays that way).

When you download and install this program you can then easily create screen videos of whatever you do. Simply talk over what you are doing while recording to create a video. You have a maximum time of 5 minutes and you can pause the video while recording.

It takes a little getting used to, but there is no editing available in jing as of this post. That is ok, we have ways to get around that for now. I personally used Sothink SWF Quicker to edit my SWF file for places where I needed to blank out sensitive information.

I could not figure out anything else I could do with this software, although my intention was to somehow edit it to fix the ending. Regardless... its good enough. This whole process is taking me longer than I would like anyway.

I also found a free flash to video encoder to then get my swf file to a youtube friendly format. I chose mpg as I know this should be small. Now be ready to wait at least 15-25 minutes. You can specify how the length of the conversion (ie you may cut some of the end of the video... wow which is exactly what I wanted to do since I somehow added 10 minutes of nothing at the end while messing with it in the previous program!) But please note that the demo version for the converter I downloaded actually ended up putting up some real annoying ads over the conversion. I would not mind in most cases, but it bounces around in the most annoying fashion all over the screen. Oh well- if I find a better tool, I will post it here. For now, at least I have my video on youtube!

Now that you know how... you should be ready to take your video and upload that baby!

By the way, I recently found out the sothink has a swf to video conversion tool which is much better than the one that i originally used. All the software mentioned here has at least a 30 day trial limit.

Labels: , , , , , , , , , , , , , ,