Archive for the ‘Web development’ Category

Filtering guestbook spam

Saturday, December 16th, 2006

Guestbooks, as well as all public forms on the WWW, are constantly abused nowadays by spam bots trying to fill them with spam links. In the guestbook for my band, I had a ratio of 1/10 – about 9 spams for every valid post. Here are the spam filtering techniques I implemented that worked for me:

  • First, a black list. I have an array with bad words (viagria, cialis, roulette, casino) which are common in spam posts and quite uncommon in valid guestbook entries. Every post is checked against the black list. The black list also contains a few URL:s that are often used by spammers (blogspot.com and hometown.aol.com) as well as the tag [url= which is probably BBcode.
  • Link spamming. A quick check is made on the number of http:// links, if it’s above 5 – well, it’s most probably a spam!
  • Cookie test. This is something I picked up on a mailing list a few weeks ago, and it works brilliantly. The idea is that spam bots aren’t valid browsers, they just look for forms and submit them. The trick is to set a cookie when the form is displayed, and then check for the existance of that cookie when the form is received, before it’s saved. If there’s no cookie – the post isn’t saved! This stops people with cookies disabled from entering posts, but it stops a LOT of spam.

BTW, here’s my entire black list as of today:
levitra,viagra,cialis,porn,roulette,casino,hometown.aol.com,blogspot.com,[url=

Maximum image size in WordPress 2

Friday, December 8th, 2006

There seems to be a hard-coded maximum size for images uploaded in WordPress 2.0 – images larger than 3 Mpixels aren’t resized into thumbnails for some odd reason (maybe not to stress the web server?).

If you think your web host has enough horse power to resize large images, go ahead and modify line 89 in wp-admin/inline-uploading.php and change the number three to something higher:

if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {

This should be added to the WordPress Codex.

A javascript bookmarklet for converting timestamps

Monday, November 28th, 2005

I spend a lot of time working with timestamps (unixtime aka epoch) in phpMyAdmin, and got really tired of either cut-and-paste:ing the timestamps to my home-made timestamp converter or adding “FROM_UNIXTIME(created)” to the SQL queries to get the timestamps in a readable format…

The other day I got the idea to make a bookmarklet that does the conversion for me, and voilá! All you have to do is mark the timestamp and click the “Convert” bookmarklet. You’ll get an input field if you don’t mark anything.

Here’s the bookmarklet:
Convert timestamp (Bookmark the link, don’t click it!)

Please let me know if you find it useful or think of a way to improve it.