国产探花免费观看_亚洲丰满少妇自慰呻吟_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);

}

 

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 天祝| 玉树县| 闻喜县| 泰兴市| 上犹县| 图木舒克市| 武义县| 凭祥市| 夏邑县| 中方县| 沙坪坝区| 凉城县| 霍邱县| 邓州市| 吕梁市| 乌审旗| 保山市| 巫山县| 青州市| 马龙县| 离岛区| 衡东县| 行唐县| 永福县| 探索| 阳高县| 松溪县| 建始县| 衡南县| 南投县| 信阳市| 靖江市| 和田县| 晋宁县| 儋州市| 白银市| 淅川县| 江陵县| 博乐市| 梅河口市| 罗定市|