<?php
header("content-type:image/png");
$img=imagecreatetruecolor(80,40);
$red=imagecolorallocate($img,0xff,0x00,0x00);
$black = imagecolorallocate($img, 0x00, 0x00, 0x00);
$green = imagecolorallocate($img, 0x00, 0xFF, 0x00);
$white = imagecolorallocate($img,255,255,255);
imagefill($img,0,0,$white);
$str='';
$arr=explode(',',file_get_contents("yanzheng.txt"));
$arrlen=count($arr);
for($i=0;$i<4;$i++){
$num=rand(0,35);
$str.=$arr[$num];
}
for($i=0;$i<500;$i++) {
imagesetpixel($img,rand(0,100),rand(0,100),$black);
imagesetpixel($img,rand(0,100),rand(0,100),$green);
}
for($i=0;$i<10;$i++) {
imageline($img,rand(0,80),rand(0,40),rand(0,80),rand(0,40),$black);
imageline($img,rand(0,80),rand(0,40),rand(0,80),rand(0,40),$green);
}
$font="C:\Windows\Fonts\simhei.ttf";//字体
setcookie("yanzheng",$str,time()+60);
imagettftext($img,20,0,10,30,$red,$font,$str);
imagepng($img);
imagedestroy($img);