查看: 5625|回复: 2
打印 上一主题 下一主题

求php生成的附加码代码

[复制链接]
跳转到指定楼层
1#
发表于 2007-10-4 16:59:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
<?
/////////////////////////////////////////////////////////////////////////////////////////////////////
//File:     getcode.php
//Author:   TZNKTG
//Purpose:  This page is get append code.
/////////////////////////////////////////////////////////////////////////////////////////////////////

session_start();
srand((double)microtime()*1000000);
while(($verifycode=rand()%10000)<1000);
$_SESSION['verifycode']=$verifycode;
Header("Content-type: image/PNG");  
srand((double)microtime()*1000000);
$im = imagecreate(50,18);
$bgcolor = ImageColorAllocate($im, 255,255,255);
$textcolor = ImageColorAllocate($im, 0,0,0);
imagefill($im,50,18,$bgcolor);
while(($authnum=rand()%100000)<10000);
//将四位整数验证码绘入图片
imagestring($im,5, 7, 1, $_SESSION['verifycode'], $textcolor);
for($i=0;$i<200;$i++)   //加入干扰象素
{
        $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
        imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
ImagePNG($im);
ImageDestroy($im);         
exit();



?>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
2#
 楼主| 发表于 2007-10-4 16:59:21 | 只看该作者
台州网址导航
<form name="form1" method="post" action="login.php">
<input type="hidden" value="8kjbas" name="sid">
<table class="tableborder" cellspacing="1" cellpadding="4" width="50%" align="center">
  <tbody>
  <tr class="header">
    <td colspan=2 align="center">【<?php echo $title ?>】网站后台管理登陆</td></tr>
  <tr>
    <td class="altbg1" width="25%" align="center">管理员名称:</td>
    <td class="altbg2"><span class="font-14red  style1">
      <input name="username" type="text" id="username" size="30">
    </span></td></tr>
  <tr>
    <td class="altbg1" width="25%" align="center">管理员密码:</td>
    <td class="altbg2"><span class="font-14red  style1">
      <input name="password" type="password" id="password" size="25">
    </span><span class="font-14red  style1">
    <input name="usnamed" type="password" id="usnamed" size="5">
    </span></td>
  </tr>
  <tr>
        <td class="altbg1" width="25%" align="center"><b>附加码:</b></td><td valign=middle class="altbg2"><input name=verifycode type=text value="" size="20"> 请输入 <img style="border: 1px solid #3C67BF;" align="absmiddle" src="../include/getcode.php" width="50" height="18"></td></tr>
        </td>
  </tr>
  <tr>
    <td class=altbg1> </td>
    <td class=altbg2><span class="font-14red  style1">
      <input type="submit" name="submit" value="登陆">
    </span><span class="font-14red  style1">  
    <input type="reset" name="submit2" value="重置">
    </span></td>
  </tr>
  </tbody>
  </table>
<br>
</form>
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
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">';
?>
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表