if (!isset ($_session)) {//Determine if SESSION is open Session_Start (); Open on the session } $width = 70; width of cloth painting $height = 25; Cloth painting Height $length =4;//Verification Code length $code =getcode ($length); Get random string $_session[' verfycode '] = $code; $img =imagecreate ($width, $height); $bgcolor =imagecolorallocate ($img, 240,240,240); $rectangelcolor =imagecolorallocate ($img, 150,150,150); Imagerectangle ($img, $width-1, $height-1, $rectangelcolor);//Draw Border for ($i =0; $i < $length; $i + +) {//circular writing $codecolor =imagecolorallocate ($img, Mt_rand (50,200), Mt_rand (50,128), Mt_rand (50,200)); $angle =rand ( -20,20); $charx = $i *15+8; $chary = ($height +14)/2+rand ( -1,1); Imagettftext ($img, $angle, $charx, $chary, $codecolor, ' C:windowsfontssimkai.ttf ', $code [$i]); } for ($i =0; $i <20; $i + +) {//Loop draw line $linecolor =imagecolorallocate ($img, Mt_rand (0,250), Mt_rand (0,250), Mt_rand (0,250)); $linex =mt_rand (1, $width-1); $liney =mt_rand (1, $height-1); Imageline ($img, $linex, $liney, $linex +mt_rand (0,4)-2, $liney +mt_rand (0,4)-2, $linecolor); } for ($i =0; $i <100; $i + +) {//Loop draw point $pointcolor =imagecolorallocate ($img, Mt_rand (0,250), Mt_rand (0,250), Mt_rand (0,250)); Imagesetpixel ($img, Mt_rand (1, $width-1), Mt_rand (1, $height-1), $pointcolor); } function GetCode ($length) {//Generate PHP random number $pattern = ' 1234567890ABCDEFGHIJKLOMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ';//character descriptors for ($i =0; $i < $length; $i + +) { $key. = $pattern {Mt_rand (0,35)}; } return $key; } Ob_clean (); Header (' content-type:image/png '); Imagepng ($IMG); ?> |