Ec (2); & lt ;? Phpsession_start (); # obtain the random character functiongetRandStr ($ length4, $ mode1) {& nbsp; $ str4173456789; & nbsp; $ str2abcdefghijklmnopqrstuvwxyz; & nbsp; $ str3ABCDEFGHIJKLMNPQRSTUVW script ec (2); script
Session_start ();
# Obtain random characters
Function getRandStr ($ length = 4, $ mode = 1)
{
$ Str1 = '20140901 ';
$ Str2 = 'abcdefghijklmnopqrstuvwxy ';
$ Str3 = 'abcdefghijklmnpqrstuvwxy ';
$ Str4 = '_';
$ Str5 = ''~! @ # $ % ^ & * ()-+ =\|{} [];: '",./? ';
$ Str6 = 'Sun jihai has made meritorious deeds. Don't give the Japanese any chance. Great China's right-back: He inherits the glorious tradition of the Chinese nation, Dong cunrui, Huang Jiguang, Qiu shaoyun. At this moment, Sun jihai stands for a long time in Chinese National Football. the tradition at this moment, he is not fighting alone. He is not alone. Li Yi, the emperor, is facing the penalty. He is facing the eyes of Chinese fans all over the world and is expecting that Sichuan can live in an additional round that used to be pre-selected for the World Cup. the Emperor is sure to know that he can still face the person in front of him with a smile. How will he get the expression after the match is over? victory for the Japanese team they did not once again come in front of Jike great People's Republic of China great Chinese team right-back kitten today happy birthday to the People's Republic of China long live Japanese team may regret him playing one more person in the second half playing too conservative, too calm, he lost his courage to face the long history and tradition of Chinese football. He didn't come up with a group stage as a collision with the goalkeeper. Finally, they should go home. They don't have to go back far. because they will choose to commit suicide collectively ';
Switch ($ mode)
{
Case '0 ':
$ Str = $ str1. $ str2. $ str3. $ str4;
Break;
Case '1 ':
$ Str = $ str1;
Break;
Case '2 ':
$ Str = $ str2;
Break;
Case '3 ':
$ Str = $ str3;
Break;
Case '4 ':
$ Str = $ str2. $ str3;
Break;
Case '5 ':
$ Str = $ str1. $ str2;
Break;
Case '6 ':
$ Str = $ str1. $ str3;
Break;
Case '7 ':
$ Str = $ str1. $ str2. $ str3;
Break;
Case '8 ':
$ Str = $ str1. $ str2. $ str3. $ str4. $ str5;
Break;
Case '9 ':
$ Str = $ str6;
Break;
Default:
$ Str = $ str1. $ str2. $ str3. $ str4;
Break;
}
$ Result = "";
If ($ mode = 9)
{
$ Tmp1 = $ length/2;
$ Tmp = explode (".", strlen ($ str)/2 );
For ($ I = 0; $ I <$ tmp1; $ I ++)
{
$ Result. = Substr ($ str, mt_rand (0, $ tmp [0]) * 2-$ length, 2 );
}
}
Else
{
For ($ I = 0; $ I <$ length; $ I ++)
{
$ Result. = $ str [mt_rand (0, strlen ($ str)-1)];
}
}
Return $ result;
}
##
# Generating Verification Code Images
#
Function createAuthNumImg ($ randStr, $ isGB = false)
{
Header ("Content-type: image/PNG ");
$ Im = imagecreate (50, 20 );
$ Black = ImageColorAllocate ($ im, 0, 0 );
$ White = ImageColorAllocate ($ im, 255,255,255 );
$ Gray = ImageColorAllocate ($ im, 0,100,150 );
Imagefill ($ im, 50, 19, $ gray );
For ($ I = 0; $ I <80; $ I ++) # Add interference pixels
{
$ Randcolor = ImageColorallocate ($ im, rand (0,255), rand (0,255), rand (0,255 ));
Imagesetpixel ($ im, rand () % 50, rand () % 19, $ randcolor );
}
If ($ isGB! = False) # use a Chinese Verification Code
{
Require_once ("GB2312toUTF8. inc. php ");
$ GB2312toUTF = new GB2312toUTF8 ();
Imagettftext ($ im, 10, 5, 5, 16, $ white, "simsun. ttc", $ GB2312toUTF-> gb2utf8 ($ randStr ));
}
Else imagestring ($ im, 8, 8, 3, $ randStr, $ white); # print the verification code into the image
ImagePNG ($ im );
ImageDestroy ($ im );
$ _ SESSION ['chknum'] = $ randStr; # Save the verification code
}
$ M = $ _ GET ["m"];
If (empty ($ m )){
$ M = 9;
}
CreateAuthNumImg (getRandStr ("6", $ m), 1)
?>