|
|
3#

楼主 |
发表于 2007-10-4 16:59:38
|
只看该作者

php生成的附加码其他参考代码
<?
/*
* Filename: authpage.php
* Date: 2003-7-13
* Version: 1.3.2
*/
session_start();
//验证用户输入是否和验证码一致
if (isset($_POST['authinput']))
{
if ($_SESSION['auth'] == $_POST['authinput'])
{
echo "验证成功!";
exit;
} else echo "验证失败!";
}
?>
<form action=authpage.php method=post>
<table><tr><td>请输入验证码:<input type=text name=authinput style="width: 80px"><img src=authimg.php></td></tr>
<tr><td><input type=submit name="验证" value="提交验证码">
</td></tr>
</table>
</form>
===============================================================================
<?php
/*
* Filename: authimg.php
* Date: 2003-7-13
* Version: 1.3.2
*/
session_start();
srand((double)microtime()*1000000);
while(($authnum=rand()%10000)<1000);//生成四位随机整数验证码
$_SESSION['auth']=$authnum;
//生成验证码图片
Header("Content-type: image/PNG");
$im = imagecreate(50,20);
$black = ImageColorAllocate($im, 200,10,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 230,230,230);
imagefill($im,68,30,$gray);
//将四位整数验证码绘入图片
//位置交错
for ($i = 0; $i < strlen($authnum); $i++) {
if ($i % 2 == 0) $top = 1;
else $top = 5;
imagestring($im, 5, 10*$i+6, $top, substr($authnum,$i,1), $black);
}
for ($i = 0; $i < 150;$i++) //加入干扰象素
{
imagesetpixel($im, rand()%70 , rand()%30 , $black);
}
ImagePNG($im);
ImageDestroy($im);
?>
<?php
Header("Content-type: image/png");
function random($length=6)
{
$hash = '';
$chars = '0123456789';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++)
$hash .= $chars[mt_rand(0, $max)];
return $hash;
}
$rand=random(6);
$_SESSION['randomcode']=$rand;
$im = imagecreate(60,25);
$white = ImageColorAllocate($im, 255,255,255);
$red = ImageColorAllocate($im, 255,0,0);
imagestring($im, 5, 4, 6,$rand, $red);
Imagepng($im);
ImageDestroy($im);
?>
______________________________________________________________________________________________
答6:
<?
/* login.php */
session_start();
?>
<FORM METHOD=POST ACTION="ii.php">
<input type=text name=number maxlength=4><img src="yan.php">
<INPUT TYPE="submit" name="sub">
</FORM>
<?
if(isset($_POST["sub"])){
if($_POST["number"]!=$_SESSION["auth"]||empty($_POST["number"])){
echo "验证码错误" ;
unset($_SESSION['auth']);
}else{
echo"验证码正确";
unset($_SESSION['auth']);
};
};
?>
====================
yan.php
<?php
session_start();
srand((double)microtime()*1000000);
while(($authnum=rand()%10000)<1000);//生成四位随机整数验证码
$_SESSION['auth']=$authnum;
//生成验证码图片
Header("Content-type: image/PNG");
$im = imagecreate(50,20);
$black = ImageColorAllocate($im, 200,10,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 230,230,230);
imagefill($im,68,30,$gray);
//将四位整数验证码绘入图片
//位置交错
for ($i = 0; $i < strlen($authnum); $i++) {
if ($i%2 == 0) $top = 1;
else $top = 5;
imagestring($im, 5, 10*$i+6, $top, substr($authnum,$i,1), $black);
}
for($i=0;$i<150;$i++) //加入干扰象素
{
imagesetpixel($im, rand()%70 , rand()%30 , $black);
}
ImagePNG($im);
ImageDestroy($im);
?>
______________________________________________________________________________________________
答7:
我自己写的 你可以再写些东西加上
graphic.php
<?php
error_reporting(0);
session_start();
$im=imagecreate(110,140); //创建空白图片
imagefill($im,0,0,imagecolorallocate($im, 100, 255, 255));//图片填充白色
imagestring($im,5,10,10,$_SESSION['validata'],imagecolorallocate($im, 255, 0, 0));//图片上写字
imagepng($im); //显示图片,格式png
imagedestroy($im); //垃圾回收
exit
?>
login.php
<?
session_start();
$_SESSION['validata']=rand(10000,99999);
echo $_SESSION['validata'];
echo '<img src="../graphic.php">';
?> |
|