Archive for the ‘Website building’ Category

Phoload interview

Monday, December 1st, 2008

phoload main pagePhoload is a new website where you can download free mobile software. Here is our interview with Phoload CEO Jamie McDonald.

What is phoload?

Phoload showcases free-to-download mobile games and applications that have been uploaded directly to the site by software developers. Users of the website can download, rate, review and recommend the software. We’re hoping to build a community around the software, with participation from both users and developers.

What does the name ‘phoload’ mean?

Contrary to some articles about us, it has nothing to do with ‘pho’ noodles! It is an amalgam of ‘phone’ and ‘download’. We wanted a name that was short, snappy and did not have many existing search results. We also rather liked the aesthetic appearance of the letters.

Why did you decide to create phoload?

We’ve been mobile software enthusiasts for a long time, but I think it is only in the last few years that we have seen the emergence of a whole raft of startups and individuals creating free-to-download location based mobile apps, mobile social networks, and messaging software. We wanted to create a site that made discovering and downloading all this fantastic new mobile software as easy and enjoyable as possible for users.

What are the most popular downloads?

As of today, the most popular download on Phoload is amazeGPS, which is a mobile satnav application. In our top ten we also have another mapping application, a language translator, a music player, a scientific calculator, a couple of apps that interface to various information feeds, as well as several games. I think that the top ten really shows the diversity of mobile software available today.

Which phones are people downloading software onto?

Principally, Nokia, Sony Ericcson, Samsung and Blackberry phones (in that order of popularity). The most popular phones are almost all smartphones or other high end phones, with the most popular phone with Phoload users being the Nokia N95. Since launching support for Android last week, we’ve also seen a large number of T-Mobile G1s browsing and downloading software from the site.

What are your mobile software predictions for 2009?

I don’t think we are going to see anything revolutionary in 2009, just a continuation of the trends that have already started. That is to say, increasing usage and awareness of mobile software, increasing smartphone adoption, and the increasing popularity of mobile social networks and location based applications. I also think that the Android platform has a bright future. It certainly has enthused the developer community.

What technology is behind the site?

Phoload is written in Java. We use the excellent Stripes web framework, and Hibernate for mapping our Java objects to the database. As Phoload is a read-mostly site, we do a lot of caching using Ehcache both as a Hibernate second level cache, and for caching frequently accessed results that have been detached from Hibernate.

How is the site hosted?

On a dedicated server in Dallas in the US. We host with an excellent New Zealand based company called RimuHosting.

What challenges did you face in getting the site launched?

From a development perspective, the toughest challenge was creating a mobile software distribution system that handles the device fragmentation (especially in J2ME devices) in the best possible way. The system had to make it as easy as possible for developers to upload, and specify phone compatibilities for, multiple versions of a single item of software, while masking this complexity from users. I think that we have done well in this area.

Another challenge was sourcing the initial portfolio of mobile software, which was a lot of work. We spent many hours searching for and emailing developers.

What strategies have you used to get people to visit your site?

To promote the site, we started by emailing mobile industry and news site blogs, telling them about Phoload. We’ve found that this strategy has worked pretty well and we’re pleased with the press that we have received so far. We also try to promote Phoload by promoting the software on the site, highlighting relevant software to bloggers, and to users on forums etc. etc.

A search on Google for ‘phoload’ on currently gives 11200 results, how did you manage to get mentioned on so many web pages?

First of all, I think Google might be exaggerating a little, as when you click through to the last page of search results, there are actually far fewer results. But, there are still plenty, and I think one of the reasons for this is the blog coverage that I previously mentioned. Many of articles written about Phoload have been syndicated all over the web, so this accounts for a lot of results. These articles also prompt follow up articles and interviews, so there is a large ripple effect there.

How is the site funded?

We are self-funded.

What are your plans for monetizing the site?

We don’t plan to have any software sales on the site. We want to keep it purely focused on free-to-download software. Eventually, we’ll put some non-intrusive ads on the site. We’ll probably do this once our hosting costs start increasing.

Why should developers give their software away for free on this site?

phoload atomic
Primarily, developers will gain users and publicity. We hope to provide an excellent service to developers, and those who upload their software receive pages showcasing their products on the site, regular download reports, and feedback from the user community.

Also, we don’t just accept freeware, we also accept ad-supported and demo/trial software, and demo software can be associated with a purchase link to an external website.

How did you find the initial mobile software for the site?

On the whole, we used Google. We scoured the internet searching for mobile software that we liked and then contacted the developers of the software directly to ask if they would like to upload their software to Phoload.

What kind of testing do you do on the submitted software?

If it’s compatible with a phone we have, we’ll give it a try and report any feedback we have to the developer. However, we don’t make any guarantees to our users that the software has been tested.

Currently you support J2ME. Are there plans to offer software for written in other languages – e.g. Symbian, Android?

Yes, we launched Android support on the site last week and are really pleased with the amount of traffic the Android section of Phoload has received so far. We plan to add support for more software platforms soon, starting with Symbian.

Where do you want the site will be in one years time?

Hopefully, Phoload will be established as one of the best places to download and discuss the latest free mobile software. Also, by then, we will support all of the major mobile software platforms.

And finally can you give us a few tips for anyone setting up a new website of their own?

I think that virtually everything, from starting the company, sorting out the legal documents, contacting developers, and of course developing the site, took longer than we anticipated. So, I would encourage people to be realistic about how much time everything takes.

One specific mistake we made was with regard to search engine optimisation. I think if you anticipate that you will receive most of your traffic from search engines, then you have to think deeply about this from the start and during the whole design process. We thought we had done this (with search engine friendly urls etc.), but we still found that we received duplicate results in the Google index due to session IDs creeping into the urls unnecessarily, and both the and domains being indexed separately. We’ve fixed these issues now but wish we had fully addressed them before launch.

Thanks for your time.
You can visit Phoload at

Are your website and blog earnings at risk?

Wednesday, August 20th, 2008

There are a lot of websites out there telling you how you can make money out of your website or blog. You may have decided to try some of these ideas to make some money out of your web presence. Perhaps you even rely on your web-generated money for a significant slice of your income. If you have then have you ever analysed how secure this income is?

Let’s look at a five such risk factors.

Relying on a single income stream

Like many sites out there you may use Google AdSense. It is quite likely that it is responsible for most / all of your web income. Just imagine if that income suddenly stopped!

Is this likely? Well, if you read the many AdSense forums out there it seems that there is certainly a chance of this happening to you. Many people wake up to find an email from Google in their inbox to tell them that their AdSense account has been terminated. The usual reasons for this include either click fraud (clicking on your own ads), or not obeying the AdSense terms and conditions.

Unfortunately a lot of people seem to be getting banned through no fault of their own. This usually seems to be as a result of their site being ‘click bombed’. In other words other people deliberately click on loads of the adverts in order to get the site banned.

This kind of account termination could happen with any kind of income programme that you use. I’m just using AdSense as an example as there are a lot of documented cases of people having their accounts banned.

To protect yourself from this you should use a variety of income generating programmes.

If you can you should construct your website in such a way that you can easily switch from one programme to another if you should become banned from one. This also has the advantage that if one programme proves to be a better earner than another, you can switch more of your site to the higher earning one.

Relying on one main traffic source

Another risk factor is related to where your traffic comes from. If most of your traffic comes from one source then you are at risk. As an example it wouldn’t surprise me if 80% of your traffic came from Google. Let’s imagine that next week they introduce a major search algorithm update which sends your site plummeting in the rankings. You could suddenly find that you have hardly any traffic!

Other risks include having your site identified as a spam site and being penalised in the rankings or even dropped.

Mitigating the risk involves looking at where your traffic comes from and working to get visitors from more sources. For instance getting links on related websites, or getting coverage in other search engines.

This particular risk can be very hard to reduce due to the dominance of Google. Your best defence could well be to keep in Google’s good books. Simply sake sure that your site complies with their webmaster guidelines and you should be ok.

Having just one website

All websites go through highs and lows. Sometimes there will be an obvious reason. Your Christmas related website is unlikely to do well in the Summer. Other times you may not be able to work out why your traffic goes up and down.

With only a single site you are susceptible to these kind of changes. In general if your traffic goes down then so does your earnings. If you have multiple sites then it more likely you will be sheltered from the peaks and troughs as when one site decreases in popularity another site may be rising.

You can think of it like having a balance portfolio of investments. You wouldn’t invest all your money on the stock market would you? If you were sensible you’d probably spread your money through a mixture of stocks, property, and cash accounts.

Having just one web host

Another kind of risk comes from using just one web host. Think for example what would happen if they went bust? All your sites could disappear in an instant. You may then find it quite hard to get your domains back. Even when you do you may find that you have lost all your search engine rankings, links and visitors.

It can happen – about 10 years ago I lost a domain of mine when my host went bust. It was very inconvenient.

To reduce the risk first be careful about who you trust to host your website and domain names. Don’t go for a company that looks in any way financially unstable.

The second more extreme risk reduction strategy is to use multiple web hosts. This is only really relevant if you have multiple sites. If you have two hosts then you can spread your sites between them. Of course you may now have double the chance of one of your hosts going bust, but at least you aren’t in a all or nothing situation like you were before.

Forgetting to renew your domains

Keep a careful record of which domains you own and when they need to be renewed. Hopefully your host will automatically renew them for you. If they do then make sure that they have your up to date credit / debit card details.

Good hosting companies will re-register the domain even if they don’t have the correct payment information from you. Not so good hosting companies will release expired domains back into the wild. This can be disastrous as someone else can then quite legitimately register your domain. They will then inherit all your traffic, links and search engine placements. There could be no way for you to get it back.


You may notice a theme throughout all my risks. They are mostly about removing the single point of failure to spread the risk. Whenever you rely on just one factor you are at risk of losing everything if that factor should change.

Stay safe, and spread that risk around!

Batch processing photos with DOS and ImageMagick

Thursday, August 7th, 2008

For my recent walking project I knew I was going to be taking lots of photos. I wanted a DOS script which would batch process the JPEG photos from my camera into the ‘full sized images’ (which are much smaller than the raw camera images), and the poloroid-like thumbnails.

The excellent ImageMagick tool provides a way to generate poloroid-like thumbnails automatically. I also wanted the thumbnails to be rotated at random angles which ImageMagick can do as well.

However the ImageMagick instructions were missing a few things 1) they seem to be aimed at people using Unix / Linux scripts whereas I’m using DOS scripts and 2) they show how to do this processing on single images rather than on a whole directory of them.

Poloroid rotation with ImageMagick Poloroid rotation with ImageMagick

It is quite easy to generate a random rotation angle with a simple bit of perl. The below line will generate a random floating point number between -7 and +7. I want both negative and positive numbers so that some of the poloroids will be tilted to the left, and others to the right.

perl -e "print rand() * 14 - 7"

I wanted to do all the processing through a DOS batch file so the next problem was how to get the random number into a DOS environmental variable. The answer is to use the ‘for /f‘ command to assign the output of a command into a variable:

for /f %%i in ('perl -e "print rand() * 14 - 7"') do set ANGLE=%%i

At the time when I wrote this script generating a poloroid involved a whole sequence of commands. Something like below!

-bordercolor white -border 6 -bordercolor grey60 -border 1 -background none -rotate %ANGLE% -background black ( +clone -shadow 60x4+4+4 ) +swap -background white -flatten

My script still uses this long poloroid command, but you might want to use the new one word ‘poloroid‘ command which is built straight into the latest versions of ImageMagick instead.

As well as generating the poloroid thumbnails it will also generate the full size website friendly images which are tagged with the website URL.

Your JPEG images are in an ‘images’ directory.

ProcessPhotos.bat [path of directory that contains ‘images’ directory]

A new directory called ‘generated’ in the input directory containing a full size image (which has been tagged with the website URL), and a poloroid thumbnail.

In order to use this script you will have to customise 1) the location of the ImageMagick executable 2) the reference to the drive – it is assuming a ‘f:’ drive here and 3) the website URL.

pushd .
goto :skip_functions
	echo %1
	set jpg=%1
	set jpg=%jpg:~0,-4%
	echo %jpg%
	for /f %%i in ('perl -e "print rand() * 14 - 7"') do set ANGLE=%%i
	set ANNOTATE=-gravity south -stroke "#000C" -strokewidth 2 -annotate +0+20 "" -stroke none -fill white -annotate +0+20 ""
	set POLOROID=-bordercolor white -border 6 -bordercolor grey60 -border 1 -background none -rotate %ANGLE% -background black ( +clone -shadow 60x4+4+4 ) +swap -background white -flatten
	D:appsImageMagick-6.3.6-Q16convert %1 ( +clone -resize 600x -auto-orient %ANNOTATE% -compress JPEG -quality 70 -write %jpg%_full.jpg +delete ) -resize 180x -auto-orient %POLOROID% -compress JPEG -quality 80 -sampling-factor 2x1 -strip %jpg%_th.jpg
goto :EOF
cd %1images
for /f %%i in ('dir /b *.jpg') do call :makeThumb %%i
md %1generated
move *_full.jpg ..generated
move *_th.jpg ..generated

AdSense Injection WordPress plugin tweaks

Thursday, July 24th, 2008

Update 7th December 2010: Use the new Ad Injection plugin for WordPress instead as it will do what these tweaks do, and more.

On this blog I use the Adsense Injection plugin to automatically add Google’s targeted AdSense adverts to my posts. The plugin is excellent and has helped to make more money for this site but there are a few tweaks that I have done.

First, I’ve made a modification so that if a individual post page is shorter than a certain number of characters then the number of adverts is limited to one.

Second, I’ve made a change so instead of looking for ‘<p’ tags to use as AdSense insertion points it looks for the full paragraph tag – ‘<p>’. The reason I did this is because I often include code in my posts in <pre> tags and the AdSense plugin code was inserting adverts in my source code snippets which looked wrong. After making this change the adverts only appear in the text of my posts.

Both sets of changes are shown in the code below. You can simply replace the ai_the_content() function in version 2.0 of the plugin with this version.

function ai_the_content($content){
  global $doing_rss;
  if(is_feed() || $doing_rss)
    return $content;
  if(strpos($content, "<!--noadsense-->") !== false) return $content;
  if(is_home() && get_option('ai_home') == "checked=on") return $content;
  if(is_page() && get_option('ai_page') == "checked=on") return $content;
  if(is_single() && get_option('ai_post') == "checked=on") return $content;
  if(is_category() && get_option('ai_cat') == "checked=on") return $content;
  if(is_archive() && get_option('ai_archive') == "checked=on") return $content;
  global $ai_adsused, $user_level;
  if(get_option('ai_betatest') == "yes" && $user_level < 8)
    return $content;
  if(get_option('ai_notme') == "yes" && $user_level > 8)
    return $content;
  # RML: backup content
  $original_content = $content;
  $numads = get_option('ai_nads');
    $numads = get_option('ai_nadspp');
  $content_hold = "";
  if(strpos($content, "<!--adsensestart-->") !== false){
    $content_hold = substr($content, 0, strpos($content, "<!--adsensestart-->"));
    $content = substr_replace($content, "", 0, strpos($content, "<!--adsensestart-->"));
  while($ai_adsused < $numads)
    $poses = array();
    $lastpos = -1;
    # RML: change <p to <p> to stop ads before <pre>
    $repchar = "<p>";
    if(strpos($content, "<p>") === false)
      $repchar = "<br";
    while(strpos($content, $repchar, $lastpos+1) !== false){
      $lastpos = strpos($content, $repchar, $lastpos+1);
      $poses[] = $lastpos;
    //cut the doc in half so the ads don't go past the end of the article.  It could still happen, but what the hell
    $half = sizeof($poses);
    $adsperpost = $ai_adsused+1;
      $half = sizeof($poses)/2;
    while(sizeof($poses) > $half)
    $pickme = $poses[rand(0, sizeof($poses)-1)];
    $replacewith = ai_pickalign(get_option('ai_lra'));
    $replacewith .= ai_genadcode()."</div>";
    # RML: remove hardcoded length
    $content = substr_replace($content, $replacewith.$repchar, $pickme, strlen($repchar));
    # RML: if content is short then limit to one advert
    if(strlen($original_content) < 2500) return $content_hold.$content;
  return $content_hold.$content;

Using a common form mail script for multiple websites

Thursday, June 12th, 2008

I run a number of different websites. Most of them have a contact page which is powered by a form mail script. Until recently each of these websites used an almost identical copy of the same form mail script – I use PHPFormMail but you could adapt this solution for other form mail scripts. Each contact us page has very similar HTML in it. I wanted a way of sharing a common form script and wanted to avoid the duplicated HTML without losing the individual styling of each contact us page.

For this to work for you you’ll need:

  1. All your websites to be on a single host. The code on this page is what I used on my 1and1 hosting account, but the solution should be similar for other web hosts.
  2. To be allowed to use .htaccess files.
  3. Have enough technical knowledge to understand what I’m saying and to customise this for your own site. I’ll give you enough information to implement this, but only if you have enough understanding of knowledge of HTML, PHP and .htaccess files.

On my web server I use one directory for each domain. I map my domain names to directories like this:    ->   /advancedhtml-web/    ->   /reviewmylife-web/ ->   /interrail-web/

You’ll note that it is not possible to access the root of my web hosting account ‘/’ from the web.

I’ve added a common directory to store the form mail script and the form HTML. This directory is not accessible from any web address. I’ll explain the contents of the later on.


The formmail.php is my usual PHPFormMail script.

I then set up a global variable in a .htaccess file in the root of my web server. This .htaccess file is not accessible to any of my website visitors but it is processed.

The contents of the .htaccess look like the below snippet. You’ll need to replace the /kunden… part with the path of your own common directory.

SetEnv COMMON_PATH /kunden/homepages/25/dxxxxxxx/htdocs/common

If you don’t know what your web server path looks like create a file called ‘test.php’ with the following contents – <?PHP phpinfo(); ?> and then load file from your browser. You can use this test.php to verify that your new environmental variable is present. Below is my
<form method="post" action="commonformmail.php">
<table width="80%" cellpadding="0" cellspacing="0">
  <td><font face="arial">Name</font></td>
  <td><p><input type="text" name="name"></p></td>
  <td><font face="arial">Email</font></td>
  <td><p><input type="text" name="email"></p></td>
  <td><font face="arial">Subject</font></td>
  <td><p><input type="text" name="subject"></p></td>
  <td><font face="arial">Message</font></td>
  <td><p><textarea name="message" rows="15" cols="45"></textarea></p></td>
  <td><p><input type="submit" name="Submit" value="Send"></p></td>
<input type="hidden" name="redirect" value="thanks.htm"></p>
<input type="hidden" name="recipient" value="commonmail">
print "<input type="hidden" name="referer" value="" . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] . "">n";
<input type="hidden" name="env_report"

Look at the PHPFormMail documentation for information about the redirect, recipient and env_report fields. You’ll note that I have added a referer field so that I’ll know which of my websites this form was posted from. The value of the recipient field has to be present in the PHPFormMail $recipient_array. If your contact page is a .html rather than a .php you’ll have to make sure that you can use PHP in HTML files.

In your contact us/email HTML file you can include the form like this:

include_once($_SERVER['REDIRECT_COMMON_PATH'] . '/');

The final part of the solution is to add a commonformmail.php to each of your individual website directories. It will look like this and just includes the shared form mail script.

include_once($_SERVER['REDIRECT_COMMON_PATH'] . '/formmail.php');

From now on you can change the behaviour and look of all your website forms from one place.

Hidden field spam trap for PHPFormMail

Friday, May 30th, 2008

If you have a form mail script on your website you may find that you reguarly recieve automated spam to your email account. Even worse it is possible that spammers may use your form mail script to send spam to other people.

One well known method of significantly reducing (or even stopping) spam without having any impact on your website visitor is to add a hidden field to your form. Real human visitors will not see this field and leave it blank. Automated spam scripts will fill it in. You can therefore easily tag or reject any emails that have this hidden field filled in. This method of stopping spam has been talked about on many other blogs – for example on modernblue, and horizonweb.

I’m not going to explain the technique in depth – you can read about it on the above links. I’m just going to show you how to apply this form of spam protection if you are using the PHPFormMail script.

You will need to add an entry to your style sheet to hide the spam trapping field. I use two fields with similar names – one to display a field as normal and one to hide a field. I suggest you use different names to me to make it less likely that spam scripts will work around this trap.

div#formstyle1 { display: inline; }
div#formstyle2 { display: none; visibility: hidden; }

In blue you can see where I have added the spam trap field next to the usual message field.

<td><font face="arial">Message</font></td>
<div id="formstyle1">
  <textarea name="message" rows="10" cols="40"></textarea>
<div id="formstyle2">
  <p>Please leave the following field blank: </p><input type="text" name="spamtrap">

There are two things I can do in the PHPFormMail script if spam is detected (i.e. if the spamtrap field is not empty). I can either tag the email with a [spam?] tag, or I can reject it.

I have commented out the ’email rejection’ lines so the below modification will tag the email. If you want to enable the ’email rejection’ then you can simply uncomment the relevant two lines.

function send_mail()
	global $form, $invis_array, $valid_env, $fieldname_lookup, $errors;
	$email_replace_array = "r|n|to:|cc:|bcc:";
	### Anti-spam: start - reject email ###
	#if (($form['spamtrap']) != '')
	#	return true;
	### Anti-spam: end                  ###
	if (!isset($form['subject']))
			$form['subject'] = 'WWW Form Submission';
	if (isset($form['subject_prefix']))
			$form['subject'] = $form['subject_prefix'] . $form['subject'];
	if (!isset($form['email']))
			$form['email'] = '';
	### Anti-spam: start - tag email ###
	if (($form['spamtrap']) !='' )
			$form['subject'] = '[SPAM?]: ' . $form['subject'];
	### Anti-spam: end               ###
	switch ($form['mail_newline']) {
		case 2:		$mail_newline = "r";
		case 3:		$mail_newline = "rn";

Since applying these changes to my various sites, the script has caught all the formmail spam that I was previously getting.

If you do decide to adopt these changes then make sure you test them carefully – first try testing with the spam trap field visible, before making it invisible. I’d also suggest that you adjust the field and style sheet names to make it harder for spammers to bypass.

Custom error pages on 1and1 when HTML files are set as PHP types

Monday, May 26th, 2008

A long time ago I set up custom error pages on my 1&1 hosted websites. However recently I noticed that they had stopped working. When a 404 error occured, instead of redirecting to my error page I got an advert filled parking page.

1and1 error page

I re-checked their instructions for setting up the error pages on their FAQ and I was pretty sure that I was setting the pages up correctly.

After spending over an hour trying to figure out what was going wrong I stumbled on the ‘Empty Parking Pages’ link on the Domain Overview in their Administration control panel. You can see the position of this link in the red box.

1and1 admin page

On this page is the option to turn off their ‘Empty Parking Pages’. I turned this option off – it then took a few minutes for the change to be visible on my website.

1and1 empty pages parking

Part of the message says:

When using this service, a page from our webserver will be displayed instead. Unless, of course, you have set up your own error message.

Now instead of getting the advert filled parking page I got a plain:

Error 404 – Not found
Your browser can’t find the document corresponding to the URL you typed in.

It is better than before but it is still not my error message!

It seemed the only way I could get correctly working error files is to create files with the following file names in your site’s root directory – ‘error400.html’, ‘error403.html’, ‘error404.html’ and ‘error500.html’. No entry in the .htaccess file is needed – 1&1 automatically picks these files up as your error pages.

So why weren’t the ErrorDocument lines in my .htaccess working?

In my .htaccess file I also have the following line:
AddType x-mapp-php4 .html .htm

This line allows PHP code to be processed from .htm and .html files. If I remove this line then my ErrorDocument lines start working. It therefore seems that 1and1 have configured their servers so that you can only errors generated when you try to access static pages will cause the ErrorDocument directive to be used. Usually .html and .htm are static, however my AddType line in the .htaccess changed them into dynamic pages.

I removed .html from the AddType line. After doing this the ErrorDocument worked for .html files but not for .htm.

After all this I have deduced the following:

  1. If you want to get rid of the advert filled parking pages you need to use the control panel.
  2. If you configure your 1&1 .htaccess file to allow PHP in .htm and .html then the ErrorDocument line won’t work for any missing .htm or .html files. However the ErrorDocument will work for non-PHP files types.
  3. The ErrorDocument directive will never work for .php file types as these are always registered as being PHP types.
  4. The only way to get working error files for all types of errors is to create ‘error400.html’, ‘error403.html’, ‘error404.html’ and ‘error500.html’ files.

Final tip

In the 1&1 FAQ on creating error pages they give three suggestion for creating custom error pages:

  1. Using ErrorDocument in .htaccess (which only works for static document types).
  2. Adding the errorXXX.html error pages (which does work for all document types).
  3. Adding the below code to your .htaccess.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /errordocument.html

I would suggest that you don’t add this to your .htaccess! This redirects any 404 ‘not found’ errors to the errordocument.html webpage. This causes a 200 error code to be returned rather than a 404 error code. This is a bad idea as it could cause search engines to end up indexing all the error pages on your website.

Quick Claiming your blog on Technorati without giving up your password

Friday, May 16th, 2008

Today I had a go at claiming my blogs on Technorati. Claiming your blog gives you a bit more control over how your blog appears on the Technorati site. You can edit the blog description, add a user image and add tags.

In order to claim your blog you must prove that you own it. There are two ways to do this; Quick Claim or Post Claim. Post Claim involves writing a new post with a visible tag in it. I didn’t really fancy doing this. The other method is Quick Claim. To Quick Claim you need to enter your blog username and password. Technorati will then log into your blog to check that you are the owner. This option sounded like less hassle but I didn’t want to give them my real password. They say that they don’t store it but I think it is best not to take any chances.

technorati blog claim

What I decided to do was to create a new temporary user for the purposes of claiming my blog. After it was claimed I could delete it. Here’s how to do it using a self hosted WordPress blog. Something similar will probably work for other blog software.

In your WordPress control panel go to Users->Authors & Users. Then add a new user. Use a different password to your usual one. You’ll need to give your new user the Administrator role. I tried with the other roles but Technorati won’t accept anything less than an Admin account.

wordpress add new user

I then went back to the Technorati website entered my temporary admin user details and it worked!

technorati blog claim

Once your blog is claimed remember to delete your temporary user – but take care – don’t accidently delete yourself my mistake!

Improved KML embedding of Google Maps into web pages

Sunday, December 23rd, 2007

I’ve been further improving the code that I described in my previous in my previous post – ‘Adding KML Google Maps overlays to WordPress posts‘.

I’ve made these changes:

  1. Option to specify a latitude / longitude / zoom for the map. This allows you to have one map and then show lots of different views of it
  2. The code is now implemented as a function rather than as included PHP. This means that the full map can be included in one line of PHP and the code only has to be included once in each page.

As before you can include a whole map which will be automatically centred and zoomed for you. The require_once is only needed once on each page, but no harm will come to you if it is included more than once. Only one argument is needed – the full URL to the KML file. A width / height can be included if you want.


In the require_once you can either include an absolute path or a relative path.

View Larger Map
The new options allow you to specify the latitude, longitude and zoom values. When you specify these values you also have to specify the width / height of the map. The argument list is:

  1. Full URL of KML – note this is the full URL not a relative one
  2. Width of map – in pixels
  3. Height of map – in pixels
  4. Latitude
  5. Longitude
  6. Zoom
	450, 400, "51.515339", "-0.054374", 15);

View Larger Map
To get the latitude / longitude / zoom values view your KML file in Google Maps. Click on ‘Link to this page’ as described in the previous post. Alter the zoom and position of the map so it shows that you want. Then copy the latitude / longitude / zoom values from the HTML box. The latitude / longitude are the values in the ‘ll’ parameter (latitude is first). The zoom is the ‘z’ parameter.

So if we are looking at the following page in Google Maps.

Getting latitude, longitude, and zoom values from Google Maps

The latitude is 51.49966, the longitude is -0.053108 and the zoom is 16.

Here are the three files you’ll need.


You can see a demonstration of these scripts at Here I have one KML file for my whole walking route, but I include multiple zoomed-in views of the map so I can describe the route in small sections.

For these scripts to work they’ll need to be interpreted as PHP4 rather than PHP5. If your web host is interpreting PHP files as PHP5 by default (which more and more of them are) simply put these PHP files in a separate directory and add a .htaccess with the following contents to that same directory.

# Treat files in this directory as PHP4
AddType x-mapp-php4 .php

Adding KML Google Maps overlays to WordPress posts

Thursday, December 20th, 2007

Embedding basic KML Maps into your blog post

There is an easy way to include Google Maps KML overlays in your WordPress blog if you are willing to have all the size and style information hardcoded into each post. All you have to do is to go to type the KML location into the search box and then click on ‘Link to this page’.

Embedding KML into your WordPress blog using Google Maps

You can then add the HTML into your blog post by copy / pasting it from the second text box.

HTML for embedding Google Maps in a WordPress blog post

Google make it easy to change simple settings such as the map size by following the ‘Customise…’ link. Below is what the actual embedded map would look like. Handily the map is automatically zoomed into whatever data is in your KML file – In this example we’re looking at a walking track across London.

View Larger Map

This is great for if you want to add the odd maps to your blog, or if you don’t believe you’ll need to alter the style later on. The problem comes if you want to separate all the style information out of the embedded map iframe.

The problem with the Google Maps HTML generator

Imagine if you had a site with dozens or even hundreds of embedded KML files. One day in the future you decide that you want to change the style and look of all the maps. Maybe you want to change the size, add some extra links under each map, or add new features from the Google Maps API to each map. Below is what the actual HTML code embedding this KML file looks like. As you can see it is pretty ugly and it wouldn’t be fun to edit dozens / hundreds of these to change the way they look.

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src=";hl=en&amp;geocode=&amp;time=&amp;date=&amp;ttype=&amp;;ie=UTF8&amp;ll=51.497414,-0.054315&amp;spn=0.044967,0.044325&amp;om=0&amp;output=embed&amp;s=AARTsJozG9M05ndgSB8zlZU1Qavi7qH_cw"></iframe><br /><small><a href=";hl=en&amp;geocode=&amp;time=&amp;date=&amp;ttype=&amp;;ie=UTF8&amp;ll=51.497414,-0.054315&amp;spn=0.044967,0.044325&amp;om=0&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>

Under normal circumstances it would be easy to separate out this code into a different file and pass in the KML file URL as a parameter. The problem is that Google have added a security parameter to the argument list (s=AARTsJozG9M05ndgSB8zlZU1Qavi7qH_cw in this case) which locks in the KML URL. You can edit the style parameters (width / height etc) but you can’t change the URL. If you do you get an error saying “Forbidden Your client does not have permission to get URL…”. Google have done this so they can keep a track of how much load individual sites are putting on their server. Unfortunately it means that if you want to use a new KML you have to use the Google Maps site to generate the HTML.

A solution and another problem for WordPress bloggers

There is a way around this, and that is to use the Google Maps API. This will allow you to programatically include as many KMLs as you want without using Google’s HTML generator. To use the API you have to sign up for a Google Maps API Key. There is one final problem – each key can only be used from one individual web directory. This can be a big problem if you are a WordPress user. Bill from the techrageo blog has already written about this so I won’t repeat what he has said. You can read his blog and look at his solution for yourself.

There are however some problems with his solution.

  1. You would need to create a new HTML file for each Google Map you are embedding.
  2. The width and height of the iframe have to be embedded in each map in each blog post or HTML page that you use it on.
  3. The JavaScript in his solution doesn’t quite do what I want.

Here is my solution which is inspired by his but solves these three issues. Please note that as with Bill’s solution this will require some programming knowledge. You will need to make modifications to my scripts to get them to work on your site.

To embed a KML file with my solution all you have to do is include a small section of PHP in your blog post. To allow me to embed PHP in my blog posts I’ve installed the Exec-PHP plugin. This is what the PHP looks like.


You must set the $mapxml variable which points to your KML file – it has to be the full URL, not a relative one. You then load the mapiframe.php file with the ‘require’ command. Optionally you can set a $width and a $height variable for the width/height in pixels, but this will re-introduce problem number 2. If you don’t set these values then default sizes (which you can change) will be used.

Embedding the KML with this PHP means that your blog posts now don’t contain any formatting infomation for the maps. All the formatting can be controlled from the following common scripts.

This is what your mapiframe.php looks like, it contains the common iframe information. You will probably need to fix the link to the loadmap.php file for your own web server.

Include a KML on WordPress Blog
See for details.
if (!isset($mapxml))
	print "ERROR: Missing mapxml";
if (!isset($width))
	$width = "450";
if (!isset($height))
	$height = "450";
$mapxml = urlencode($mapxml);
print <<<ENDHTML
<iframe width="$width" height="$height" scrolling="no"
frameborder="0" marginheight="0" marginwidth="0"
If you see this, your browser doesn't support iframes.
Please upgrade to a more recent browser.</iframe><br /><small>
<a href=";hl=en&amp;q=$mapxml&amp;ie=UTF8&amp;om=1&amp;source=embed"
style="color:#0000FF;text-align:left">View Larger Map</a></small>

Here is the code for loadmap.php. You’ll need to replace the Google Maps API key with your own one.

Include a KML on WordPress Blog
See for details.
Remember to replace the Google API key with your
own one or this script won't work!
if (!isset($mapxml))
	print "ERROR: Missing mapxml";
if (!isset($width))
	$width = "450";
if (!isset($height))
	$height = "450";
print <<<ENDHTML
  <title>Google Map Loader - $mapxml</title>
  <script src="" type="text/javascript"></script>
  <script src="googlemaploader.js"></script>
<body onload="initialize()" onunload="GUnload()">
<div id="map" style="width:$width; height:$height"></div>
<span id="mapxml" name="$mapxml"></span>
<script type="text/javascript">
 function initialize() {
  if (GBrowserIsCompatible()){

This is the googlemaploader.js file which loads the KML using the Google Maps API. It correctly sets the viewport in the map view and adds a few controls to the map.

// Script to load and position a KML/XML Google Map
// See for details.
var kml;
function LoadGoogleMap(){
  // Find mapinfo span and get name attribute
  var mapxml = document.getElementById('mapxml').getAttribute('name');
  kml = new GGeoXml(mapxml, PositionMapCallback);
function PositionMapCallback(){
  var map = new GMap2(document.getElementById("map"));
  map.addControl(new GSmallMapControl());
  map.addControl(new GMapTypeControl());

This is the final result. Yes it looks very similar to the one generated by the Google Maps HTML generator. But if I ever need to change all my embedded maps it will be really easy for me.

View Larger Map
Here are some download links for the three files you need.


You’ll need to change the Google API key in loadmap.php. You’ll also need to fix the inter-file references so all the scripts reference each other correctly. All three scripts should be placed in the directory that you created the Google API key for.

Update: Make sure you check out my Improved KML embedding of Google Maps into web pages post for some updates to these scripts.