<!--#include file="../Include/conig.asp"-->
<!--#include file="../Include/md5.asp"-->
<%
dim LoginName,LoginPassword,AdminName,Password,AdminPurview,Working,UserName,rs,sql,mycode,Renzhen
LoginName=trim(request.form("LoginName"))
LoginPassword=Md5(request.form("LoginPassword"))
mycode = trim(request.form("code"))
Renzhen = trim(request.form("Renzhen"))
set rs = server.createobject("adodb.recordset")
sql="select * from Web_rui_v_manage where AdminName='"&LoginName&"'"
rs.open sql,conn,1,3

if rs.eof then
   response.write "<script language=javascript> alert('管理员名称不正确，请重新输入。');location.replace('Admin_Login.asp');</script>"
   response.end
else
   AdminName=rs("AdminName")
   Password=rs("Password")
   AdminPurview=rs("AdminPurview")
   Working=rs("Working")
   UserName=rs("UserName")
end if

if LoginPassword<>Password then
   response.write "<script language=javascript> alert('管理员密码不正确，请重新输入。');location.replace('Admin_Login.asp');</script>"
   response.end
end if 

if Renzhen<>trim(Certif) then
   response.write "<script language=javascript> alert('您输入认证码错误，请返回重新登录！');location.replace('Admin_Login.asp');</script>"
   response.end
end if

if mycode<>Session("getcode") then
   response.write "<script language=javascript> alert('您输入验证码错误，请返回重新登录！');location.replace('Admin_Login.asp');</script>"
   response.end
end if

if Working=0 then
   response.write "<script language=javascript> alert('不能登录，此管理员帐号已被锁定。');location.replace('Admin_Login.asp');</script>"
   response.end
end if 
 
if LoginName=AdminName and LoginPassword=Password then
   rs("LastLoginTime")=now()
   rs("LastLoginIP")=Request.ServerVariables("Remote_Addr")
   rs.update
   rs.close
   set rs=nothing  
   session("webruiAdmin")=AdminName
   session("webruiUser")=UserName
   session("AdminPurview")=AdminPurview
   
   response.cookies("webrui")("webruiAdmin")=AdminName
   response.cookies("webrui")("webruiUser")=UserName 
   response.cookies("webrui")("AdminPurview")=AdminPurview

   session("SessCkeck")="RuiSystem"
   Response.Cookies("webrui").Expires=DateAdd("n",60,now()) 
   Session.Timeout = 60
   '==================================
   dim LoginIP,LoginTime,LoginSoft
   LoginIP=Request.ServerVariables("Remote_Addr")
   LoginSoft=Request.ServerVariables("Http_USER_AGENT")
   LoginTime=now()
   '====================================
   set rs = server.createobject("adodb.recordset")
   sql="select * from Web_rui_v_manageLog"
   rs.open sql,conn,1,3
   rs.addnew
   rs("AdminName")=AdminName
   rs("UserName")=UserName
   rs("LoginIP")=LoginIP
   rs("LoginSoft")=LoginSoft
   rs("LoginTime")=LoginTime
   rs.update
   rs.close
   set rs=nothing 
   '========================================
   response.redirect "admin_index.asp"
   response.end
end if
%>
</BODY>
</html>