<!--#include file="Conn.asp"-->
<!--#include file="../Include/md5.asp"-->
<%dim admin,password,verifycode
admin      =replace(trim(request("admin")),"'","")
password   =md5(replace(trim(request("password")),"'",""),16)
verifycode =replace(trim(request("verifycode")),"'","")
adminIP	   = Request.ServerVariables("Remote_Addr")

if admin="" or password="" then

dim adminloginrs
set adminloginrs=server.CreateObject("adodb.recordset")
adminloginrs.Open "select * from BJX_adminloginlog " ,conn,1,3
adminloginrs.AddNew
adminloginrs("adminuser")="无"
adminloginrs("adminip")=adminIP
adminloginrs("shijian")="登录管理ID或密码有误，登录失败！"
adminloginrs.update
adminloginrs.Close
set adminloginrs=nothing

response.Write "<script LANGUAGE='javascript'>alert('您的管理ID或密码有误！');history.go(-1);</script>"
response.end
end if

if cstr(session("getcode"))<>cstr(trim(request("verifycode"))) then

set adminloginrs=server.CreateObject("adodb.recordset")
adminloginrs.Open "select * from BJX_adminloginlog " ,conn,1,3
adminloginrs.AddNew
adminloginrs("adminuser")=admin
adminloginrs("adminip")=adminIP
adminloginrs("shijian")="验证码不正确，登录失败！"
adminloginrs.update
adminloginrs.Close
set adminloginrs=nothing

response.Write "<script LANGUAGE='javascript'>alert('请输入正确的验证码！');history.go(-1);</script>"
response.end
end if

set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from BJX_admin where admin='"&admin&"'" ,conn,1,1
if not(rs.bof and rs.eof) then
if password=rs("password") then
session.timeout=30
session("bjxadmin")=trim(rs("admin"))
session("flag")=int(rs("flag"))
rs.Close
set rs=nothing
set adminloginrs=server.CreateObject("adodb.recordset")
adminloginrs.Open "select * from BJX_adminloginlog " ,conn,1,3
adminloginrs.AddNew
adminloginrs("adminuser")=admin
adminloginrs("adminip")=adminIP
adminloginrs("shijian")="登录成功！"
adminloginrs.update
adminloginrs.Close
set adminloginrs=nothing
response.Redirect "index.asp"
else
set adminloginrs=server.CreateObject("adodb.recordset")
adminloginrs.Open "select * from BJX_adminloginlog " ,conn,1,3
adminloginrs.AddNew
adminloginrs("adminuser")=admin
adminloginrs("adminip")=adminIP
adminloginrs("shijian")="密码错误，登录失败！"
adminloginrs.update
adminloginrs.Close
set adminloginrs=nothing
response.write "<script LANGUAGE='javascript'>alert('对不起，登陆失败！');history.go(-1);</script>"
end if
else
set adminloginrs=server.CreateObject("adodb.recordset")
adminloginrs.Open "select * from BJX_adminloginlog " ,conn,1,3
adminloginrs.AddNew
adminloginrs("adminuser")=admin
adminloginrs("adminip")=adminIP
adminloginrs("shijian")="没有该用户名，登录失败！"
adminloginrs.update
adminloginrs.Close
set adminloginrs=nothing
response.write "<script LANGUAGE='javascript'>alert('对不起，登陆失败！');history.go(-1);</script>"
end if
%>
