There will be a short description of each package of Sourdough. This page is not intended to provide you with a full-featured documentation of all components. If any samples provided do not work with your existing Sourdough install, please grab the most recent version from SVN [1].

For a detailed class reference, check the API documentation [2].

  • Captcha - anti-flood image verification

Captcha - anti-flood image verification

package: image
location: Sd_Image/
classes: Sd_Captcha
example: examples/Sd_Image/example2/

A Captcha [3] (an acronym for "completely automated public Turing test to tell computers and humans apart") is a type of challenge-response test used in computing to determine whether or not the user is human. This class is used to generate a captcha image for usage as anti-flood protection in webforms.

To get a Captcha-object, simply call:

$Sourd = new Sourdough();

For a working user verification sample we are going to create the following 3 files:

  • index.php - user verification form
  • image.php - Captcha image generator, embedded as image in index.php
  • process.php - Process user input and verify it


<form method="POST" action="process.php" enctype="multipart/form-data">
    <table cellpadding="3" cellspacing="1">
        <tr><td><img src="image.php"></td></tr>
        <tr><td><input type="text" name="captcha"></td></tr>
        <tr><td><input type="submit" value="Enter" ></td></tr>


// create main Sourdough object
$Sourd = new Sourdough();

// get Captcha object and return the image
$captcha = $Sourd->Captcha();


$Sourd = new Sourdough();
$captcha = $Sourd->Captcha();

if($captcha->isValid()) {
    echo "SUCCESSFULLY !";
} else {
    echo "WRONG INPUT !!!";

There's nothing more to do. It's really that easy. For a detailed working sample please check the code in /examples/Sd_Image/example2 or run directly by clicking on the following link: example2 [4].

By using the new Captcha image generation with ImageMagick [5], it makes life of spambots quite a bit harder. Check the sample code in example3 [6].

Driven by coWiki 0.3.4 web collaboration tool.