Almost all my websites point to a domain of mine where I host a helpdesk software. This is used instead of maintaining several “contact us” forms. This is a great way to streamline your communications and makes it easy for customers as well. The helpdesk is hosted on a domain name referencing my business name and therefore works for all my websites and I do not need to customize it. I am using Intellodesk as my helpdesk software. It was up to date when I bought it, but development has stalled since then and the software has a bug. This bug allows tickets to be submitted without being registered. Of course spammers figured that out and I am getting 10+ tickets a day filled with porn SPAM. Intellodesk is encoded software and so I cannot make any changes to it. I submitted a ticket to the maker and they offered to install captcha image verification for me, but that was the last thing I heard. No response and no action from them. Since I am not ready to spend $30 on Kayako (my next choice) eSupport Software I am kinda stuck.

So, I came up with a small (inconvenient) workaround. I moved the helpdesk to a different directory and installed a new page in the root directory. From there the visitor is asked to enter a captcha security code and then continue. If the code input fails I am logging the IP addresses of the visitors and will then enter them into my .htaccess files. If they succeed entering the code they can access the helpdesk and open a ticket. I figured if somebody really wants to contact me, the will have no problems completing this initial step – even though it is inconvenient.I also updated my robots.txt file to exclude the entire site from being spidered. Since this is my helpdesk I don’t need it in Google or Yahoo. I know this is not perfect, but for the time being the best thing in my opinion.

This also gave me the opportunity to refresh some of my PHP knowledge. I used a pre-existing script for the captcha and then modded it to do the extra IP address logging. Now IP addresses are dynamically inserted into the .htaccess file and spammers are banned. I am using session based information and upon 3rd try the IP address goes into the .htaccess. The code snippet to dynamically update an .htaccess file looks like this:


$ip = getenv(’REMOTE_ADDR’);
$handle = fopen(”../.htaccess”, “a”);
fwrite($handle, “Deny from $ip\n”);
echo “The IP Address $ip has banned from this domain due to SPAM.”;
mail(””, “Banned IP”, “Deny from $i”);

You can use this code for many other pieces and that makes it so interesting. Grab the referrer information for keyword or website that brought the visitor to your website and do something with it. Normal web statistic programs like AWStats do a good job, but it just does not tell you which keyword lead the visitor to which webpage of yours. You would need to do a lot of digging yourself to check search engines and rankings to gather that information. Now instead of piping that information into an email (like the example above does), dump it into a database or text file. We are going to use the HTTP_REFERRER variable for this. What is HTTP_REFERRER?

‘HTTP_REFERER’ = The address of the page (if any) which referred the user agent to the current page.

The following code snippet would display the keyword the user came of from Google in your PHP-based web page. Replace the “echo” line with what ever you want to do with the information (email, database, etc.). Register_Globals needs to be enabled on your server for this to work.

if(strpos($_SERVER[’HTTP_REFERER’], “”) !== false) {
$keyword = array_pop(explode(”&q=”, $referer));

Have fun getting better keyword information from your website.