下一篇 » « 上一篇

phpArticle登录雪花水印验证码mod

作者:guggle    时间:2008-01-22    来源:21ds.net    点击:8341    本文共1篇文章 字体:[ ]

phpArticle登录雪花水印验证码mod

注意事项:在DIY前,请你先对要修改的模板进行备份。

php学习之家http://www.444p.com

需要修改的是以下这些内容:
1、新建生成图片的文件YanZhengMa.php ,代码如下。保存完之后上传到Admin目录。 php学习之家http://www.444p.com


本文来自 www.444p.com

<?php
session_start();
session_register("login_check_number");

$img_height=24;
$img_width=100;
if($HTTP_GET_VARS["act"]== "init"){
&nbsp; &nbsp;for($Tmpa=0;$Tmpa<4;$Tmpa++){
&nbsp; &nbsp; &nbsp; &nbsp;$nmsg.=dechex(rand(0,15));
&nbsp; &nbsp;}

$HTTP_SESSION_VARS[login_check_number] = $nmsg;

&nbsp; &nbsp;$aimg = imageCreate($img_width,$img_height);
&nbsp; &nbsp;ImageColorAllocate($aimg, 255,255,255);
&nbsp; &nbsp;$black = ImageColorAllocate($aimg, 0,0,0);
&nbsp; &nbsp;ImageRectangle($aimg,0,0,$img_width-1,$img_height-1,$black);

&nbsp; &nbsp;for ($i=1; $i<=100; $i++) {
&nbsp; &nbsp; &nbsp; &nbsp;imageString($aimg,1,mt_rand(1,$img_width-4),mt_rand(1,$img_height-7),"*",imageColorAllocate($aimg,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255)));
&nbsp; &nbsp;}

&nbsp; &nbsp;for ($i=0;$i<strlen($HTTP_SESSION_VARS[login_check_number]);$i++){
&nbsp; &nbsp; &nbsp; &nbsp;imageString($aimg, mt_rand(3,5),$i*$img_width/4+mt_rand(1,10),mt_rand(1,$img_height/4), $HTTP_SESSION_VARS[login_check_number][$i],imageColorAllocate($aimg,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200)));
&nbsp; &nbsp;}
&nbsp; &nbsp;Header("Content-type: image/png");
&nbsp; &nbsp;ImagePng($aimg);
&nbsp; &nbsp;ImageDestroy($aimg);
}
?>

 2、修改admin目录下的adminfunctions.php

echo " <td width='232'><font class='normalfont'><input class=text type='password' name='password' value=''></font></td></tr>";


后增加两行: www.444p.com版权所有


www.444p.com

<td width='118'><font class='normalfont'>验证码:</font><img src=../admin/YanZhengMa.php?act=init></td>";
        echo " <td width='232'><font class='normalfont'><input class=text type='text' name='number' value=''></font></td></tr>";

 3、修改admin目录下的global.php和manage目录下的global.php
本文来自 www.444p.com

error_reporting(7);

后增加一行:

www.444p.com版权所有

CODEsession_start();


www.444p.com

if ($_POST[action]=="login") {

后面增加4行  php学习之家

  echo " <tr class=secondalt>if($HTTP_POST_VARS["number"] != $HTTP_SESSION_VARS[login_check_number] || empty($HTTP_POST_VARS["number"])){
  loginlog($_POST[username],$_POST[password],"Referer: ".getenv("HTTP_REFERER"));
  displaylogin();
}else{

还需要在  php学习之家http://www.444p.com

cpfooter();
} else {
loginlog($_POST[username],$_POST[password],"Referer: ".getenv("HTTP_REFERER"));
displaylogin();
}

 
后面增加一个反括号

php学习之家http://www.444p.com

CODE}

4、注意事项
admin中的global.php和manage中的global.php需要分别修改,不能相互覆盖,因为他们的if ($_POST[action]=="login") 后面的原始代码不同。 本文来自 www.444p.com

5、建议
为了更好的提高安全性,还可以在manage中的各个控制文件中做限制,比如不让manage管理员编辑和删除30天前的内容。这样做的好处是即便有manage帐号泄露或者误操作,都不至于引起很严重的后果。

www.444p.com版权所有

6、效果图 www.444p.com

责任编辑:semirock
发表评论
密码: (游客不需要密码)
记住我【Alt+S 或 Ctrl+Enter 快速提交】

搜索工具


热门搜索: [html][html][else][MYsql][mysql][调用][date][print][配置][配置]

《Phparticle》点击排行