PHP Classes

OneClickCaptcha: CAPTCHA validation based on user clicks on circles

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (16)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (2 months ago) RSS 2.0 feedStarStarStar 52%Total: 811 This week: 1All time: 4,249 This week: 560Up
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: 91726 in Poland Poland
Week rank: 27 Up1 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  
  • occ.png
  Files folder image Files  
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  /  example  
File Role Description
  Accessible without login Plain text file example.php Example Example script

  Files folder image Files  /  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  /  src  /  Config  
File Role Description
  Accessible without login Plain text file Config.php Conf. Configuration script

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

  Files folder image Files  /  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  /  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  /  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  /  tests  /  Config  
File Role Description
  Accessible without login Plain text file ConfigTest.php Test Unit test script

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

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

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

 Version Control Unique User Downloads Download Rankings  
 94%
Total:811
This week:1
All time:4,249
This week:560Up
User Ratings User Comments (1)
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:52%StarStarStar
Rank:2331
 
Great idea.
10 years ago (Eduardo souza)
70%StarStarStarStar