<!--#include file="../inc/conn2.asp"-->
<!--#include file="../inc/md5.asp"-->
<% Response.CacheControl = "no-cache" %>
<% If Trim(Request.Cookies("PassWord"))=PassWord and UserType=1 Then response.Redirect "index.asp" %>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理系统 - Powered By EIMS</title>
<style type="text/css">
body,td,th {font-size: 12px;font-family:"宋体",Arial, Helvetica, sans-serif;}
body {background:url(img/bg.gif) center repeat-x; margin:0;}
</style>
<script language="javascript" src="eims.js"></script>
<script language="JavaScript" type="text/javascript">
function CKLogin(){
   if (trim(document.eform.UserName.value).length<3){
	  alert("账号错误！");
	  return false;
	  exit;}
   if (trim(document.eform.PassWord.value).length<5){
	  alert("密码错误");
	  return false;
	  exit;}
   if (trim(document.eform.CheckCode.value)==""){
	  alert("请填写验证码!");
	  return false;
	  exit;}
   return true;
}
</script>
</head><body>
<%
if Trim(request.QueryString("Action"))="Login" then
fUserName = Trim(Trim(Request.Form("UserName")))
fPassWord = Md5(Request.Form("PassWord"))

Str1=Cstr(Session("EIMSCode"))
Str2=Cstr(Trim(Request.Form("CheckCode")))
if StrComp(Str1,Str2)<>0 then ReLoadMsg("验证码错误!")

Set Rs = Server.Createobject("Adodb.Recordset")
Sql="Select * From [eims_User] Where UserName='"&fUserName&"'"
Rs.Open Sql,Conn,1,1
If Rs.Eof Then   
   ReLoadMsg("此账号不存在!")
Else
   UserID = Cint(Trim(Rs("ItemID")))
   UserName = Trim(Rs("UserName"))
   PassWord = Trim(Rs("PassWord"))
   eType = Cint(Rs("eType"))   
   ItemRec = Cint(Rs("ItemRec"))
   Permission = Trim(Rs("Permission"))
End If
if ItemRec<>1 then ReLoadMsg("此账号已经被冻结!")
If eType<>1 Then ReLoadMsg("此账号不是管理员!")
If fPassWord<>PassWord Then ReLoadMsg("密码错误!")

If fUserName=UserName and fPassWord=PassWord Then
'----------------------判断记录------------------
Set RsLog=Server.Createobject("Adodb.Recordset")
Sql="Select * From [eims_UserLog] Where UserID="&UserID
RsLog.Open Sql,Conn,1,3
If RsLog.RecordCount>=LogRec Then
RsLog.MoveFirst
RsLog.Delete
End If
RsLog.AddNew
RsLog("UserID")=UserID
RsLog("UserName")=UserName
RsLog("LoginTime")=Now()
RsLog("LoginIP")=Userip()
RsLog.Update
RsLog.Close
Set RsLog=Nothing
'----------------------------------------
'转向系统管理
'----------------------------------------
	Response.Cookies("UserID") = UserID
	Response.Cookies("UserName") = UserName
	Response.Cookies("PassWord") = PassWord
	Response.Cookies("Permission") = Permission	
	Response.Cookies("UserID").expires = DateAdd("n", 90, Now())
	Response.Cookies("UserName").expires = DateAdd("n", 90, Now())
	Response.Cookies("PassWord").expires = DateAdd("n", 90, Now())
	Response.Redirect "Index.asp"
	Response.End
End If
Call CloseConn()
end if
%>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="middle"><fieldset style="padding:8px;width:330;height:188;">
      <legend class="title" align="center" style="font-size:14px; font-weight:bold"> 后台管理系统登录 </legend>
      <br>
      <table border="0" cellspacing="3" cellpadding="3">
        <form action="Login.asp?Action=Login" method="post" name="eform" onSubmit="return CKLogin()">
          <tr>
            <td align="center">账&nbsp;&nbsp;号：</td>
            <td><input name="UserName" type="text" style="width:120px;"></td>
          </tr>
          <tr>
            <td align="center">密&nbsp;&nbsp;码：</td>
            <td><input name="PassWord" type="password" style="width:120px;"></td>
          </tr>
          <tr>
            <td align="center">验证码：</td>
            <td valign="middle"><input name="CheckCode" type="text" class="input" style="width:55px;" id="CheckCode">
            <span style="cursor:pointer" title='点击刷新验证码'><img src='../inc/code.asp' align="absmiddle" onClick="this.src='../inc/code.asp?'+Math.random()"></span>
			</td>
          </tr>
          <tr>
            <td align="center"></td>
            <td valign="middle"><input type="submit" value="登陆系统"></td>
          </tr>
        </form>
      </table>
      </fieldset>
      <div style="margin-top:10px;font-family:Arial, Helvetica, sans-serif;" align="center">
Powered By <a href="http://www.v-wrold.me/" target="_blank">V-World</a> &copy; 2012~<% =Year(Now()) %> All Rights Reserved.<a href="../" target="_blank">HOME</a></div></td>
  </tr>
</table>

</body>
</html>
