Файл: captcha.php
Строк: 46
<?php
/* DCMS Special)
* Дата последнего редактирования 27.12.2015
* Модифицировал densnet
*/
require_once 'sys/inc/start.php';
require_once 'sys/inc/sess.php';
require_once 'sys/inc/settings.php';
require_once 'sys/inc/db_connect.php';
require_once 'sys/inc/ipua.php';
require_once 'sys/inc/fnc.php';
$show_all = true;
require_once 'sys/inc/user.php';
$_SESSION['captcha'] = '';
$first = mt_rand(11, 55);
$second = mt_rand(1, 9);
$_SESSION['captcha'] = ($first + $second);
$code = "$first + $second=";
$width = 80;
$height = 30;
$sign = strlen($code);
$figures = array('50', '70', '90', '110', '130', '150', '170', '190', '210');
$img = imagecreatetruecolor($width, $height);
$fon = imagecolorallocate($img, 255, 255, 255);
imagefill($img, 0, 0, $fon);
for ($i = 0; $i < $sign; $i++) {
$h = 1;
$color = imagecolorallocatealpha(
$img, $figures[rand(0, count($figures) - 1)], $figures[rand(0, count($figures) - 1)], $figures[rand(0, count($figures) - 1)], rand(10, 30));
$letter = $code[$i];
if (empty($x)) {
$x = $width * 0.08;
} else {
$x = $x + ($width * 0.8) / $sign + rand(0, $width * 0.01);
}
if ($h == rand(1, 2)) {
$y = (($height * 1) / 4) + rand(0, $height * 0.1);
} else {
$y = (($height * 1) / 4) - rand(0, $height * 0.1);
}
$code.= $letter;
imagestring($img, 7, $x, $y, $letter, $color);
}
header("Content-type: image/jpeg");
imagejpeg($img);