<%session.Timeout = 333%>
<!--#include file="../Include/Conn.jsp"-->
<!--#include file="../Include/md5.jsp"-->
<%
	dim mSql,rs
	dim mUserName,mPassword
	if Trim(Request.form("txtCheckCode"))<>CStr(session("CheckCode")) then
       response.write "<script>alert('您输入的确认码和系统产生的不一致，请重新输入！');history.back();</Script>"
	   Response.end
   end if

	mUserName=Trim(Request.Form("txtUserName"))
	mPassword=Trim(Request.Form("txtPassword"))
	mSql="Select F_UserName,F_PassWord,F_UserGrade,F_LoginCount,F_Flag from T_Admin Where F_UserName='" & mUserName & "'"
    set rs=server.createobject("adodb.recordset")
    rs.open mSql,conn,1,1
		if rs.bof and rs.eof then
		    response.write "<script>alert('对不起，该用户不存在！');history.back();</Script>"
            response.end			
	    else
			if md5(mPassword)<>rs("F_PassWord") or mUserName<>rs("F_UserName") then
			    response.write "<script>alert('对不起，请输入正确的站长口令。！');history.back();</Script>"
			else
				Session("curUserName") = mUserName
				session("curAddtime") = now()
				session("curLoginCount") = rs("F_LoginCount")
				if rs("F_UserGrade") = 1 then
				   session("curUserGrade") = "超级用户"
				else
				   Session("curUserGrade") = "普通管理员"
				end if
				Session("master") = mUserName
                Session("flag") = rs("F_Flag")
				mIPInfo=request.ServerVariables("REMOTE_HOST")
				mSql="update T_Admin set F_LoginCount=F_LoginCount+1,F_AddTime='"&now&"',F_IPInfo='"&mIPInfo&"' Where F_UserName='" & rs("F_UserName") &"'"
				conn.execute(mSql)
				if Request("action")="Expir" then 
				   Response.Redirect "Admin_Exit.jsp"
				else
				   Response.Redirect "Admin_Main.jsp"
				end if
				
			end if
		end if
    rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%>
