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

首頁 > 網站 > 建站經驗 > 正文

php 生成復雜驗證碼圖片

2024-04-25 20:37:08
字體:
來源:轉載
供稿:網友

php 生成復雜驗證碼圖片

代碼如下:

function image3($length=4,$type='png',$width=180,$height=60,$fontface='fpnf.ttf',$verifyName='verify') {

$code = $this->rand_string($length,4);

$width = ($length*25)>$width?$length*25:$width;

$authCode = new Zend_Session_Namespace('Auth_Code');

$authCode->imagecode = $randval;

$im=imagecreatetruecolor($width,$height);

$borderColor = imagecolorallocate($im, 100, 100, 100); //邊框色

$bkcolor=imagecolorallocate($im,250,250,250);

imagefill($im,0,0,$bkcolor);

@imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor);

// 干擾

for($i=0;$i<15;$i++){//開源代碼phpfensi.com
$fontcolor=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imagearc($im,mt_rand(-10,$width),mt_rand(-10,$height),mt_rand(30,300),mt_rand(20,200),55,44,$fontcolor);

}

for($i=0;$i<255;$i++){
$fontcolor=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imagesetpixel($im,mt_rand(0,$width),mt_rand(0,$height),$fontcolor);

}

if(!is_file($fontface)) {

$fontface = dirname(__FILE__)."/".$fontface;

}

for($i=0;$i<$length;$i++){
$fontcolor=imagecolorallocate($im,mt_rand(0,120),mt_rand(0,120),mt_rand(0,120)); //這樣保證隨機出來的顏色較深。

$codex= substr($code,$i,1);
imagettftext($im,mt_rand(16,20),mt_rand(-60,60),40*$i+20,mt_rand(30,35),$fontcolor,$fontface,$codex);

}

$this->output($im,$type);

}

function output($im,$type='png')

{

header("Content-type: image/".$type);

$ImageFun='Image'.$type;

$ImageFun($im);

imagedestroy($im);

}

 

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永顺县| 合山市| 梁平县| 岱山县| 休宁县| 新丰县| 镇原县| 金湖县| 灵台县| 宾阳县| 贵德县| 嘉峪关市| 洪洞县| 松江区| 饶平县| 澎湖县| 平泉县| 延安市| 小金县| 华容县| 宁武县| 遵义县| 文成县| 姚安县| 上虞市| 宜宾市| 桐城市| 霍山县| 宁远县| 蕉岭县| 剑川县| 嘉鱼县| 东港市| 额尔古纳市| 韶关市| 石景山区| 望城县| 徐州市| 普安县| 乌拉特前旗| 都江堰市|