<!--#include file="../conn/conn.asp"-->
<!--#include file="../conn/md5.asp"-->
<!--#include file="../conn/nosql.asp"-->
<%if Not ChkPosturl then response.redirect ("login.asp")
dim admin,password
   admin=nosql(trim(request("admin")))
   password=md5(nosql(trim(request("password"))))
       userip = nosql(Request.ServerVariables("HTTP_X_FORWARDED_FOR"))
       userip2 = nosql(Request.ServerVariables("REMOTE_ADDR"))
               if admin="" or password="" then
                   response.Write "<center><a href=login.asp><font color=red size=2>对不起，登陆失败，请检查您的登陆名和密码</font></a></center>"
                   response.end
               end if
    set rs=server.CreateObject("adodb.recordset")
    rs.Open "select * from mini_admin where adminname='"&admin&"' and adminpass='"&password&"' " ,conn,1,1
       if not(rs.bof and rs.eof) then
           if password=rs("adminpass") then
                 Set rs2 = Server.CreateObject("ADODB.Recordset")
                 sql2="select * from mini_admin_ip "
                 rs2.open sql2,conn,1,3
                 rs2.addnew
		     	 rs2("ipname")=rs("adminname")
			       if userip = ""  then
		         rs2("ip")=userip2
	               else
		         rs2("ip")=userip
	               end if
		     	 rs2("win")=Request.ServerVariables("HTTP_USER_AGENT")
			     rs2("ipdate")=now()
                 rs2.update
                 rs2.close
                 session("adminid")=trim(rs("id"))
                 session("adminname")=trim(rs("adminname"))
                 session("adminflag")=int(rs("adminflag"))
                     if userip = ""  then
	            	     session("ip")=userip2
	                 else
		                 session("ip")=userip
	                 end if
                 session("date")=now()
                 session.Timeout=20
                 rs.Close
                 set rs=nothing
                    response.Redirect "index.asp"
           else
                 response.write "<script LANGUAGE='javascript'>alert('对不起，登陆失败！');history.go(-1);</script>"

           end if
       else
                 response.write "<script LANGUAGE='javascript'>alert('对不起，登陆失败！');history.go(-1);</script>"
       end if
%>