<%session.Timeout = 333%>
<!--#include file="../Include/Conn.asp"-->
<!--#include file="../Include/md5.asp"-->
<%
	dim mSql,rs
	dim mUserName,mPassword

	mUserName=Trim(Request.Form("txtUserName"))
	mPassword=Trim(Request.Form("txtPassword"))
	mSql="Select F_UserName,F_PassWord,F_UserGrade,F_LoginCount,F_Flag from jy_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("flag1") = rs("F_Flag")
				mIPInfo=request.ServerVariables("REMOTE_HOST")
				mSql="update jy_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.asp"
				else
				   Response.Redirect "Admin_Main.asp"
				end if
				
			end if
		end if
    rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%>