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

首頁 > 語言 > PHP > 正文

php 復雜生成驗證碼圖片

2024-09-04 11:44:24
字體:
來源:轉載
供稿:網友
  1. function image3($length=4,$type='png',$width=180,$height=60,$fontface='fpnf.ttf',$verifyName='verify') { 
  2.         $code = $this->rand_string($length,4); 
  3.         $width = ($length*25)>$width?$length*25:$width
  4.         $authCode = new Zend_Session_Namespace('Auth_Code'); 
  5.         $authCode->imagecode = $randval
  6.          
  7.         $im=imagecreatetruecolor($width,$height); 
  8.         $borderColor = imagecolorallocate($im, 100, 100, 100);                    //邊框色 
  9.         $bkcolor=imagecolorallocate($im,250,250,250); 
  10.         imagefill($im,0,0,$bkcolor); 
  11.         @imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor); 
  12.         // 干擾 
  13.         for($i=0;$i<15;$i++){//開源代碼Vevb.com 
  14.             $fontcolor=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); 
  15.             imagearc($im,mt_rand(-10,$width),mt_rand(-10,$height),mt_rand(30,300),mt_rand(20,200),55,44,$fontcolor); 
  16.         } 
  17.         for($i=0;$i<255;$i++){ 
  18.             $fontcolor=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); 
  19.             imagesetpixel($im,mt_rand(0,$width),mt_rand(0,$height),$fontcolor); 
  20.         } 
  21.         if(!is_file($fontface)) { 
  22.             $fontface = dirname(__FILE__)."/".$fontface
  23.         } 
  24.         for($i=0;$i<$length;$i++){ 
  25.             $fontcolor=imagecolorallocate($im,mt_rand(0,120),mt_rand(0,120),mt_rand(0,120)); //這樣保證隨機出來的顏色較深。 
  26.             $codexsubstr($code,$i,1); 
  27.             imagettftext($im,mt_rand(16,20),mt_rand(-60,60),40*$i+20,mt_rand(30,35),$fontcolor,$fontface,$codex); 
  28.         } 
  29.         $this->output($im,$type); 
  30.     } 
  31.      
  32.     function output($im,$type='png')  
  33.     { 
  34.         header("Content-type: image/".$type); 
  35.         $ImageFun='Image'.$type
  36.         $ImageFun($im); 
  37.         imagedestroy($im); 
  38.     } 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 类乌齐县| 宁南县| 福州市| 二连浩特市| 博客| 景宁| 蕉岭县| 齐齐哈尔市| 孝感市| 抚宁县| 林州市| 喀喇沁旗| 江孜县| 深州市| 宁陵县| 莲花县| 大安市| 恭城| 南宁市| 二连浩特市| 静宁县| 茌平县| 平安县| 万源市| 长丰县| 庆安县| 松原市| 吉木萨尔县| 方城县| 陵水| 双城市| 莒南县| 六盘水市| 温宿县| 镇雄县| 黑水县| 安阳县| 竹北市| 于田县| 忻州市| 舞钢市|