Monthly Archive for July, 2009

Bird Breath

index1

  • Share/Bookmark

slow moonshine

  • Share/Bookmark

Anti Spam Image Generator

Anti-spam Image Generator will render PNG image with code to protect your blog/comments/feedback section from spammers and bots (known as CAPTCHA). Requirements:

  • PHP >4.0.6
  • GD 2.0.1 or later
  • TTF font to use for rendering code. By default it uses arial.ttf. You can find it online.
  • You can define characters set to use (by default 0123456789abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYZ)
  • Customizable code length (default is 4)
  • Easy to use / light server load, not overloaded with features

Sample usage:

  • Add this html code where you want to place antispam image: <img src=”http://www.website.com/path/to/antispam.php”>
  • Add field to the html form to enter code, name it anti_spam_code: <input name=”anti_spam_code”>
  • Add following check in the php code to check if user entered CAPTCHA correctly:
@session_start(); // start session if not started yet
if ($_SESSION['AntiSpamImage'] != $_REQUEST['anti_spam_code']) {
// set antispam string to something random, in order to avoid reusing it once again
$_SESSION['AntiSpamImage'] = rand(1,9999999);

// here you add code to let user know incorrect code entered

}
else {
// set antispam string to something random, in order to avoid reusing it once again
$_SESSION['AntiSpamImage'] = rand(1,9999999);

// everything is fine, proceed with processing feedback/comment/etc.


}

Download Anti Spam image generator

  • Share/Bookmark