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    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (9 months ago) RSS 2.0 feedStarStarStar 52%Total: 816 All time: 4,227 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  
Name: Kacper Rowinski <contact>
Classes: 14 packages by
Country: Poland Poland
Age: 40
All time rank: 91426 in Poland Poland
Week rank: 195 Up2 in Poland Poland Up
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

  Files folder image Files (17)  /  example  
File Role Description
  Accessible without login Plain text file example.php Example Example script

  Files folder image Files (17)  /  src  
File Role Description
Files folder imageConfig (1 file)
Files folder imageProxy (1 file)
Files folder imageRepository (2 files)
Files folder imageService (2 files)

  Files folder image Files (17)  /  src  /  Config  
File Role Description
  Accessible without login Plain text file Config.php Conf. Configuration script

  Files folder image Files (17)  /  src  /  Proxy  
File Role Description
  Plain text file ImageProxy.php Class Class source

  Files folder image Files (17)  /  src  /  Repository  
File Role Description
  Plain text file SessionStorageInterfaceRepository.php Class Class source
  Plain text file StorageInterface.php Class Class source

  Files folder image Files (17)  /  src  /  Service  
File Role Description
  Plain text file OneClickCaptchaService.php Class Class source
  Plain text file OneClickCaptchaServiceFactory.php Class Class source

  Files folder image Files (17)  /  tests  
File Role Description
Files folder imageConfig (1 file)
Files folder imageProxy (1 file)
Files folder imageRepository (1 file)
Files folder imageService (1 file)

  Files folder image Files (17)  /  tests  /  Config  
File Role Description
  Accessible without login Plain text file ConfigTest.php Test Unit test script

  Files folder image Files (17)  /  tests  /  Proxy  
File Role Description
  Accessible without login Plain text file ImagineProxyTest.php Test Unit test script

  Files folder image Files (17)  /  tests  /  Repository  
File Role Description
  Accessible without login Plain text file SessionPostRepositoryTest.php Test Unit test script

  Files folder image Files (17)  /  tests  /  Service  
File Role Description
  Accessible without login Plain text file OneClickCaptchaServiceTest.php Test Unit test script

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,227
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:2359
 
Great idea.
11 years ago (Eduardo souza)
70%StarStarStarStar