PHP Classes

SGCaptcha: CAPTCHA validation using geometric shapes

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 372 This week: 1All time: 6,787 This week: 560Up
Version License PHP version Categories
sgcaptcha 1MIT/X Consortium ...5.0PHP 5, Graphics, Validation, Security
Description 

Author

This class implements CAPTCHA validation using geometric shapes.

It can generate an image with several geometric shapes and associated numbers on them.

The user is required to enter the numbers that are in images of one of the types of geometric shape displayed in the end of the CAPTCHA image.

The correct answer is stored in session variable for subsequent verification.

Innovation Award
PHP Programming Innovation award nominee
July 2014
Number 3


Prize: One downloadable copy of PhpED Professional
CAPTCHA solutions are useful to prevent that sites are abused by robot scripts.

However, some CAPTCHA solutions become a little to hard to authenticate real users.

This class implements an approach that provides a simple solution by letting the users pick numbers associated with given geometric shapes displayed around the numbers.

Manuel Lemos
Picture of Francisco del Aguila
  Performance   Level  
Name: Francisco del Aguila <contact>
Classes: 2 packages by
Country: Spain Spain
Age: 58
All time rank: 167842 in Spain Spain
Week rank: 416 Up14 in Spain Spain Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<?php
   
// Example for the PHP simple geometric captcha
   
session_start();
   
$sent = (isset($_SESSION['captcha'])) ? TRUE : FALSE;
    if (
$sent) {
       
$value = stripslashes(strip_tags(trim($_POST['value'])));
       
$captchaOk = ($value == $_SESSION['captcha']) ? TRUE : FALSE;
        unset(
$_SESSION['captcha']);
    }
?>
<!DOCTYPE html>
<head>
    <meta charset="UTF-8" />
    <meta name="application-name" content="Simple geometric captcha for PHP" />
    <meta name="author" content="Francisco del Aguila. faguila@alboran.net" />
    <title>Simple geometric captcha example</title>
</head>
<body>
    <?php
       
if ($sent) {
            if (
$captchaOk) {
                echo
'CORRECT<br/><hr/>';
            } else {
                echo
'INCORRECT<br/><hr/>';
            }
        }
   
?>
<h1>Simple geometric captcha example</h1>
    <img src="sgcaptcha.php" style="width:350px;" alt="Captcha" />
    <br/>
    Input the digits inside the key figures.
    <br/>
    (Key figures are the ones equal to the black coloured, at the right)
    <br/>
    <form action="example.php" method="post">
        <input type="text" name="value" size="12" maxlength="12" />
        <br/>
        <input type="submit" value="submit" />
    </form>
    <br/><br/>
    <span style="font-size:.8em;">
        Copyright &copy; 2014, Francisco del Aguila<br/>
        This software is under the MIT license.<br/>
        See contents of file README.txt for more information.
    </span>
</body>
</html>


Details

Simple geometric captcha for PHP -------------------------------- Version 1. 2014-06-07. Author: Francisco del Aguila (http://www.alboran.net, faguila@alboran.net) Generate a captcha with geometric figures. USAGE Include the next line in your HTML/PHP webpage: <img src="{path}/sgcaptcha.php" alt="Captcha" /> The captcha solution value is stored in $_SESSION['captcha'] The key figure appears at right with no value. User must input digits inside the key figures. The result may be an empty string. See the 'example.php' file. You can change the colour schema and length of the key editing the file 'captcha.php'. REQUIREMENTS Requires GD library enabled in PHP. LICENSE This software is published under the MIT license. (see http://opensource.org/licenses/MIT) This information must remain in all copies of this software. HISTORY Version 1, 2014-06-07. First version.

Screenshots  
  • Image1.jpg
  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Sample use of sgcaptcha.php
Accessible without login Plain text file LICENSE.txt Lic. License
Accessible without login Plain text file README.txt Doc. Basic information
Plain text file sgcaptcha.php Class The sgcaptcha class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:372
This week:1
All time:6,787
This week:560Up