Файл: captcha.php
Строк: 46
<?php
session_start();
$word = intval($_SESSION['captcha']);
$word = "$word";
$img = imagecreatefrompng('design/captcha/1.png');
$sz = getimagesize('design/captcha/1.png');
$size = 20;
$font = 'design/fonts/default_font.ttf';
$im = imagecreatetruecolor(80, 30);
for($i = 0; $i < 2; $i++) {
$rndX = mt_rand(0, $sz[0]);
$rndX1 = mt_rand(0, $sz[0]);
$rndY = mt_rand(0, $sz[1]);
$rndY1 = mt_rand(0, $sz[1]);
$rndX2 = mt_rand(0, $sz[0]);
$rndX3 = mt_rand(0, $sz[0]);
$rndY2 = mt_rand(0, $sz[1]);
$rndY3 = mt_rand(0, $sz[1]);
$color = imagecolorallocate($im, 140, 140, 140);
imageline($img, $rndX, $rndY, $rndX1, $rndY1, $color);
imageline($img, $rndX2, $rndY2, $rndX3, $rndY3, $color);
}
for($i = 0; $i < 4; $i++) {
$angle = mt_rand(-20, 20);
if ($i == 0) $x = 8;
else $x = $x + 12;
$y = 28;
$color = imagecolorallocate($im, 255, 255, 255);
imagettftext($img, $size, $angle, $x, $y, $color, $font, $word[$i]);
}
imagecopyresampled($im, $img, 0, 0, 0, 0, 70, 35, 70, 35);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>