<?php
session_start();
$_SESSION['code']=(string)substr(str_shuffle ('qwertyuiopasdfghjklzxcvbnm123456789'),rand(0,30),4);
$arr=ImageCreate(72,30);
imagecolortransparent($arr,imagecolorallocate ($arr,0xff,0xff,0xff));
function imagekub($arr,$size,$i1,$niz1,$chr=NULL) { $color1=imagecolorallocate($arr,($l1=rand (150,200)),($l2=rand(150,200)),($l3=rand(150,200)));
$color2=imagecolorallocate($arr,($l1-50),($l2-50),($l3-50));
$color3=imagecolorallocate($arr,($l1-100), ($l2-100),($l3-100));
$color4=imagecolorallocate($arr,($l1+55), ($l2+55),($l3+55));
$niz3=$niz1;
$niz2=($niz1+($b=(12+$size)));
$i2=$i1+(12+$size);
do { imageline($arr,$i2, (++$niz3),$i1,$niz3,$color2); --$b;
}
while($b>1);
imageline($arr,$i2,$niz1,$i1,$niz1,$color1);
imageline($arr,$i1,$niz2,$i1,$niz1,$color1);
imageline($arr,$i2,$niz1,$i2,$niz2,$color3);
imageline($arr,$i2,$niz2,$i1,$niz2,$color3);
if($chr!==NULL) { imagechar($arr,$size,$i1+5,($niz1+ ($size<1?4:($size<2?3:2))),$chr,$color3);
imagechar($arr,$size,$i1+4,($niz1+ ($size<1?3:($size<2?2:1))),$chr,$color4); } return; }
for($i=0;
$i<20; ++$i) imagekub($arr,rand(0,2),rand(0,56),rand (0,14),' ');
$o=-1;
for($i=1;
$i<=57;
$i+=18) imagekub($arr,rand(2,4),$i,rand(0,14),substr ($_SESSION['code'],(++$o)));
ob_start();
ImageGif($arr);
ImageDestroy($arr);
header("Content-Type: image/gif");
header('Content-Disposition: inline; filename=code.gif');
header('Content-Length: '.ob_get_length());
ob_end_flush();
?>