<!--#include file=connn.asp-->
<!--#include file=../md5.asp-->
 <link href="Style.css" rel="stylesheet" type="text/css">
 <LINK href="images/fox.css" rel=stylesheet></LINK>
<%
	dim sql
	dim rs
	dim username
	dim password
	username=replace(trim(request("username")),"'","‘")
	password=md5(replace(trim(request("password")),"'","‘"))
	
ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR" ) 
If userip = "" Then 
ip = Request.ServerVariables("REMOTE_ADDR" )
end if

if request("username")="" and request("password")="" then
userid="用户名密码为空"
elseif request("password")="" then
userid="密码为空"
elseif request("username")="" then
userid="用户名为空"
else
userid=""&request("username")&"|尝试登录"
end if
sql2 = "insert into FOX_count (postdate,user,ip) values('" & now() & "','"&userid&"','"&ip&"')"
conn.Execute (sql2)
	
   'session("fox_err")=0
	if session("fox_err")="" then
	session("fox_err")=0
	else
	if session("fox_err")>=30 then '错误次数设置
	response.write " <script LANGUAGE='javascript'>alert('你已经被锁定，请不要尝试非法登陆！');history.go(-1);</script>"
	response.end
	end if
	end if
	if trim(request("username"))="" or trim(request("password"))="" then
	response.write "<script LANGUAGE='javascript'>alert('账号密码为空！');history.go(-1);</script>"
	response.end
	end if

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

	set rs=server.createobject("adodb.recordset")
	sql="select * from [FOX_admin] where Password='"&Password&"' and UserName='"&UserName&"'"
	rs.open sql,conn,1,1
 	if not rs.bof and not rs.eof then
 		if password=rs("password") then
        Response.cookies("foxwww")("administrator")=rs("username")
        Response.cookies("foxwww")("fox")=rs("level")
        session("admin_name")=rs("username")
        session("admin_fox")=now()
        Response.cookies("foxwww")("domain")=Request.ServerVariables("SERVER_NAME")
		Response.Redirect "index.asp"
 		else
            session("fox_err")=session("fox_err")+1
            response.write "<script LANGUAGE='javascript'>alert('身份确认失败，请重新登录！');history.go(-1);</script> "  
            response.end
 		end if
	else
            session("fox_err")=session("fox_err")+1
            response.write "<script LANGUAGE='javascript'>alert('身份确认失败，请重新登录！');history.go(-1);</script> "            
            response.end
	end if
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%></body></html>