Category Archives: Internet

PHP Code Snippet

Because of the re-design, there’s a lot of broken links – mainly because the blog used to live under the /whatithink/ folder on the server and now resides in the root folder. So all those Google links now point to a part of the site that no longer exists.

So anyone coming here from Google is going to get a 404 error. Not good.

While I get my head around using .htaccess to automatically rewrite the broken URLs, I’ve created a 404 page that will, (hopefully), correct the URL.

Here’s the PHP:

$requested = $_SERVER['REQUEST_URI'];$parts = explode('/', $requested);foreach ($parts as $part) {switch($part) {case ('whatithink'):break;case (''):break;default:$out .= '/' . $part;}}$out = 'http://' . $_SERVER['HTTP_HOST'] . $out;

Because all my broken URLs have an extra “/whatithink/” section, I can just break the requested URL into parts, and rebuild it without that section.

Top 20 Irish Blogs By Traffic

Being that it’s the first day of 2009, it’s common to do some sort of review: what was good, bad, popular and unpopular about the year that’s just past.

I couldn’t be bothered.1

Instead, I decided to do a “snapshot” post – one of those posts that looks at something current, so that in twelve months time I can look back, do it all again and say “Look what’s changed in the last twelve months”.

After my previous post about the most popular social networking sites in Ireland, I decided to have a look at the most popular Irish Blogs. Before I go through the list, here’s a couple of things to remember:

  • I checked the rankings for 179 blogs. This is by no means an exhaustive list of Irish blogs, so if your one isn’t on the list, email me and I’ll update it.
  • The list of blogs was taken from my own feed reader and from the Blogrolls of a couple of the more popular blogs on this list.
  • The traffic data is taken from Alexa, so while it may not be entirely accurate, it should give a general indication of the relative popularity of those on the list.
  • The traffic is based on the last three months only.
  • The traffic stats do not contain any information regarding email or RSS subscribers.
  • Due to the way that Alexa gathers traffic stats, I was unable to gather stats for blogs hosted on the following sites:,,,

So with all of that out of the way, lets move on to the list:

Number 20 – John Breslin

John Breslin

John Breslin

Number 19 – Bernard Goldbach

Bernard Goldbach

Bernard Goldbach

Number 18 – Cybercom



Number 17 – John M. Ryan

John M. Ryan

John M. Ryan

Number 16 – Twenty Major

Twenty Major

Twenty Major

Number 15 – Grannymar



Number 14 – K8 The G8

K8 The G8

K8 The G8

Number 13 – Limerick Blogger

Limerick Blogger

Limerick Blogger

Number 12 – Jason Roe

Jason Roe

Jason Roe

Number 11 – Whois Ireland

Whois Ireland

Whois Ireland

Number 10 – Cormac Moylan

Cormac Moylan

Cormac Moylan

Number 9 – Frank Prendergast

Frank Prendergast

Frank Prendergast

Number 8 – Sabrina Dent

Sabrina Dent

Sabrina Dent

Number 7 – Bock The Robber

Bock The Robber

Bock The Robber

Number 6 – Head Rambles

Head Rambles

Head Rambles

Number 5 – Tom Raftery

Tom Raftery's I.T. Views

Tom Raftery's I.T. Views

Number 4 – Michele Neylon

Michele Neylon

Michele Neylon

Number 3 – Donncha O’Caoimh

Donncha O'Caoimh

Donncha O'Caoimh

Number 2 – Redfly Marketing

Red Fly Marketing

Red Fly Marketing

In at number one, drum roll please….

Number 1 – Damian Mulley

Damian Mulley

Damian Mulley

In the interests of transparency, you can download the full list of blogs that I checked here. The file is a standard .csv.

  1. Mainly because my memory is so bad, I can’t remember what was good or bad about last week, never-mind the last twelve months. []

Setting Up Movable Type 4 on a MAMP Server

Recently my hosting provider, Blacknight Solutions, requested that bloggers using WordPress use the WP-Cache plugin to reduce the load on their servers. Michele at Blacknight has been somewhat critical of WordPress in the past, mainly due to it’s inefficient SQL and the resultant high number of database queries required to generate even a simple page. Based on this Michele moved over to Movable Type 4, and despite a few teething problems, he seems to be quiet happy with it.

As part of their control panel, Blacknight provide the handy Installatron Script Installer, however, there is no installer available for MT, so users have to manually install it themselves. Unfortunately my upload connection is so bad, that it me takes hours to upload the approximately 20 MB of MT install files. As I use MAMP for local site development, I’d thought I’d have a go at a local install of MT.

Because of where MAMP is installed, it’s not a straightforward process, there are a couple of “gotchas” along the way. So for those of you interested in performing a local install of MT4, here’s a quick HOWTO.

Before you start, you’ll obviously need MAMP Server, and MT4. You can grab MAMP here, and MT4 here.

Part I: Getting Ready To Install Movable Type

  1. Once you have downloaded the MT4 ZIP file, extract the files to a folder of your choice.
  2. Within this folder, you should now have an MTOS-4.1-en folder.
  3. Open this folder and locate the mt-static folder.
  4. Move the mt-static folder to /Applications/MAMP/htdocs/
  5. Open a new Finder window and browse to /Applications/MAMP/cgi-bin/
  6. Create a new folder, and name it mt
  7. Move the remaining files in the MTOS-4.1-en folder to /Applications/MAMP/cgi-bin/mt/

Part II: Create a SQLite Database

Before starting the Movable Type installer, you need to create a database in which to store your blog settings, posts etc. While the MT developers recommend that you use MySQL for your database, an additional Perl Module is required otherwise MT will not recognise your MySQL server. However, as this will be a local install, SQLite should be more than enough for your needs. (If you really need it, the required module is DBD::mysql which can be found here, but be warned installing it is problematic and time consuming).

  1. Start the MAMP application and click the “Open Start Page” button, or alternatively, type http://localhost:8888/MAMP/ into your address bar.
  2. Click the link for the SQLiteManager at the top of the page.
  3. Type in the name of your database, and select Version 3.
  4. The full path to the database file also needs to be provided. In this example, I’ve called my database mt4, but you’re free to call it whatever you wish.
  5. Note that the path to your database will be /Applications/MAMP/db/sqlite/[your database name].db
  6. Click the Save button, and your database will be created.

Part III: Installing Movable Type

Now that you have all the MT4 files in place, and your database has been created, you’re ready to start the Movable Type web-based installer.

  1. Open your browser, and type in the following address: http://localhost:8888/cgi-bin/mt/mt.cgi
  2. The installer will tell you that the mt-static has either been renamed or moved and will request both the Static Web Path and Static File Path to the folder. Enter the following paths:
    • http://localhost:8888/mt-static
    • /Applications/MAMP/htdocs/mt-static
  3. Click the Begin button and the installer will confirm that the paths you have entered are correct.
  4. The next step brings us to the database connection setup page. Here is where we’ll tell Movable Type where our database is and how to connect to it.
  5. You’ll note that the only database connection available to us is the SQLite Database and once again we’re being asked for the path to the database. This is the exact same path that you entered in Step 6 of Part II above:
  6. In order to proceed, you’ll need to Test the Connection.
  7. Once MT can talk to your database, then Continue onto the next step -setting up your email.
  8. From the drop-down, select Sendmail and accept the default Sendmail path. Enter your email address and click the Send Test Email Button.
  9. The next step is to set up the admin user and password.
  10. The final step is to create your first blog!

Using .htaccess to Prevent Hot Linking

Hot linking is when another website embeds an image from your website in theirs by directly linking to the image. It’s considered bad form, as every time the image is requested by a browser it’s your bandwidth being used, and bandwidth costs money.

The good news is that you can prevent hot linking by adding the following lines to your .htaccess file:

<IfModule rewrite.c>RewriteEngine OnRewriteCond %{HTTP_REFERER} !^http://(.+.)? [NC]RewriteCond %{HTTP_REFERER} !^$RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]</IfModule>

Thanks to altlab for the .htaccess rewrite rules.

Using Telnet to Send Email

Following up on from my previous post about using telnet to check your email, here’s how you can use telnet to send an email.

There is one very important difference between checking your email and sending an email. Due to the huge amount of spam being sent every day, most ISP’s require that you use their email server to send email. So before you can send an email, you’ll need the name of your ISP’s SMTP server. If you don’t know it, and you’re using either Linux or MacOS X, you can use the nslookup command line utility to find it. Here’s how:

  • Open a command prompt,
  • Type nslookup, and hit enter,
  • Type set querytype=mx, followed by enter,
  • Type the domain name for your isp, i.e.,, hit enter.
  • nslookup will return the mail exchanger address for your isp,
  • Type exit to quit nslookup.

If you don’t have access to nslookup you may be able to guess it from the ISP’s domain name. Taking the ISP domain name to be


Now that you have the SMTP server address, you can start sending email. Back to your command prompt and run the following command:

telnet 25

Once you have connected to the SMTP server, you’ll need to tell it who you are, so type:

helo localhost

You should get a response similar to:

250 helo localhost [Your IP Address]

Unlike sending email, you don’t need a username and password to login. The next step is to tell the server the email address you’re sending from:

mail from:[Your Email Address]

If the address is accepted by the server you should see:

250 OK

Now tell it the address that you want to email:

rcpt to:[Recipients Email Address]

Once again, if the address is accepted the server will tell you with:

250 Accepted

Now it’s time to start writing your email. You tell the server that you’re ready with this command:


All going well, the server will respond with:

354 Enter message, ending with "." on a line by itself

Before you can write the actual message content, you need to provide a couple of headers for the email. Not including some basic headers could result in your email being classified as spam, resulting in it being rejected by the recipient. The basic headers to include are Date, From, To, and Subject, as follows:

Date: [Todays Date & Time]From: [Your Email Address]To: [Recipients Email Address]Subject: [Your Email Subject]

Just before starting the content of your email, hit enter to leave a blank line, then start typing!

When you are finished writing your email, hit enter to leave a blank line, type a “.” (no quotes), and hit enter a again. The server should respond with:

250 OK [Message ID]

And that’s it, your message will be queued by the email server and sent on to your recipient.

Using Telnet to Check Your Email

Like a lot of people at this time of year I went home for a few days. It was great to get home for a while, but it has it’s downside – no broadband. So I was transported back to the the dark days of dial-up.

It’s been so long since I used dial-up that I’d forgotten how slow it is. Even checking email can take an age. So here’s a quick guide on how to use telnet to do a quick email check.

Before you start, you’ll need three pieces of information:

  • your mail server address,
  • your user name, and
  • your password.

Once you have these, open a command prompt and type:

telnet mail.server.tld 110

It might take a couple of seconds, but you should get a response from the server. Something along the lines of:

+OK server ready

The next step is to logon to the server with your user credentials:

Enter your user name:

user user name

If the user name has been accepted, the server will respond with:


Now enter your password:

pass password

If you have provided the correct password, then you should get the following server response:

+OK Logged in

To see if you have any messages, you can use either of the following commands:




The list command will return a list of all messages and their respective sizes, while the stat command will return the total number of messages and the total size.

Sample output from the list command:

+OK 2 messages:1 11952 2365.

Sample output from the stat command:

+OK 2 3560

You’ll note from the output of the list command, that each email is numbered. To read your emails, use the retr command:

retr 1

This command will display the entire email message including the headers. If you want to view just part of the message, then use the top command.

top 1 20

The above command will return the first 20 lines of email number one on the server, not including the email headers.

If like me, you receive a lot of spam, then you might want to delete an email without actually downloading it. This is accomplished using the dele command.

dele 1

The server should respond with a success code:

+OK Marked to be deleted

Be very careful when using this command, as any email messages deleted using this method are irretrievable and gone forever. There are no “Trash” or “Deleted Items” folders on the server.

As a side note, these commands are part of the official POP3 standard, and as such are the commands used by all email programs to retrieve email from POP email servers. (IMAP is a different standard, and uses different commands.)

If you want to send an email, then a different protocol must be used: SMTP, and that’s another post.

Setting Up Apache, PHP, MySQL – The Easy Way

I’ve been experimenting with Content Management Systems recently, and after some research, I’ve decided to use Joomla for my next couple of projects. The idea is that I don’t need to spend as much time writing code, and I can get a website up and running quickly. In order to get more experience with of Joomla I decided to install it on my MacBook.

In order to use Joomla, you need three things: Apache, PHP and MySQL. Individually, these are easy enough to install, but getting them to work together can be a bit of a headache. Config files need to be edited, file permissions need to be changed, servers need to be started and restarted, and it can be a bit daunting, not to say time consuming.

That’s where MAMP comes in. An acronym for Mac, Apache, MySQL, PHP, it’s a collection of all these programs in one handy installer that does all the work for you. It took a couple of minutes to download and about 30 seconds to install. Once installed you have a full Apache server, MySQL server and PHP 4 and PHP 5 installation. Better still, it doesn’t interfere with any other Apache, MySQL, or PHP installations you may have running, and it’s controllable from a handy Dashboard Widget.

Once MAMP is installed and running, it’s just a matter of downloading the package and installing Joomla. A simple browser-based installer guides you through the setup, and within minutes I was up and running. The only issue I came across was that the permissions of the Joomla folder had to be updated to allow the installation. It was just a matter of selecting the folder, holding Option-I and changing the permissions for “Others”. Done and dusted.

For those of you not on the Mac platform there are also versions for Windows, Linux, and Solaris available, along with a Joomla Standalone Server (Windows based).