Wow, that was quick… You can download WordPress 2.6 “Tyner” from the usual location.

You can read more about this release from WordPress.org’s announcement post.

Update: And HTNet’s running it 🙂 Upgrade is smooth as you’d expect from any WordPress build.

I’ve upgraded several of my blogs to WordPress 2.5. However, I noticed that two of them didn’t handle 404 (Page Not Found) errors properly after the upgrade. Every invalid URL gets redirected to the index page; worse still, they returned a 200 server response code which tells the browser that the URL is valid!

Another bad outcome of this bug is that your sites won’t get verified in Google Webmaster Tools.

This problem only occurs on WordPress blogs that uses a page (instead of the more common latest posts listing) as the front page. So how can we fix this?

The good news is that this is a known problem for the WP devs and that a patch is already available. The bad news is that this fix will only be released in WP 2.5.1; and the release date is unknown.

You can apply the fix manually by editing the /wp-includes/query.php file. The offending code is on line 922:

if ( ('page' != get_option('show_on_front') ) || ( $reqpage != get_option('page_for_posts') ) ) {

Change it to:

if ( ('page' != get_option('show_on_front') ) || ( $reqpage !==get_option('page_for_posts') ) ) {

Yes, the only change needed is the additional equal sign as highlighted above! Save the file and your WP 2.5 installation should render 404 errors correctly now.

Hope this helps those who are in a similar situation!

What if there’s a WordPress widget that can display text on a specific section of your blog? Let’s say you have some bookmarking JavaScript that you only want displayed in posts but not on other WordPress pages.

This was the problem I wanted to solve. I searched for a widget that already does this, but found none. I didn’t think that this would be too hard to code myself and decided to give it a go. A few hours later; Section Specific Text Widget was born.

With this widget, you can insert HTML (and even PHP; with third party plugins) content into the sidebar area of specific sections in your WordPress blogs. For example, you can have text that only show in the front page of your blog and not anywhere else. The widget even allows for the content to be shown everywhere except for a section that you’ve chosen.

Give Section Specific Text widget a whirl and tell me what you think.

As a server administrator, there’s nothing that bugs me more than services that die all of a sudden. For a web server, an hour’s down time could mean losing a few hundred visitors. This could translate to a loss of advertising income too if you serve ads on your web pages.

I found a snippet of code that I modified to use as a simple service monitoring and restarting tool that I would like to share with all of you.

First off, let me state that I did not write the following script myself. It was adapted from a script I found somewhere (but I didn’t bookmark the source). Just create an empty file and enter the following lines in it:

#!/bin/bash # Services Restarter - Automatically restart httpd and pure-ftpd if they die /bin/netstat -ln | /bin/grep ":80 " | /usr/bin/wc -l | /bin/awk '{if ($1 == 0) system("/sbin/service httpd restart") }' /bin/netstat -ln | /bin/grep ":21 " | /usr/bin/wc -l | /bin/awk '{if ($1 == 0) system("/sbin/service pure-ftpd start") }'

Now just save the file somewhere. As an example, I going to assume that you saved the file as /scripts/svcschk.

So what does the script do? Essentially, the script uses the netstat command line tool to see whether the server is listening on ports 80 (http service) and 21 (ftp service). If the server is not listening to the ports, then it will attempt to start the appropriate services.

Let’s chop the line that monitors the http service into smaller bits so we can understand what’s being done:

/bin/netstat -ln

Invokes the netstat command to list all listening ports and using presenting bound IP addresses in numeric format. The reason we’d want to use the numeric format for IPs is that it is much faster because we’re not resolving the IPs to hostnames.

| /bin/grep ":80 "

We then pipe the output of netstat to grep looking for addresses that are listening to port 80.

If you noticed, we actually checked for ":80 "; ie 80 with a space afterwards. The reason for the space is to filter out other services that run on ports 8000 or 8080 for example, which will be matched if we were to just use :80.

| /usr/bin/wc -l

Next, we pipe the output of grep to wc, which is essentially a command line word counter.

The -l flag used simply tells wc to count the total number of objects passed to it. Since we already grep-ed the relevant ports, this would return either 0 if the service has died or 1 if it’s alive and listening.

| /bin/awk '{if ($1 == 0) system("/sbin/service httpd restart") }'

Following that, we pass the output sent out by wc to awk, a fast text processing engine that can be programmed to do perform simple text processing jobs.

Here, we simply want awk to tell us if the argument passed to it was 0 (the number zero). If this is the case, then run /sbin/service httpd restart (the command to start the httpd service).

To make the script functional, you should set the appropriate ownership and permissions to it. For example: chown root:root /scripts/svcschk; chmod 700 /scripts/svcschk. This will set the ownership of the script to root and make it executable only to this user.

You can then set it to run every minute by adding an entry to your crontab similar to this:

*/1 * * * *    /scripts/svcschk > /dev/null 2>&1

Hope this code snippet and the explanations are useful to you. If you have any questions on them, feel free to ask me by commenting below.

A lot of IT graduates from the 80s and early 90s will find that the skills developed from their university or college days are becoming obsolete with each passing day. Heck, some of the programming languages they’ve implemented projects with are probably no longer in existence today (or more likely to have evolved to the point of being unrecognizable).

One area that is almost unheard of back then is web applications development. Today, your web browser is not just used to explore web sites, it is an applications platform in its own right.

I can’t think of any traditional software that doesn’t have a web based equivalent. From office suites to something as specialised as healthcare management software, web based applications are being deployed much faster than anything we have seen in computing history. My take on it is that it will only become more prevalent.

I can think of a couple of reasons why web based software grew phenomenally in such a short period of time:

  1. It is easy to deploy: Code once and serve as much clients as your servers could handle. Updates are also less time and resource consuming to deploy
  2. Centralized expansion cost center: You’ll virtually only need to be concerned of the specs of the hosting server rather than your clients’ equipment
  3. Platform agnostic: Once you’ve decided on your hosting platform, web applications can pretty much run on any operating system and Internet-enabled devices (not only computers!)
  4. Growing toolsets: New web programming languages, libraries, scripts and toolkits are born almost daily, adding to the arsenal at the disposal of developers
  5. More reliable transmission infrastructure: Billions are invested each year to make the Internet faster and more efficient. Web application developers are virtually riding on this growth for free

Although I don’t foresee there will ever be a day where everything runs off the Internet (at least in my lifetime), it is nevertheless too gigantic to turn a blind eye to. Every traditional software company is moving on to Internet applications… so should every developer.