Skip to content

Repository files navigation

simple-captcha

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

version 2.6.2

SimpleCaptcha

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 = (newSimpleCaptcha())
->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(); ?><formaction="/validate" method="post"><!-- you can store the captcha hash in the $_SESSION or in $_COOKIE as well --><inputtype="hidden" name="hash" value="<?php echo $captcha->getHash(); ?>" />
Compute result <imgsrc="<?php echo $captcha->getCaptcha(); ?>" /><inputtype="text" name="answer" value="" /><buttontype="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 wellif ($captcha->validate($_POST['answer'], $_POST['hash']))
{
// correct captcha
}
else
{
// wrong captcha
}
});

see also:

  • ModelView a simple, fast, powerful and flexible MVVM framework for JavaScript
  • tico a mini, 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 flexible publish-subscribe pattern implementation for PHP, JavaScript, Python
  • Localizer a simple and versatile localization class (l10n) for PHP, JavaScript, Python
  • Importer simple class & dependency manager and loader for PHP, JavaScript, Python
  • EazyHttp, easy, simple and fast HTTP requests 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

About

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

Topics

Resources

Stars

8 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages