When doing some work in PHP over the last few weeks I have been battling an undocumented behavior of PHP’s mb_string module.

Whenever the mb_convert_encoding function encounters a character in the source string that is illegal for the target encoding it replaces it with a pre-determined character. This character is set in the php.ini file using the "mbstring.substitute_character" property. Unfortunately if you want to simply leave out any illegal characters you will come up against a problem...

Read more...

Generating Captchas that are easy for a human to read and difficult for a computer to decipher is not the easiest of tasks.

Luckily human nature has given us a tool that we can work with: Pattern Recognition. Humans are very good at recognizing words written in the language that they speak, read, and write on a daily basis. This means that Captchas which contain actual words are much easier to read than others that contain random strings.

If we select the Captcha text from a fairly large word-list then we greatly reduce the chance of a spammer getting the right answer through brute force while still making the Captcha easy to solve for our users. This is very important, because if a user finds your validation technique too annoying they will stop visiting your site.

Read more...

Object orientation in JavaScript can be tricky sometimes. Being forced to refer to all variables (including objects and functions) by value instead of reference can make some tasks very tricky that would be simple in other languages.

One common example is assigning a method of an object to an event or setTimeout() only to discover that it no longer works as expected. Here I will detail a simple solution to this problem, closures.

Read more...

IceBox is a fast, lightweight, and easy to deploy alternative to the very common "Lightbox" script. It’s feature set is somewhat more limited than Lightbox’s but it more than makes up for that with it’s compact size. At just 8KB for the production version of the script you can be sure that it’s not going to slow down your page loads!

Read more...

While working on a project for a client a while ago I noticed that whoever had written their CMS hadn’t implemented any sort of access control! This meant that anyone that knew the URL of their management pages could change their live site, without even having to enter a password!

Obviously this needed to be fixed...

Read more...

While doing some coding the other day I was reminded of a project that I wrote many years ago, a simple encryption/decryption function. For a bit of fun I thought I would re-write it using PHP. Obviously the code I have written now is very different to the code I wrote back then, years of experience have made a world of difference!

Read more...
Results 7 - 12 of 16