session_start();
$image_x = \"100\";
$image_y = \"30\";
$shum = \"4\";
$min_fon_size = \"20\";
$ugol_max = \"30\";
$text_len = \"4\";
$line_len = \"20\";
$pat_font = \"../font/verdana.ttf\";
//Создаем изоброжение
$img = imagecreatetruecolor($image_x , $image_y);
//Установливаем цвет фона
$fon = imagecolorallocate($img, 255,255,255);
//Заливаем картинку цветом
imagefill($img, 0, 0, $fon);
for($i=0; $i < $text_len; $i++)
{
srand((float) microtime()*1000000);
$text = rand(0,9);
$num = $num.$text;
$ugol = rand(360 - $ugol_max,360 + $ugol_max);
$size = rand($min_fon_size, $image_y/2);
$color_rand[$i] = imagecolorallocate($img, rand(0,250),rand(0,250),rand(0,250));
$y = rand(($image_y-$size)/4+$size, ($image_y-$size)/2+$size);
$x = rand(($image_x/$text_len-$size)/2, $image_x/$text_len-$size)+$i*$image_x/$text_len;
imagettftext($img, $size, $ugol, $x, $y, $color_rand[$i], $pat_font, $text);
}
for($i = 0; $i < round($image_x*$image_y*$shum/100)/2; $i++)
{
srand((float) microtime()*1000000);
$color = rand(0,count($color_rand));
imagesetpixel($img,rand(0, $image_x), rand(0, $image_y), $color_rand[$color]);
imagesetpixel($img,rand(0, $image_x), rand(0, $image_y), $fon);
}
for($i = 0; $i < round($line_len/2); $i++)
{
srand((float) microtime()*1000000);
$color = rand(0,count($color_rand));
if(rand(0,1) == 1)
{
imageline($img,rand(0,$image_x),rand(0,$image_y),rand(0,$image_x),rand(0,$image_y),$color_rand[$color]);
imagedashedline($img,rand(0,$image_x),rand(0,$image_y),rand(0,$image_x),rand(0,$image_y), $fon);
}
else
{
imageline($img,rand(0,$image_x),rand(0,$image_y),rand(0,$image_x),rand(0,$image_y),$fon);
imagedashedline($img,rand(0,$image_x),rand(0,$image_y),rand(0,$image_x),rand(0,$image_y), $color_rand[$color]);
}
}
$_SESSION[\"captcha\"] = $num;
if($img)
{
header(\"Content-type: \".image_type_to_mime_type(IMAGETYPE_PNG));
imagepng($img);
}
|