Giter VIP home page Giter VIP logo

phpcaptcha's Introduction

PHPCaptcha

wakatime

PHPCaptcha is a PHP library for easy Implementations of captchas.

A captcha is a completely automated public Turing test to tell computers and humans apart.

Place on website

To place the captcha on your website you need to do the following steps:

  1. Import PHPCaptcha.php into the namespace (this has to be before initiating the object)
include 'PHPCapcha.php';

  1. Create a PHPCaptcha object with the path to the folder where the captcha images are stored as argument
$captcha = new PHPCaptcha('img/');

  1. (Set the width of the image in px)
$captcha->setWidth(200);

This is only necessary if you want to change the with of the image which is set to 300px by default.


  1. Add the verify() function to your existing code
$error = !$captcha->verify($_POST['input'], $_POST['hash']);

  1. Add/Remove the verify button of the captcha:

Normaly the captcha is used below an input form, so there should already be a button to send of the form.

If you still want to display the verify button add this line:

$captcha->displayButton(true);

with this button you can just use this code to verify the input:

if(isset($_POST['verify'])){
	if($captcha->verify($_POST['input'], $_POST['hash']))
		echo "true";
	else
		echo "false";
}

  1. To display the captcha use the show() function in the place you want it to be displayed
$captcha->show();

Styles

There is a stylesheet which only contains some basic styles. Feel free to add your own styles in there :)

Generate Images

To generate the images, just run create.py with the number of images you want to generate as argument.

(If you have not added the python lib Pillow just run install.py or get it from the official page.)

These images will be saved in the img/ folder in the same directory as the py folder. The file name of the images is the text displayed on them hashed with sha256

Sample Images

If you do not want to generate your own images, there are 50 sample images in the img folder for you to use.

Requirements

Just for the Captcha you only need PHP 8.0 running

If you want to generate your own captcha images you also need python 3.4 or higher Additionaly you need pip in order to install Pillow

phpcaptcha's People

Contributors

martinwiesinger avatar lgbsalzburg avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.