2016-07-22 20:00:27 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-25 10:47:09 +00:00
|
|
|
require_once ('vn/web/rest-request.php');
|
2016-07-22 20:00:27 +00:00
|
|
|
require_once ('PEAR.php');
|
|
|
|
require_once ('Text/CAPTCHA.php');
|
|
|
|
|
2016-08-25 10:47:09 +00:00
|
|
|
class Captcha extends Vn\Web\RestRequest
|
2016-07-22 20:00:27 +00:00
|
|
|
{
|
|
|
|
function run ()
|
|
|
|
{
|
|
|
|
$options =
|
|
|
|
[
|
|
|
|
'width' => 130
|
|
|
|
,'height' => 45
|
|
|
|
,'output' => 'png'
|
|
|
|
,'imageOptions' =>
|
|
|
|
[
|
|
|
|
'font_size' => 20
|
|
|
|
,'font_path' => __DIR__
|
|
|
|
,'font_file' => 'IndieFlower.ttf'
|
|
|
|
,'text_color' => '#559955'
|
|
|
|
,'lines_color' => '#559955'
|
|
|
|
,'background_color' => '#DDDDDD'
|
|
|
|
,'antialias' => true
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
$captcha = Text_CAPTCHA::factory ('Image');
|
|
|
|
$retval = $captcha->init ($options);
|
|
|
|
|
|
|
|
if (PEAR::isError ($retval))
|
|
|
|
throw new Exception ('Error initializing CAPTCHA: %s!',
|
|
|
|
$retval->getMessage());
|
|
|
|
|
|
|
|
$png = $captcha->getCAPTCHA ();
|
|
|
|
|
|
|
|
if (PEAR::isError ($png))
|
|
|
|
throw new Exception ('Error generating CAPTCHA: %s!',
|
|
|
|
$png->getMessage ());
|
|
|
|
|
|
|
|
// Get secret passphrase
|
|
|
|
$_SESSION['captcha'] = $captcha->getPhrase ();
|
|
|
|
|
|
|
|
header ('Content-Type: image/png');
|
|
|
|
echo $png;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|