Here we introduce a relatively high-security verification generation program, which can include interference lines and other content, which can effectively prevent users from using the program to identify the verification code.
The code is as follows
|
Copy code
|
||||
* Created on 2011-3-11 * Programmer: xiaoyao, QQ:1045195056 Verify by judging the input value and $_SESSION['check_pic'] value */ session_start(); function RandAscii($number){//$number generates the number of numbers and letters $arr=array('0','1','2','3','4','5','6','7','8','9', 'a','b','c','d','e','f','g','h','i','j','k','l','m ','n','o','p','q','r','s','t','w','v','u','x','y', 'z'); for ($i=1;$i<=$number;$i++) { $rand= $rand.$arr[rand(0,35)]; } return $rand; } $rand=RandAscii(4); $_SESSION['check_pic']=$rand;//Four randomly generated numbers are assigned to the session for verification. $x=80; $y=24; $im=imagecreatetruecolor($x,$y);//Create image $bg=imagecolorallocate($im,255,255,255);//Set color background imagefill( $im,0,0,$bg); $wh=imagecolorallocate($im,255,255,0); $grey=imagecolorallocate($im,128,128,128); $yellow=imagecolorallocate($im,255,255,0); $red=imagecolorallocate($im,0,255,0); $foregroundArr = array(imagecolorallocate($im, rand(0, 20), rand(0, 20), rand(0, 20)), imagecolorallocate($im, rand(0, 20), rand(0, 10), rand(245, 255)), imagecolorallocate($im, rand(245, 255), rand(0, 20), rand(0, 10)), imagecolorallocate($im, rand(245, 255), rand(0, 20), rand(245, 255)) );//Word color array //Draw a border $border = imagecolorallocate($im, 133, 153, 193); imagerectangle($im, 0, 0, $x - 1, $y - 1, $border); |