Code: Select all
<?php
session_start();
srand(microtime() * 1000000);
$secur = rand(100000,999999);
$_SESSION['secur']=$secur;
$newImg = imagecreate(135,40);
$bg = imagecolorallocate($newImg,255,255,255);
$textcolor = imagecolorallocate($newImg,rand(0,100), rand(0,100), rand(0,255));
$bgnoise=1;
while ($bgnoise<15)
{
$a=rand(0,135);
$b=rand(0,40);
$c=rand(0,135);
$d=rand(0,40);
$lincol1=rand(160,255);
$lincol2=rand(215,255);
$lincol3=rand(190,255);
$linecolor=imagecolorallocate($newImg,$lincol1,$lincol2,$lincol3);
imagefilledrectangle($newImg,$c,$d,$a,$b,$linecolor);
$bgnoise++;
}
$font = imageloadfont("v3.gdf");
imagestring($newImg, $font, 10, rand(5,15), substr($secur,0,3) , $textcolor);
imagestring($newImg, $font, 70, rand(5,15), substr($secur,3,6) , $textcolor);
imagefill($newImg,0,0,$bg);
header ("Content-type: image/gif");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$newImg = imagerotate($newImg, rand(-10,10), 0);
imagegif($newImg);
imagedestroy($newImg);
?>Carlos