當前位置:名人名言大全網 - 祝福短信 - 求完整的PHP驗證碼。

求完整的PHP驗證碼。

& lt?服務器端編程語言(Professional Hypertext Preprocessor的縮寫)

header(" content-Type:image/gif ");函數getRandStr($len=4,$type=0){

mt _ srand(microtime(true)* 10000);

$ num =“”;

//獲取號碼

for($ n = 48;$ n & lt58;$n++){

$num。= chr($ n);

} $ xiaoie =“”;

//獲取小寫

for($ m = 97;$ m & lt123;$m++){

$小謝。= chr($ m);

} $ daie =“”;

//獲取大寫

for($ n = 65;$ n & lt91;$n++){

$大榭。= chr($ n);

}

開關($類型){

案例0:

$allstr=$num。$大榭。$小謝;

打破;

案例1:

$ allstr = $ num

打破;

案例二:

$allstr=$daxie。$小謝;

打破;

默認值:

$allstr=$num。$大榭。$小謝;

打破;

}

$ strlen = strlen($ all str);

if($ len & gt;$strlen)

返回“”;

$ rand =“”;

for($ l = 0;$ l & lt$ len$l++){

美元蘭特。=$allstr{mt_rand(0,$ strlen-1)};

}

返回$蘭特;

}

$ w = 80

$ h = 30//創建畫布

$im=imagecreate($w,$ h);//創建壹個真彩色畫布,效果同上。

//$im=imagecreatetruecolor($w,$ h);//設置背景顏色

$ BG _ color = imagecolorlallocate($ im,rand(100,150),rand(200,255),rand(100,150));//設置模糊點的顏色。

$ mohu _ color = imagecolorloculate($ im,mt_rand(20,50),mt_rand(20,50),mt_rand(100,200));

//模糊背景。

for($ I = 0;$ i & lt100;$i++){

imagesetpixel($im,rand(1,$w-1),rand(1,$h-1),$ mohu _ color);

}//設置線條顏色

$ line _ color = imagecolorlocate($ im,mt_rand(20,50),mt_rand(20,50),mt_rand(100,200));

for($ j = 0;$ j & lt5;$j++){

//畫線

imageline($im,mt_rand(0,$w),mt_rand(0,$h),mt_rand(0,$w),mt_rand(0,$w),$ line _ color);

} $ randstr = getrandStr();

$ _ SESSION[' rand code ']= $ randstr;$ font _ color = imagecolorlallocate($ im,mt_rand(20,50),mt_rand(20,50),mt_rand(100,200));

$font= "。/Fonts/ARIALNI。TTF”;

//王圖片加字符串

imagettftext($im,14,rand(0,6),15,20,$font_color,$font,$ randstr);//生成GIF圖片

imagegif($ im);//毀圖

imagedestroy

& gt