Каптча (by Up)
<?php
# Created by Up
session_start();
$_SESSION['code']=(string)substr(str_shuffle ('QWERTYUIPASDFGHJKLZXCVBNM123456789'),rand(0,30),4);
$thiz=ImageCreate(72,30); // Размер изображения
imagecolortransparent($thiz,imagecolorallocate ($thiz,0xff,0xff,0xff)); // Прозрачный фон
function imagekub($thiz,$size,$i1,$niz1,$chr=NULL) { $color1=imagecolorallocate($thiz,($l1=rand (150,200)),($l2=rand(150,200)),($l3=rand(150,200)));
$color2=imagecolorallocate($thiz,($l1-50),($l2-50),($l3-50));
$color3=imagecolorallocate($thiz,($l1-100), ($l2-100),($l3-100));
$color4=imagecolorallocate($thiz,($l1+55), ($l2+55),($l3+55));
$niz3=$niz1;
$niz2=($niz1+($b=(12+$size)));
$i2=$i1+(12+$size);
do { imageline($thiz,$i2, (++$niz3),$i1,$niz3,$color2); --$b;
}
while($b>1);
imageline($thiz,$i2,$niz1,$i1,$niz1,$color1);
imageline($thiz,$i1,$niz2,$i1,$niz1,$color1);
imageline($thiz,$i2,$niz1,$i2,$niz2,$color3);
imageline($thiz,$i2,$niz2,$i1,$niz2,$color3);
if($chr!==NULL) { imagechar($thiz,$size,$i1+5,($niz1+ ($size<1?4:($size<2?3:2))),$chr,$color3);
imagechar($thiz,$size,$i1+4,($niz1+ ($size<1?3:($size<2?2:1))),$chr,$color4); } return; }
for($i=0;
$i<20; ++$i) imagekub($thiz,rand(0,2),rand(0,56),rand (0,14),'?');
$o=-1;
for($i=1;
$i<=57;
$i+=18) imagekub($thiz,rand(2,4),$i,rand(0,14),substr ($_SESSION['code'],(++$o)));
ob_start();
ImageGif($thiz);
ImageDestroy($thiz);
header("Content-Type: image/gif");
header('Content-Disposition: inline; filename=code.gif');
header('Content-Length: '.ob_get_length());
ob_end_flush();
?>