<!--#include file="sd_mdb.asp"-->
<!--#include file="../sd_md5.asp"-->
<%
verifycode=request.form("verifycode")

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

dim admin,password,k
if request.cookies("adminminlong")("errors")="" then
	k=0
else
	k=request.cookies("adminminlong")("errors")
end if
if request.cookies("adminminlong")("errors")>5 then
	response.Write "<script LANGUAGE='javascript'>alert('您输入的密码错误次数太多，系统保护中。');history.go(-1);</script>"
	response.end

end if
admin=replace(trim(request("username")),"'","")
password=md5(replace(trim(request("password")),"'",""))
if admin="" or password="" then
	Response.cookies("adminminlong")("errors")=k+1
	response.Write "<script LANGUAGE='javascript'>alert('您的管理ID或密码有误！');history.go(-1);</script>"
	response.end
end if
set rs=server.CreateObject("adodb.recordset")
rs.Open "Select * From [sd_Admin] where sd_Name='" &admin&"' and sd_Password='"&password&"'", conn, 1,3
if rs.eof then
	Response.cookies("adminminlong")("errors")=k+1
	response.write"<SCRIPT language=JavaScript>alert('您输入的密码错误！您还有"&(5-k)&"次登陆机会!');"
	response.write"window.location = 'sd_admin_login.asp';</SCRIPT>"
	response.end
else
	session("LoginIP")=rs("sd_LoginIp")
	session("Logintime")=RS("sd_LoginTime")
	rs("sd_LoginIp")=Request.ServerVariables("remote_addr")
	rs("sd_LoginCount")=rs("sd_LoginCount")+1
	rs("sd_LoginTime")=date &" "& time
	rs.update
	session("User")=rs("sd_Name")
	session("UserKey")=rs("sd_Level")
	rs.close
	set rs=nothing
end if
response.Redirect "index.asp"
%>