File | Date | Author | Commit |
---|---|---|---|
font | 2013-05-22 |
![]() |
[45a351] Add OSS font |
CHANGELOG | 2013-05-22 |
![]() |
[a4bac7] Allow to check result with string variables con... |
LICENSE | 2013-05-22 |
![]() |
[e93179] Initial commit |
README.md | 2013-05-22 |
![]() |
[70e50c] Use easier operands, well-known sign for multip... |
catcha.php | 2013-05-22 |
![]() |
[a4bac7] Allow to check result with string variables con... |
composer.json | 2013-05-22 |
![]() |
[a4bac7] Allow to check result with string variables con... |
Catch-a spammer with a CAPTCHA.
Copyright (C) 2013 J.M. me@mynetx.net
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
Please enable the GD extension in your PHP environment.
require_once 'catcha.php';
$catcha = new Catcha;
$catcha->outputImage();
$_SESSION['catcha'] = $catcha;
$catcha = $_SESSION['catcha'];
$entered_result = -1;
if (isset($_POST['your_field_name'])) {
$entered_result = intval($_POST['your_field_name']);
}
$catcha_solved = $catcha->isCorrectResult($entered_result);
The canvas size defaults to 100 x 25 pixels. Customize the size:
$catcha->setImageSize($desired_width, $desired_height);
By default, Catcha uses the Averia Light font licensed under the SIL
Open Font License Version 1.1 (http://scripts.sil.org/OFL).
You may as well use a custom True Type font (*.ttf):
$catcha->setImageFont($path_to_font);
The supported color codes include (upper- and lower case)
$catcha->setImageColorBackground('#ffff00');
$catcha->setImageColorForeground('#ff0000');
$catcha->newChallenge();
The raw image data are in binary JPEG format, quality 80.
$image_data = $catcha->getImage();