国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > PHP > 正文

php驗(yàn)證碼程序代碼

2024-05-04 21:58:46
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

網(wǎng)上生成php驗(yàn)證碼程序用很多,下面我來(lái)給大家分享一款超不錯(cuò)的php驗(yàn)證碼程序代碼,有需要的朋友可參考,驗(yàn)證碼識(shí)別一般分為以下幾個(gè)步驟:1. 取出字模,2. 二值化,3. 計(jì)算特征,4. 對(duì)照樣本.

php驗(yàn)證碼程序代碼如下:

  1. function _code($_code_length = 4, $_width = 75, $_height = 25){ 
  2.     for($i=0;$i<$_code_length;$i++){ 
  3.         $_nmsg .= dechex(mt_rand(0,15)); 
  4.     } 
  5.     $_SESSION["code"] = $_nmsg
  6.  
  7.     $_img = imagecreatetruecolor($_width$_height); 
  8.  
  9.     $_white = imagecolorallocate($_img, 250, 250, 250); 
  10.  
  11.     imagefill($_img, 0, 0, $_white); 
  12.  
  13.     $_gray = imagecolorallocate($_img, 196, 196, 196); 
  14.  
  15.     imagerectangle($_img, 0, 0, $_width-1, $_height-1, $_gray); 
  16.  
  17.     for ($i=0; $i < 6; $i++) {  
  18.         $_md_color = imagecolorallocate($_img, mt_rand(200,255), mt_rand(200,255), mt_rand(200,255)); 
  19.         imageline($_img, mt_rand(0,$_width), mt_rand(0, $_height),mt_rand(0,$_width), mt_rand(0, $_height), $_md_color); 
  20.     } 
  21.  
  22.     for ($i=0; $i < 50; $i++) {  
  23.         $_md_color = imagecolorallocate($_img, mt_rand(200,255), mt_rand(200,255), mt_rand(200,255)); 
  24.         imagestring($_img, 1, mt_rand(1,$_width-5), mt_rand(1, $_height-5), "*"$_md_color); 
  25.     } 
  26.  
  27.     for ($i=0; $i < $_code_length ; $i++) {  
  28.         $_md_color = imagecolorallocate($_img, mt_rand(0,102), mt_rand(0,102), mt_rand(0,102)); 
  29.         imagestring($_img, 5, $i * $_width/$_code_length+ mt_rand(1, 10), mt_rand(1, $_height/2), $_SESSION["code"][$i], $_md_color); 
  30.     } 
  31.  
  32.     header("Content-Type:image/png"); 
  33.  
  34.     imagepng($_img); 
  35.  
  36.     imagedestroy($_img); 
  37.  
  38. //驗(yàn)證碼使用方法 
  39.  //開源代碼Vevb.com 
  40. $getcode = $_POST['code']; 
  41.  
  42. if$_SESSION["code"] = $getcode ) 
  43.   echo ' 驗(yàn)證合法,進(jìn)入下一步'
  44.   unset( $_SESSION["code"] ); 
  45. else 
  46.   echo ' 驗(yàn)證碼不正確'
  47.   header('location:vial.php'); 

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 建昌县| 桓台县| 比如县| 左贡县| 额济纳旗| 黔江区| 壤塘县| 汶川县| 嵊泗县| 威宁| 武冈市| 关岭| 库伦旗| 永年县| 偃师市| 涞源县| 新竹市| 永嘉县| 海林市| 徐水县| 定日县| 红桥区| 固原市| 鄂州市| 修文县| 鄂伦春自治旗| 会泽县| 漾濞| 开江县| 胶南市| 上蔡县| 望奎县| 顺义区| 南阳市| 江永县| 康平县| 开鲁县| 镇江市| 上饶县| 泽库县| 西贡区|