<?php
	ini_set("error_reporting","E_ALL & ~E_NOTICE");	
  
	$UserName = $_COOKIE["AdminUserName"];
	$Password = $_COOKIE["AdminPassword"];
	
	include "comm/config.php";
	if (isset($_COOKIE["AdminUserName"]) && isset($_COOKIE["AdminPassword"]) && $UserName == $adminUser && $Password == $adminPass)
	{
		header("location:index.php");
	}
	if($_GET["CheckUser"] == "true" &&  trim($_POST["UserName"]) == $adminUser && trim($_POST["Password"]) == $adminPass && trim($_POST["UserCode"]) == $_COOKIE["UserKey"] )
	{
		   setcookie("AdminUserName",$adminUser,time() + 36000);
		   setcookie("AdminPassword",$adminPass,time() + 36000);
		   header("location:index.php");
	}else
	{
		   setcookie("Append1",rand(0,20),time() + 36000);
		   setcookie("Append2",rand(0,20),time() + 36000);
		   setcookie("UserKey",$_COOKIE["Append1"] + $_COOKIE["Append2"],time() + 36000);
	}
?>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<title>用户登录</title></head>
<body>

<form id="Main" name="Main" method="post" action="login.php?CheckUser=true">
  <table width="54%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#006699">
    <tr>
      <td width="44%" height="35" bgcolor="#FFFFFF"><div align="center">用户名:</div></td>
      <td width="56%" height="35" bgcolor="#FFFFFF"><div align="center">
        <input name="UserName" type="text" id="UserName" />
      </div></td>
    </tr>
    <tr>
      <td height="35" bgcolor="#FFFFFF"><div align="center">密码:</div></td>
      <td height="35" bgcolor="#FFFFFF"><div align="center">
        <input name="Password" type="password" id="Password" />
      </div></td>
    </tr>
    <tr>
      <td height="35" bgcolor="#FFFFFF"><div align="center">验证码:</div></td>
      <td height="35" bgcolor="#FFFFFF"><div align="center">
	  <?php
	  	echo $_COOKIE["Append1"];
	   ?>
	  +
	  <?php  
		echo $_COOKIE["Append2"];  
	  ?>等于几？

	   <label>
	   <input type="text" name="UserCode" />
	   </label>
	   <a href="login.php??UserLogin">取得验证码</a>
      </div></td>
    </tr>
    <tr>
      <td height="35" colspan="2" bgcolor="#FFFFFF">
        <div align="center">
          <input type="submit" name="Submit" value="提交" />
        </div></td>
    </tr>
  </table>
</form>
</body>
</html>
