dim adminname,adminpass,adminsalt,rs,doc,ip,logcount,sql
adminname=left(form("adminname"),12)
if len("adminname")>0 and len(form("adminpass"))>0 then
adminpass=md5(form("adminpass"),1)
on error resume next
set conn=server.createobject("adodb.connection")
conn.open objconn
if err.number<>0 then
set doc=Server.CreateObject(king_xmldom)
doc.async=false
doc.load(server.mappath(king_system&"system/language/"&king_language&".xml"))
response.clear
response.write doc.documentElement.SelectSingleNode("//kingcms/error/db").text
response.end()
end if
err.clear
ip=request.servervariables("http_x_forwarded_for")
if ip="" then ip=request.servervariables("remote_addr")
if king_dbtype=1 then
sql="select count(logid) from kinglog where ip='"&safe(ip)&"' and lognum=2 and getdate()-logdate<0.25;"
else
sql="select count(logid) from kinglog where ip='"&safe(ip)&"' and lognum=2 and now()-logdate<0.25;"
end if
logcount=conn.execute(sql)(0)
if logcount>=king_loginnum then
response.write "<p class=""red"">您尝试登录次数过多,已被系统锁定</p>"
else
set rs=conn.execute("select adminid from kingadmin where adminname='"&safe(adminname)&"' and adminpass='"&safe(adminpass)&"';")
if not rs.eof and not rs.bof then
conn.execute "update kingadmin set admindate='"&tnow&"',admincount=admincount+1 where adminname='"&safe(adminname)&"';"
conn.execute "insert into kinglog (adminname,lognum,ip,logdate) values ('"&safe(adminname)&"',1,'"&safe(ip)&"','"&tnow&"')"
response.cookies(md5(king_salt_admin,1))("name")=adminname
response.cookies(md5(king_salt_admin,1))("pass")=adminpass'newpass
response.redirect "manage.asp"
else
conn.execute "insert into kinglog (adminname,lognum,ip,logdate) values ('"&safe(adminname)&"',2,'"&safe(ip)&"','"&tnow&"')"
if king_loginnum-logcount=1 then
response.write "<p class=""red"">您尝试登录次数过多,已被系统锁定</p>"
else
response.write "<p class=""red"">您的帐号或密码有误 !还有"&(king_loginnum-logcount-1)&"次登录的机会。</p>"
end if
end if
rs.close
set rs=nothing
end if
end if