深圳市一览网络股份有限
公司
ShenZhen Elanw Network
Co.,Ltd.
地址:南山科技园南区数字技术园
B2 栋 4A
Add: Room A,4th Floor,Block
B2,Digi-Tech Park ,
电话(Tel):0755-86133725
传真(Fax):0755-22632616
网址
(Web):www.YL1001.com
imagettftext(
$this
->img,
$this
-
>fontSize,mt_rand(-30,30),
$i
*
$x
+mt_rand(1,5),
$this
->height/1.4,
$this
->fontColor,
$this
->font,
$this
->code[
$i
]);
// www.jbxue.com
//imagestring($this->img,5,$i*$x+mt_rand(1,5),5,$this->code[$i],$this->fontColor);
}
}
//生成线条、雪花
private
function
createDisturb(){
for
(
$i
= 0;
$i
< 6;
$i
++) {
$color
=imagecolorallocate(
$this
->img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));
imageline(
$this
->img,mt_rand(0,
$this
->width),mt_rand(0,
$this
->width),mt_rand(0,
$this
-
>width),mt_rand(0,
$this
->width),
$color
);
}
for
(
$i
= 0;
$i
< 100;
$i
++) {
$color
=imagecolorallocate(
$this
->img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
imagestring(
$this
->img,mt_rand(1,5),mt_rand(0,
$this
->width),mt_rand(0,
$this
->height),'*',
$color
);
}
}
//输出
private
function
outPut(){
header("Content-Type:image/png");
imagepng(
$this
->img);
imagedestroy(
$this
->img);
}
public
function
showCode(){
$this
->createBg();
$this
->createCode();
$this
->createDisturb();
$this
->createFont();
$this
->outPut();
}
//获取验证码
public
function
getCode(){
return
strtolower
(
$this
->code);
}
}
?>
code.php
复制代码
代码如下:
<?php
session_start();
require_once
'VerificationCode.class.php';