<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<!--#include file="md5.asp"-->
<%

dim action:action=request("action")
if action="chk" then
  '管理登陆
 dim admin,password
 
 admin=checkstr(trim(request.form("admin")))
 password=checkstr(trim(request.form("password")))
 
 if admin="" or password="" then
   call mb("请输入登陆帐号或登陆密码！","",0)
 end if
 
 set rs=server.createobject("adodb.recordset")
 sql="select * from admin where admin='"&admin&"'"
 rs.open sql,conn,1,3
 
 if rs.bof and rs.eof then
   call mb("对不起，您的帐号或密码有误！","",0)
 elseif rs("password")<>md5(password,"long") then
   call mb("对不起，您的帐号或密码有误！","",0)
 elseif rs("islock") then
   call mb("对不起，您的帐号处于锁定状态，请和管理员联系！","",0)
 else
   '登陆成功
   rs("logins")=rs("logins")+1  '登陆数加１
   rs("lastlogin")=now()  '最后登陆
   rs("lastip")=request.servervariables("remote_addr")  '写入最后登陆ＩＰ
   rs.update
   
   session("admin")=admin
   session("flag")=rs("flag")  '管理员帐号
  rs.close
  set rs=nothing
  response.redirect("admin_index.asp")  
 end if

elseif action="logout" then
  
   '退出登陆
   session("admin")=""
   session("flag")=""
   
   response.redirect("admin_login.asp")
else
 '登陆界面
%>
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理员登陆</title>
<link href="admin.css" rel="stylesheet" type="text/css">
</head>

<body>

<p>　</p>
<p>　</p>
<p>　</p>
<p>　</p>
<form action="?action=chk" method="post" name="login" id="login">
  <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr align="center" bgcolor="#EFEBEF" > 
      <td height="23" colspan="2"><font color="#000000">管 理 员 登 陆</font></td>
    </tr>
    <tr> 
      <td width="73" height="30" align="center" bgcolor="#FFFFFF">登陆帐号：</td>
      <td width="224" height="30" bgcolor="#FFFFFF">&nbsp; 
        <input name="admin" type="text" class="input" id="admin" size="25"></td>
    </tr>
    <tr> 
      <td height="30" align="center" bgcolor="#FFFFFF">登陆密码：</td>
      <td height="30" bgcolor="#FFFFFF">&nbsp; 
        <input name="password" type="password" class="input" id="password" size="25"></td>
    </tr>
    <tr align="center"> 
      <td height="30" colspan="2" bgcolor="#FFFFFF"> 
        <input name="Submit" type="submit" class="button" value=" 登 陆 ">
        <font color="#FF0000">如果您不是管理员请离开这里！</font> </td>
    </tr>
  </table>
</form>
<p>　</p>
</body>
</html>
<%end if%>