PHP Classes

Simple PHP Captcha Library: Show images to verify humans with math expressions

Recommend this page to a friend!
  Info   Documentation   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 124 All time: 9,456 This week: 22Up
Version License PHP version Categories
simple-captcha 2.6.0Artistic License5PHP 5, Graphics, Validation, Math, Se...
Description 

Author

This package can show images to verify humans with math expressions.

It can generate a text string with a simple math expression that users need to read and enter the result to confirm they are real human users.

The package can also verify if the user has entered the correct result to pass the human user verification.

The package also contains a version of the code in JavaScript and Python.

Picture of Nikos M.
Name: Nikos M. is available for providing paid consulting. Contact Nikos M. .
Classes: 18 packages by
Country: Greece Greece
Age: 48
All time rank: 8459 in Greece Greece
Week rank: 180 Up4 in Greece Greece Up
Innovation award
Innovation award
Nominee: 7x

Winner: 2x

Documentation

simple-captcha

Simple, image-based, mathematical captcha, with increasing levels of difficulty for PHP, JavaScript, Python

version 2.6.0

SimpleCaptcha

see also:

  • ModelView a simple, fast, powerful and flexible MVVM framework for JavaScript
  • tico a tiny, super-simple MVC framework for PHP
  • LoginManager a simple, barebones agnostic login manager for PHP, JavaScript, Python
  • SimpleCaptcha a simple, image-based, mathematical captcha with increasing levels of difficulty for PHP, JavaScript, Python
  • Dromeo a flexible, and powerful agnostic router for PHP, JavaScript, Python
  • PublishSubscribe a simple and flexible publish-subscribe pattern implementation for PHP, JavaScript, Python
  • Importer simple class & dependency manager and loader for PHP, JavaScript, Python
  • Contemplate a fast and versatile isomorphic template engine for PHP, JavaScript, Python
  • HtmlWidget html widgets, made as simple as possible, both client and server, both desktop and mobile, can be used as (template) plugins and/or standalone for PHP, JavaScript, Python (can be used as plugins for Contemplate)
  • Paginator simple and flexible pagination controls generator for PHP, JavaScript, Python
  • Formal a simple and versatile (Form) Data validation framework based on Rules for PHP, JavaScript, Python
  • Dialect a cross-vendor & cross-platform SQL Query Builder, based on GrammarTemplate, for PHP, JavaScript, Python
  • DialectORM an Object-Relational-Mapper (ORM) and Object-Document-Mapper (ODM), based on Dialect, for PHP, JavaScript, Python
  • Unicache a simple and flexible agnostic caching framework, supporting various platforms, for PHP, JavaScript, Python
  • Xpresion a simple and flexible eXpression parser engine (with custom functions and variables support), based on GrammarTemplate, for PHP, JavaScript, Python
  • Regex Analyzer/Composer Regular Expression Analyzer and Composer for PHP, JavaScript, Python

Example:

  1. Captcha with Position Distortion: Captcha with Position Distortion
  2. Captcha with Scale Distortion: Captcha with Scale Distortion
  3. Captcha with Gradient Background: Captcha with Gradient Background
  4. Captcha with custom pattern background: Captcha custom pattern background
// setup
$captcha = (new SimpleCaptcha())
    ->option('secret_key', 'SECRET_KEY')
    ->option('secret_salt', 'SECRET_SALT_')
    ->option('difficulty', 1) // 0 (easy) to 3 (difficult)
    ->option('distortion_type', 1) // 1: position distortion, 2: scale distortion
    ->option('num_terms', 2)
    ->option('max_num_terms', 4) // -1 means constant num_terms
    ->option('min_term', 1)
    ->option('max_term', 21)
    ->option('has_multiplication', true)
    ->option('has_division', true)
    ->option('has_equal_sign', true)
    ->option('color', 0x121212)
    ->option('background', 0xffffff)
;

<!-- use it -->
<?php $captcha->reset(); ?>
<form action="/validate" method="post">
<!-- you can store the captcha hash in the $_SESSION or in $_COOKIE as well -->
<input type="hidden" name="hash" value="<?php echo $captcha->getHash(); ?>" />
Compute result <img src="<?php echo $captcha->getCaptcha(); ?>" /> <input type="text" name="answer" value="" />
<button type="submit">Submit</button>
</form>

// use it
$app->on('/validate', function() use ($captcha) {
    // you can store the captcha hash in the $_SESSION or in $_COOKIE as well
    if ($captcha->validate($_POST['answer'], $_POST['hash']))
    {
    // correct captcha
    }
    else
    {
    // wrong captcha
    }
});

Screenshots (1)  
  • simple-captcha.jpg
  Files folder image Files (26)  
File Role Description
Files folder imagedemo (2 files, 1 directory)
Files folder imagesrc (3 directories)
Files folder imagetest (3 files, 3 directories)
Accessible without login Image file captcha-gradient.png Icon Icon image
Accessible without login Image file captcha-pattern.png Icon Icon image
Accessible without login Image file captcha-position.png Icon Icon image
Accessible without login Image file captcha-scale.png Icon Icon image
Accessible without login Plain text file README.md Doc. Example script

  Files folder image Files (26)  /  demo  
File Role Description
Files folder imageviews (3 files, 1 directory)
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file server.php Aux. Auxiliary script

  Files folder image Files (26)  /  demo  /  views  
File Role Description
Files folder imagelayout (1 file)
  Accessible without login Plain text file 404.tpl.php Example Example script
  Accessible without login Plain text file content.tpl.php Example Example script
  Accessible without login Plain text file index.tpl.php Example Example script

  Files folder image Files (26)  /  demo  /  views  /  layout  
File Role Description
  Accessible without login Plain text file base.tpl.php Example Example script

  Files folder image Files (26)  /  src  
File Role Description
Files folder imagejs (1 file)
Files folder imagephp (1 file)
Files folder imagepython (2 files)

  Files folder image Files (26)  /  src  /  js  
File Role Description
  Accessible without login Plain text file SimpleCaptcha.js Data Auxiliary data

  Files folder image Files (26)  /  src  /  php  
File Role Description
  Plain text file SimpleCaptcha.php Class Class source

  Files folder image Files (26)  /  src  /  python  
File Role Description
  Accessible without login Plain text file SimpleCaptcha.py Data Auxiliary data
  Accessible without login Plain text file __init__.py Data Auxiliary data

  Files folder image Files (26)  /  test  
File Role Description
Files folder imagejs (3 files)
Files folder imagephp (2 files)
Files folder imagepython (2 files)
  Accessible without login Plain text file imgdata.php Aux. Auxiliary script
  Accessible without login Image file tile.jpg Icon Icon image
  Accessible without login Plain text file tile.json Data Auxiliary data

  Files folder image Files (26)  /  test  /  js  
File Role Description
  Accessible without login Plain text file out.txt Doc. Documentation
  Accessible without login HTML file test.html Doc. Documentation
  Accessible without login Plain text file test.js Data Auxiliary data

  Files folder image Files (26)  /  test  /  php  
File Role Description
  Accessible without login Plain text file out.txt Doc. Documentation
  Accessible without login Plain text file test.php Example Example script

  Files folder image Files (26)  /  test  /  python  
File Role Description
  Accessible without login Plain text file out.txt Doc. Documentation
  Accessible without login Plain text file test.py Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:124
This week:0
All time:9,456
This week:22Up