<?php
session_start();
error_reporting(0);
#$check=$_GET['code'];
header ("Content-type:image/jpeg");
$fonts=",arial";#"brushsci,arial,oldengl,ravie,parchm,chiller";#,vivaldii
$fonts=explode(",",$fonts);
$liters='azmfhsr';#array(0=>"a",1=>"z",2=>"m",3=>"f",4=>"h",5=>"s",6=>"r");
$width=173;$height=49;
$image=imagecreatetruecolor($width,$height);
$gr=mt_rand(177,197); $grey=imagecolorallocate($image,$gr,$gr,$gr);imagefill($image,0,0,$grey);
# $white=imagecolorallocate($image,255,255,255); $green=imagecolorallocate($image,0,128,0);
$str=rand(6,9);//число от одного до 9
$str1=$liters[rand(0,strlen($liters)-1)];
$str2=rand(1,6);// число от 1 до 6
$str3=$liters[rand(0,strlen($liters)-1)];
$str4=rand(1,9);//число от одного до 34
$check="$str$str1$str2$str3$str4";
#$check="43ghrd";
$secret_code=$check;
 session_register("secret_code");

$x0=15;$y0=10;
$c=0;
for ($i=0;$i<5;$i++) {
  $r=mt_rand(1,count($fonts)-1);
  switch ($r) {
  case 1: $size=mt_rand(25,40);break;
  case 2: $size=mt_rand(25,40);break;
  case 3: $size=mt_rand(15,25);  break;
  case 4: $size=mt_rand(60,85);  break;
  case 5: $size=mt_rand(35,45);  break;
  default: $size=mt_rand(30,35);break;
  }
$angle=mt_rand(-30,30);
if ($z>=0) {$z=-1;$d=255;}else{$z=1;$d=0;}
 $color=imagecolorallocate($image,$d+$z*mt_rand($c,$c+55),$d+$z*mt_rand($c,$c+55),$d+$z*mt_rand($c,$c+55));
$x01=($width/(strlen($check)+1))*($i-1);$x03=($width/(strlen($check)+1))*($i+1);
$x=mt_rand($x01+($x03-$x01)/2-($x03-$x01)/7,$x01+($x03-$x01)/2+($x03-$x01)/7)+$x0;
$y=mt_rand($height/2+$y0-$height/6,$height/2+$y0+$height/6);
imagettftext($image,$size,$angle,$x,$y,$color,'ttf/arial.ttf',$check[$i] );
}
imagejpeg($image);
imagedestroy($image);
?>