32){ $stringlen = 32; } $stringsize = intval($height/2); $randomsize = intval($stringsize * mt_rand(90,110) * .01); $im = imagecreate($width, $height); $chunksize = $width / $stringlen; $xmax = intval($chunksize * $i + $chunksize) - $rightx; $xmin = intval($chunksize * $i) - $leftx; $ymax = intval($height) - $topy; $ymin = intval($randomsize) - $bottomy; $randx = mt_rand($xmin, $xmax); $randy = mt_rand($ymin, $ymax); $white = imagecolorallocate($im, 255, 255, 255); $color = imagecolorallocate($im, 192, 192, 192); $black = imagecolorallocate($im, 0, 0, 0); $string = md5(mt_rand(0,9999)); $new_string = strtoupper(substr($string, mt_rand(0, 32-$stringlen), $stringlen)); $_SESSION['image_verify_string'] = $new_string; imagefill($im, 0, 0, $black); $fnt = imageloadfont("batik.gdf"); imagestring($im,$fnt,50,$stringsize-8,$new_string,$white); for ($i = 0; $i < mt_rand(100,200); $i++) { imagesetpixel($im, mt_rand(0,$width), mt_rand(0,$height), $white); } for ($i = 0; $i < mt_rand(5,15); $i++) { $rand_x = mt_rand(0,$width); $rand_y = mt_rand(0,$height); if(mt_rand(0,1) < 0.5) $sign1 = -1; else $sign1 = 1; if(mt_rand(0,1) < 0.5) $sign2 = -1; else $sign2 = 1; imageline($im, $rand_x, $rand_y, $rand_x + $sign1*mt_rand(5,30), $rand_y + $sign2*mt_rand(5,30), $white); } imagepng($im); imagedestroy($im); ?>