$height) $size=$height; $left = ($width-$len*($size+$size/10))/$size; $textall=range('a','z'); $textall=array_merge(range('A','Z'),$textall); $textall=array_merge(range('0','9'),$textall); //$textall.=range('0','9'); for ($i=0; $i<$len; $i++) { $tmptext=rand(0, 61); $randtext = $textall[$tmptext]; $code .= $randtext; } $textColor = imageColorAllocate($image, 0, 0, 0); imagestring($image, $size, 4, 1, $code, $textColor); if($noise == true) setnoise(); $_SESSION['asr_verifycode'] = $code; $bordercolor = getcolor($bordercolor); if($border==true) imageRectangle($image, 0, 0, $width-1, $height-1, $bordercolor); header("Content-type: image/png"); imagePng($image); imagedestroy($image); function getcolor($color) { global $image; $color = eregi_replace ("^#","",$color); $r = $color[0].$color[1]; $r = hexdec ($r); $b = $color[2].$color[3]; $b = hexdec ($b); $g = $color[4].$color[5]; $g = hexdec ($g); $color = imagecolorallocate ($image, $r, $b, $g); return $color; } function setnoise() { global $image, $width, $height, $back, $noisenum; for ($i=0; $i<$noisenum; $i++){ $randColor = imageColorAllocate($image, rand(0, 255), rand(0, 255), rand(0, 255)); imageSetPixel($image, rand(0, $width), rand(0, $height), $randColor); } } ?>