<!--#include file="../Include/Conn.jsp"-->
<!--#include file="../Include/Char.jsp"-->
<!--#include file="../Include/md5.jsp"-->
<%
	dim mSql,rs
	dim mUserName,mPassword
	dim mIntegral
	const DEF_MasterCookies = "www.ly8.net"	
      
	mUserName = checkStr(Trim(Request.Form("username")))
	mPassword = checkStr(Trim(Request.Form("password")))
	if mUserName="" or mPassword="" then 
	   call Msgbox("对不起，请输入后提交！",1)
       Response.end	
    end if
	m_Sql = "Select Points FROM LeadBBS_User where UserName='" & mUserName & "'"
			Set Rs = conn.Execute(m_Sql)
			mIntegral = rs("Points")
	'查找用户
	mSql = "Select F_ID,F_UserName,F_Password,F_RealName,F_Email,F_Tel,f_grade,F_Mobile,F_WebSite,F_Address from T_Member Where F_IsCheck=1 and F_UserName='" & mUserName & "'"
    Set rs = conn.Execute(mSql)

	if rs.bof and rs.eof then
	   '无此用户
	   call Msgbox("对不起，不存在该用户名，或该用户名已被锁定.需管理员审核！",1)
       Response.end			
	else
   	   if md5(mPassword)<>rs("F_PassWord") then
          '密码错误
		  'rs.Close
	      
		  Call Msgbox("对不起，您的密码不正确！请输入正确的密码！",1)
		 
	   else

          'if Cookies
		  UserCookies = Request.Form("selUserCookies")
          if isnull(UserCookies) or UserCookies="" then UserCookies="0"
          select case usercookies
          case "0"
         	Response.Cookies("aspxnet")("UserCookies") = UserCookies
                       Response.Cookies(DEF_MasterCookies)("UserCookies") = UserCookies
          case 1
          	Response.Cookies("aspxnet").Expires=Date+1
	        Response.Cookies("aspxnet")("UserCookies") = UserCookies
			Response.Cookies(DEF_MasterCookies).Expires = Date+1
          case 2
  	        Response.Cookies("aspxnet").Expires=Date+31
	        Response.Cookies("aspxnet")("UserCookies") = UserCookies
			Response.Cookies(DEF_MasterCookies).Expires = Date+31
          case 3
	        Response.Cookies("aspxnet").Expires=Date+365
	        Response.Cookies("aspxnet")("UserCookies") = UserCookies
			 Response.Cookies(DEF_MasterCookies).Expires = Date+365
          end select
		  
          'Write Cookies 
          Response.Cookies("aspxnet")("RandNumber") = "i9sHflS2fAj883"
		  
          Response.Cookies("aspxnet")("CurUserID") = rs("F_ID")

          Response.Cookies("aspxnet")("CurUserName") = rs("F_UserName")
          Response.Cookies("aspxnet")("Curgrade") =rs("f_grade")
		 ' Response.Cookies("aspxnet")("RealName") = checkStr(rs("F_RealName"))

		   
		  'Response.Cookies("aspxnet")("Email") = checkStr(rs("F_Email"))

		  'Response.Cookies("aspxnet")("Tel") = checkStr(rs("F_Tel"))
		  'Response.Cookies("aspxnet")("Mobile") = checkStr(rs("F_Mobile"))
		  'Response.Cookies("aspxnet")("Address") = checkStr(rs("F_Address"))
		
          Session.Contents("OnlinUserName") = checkStr(rs("F_UserName"))
		  
	    Response.Cookies(DEF_MasterCookies)("user") = Request("username")
		Response.Cookies(DEF_MasterCookies)("pass") = Request("password")
		Response.Cookies(DEF_MasterCookies)("limit") = 0
		Response.Cookies(DEF_MasterCookies & "AtBD") = 1
		Response.Cookies(DEF_MasterCookies & "Time") = now
		Response.Cookies(DEF_MasterCookies & "_3")("Board_0") = cCur(3)
		Response.Cookies(DEF_MasterCookies & "hidden") = "no"
 

          '更新用户登陆信息
		  mIPInfo=request.ServerVariables("REMOTE_ADDR")
		  mSql = "Update T_Member set "
		  mSql = mSql + "F_LoginCount=F_LoginCount+1,"
		  mSql = mSql + "F_Integral="&mIntegral&","
		  mSql = mSql + "F_LastLoginTime='"&now&"',"
		  mSql = mSql + "F_IPInfo='"&mIPInfo&"'"
		  mSql = mSql +" Where F_UserName='" & rs("F_UserName") &"'"
		  conn.execute(mSql)

	      '返回	   
		  m_Return = Request.QueryString("return")
		 
         Select Case LCase(m_Return)
		 Case "photo"
		 Response.Redirect "photo_default.jsp"
		 Response.end
		 Case home
		 Response.Redirect "success.jsp"
		 Response.end
		 Case info
		 Response.Redirect "../info/write_info.jsp"
		 Response.end
		Case index
		 Response.Redirect "success.jsp"
		 Response.end
		 end select
	   End if
	End if
    rs.close
	CloseDatabase()
%>
