coWiki 0.3.4
Current user:   guest   Change Preferences
   List directory   History   Similar   Print version 
Home 
   Design 
   News 
   Changes 
   Credits 
   License 
Documentation 
   Installation 
   Getting Started 
   Database Abstraction 
   Components 
   FAQ 
Download 
   Development 

hosted by:
Onlime.ch Webhosting

Please donate to keep Sourdough a free software
Do you like Sourdough?
Keep it a free software!



Documentation > Components

 
rw-rw-r--   iezzip   users

Components

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.

For a detailed class reference, check the API documentation.


Captcha - anti-flood image verification

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

A Captcha (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();
$Sourd->Captcha();

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

index.php:

<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>
    </table>
</form>

image.php:

// create main Sourdough object
include_once('Sourdough.class.php');
$Sourd = new Sourdough();

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

process.php:

include_once('Sourdough.class.php');
$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.

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



Reference Components
http://sourdough.phpee.com/Documentation/Components


Prev. Database Abstraction   FAQ Next


Home | Documentation | Download | RSS 1.0 | GEO URL

Driven by coWiki 0.3.4 (Boron) web collaboration tool.