dev-master
9999999-dev https://github.com/Mod-joker/Feron-Gregwar-CaptchaCaptcha generator
MIT
The Requires
- php >=5.3.0
- ext-gd *
- ext-mbstring *
- symfony/finder ~3.0|~4.0
The Development Requires
by Feron Wu
bot captcha spam
Captcha generator
With composer :, (*2)
``` json { ... "require": { "gregwar/captcha": "1.*" } }, (*3)
Usage ===== You can create a captcha with the `CaptchaBuilder` : ```php build(); ``` You can then save it to a file : ```php save('out.jpg'); ``` Or output it directly : ```php output(); ``` Or inline it directly in the HTML page: ```php![]()
You'll be able to get the code and compare it with a user input :, (*4)
<?php // Example: storing the phrase in the session to test for the user // input later $_SESSION['phrase'] = $builder->getPhrase();You can compare the phrase with user input:, (*5)
if($builder->testPhrase($userInput)) { // instructions if user phrase is good } else { // user phrase is wrong }API
You can use theses functions :, (*6)
build()
true
if the OCR can be read using the ocrad
software, you'll need to have shell_exec enabled, imagemagick and ocrad installedocrad
If you want to change the number of character, you can call the phrase builder directly using extra parameters:, (*7)
use Gregwar\Captcha\CaptchaBuilder; use Gregwar\Captcha\PhraseBuilder; // Will build phrases of 3 characters $phraseBuilder = new PhraseBuilder(4) // Will build phrases of 5 characters, only digits $phraseBuilder = new PhraseBuilder(5, '0123456789'); // Pass it as first argument of CaptchaBuilder, passing it the phrase // builder $captcha = new CaptchaBuilder(null, $phraseBuilder);
You can also pass directly the wanted phrase to the builder:, (*8)
// Building a Captcha with the "hello" phrase $captcha = new CaptchaBuilder('hello');
You can have a look at the following repository to enjoy the Symfony 2 bundle packaging this captcha generator : https://github.com/Gregwar/CaptchaBundle, (*9)
You can use the following extension for integrating with Yii2 Framework : https://github.com/juliardi/yii2-captcha, (*10)
This library is under MIT license, have a look to the LICENSE
file, (*11)
Captcha generator
MIT
bot captcha spam