Файл: app/captcha.php
Строк: 27
<?php
$width = 120;
$height = 60;
$font_size = 14;
$font_file = '/assets/fonts/captcha.otf';
$length = mt_rand(3, 5);
$string = '123456789abcdefghijklmnpqrstuvwxyz';
$image = imagecreatetruecolor($width, $height);
imagesavealpha($image, true);
imagefill($image, 0, 0, imagecolorallocatealpha($image, 0, 0, 0, 127));
$text = null;
for ($i = 0; $i < $length; $i++) {
$color = imagecolorallocatealpha($image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100), mt_rand(20, 40));
$text .= substr(str_shuffle($string), 0, 1);
$size = mt_rand($font_size * 2 - 2, $font_size * 2 + 2);
$x = ($width - 20) / $length * $i + 10;
$x = mt_rand($x, $x + 5);
$y = ($height * 2 / 3) + mt_rand(0, 5);
imagettftext($image, $size, mt_rand(-10, 10), $x, $y, $color, $font_file, $text[$i]);
}
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);
$_SESSION['captcha'] = $text;