Archive for the 'Planet LSUCS' Category

Drupal Modules

I thought I might as well ‘publish’ two Drupal modules that I’ve been working on.

Account Reactivation (Drupal 5)
This was created for LSU CompSoc’s new site, to enable members to request that their account is re-activated at the start of the new year, once they have signed up again.

Download the module here: Drupal Account Reactivation Module

Timetable (Drupal 6)
This is a basic module I created as a test module to get back into Drupal development. It creates a timetable, with the ability to add and remove items via a form, and to set the slots available during the day on the timetable.

Download the module here: Drupal Timetable Module

————————————————————-

Please note that both these modules are provided ‘as is’ and may not be completely stable/include bugs . Do not use on a production site without first testing thoroughly.

However I will provide help/improvements/fixes if time allows for the modules.

Windows error/crash debugging

Recently my pc has been crashing a bit, which has caused it to reboot suddenly, and the error messages haven’t shown any useful details of the cause.

After a bit of googling I came across this guide which guides you through using the windows debugging tools to find the cause of the crash.

It will pinpoint the driver at fault etc. so you can update your drivers or look into ways of working round the issue.

Website Access Restrictions

I manage/admin a fair few sites covering an oil exploration equipment company to a church website. Unfortunately over time I’ve had a some issues with spammers posting random unwanted guestbook messages and so on.

Therefore I decided to go ahead and implement some measures to start blocking them. The main site this occurs on is the church site I run, which has an option to blacklist IP addresses. However as the spam comes from a range of IP addresses each time the site is ‘hit’ this would involve a tedious process of adding each address.

Therefore I decided to use the .htaccess allow/deny restrictions. While these are simple to use, getting the information required isn’t always as easy.

The method I took used three steps:

  1. Determining the IP Range involved
  2. Calculating the network prefix of the range
  3. Banning them

For the first step I noticed the IP addresses each time I was hit were similar, so I looked them up on http://software77.net/cgi-bin/ip-country/geo-ip.pl to see if they were in a single range assigned to a particular organisation or country. In this case they were.

Then I converted the range from a start and end IP address to a single address with a prefix. In my case it was 123.112.0.0/12. (you can check your conversion using http://www.csgnetwork.com/ipinfocalc.html) [The look-up link above now gives you the CIDR range]

Finally I added the following lines to my .htaccess file, including a comment for future reference

Order Allow,Deny
##Chinese IP range banned for guestbook spam 28/4/08
Deny from 123.112.0.0/12
Allow from all

As a side note banned users will get a HTTP 403 error page. I also created a custom page to be loaded for banned users, defined by the following line in my .htaccess file:

ErrorDocument 403 /errordocs/403.html

You also need to test that they have access to view this page, so I added another .htaccess file in the errordocs folder with the following lines:

order deny,allow
allow from all

PHP Server Monitoring Script

We’ve been having some issues with the availability of the LSUCS server recently, so I decided to try and put some monitoring in place. Unfortunately we’re not in the position to deploy a full monitoring suite with heartbeat monitoring etc.

So I developed a PHP script to check the status of the server remotely. This is done by checking the IP address, and connections on specified ports. The script can be configured to sends status emails, and to send error emails.

The script also accesses data from a remote PHP script on the monitored server to access disk usage data if available.

The script can be downloaded from here.

The script will probably be changed over time to support multiple servers and extra functionality.

26 Jan 2008: I’ve added support for multiple servers and extra features (see code for full details). The link above now points to the latest version.