PHP Classes

OneClickCaptcha: CAPTCHA validation based on user clicks on circles

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 52%Total: 816 All time: 4,229 This week: 40Up
Version License PHP version Categories
one-click-captcha 1.14GNU General Publi...5.3PHP 5, Graphics, Web services, Valida..., S...
Description 

Author

This class can perform CAPTCHA validation based on user clicks on circles.

It render an image with several circles on random positions. Only one circle appears cut.

The class performs CAPTCHA validation by checking the position where the user clicks on the image to verify it it is inside of the circle that is cut.

The generated image is served in PNG format. The values of the rendered circles are stored in session variables for subsequent validation.

The size and colors of the image and the circles are configurable parameters.

Picture of Kacper Rowinski
  Performance   Level  
Innovation award
Innovation award
Nominee: 8x

 

Example

<?php
declare(strict_types=1);

use
OneClickCaptcha\Service\OneClickCaptchaServiceFactory;

include
__DIR__ . '/../vendor/autoload.php';

ini_set('display_errors', '1');
error_reporting(E_ALL);

$OneClickCaptchaServiceFactory = new OneClickCaptchaServiceFactory();
$oneClickCaptcha = $OneClickCaptchaServiceFactory->getOneClickCaptcha();

// simple demonstration!
$request = $_GET['get_captcha'] ?? '';
if (
$request === 'true') {
    try {
       
$oneClickCaptcha->showCaptcha();
    } catch (
Exception $e) {
        echo
$e->getMessage();
    }
} elseif (isset(
$_REQUEST['position'][0], $_REQUEST['position'][1])) {
    if (
$oneClickCaptcha->validate((int)$_REQUEST['position'][0], (int)$_REQUEST['position'][1])) {
        echo
'<h3>You are human!!</h3>';
    } else {
        echo
'<h3>Wrong!</h3>';
    }
}

// this is all html you need to validate captcha
echo '
<form action="example.php" method="POST">
    <input type="image" src="example.php?get_captcha=true" name="position[]"/>
</form>
'
;


Details

OneClick captcha

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

This lib can perform CAPTCHA validation based on user clicks on circles.

It render an image with several circles on random positions. Only one circle appears cut.

The class performs CAPTCHA validation by checking the position where the user clicks on the image to verify it it is inside of the circle that is cut.

The generated image is served in PNG format. The values of the rendered circles are stored in session variables for subsequent validation.

The size and colors of the image and the circles are configurable parameters.

1. install using composer
composer require krowinski/one-click-captcha
2. example


include __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL);
$OneClickCaptchaServiceFactory = new \OneClickCaptcha\Service\OneClickCaptchaServiceFactory();
$oneClickCaptcha = $OneClickCaptchaServiceFactory->getOneClickCaptcha();
// simple demonstration!
$request = isset($_GET['get_captcha']) ? $_GET['get_captcha'] : '';
if ($request === 'true') {
    $oneClickCaptcha->showCaptcha();
} else {
    if (isset($_REQUEST['position'][0], $_REQUEST['position'][1])) {
        if (true === $oneClickCaptcha->validate($_REQUEST['position'][0], $_REQUEST['position'][1])) {
            echo '<h3>You are human!!</h3>';
        } else {
            echo '<h3>Wrong!</h3>';
        }
    }
}
// this is all html you need to validate captcha
echo '
<form action="example.php" method="POST">
	<input type="image" src="example.php?get_captcha=true" name="position[]"/>
</form>
';


Screenshots (1)  
  • occ.png
  Files folder image Files (17)  
File Role Description
Files folder imageexample (1 file)
Files folder imagesrc (4 directories)
Files folder imagetests (4 directories)
Accessible without login Plain text file .gitignore Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

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  
 94%
Total:816
This week:0
All time:4,229
This week:40Up
User Ratings User Comments (1)
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:52%StarStarStar
Rank:2360
 
Great idea.
11 years ago (Eduardo souza)
70%StarStarStarStar