PHP Classes
elePHPant
Icontem

Customizable CAPTCHA: Generate and validate CAPTCHA images

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2010-09-05 (4 years ago) RSS 2.0 feedNot enough user ratingsTotal: 422 All time: 5,879 This week: 1,134Up
Version License PHP version Categories  
customizable-captcha 1.0GNU General Publi...5.0PHP 5, Graphics, Validation, Security
Description Author  

This class can be used to Generate and validate CAPTCHA images.

It can generate an image with a random text made of hexadecimal digits.

The class stores the text in a session variable for posterior verification.

The image is served as the current script output in PNG format.

Picture of musthafa
Name: musthafa <contact>
Classes: 1 package by
Country: India India
Age: ???
All time rank: 3167212 in India India
Week rank: 1577 Up111 in India India Up

Details provided by the author  
A fully-customizable captcha class.

Captcha is used to stop automated form submission.
This class can be used to generate custom captcha image for your website.
It also provides method to validate the captcha.

How to use
----------

Start session
Instantiate Captcha class
Set captcha properties( background, text color, font etc.) using setXXX methods provided by the captcha object (optional).
Display image using showImage() method

	
Requirements:
	PHP5
	GD libraray ( freetype library support needed)
	
method summary
--------------

function showImage()
Generates captcha image. Outputs generated image in png format.


function setBGColor( $r, $g, $b )	
Sets the background color of captcha image.
Parameters: $r -> Red, $g -> green, $b -> blue. [ RGB format ]


function setFontSize( $size ) 
Sets the font size.
Parameter: $size -> The font size. Depending on your version of GD, 
this should be specified as the pixel size (GD1) or point size (GD2).


function setSize( $width, $height )
Sets the captcha images size.
Parameters : $width -> image width, $height -> image height.


function setFont( $font )
Sets the font of captcha.
Parameter: $font -> path to TrueType font file.

	
function setTextColor( $r, $g, $b )
Sets the captcha text color.
Parameters: $r -> Red, $g -> green, $b -> blue. [ RGB format ]

public static function isValid( $code )
Validates captcha. if valid returns true, otherwise false. 
Parameter: $code -> user input to be validated


  Files folder image Files  
File Role Description
Plain text file class.captcha.php Class captcha class
Accessible without login Plain text file form.php Example captcha demo page
Accessible without login Plain text file getcaptcha.php Example captcha loader - generates captcha image for form.php
Accessible without login Plain text file readme Doc. readme

 Version Control Unique User Downloads Download Rankings  
 0%Total:422All time:5,879
 This week:0This week:1,134Up
 User Comments (1)  
 
It is good, quick and easy solution for captcha.
4 years ago (Nikolay Boyukliev)
60%StarStarStarStar