验证码生成

Posted by 妖刀 7 March, 2007

function uf_output_yzm()
{
header ("Content-type: image/png");
session_start();
$_SESSION['validate_code']=strtoupper(substr(md5(rand()),20,4));
$im = @imagecreate (80, 20)
or die ("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate ($im, 200, 200, 200);
//设置干扰像素,防止被OCR
for ($i=0;$i<=128;$i++)
{
$point_color = imagecolorallocate ($im, rand(0,255), rand(0,255), rand(0,255));
imagesetpixel($im,rand(2,128),rand(2,38),$point_color);
}
//逐个画上验证码字符
for ($i=0;$i<=3;$i++)
{
$text_color = imagecolorallocate ($im, rand(0,255), rand(0,128), rand(0,255));
$x = 3 + $i * 20;
$y = rand(3,3);
imagechar ($im, 10, $x, $y, $_SESSION['validate_code']{$i}, $text_color);
}
//输出PNG图像
imagepng ($im);
imagedestroy ($im);
}

Categories : 技术 / 设计 Tags :

Comments
July 9, 2008

viagra cialis levitra clomid buy viagra onli generic viagra http://www.parzufim.com cipro gay viagra buy viagra online cheap viagra
free viagra
herbal viagra
propecia xenical viagra side effects buy viagra zithromax lasix female viagra cream cheapest cialis http://www.parzufim.com

Posted by parzufim.com
July 27, 2008

neploxo tak, i`m glad,

Posted by name
Leave a comment

(required)

(required)