<%@ LANGUAGE = VBScript.Encode %>
<!--#include file="../Include/Const.asp"-->
<!--#include file="../Include/ConnSiteData.asp"-->


<%
dim LoginName,LoginPassword,AdminName,Password,AdminPurview,Working,UserName,rs,sql
LoginName=ReplaceBadChar(trim(request.form("LoginName")))
LoginPassword=Md5(ReplaceBadChar(request.form("LoginPassword")))
CheckCode = LCase(ReplaceBadChar(Trim(Request("CheckCode"))))
If CheckCode = "" Then
   response.write "<script language='JavaScript'>alert('验证码不能为空，请返回检查！');" & "history.back()" & "</script>"
   response.end
End If
If Trim(Session("CheckCode")) = "" Then
   response.write "<script language='JavaScript'>alert('您在管理登录停留的时间过长，导致验证码失效。\n请重新返回登录页面进行登录。');" & "history.back()" & "</script>"
   response.end
End If
If CheckCode <> Session("CheckCode") Then
   response.write "<script language='JavaScript'>alert('您输入的验证码和系统产生的不一致，请重新输入。');" & "history.back()" & "</script>"
   response.end
End If
set rs = server.createobject("adodb.recordset")
sql="select * from wygkcndiv_Admin where AdminName='"&LoginName&"'"
rs.open sql,conn,1,3
if rs.eof then
   response.write "<script language='JavaScript'>alert('无此帐号，请返回检查！');" & "history.back()" & "</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('密码错误，请返回检查！');" & "history.back()" & "</script>"
   response.end
end if
if session("VerifyCode")<>request("VerifyCode") then
   response.write "<script language='JavaScript'>alert('验证码错误，请返回检查！');" & "history.back()" & "</script>"
   response.end
end if
if not Working then
   response.write "<script language='JavaScript'>alert('帐号被禁用！');" & "history.back()" & "</script>"
   response.end
end if
if LoginName=AdminName and LoginPassword=Password then
   rs.update
   rs.close
   set rs=nothing
   session("AdminName")=AdminName
   session("UserName")=UserName
   session("AdminPurview")=AdminPurview
   session("LoginSystem")="Succeed"
   session.timeout=60
   Response.Cookies("AdminLoginCode")=AdminLoginCode
   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 wygkcndiv_AdminLog"
   rs.open sql,conn,1,3
   rs.update
   rs.close
   set rs=nothing
   response.redirect "main.asp"
   response.end
end if
%> 