<?php
$font='inc/font.ttf';
session_id($_SERVER['QUERY_STRING']);
session_start();
$vercode=rand(1000,10000);
$_SESSION['ref'] = $vercode;
header('Content-type: image/gif');
$img = imagecreatefromgif('images/codebg.gif');
imagecolorallocate($img, 255, 255, 255);
$imgcolor = imagecolorallocate($img, 255, 255, 255);
imagettftext($img, mt_rand(18, 19), mt_rand(-10, 10), mt_rand(0, 10), mt_rand(11, 32), $imgcolor, $font, substr($vercode, 0, 1));
imagettftext($img, mt_rand(18, 19), mt_rand(-10, 10), mt_rand(20, 25), mt_rand(11, 32), $imgcolor, $font, substr($vercode, 1, 1));
imagettftext($img, mt_rand(18, 19), mt_rand(-10, 10), mt_rand(35, 40), mt_rand(11, 32), $imgcolor, $font, substr($vercode, 2, 1));
imagettftext($img, mt_rand(18, 19), mt_rand(-10, 10), mt_rand(50, 55), mt_rand(11, 32), $imgcolor, $font, substr($vercode, 3, 1));
$imgpx = mt_rand(150,200);
while($imgpx > 0){
imagesetpixel($img, mt_rand(0, 60), mt_rand(0,35), $imgcolor);
$imgpx--;
}
/*
$imglns = mt_rand(4,5);
while($imglns > 0){
imageline($img, mt_rand(0, 35), mt_rand(0,17), mt_rand(35, 70), mt_rand(17, 35), $imgcolor);
$imglns--;
}
*/
//Фильтр, включите, если у вас GD версии 2
//imagefilter($img, IMG_FILTER_SMOOTH, mt_rand(10, 12));
imagegif($img);
?>