https://github.com/gjerokrsteski/php-captcha-generator
Creates a security-captcha-image with the PHP's GD library for your web form.
https://github.com/gjerokrsteski/php-captcha-generator
captcha oop php php7
Last synced: about 1 month ago
JSON representation
Creates a security-captcha-image with the PHP's GD library for your web form.
- Host: GitHub
- URL: https://github.com/gjerokrsteski/php-captcha-generator
- Owner: gjerokrsteski
- Created: 2010-12-16T16:54:01.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2016-06-29T14:52:58.000Z (almost 9 years ago)
- Last Synced: 2025-04-04T01:41:23.191Z (3 months ago)
- Topics: captcha, oop, php, php7
- Language: PHP
- Homepage: http://gjerokrsteski.github.com/php-captcha-generator
- Size: 231 KB
- Stars: 9
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
Introduction
============
Creates a security-captcha-image with the PHP's GD library for your web form. It's easy to use - just check it out now](https://travis-ci.org/gjerokrsteski/php-captcha-generator)
Requirements & Installation
---------------------------If you have the GD library (available at » http://www.libgd.org/) you will also be able to create and manipulate
images. The format of images you are able to manipulate depend on the version of GD you install, and any other
libraries GD might need to access those image formats. Versions of GD older than gd-1.6 support GIF format images,
and do not support PNG, where versions greater than gd-1.6 and less than gd-2.0.28 support PNG, not GIF.
GIF support was re-enabled in gd-2.0.28. Read more: http://www.php.net/manual/en/image.requirements.phpHow to use it?
--------------
1. Create a file "captcha.php" and make an instance of the CaptchaGenerator in it.
You have to save the security-phrase for sample at the session. (see sample below)2. Integrate the capture-image into you form, using HTML-Tag img src="captcha.php".
```html
![]()
````3. After sending the form-data you can check if the value of the input-field "captcha-confirmation" equals with the security-phrase from the session. So that is all an the image should look like this:

Easy use
-------------------
```php
try
{
$captcha = new CaptchaGenerator(
'path/to/your/font.ttf',
'path/to/your/background-image.gif',
$the_length_of_your_phrase = 4
);// Intervene here the phrase
// and save it into the database or at the session.
$the_captcha_phrase = $captcha->getPhrase();$captcha->render();
}
catch (InvalidArgumentException $e)
{
print $e->getMessage();
}
```Customize some options
---------------------------------
```php
// ...$captcha->setFontcolor(CaptchaGenerator::FONT_COLOR_BLUE)
->setFontsize(16)
->setPhraselength(5)
->setFontxmargin(55)
->setFontymargin(4)
->render();// ...
```