ycycoco 发表于 2017-3-30 06:57:59

chkadmin.php的源代码分析

<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>  chkadmin.php的源代码如下:
  <?php
class chkinput{
  %声明一个类chkinput
var $name;
var $pwd;
  %两个属性name和pwd
  function chkinput($x,$y)
{
$this->name=$x;
$this->pwd=$y;
}
  %函数chkinput:初始化类的两个属性
  function checkinput()
{
include("../conn/conn.php");
  %将conn.php包含进来
$sql=mysql_query("select * from tb_admin where name='".$this->name."'",$conn);
  %查询数据库
$info=mysql_fetch_array($sql);
  %根据查询字符串获得结果,存放在info变量中
  
if($info==false)
{
echo "<script language='javascript'>alert('不存在此管理员!');history.back();</script>";
  %若返回结果为空,则提示不存在此管理员,并退出
exit;
}
else
{
if($info==$this->pwd){
header("location:index.php");
  %若密码是对的,则重定向到管理员的首页index.php
}
else
{
echo "<script language='javascript'>alert('密码输入错误!');history.back();</script>";
  %若密码不正确,则提示用javascript脚本提示用户:密码输入错误!
exit;
}
  }
}
}
  
$obj=new chkinput(trim($_POST),md5(trim($_POST)));
$obj->checkinput();
  
%此语句首先通过_POST获得用户名和密码,然后去掉两个字符串的开头和结尾的
  %空格,然后调用chkinut类来验证用户名和密码是否合法
  
?>
页: [1]
查看完整版本: chkadmin.php的源代码分析