author:咔咔
/**
* author:咔咔
*
* 验证码
*/
public function codeAction() {
Header("Content-type: image/PNG");
$rand ="";
for($i=0;$i<4;$i++){
$rand.=dechex(rand(0,15));
}
$im = imagecreate(100,30);
$gray = ImageColorAllocate($im, 200,200,200);
for($i=0;$i<3;$i++){
$te=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
}
imagefill($im,0,0,$gray);
while(($rand=rand()%100000)<10000);
$_SESSION['rand']=$rand;
imagestring($im, 5, 30, 10, $rand, $te);
for($i=0;$i<200;$i++)
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%100 , rand()%50 , $randcolor);
}
imageline($im,0,rand(0,100),100,rand(0,15),$randcolor);
imageline($im,0,rand(0,100),100,rand(0,15),$randcolor);
imageline($im,0,rand(0,100),100,rand(0,15),$randcolor);
ImagePNG($im);
ImageDestroy($im);
}