php代码
<?php
class image{
session_start();
//验证码类
static public function verify($code,$width=75,$height=25,$n=4){
header("content-type:image/png");
// 创建画布
$img=imagecreatetruecolor($width,$height);
// 设置背景色
$bgcolor=imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),rand(200,255));
// 将背景色填充
imagefill($img,0,0,$bgcolor);
// 绘制五条弧线
for($i=0;$i<5;$i++){
$arccolor=imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),rand(200,255));
imagearc($img,mt_rand(5,($width-5)),mt_rand(5,($height-5)),mt_rand(5,($width-5)),mt_rand(5,($height-5)),mt_rand(0,360),mt_rand(0,360),$arccolor);
}
// 绘制一百个点
for($i=0;$i<100;$i++){
$pixelcolor=imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),rand(200,255));
imagesetpixel($img,mt_rand(1,($width-1)),mt_rand(1,($height-1)),$pixelcolor);
}
// 绘制五条线段
for($i=0;$i<5;$i++){
$linecolor=imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),rand(200,255));
imageline($img,mt_rand(1,($width-1)),mt_rand(1,($height-1)),mt_rand(1,($width-1)),mt_rand(1,($height-1)),$linecolor);
}
// 设置边框颜色
$bdcolor=imagecolorallocate($img,mt_rand(150,200),mt_rand(150,200),rand(150,200));
// 绘制一个矩形无填充边框
imagerectangle($img,0,0,($width-1),($height-1),$bdcolor);
// 设置验证码字符串
$str='';
for($i=1;$i<=$n;$i++){
$str.=substr(str_shuffle($code),0,1);
}
$_SESSION['a']=$str;
//
for($i=0;$i










