PHP Classes

HN CAPTCHA: Generate a form or formpart with a CAPTCHA picture

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum (19)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 64%Total: 14,754 All time: 64 This week: 488Down
Version License PHP version Categories
hn_captcha 1.5.0GNU Lesser Genera...4.1.0HTML, Graphics, Validation, Security


This class generates a picture to use in forms that perform CAPTCHA test (Completely Automated Public Turing to tell Computers from Humans Apart). After the test form is submitted a key entered by the user in a text field is compared by the class to determine whether it matches the text in the picture.

The class is a fork of the original released also in this site by Julien Pachet with the name ocr_captcha.

The following enhancements were added:

- Support to make it work with GD library before version 2
- Hacking prevention
- Optional use of Web safe colors
- Limit the number of users attempts
- Display an optional refresh link to generate a new picture with a different key without counting to the user attempts limit verification
- Support the use of multiple random TrueType fonts
- Control the output image by only three parameters: number of text characters and minimum and maximum size preserving the size proportion
- Preserve all request parameters passed to the page via the GET method, so the CAPTCHA test can be added to existing scripts with minimal changes
- Added a debug option for testing the current configuration

All the configuration settings are passed to the class in an array when the object instance is initialized.

The class only needs two function calls to be used: display_form() and validate_submit().

hn_captcha_X1: add a garbage collector (for 'lost' images) to main class.

Since 24 December 2007, there are different classfiles for PHP 4 and PHP 5, ( merry x-mass <<<-| )

Picture of Horst Nogajski
Name: Horst Nogajski <contact>
Classes: 7 packages by
Country: Germany Germany
Age: 53
All time rank: 524 in Germany Germany
Week rank: 289 Down8 in Germany Germany Down
Innovation award
Innovation award
Nominee: 1x

  • hn_captcha/example_images.jpg
  Files folder image Files  
File Role Description
Files folder imagehn_captcha (10 files)

  Files folder image Files  /  hn_captcha  
File Role Description
  Plain text file hn_captcha.class.php Class switch to main class PHP 4 / 5
  Plain text file hn_captcha.class.php4 Class Main Class for PHP 4
  Plain text file hn_captcha.class.php5 Class Main Class for PHP 5
  Plain text file hn_captcha.class.x1.php Class switch to extension class PHP 4 / 5
  Plain text file hn_captcha.class.x1.php4 Class class extension that add a garbage collector to main class
  Plain text file hn_captcha.class.x1.php5 Class class extension that add a garbage collector to main class
  Plain text file hn_captcha.example.php Example Example for the main class
  Plain text file hn_captcha.example_formpart.php Example an example how to use the captcha test with existing Forms.
  Plain text file hn_captcha.example_formpart2.php Example another example of usage with existing forms
  Plain text file hn_captcha.x1.example.php Example Example for the garbage collector extension

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:64
This week:488Down
User Ratings User Comments (5)
 All time