谁知道这个是怎么做到的?有源码吗?

来源:百度知道 编辑:UC知道 时间:2024/06/28 02:59:04
动态显示的验证码,在这个网站上看到的. 谁知道? 最好能给份源代码
http://www.kfooo.com/seccode.php
我想知道的不是动态生成
而是生成动态. 这个要搞清楚, 我最想知道的是它是怎么动的.
一般网站的验证码都是静止的.但这个网站的验证码是怎么做到的?

<?php //前面不要有空行

//生成5位的数字图片
Header("Content-type:image/png"); //告诉浏览器,下面的数据是图片,而不要按文字显示

//定义图片宽高
$nwidth=70;
$nheight=30;
$im=@imagecreate($nwidth,$nheight) or die("Can't initialize new GD image stream"); //建立图象

//图片色彩设置
$background_color=imagecolorallocate($im,255,255,97); //匹配颜色
$text_color=imagecolorallocate($im,23,14,91);

//绘制图片边框
imagefilledrectangle($im,0,0,$nwidth-1,$nheight-1,$background); //矩形区域着色
imagerectangle($im,0,0,$nwidth-1,$nheight-1,$text_color); //绘制矩形

srand((double)microtime()*1000000); //取得目前时间的百万分之一秒值,以执行时的百万分之一秒当乱数种子
//$randval=rand();
while(($randval=rand()%100000)<10000); //5位数
imagestring($im,3,20,8,$randval,$text_color); //绘制横式字串

//加入干扰因素
for($i=0;$i<478;$i++)
{
$randcolor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im,rand()%10