<!--#include file="inc/conn.asp"-->

<%




Private Function getIP()
	Dim strIPAddr
	If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
		'strIPAddr = Request.ServerVariables("REMOTE_ADDR")
		strIPAddr = Request.ServerVariables("HTTP_Cdn-Src-Ip")
		If strIPAddr = "" Then strIPAddr = Request.ServerVariables("REMOTE_ADDR")
	ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then
		strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1)
	ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then
		strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1)
	Else
		strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
	End If
	getIP = Trim(Mid(strIPAddr, 1, 30))
End Function 





Action = Trim(Request.form("action"))
if Action="yes" then 

dim s_Usr,s_Pwd,s_Chk,ErrStr
ErrStr=""




'验证登录用户名密码

	s_Usr = YeSqlStr(ClearSQL(Trim(Request.form("UID"))),0)
	s_Pwd = YeSqlStr(Trim(Request.form("PWD")),0)

		If s_Usr <> "" And s_Pwd <> "" Then
	    	call ConnectionDatabase
			set Rs=GrateRs("select * from member where username like '"&trim(s_Usr)&"'",3)
			If Not Rs.Eof Then
				If Rs("passwd") = md5(s_Pwd) Then
					if rs("vip")=0 then 
						ErrStr="帐户未激活！"
					elseif Rs("state")=0 then
					ErrStr="您的帐户已被锁定,请联系客服!"
					else



						Session("Usr_UserName") = rs("username")
						Session("Usr_userid") = rs("id")
						Session("loginip") = rs("ip")
						Session("logdate") = rs("logdate")
						Session("bufa") = rs("bufa")
						rs("logdate")=now()
						rs("ip")=getIP()
						rs.update
						Session("Usr_PassWord") = md5(s_Pwd)

					end if
				Else


					ErrStr="密码不正确!"
				End If
			Else


				ErrStr="用户不存在!"
			End If


			call DBConnEnd
		Else
			ErrStr="用户名和密码不能为空!"
		End If
		

'转向
	
	if ErrStr="" then 
	response.Redirect "/vendor/dashboard.asp"
	else
		response.write "<script>alert('"&ErrStr&" 请返回重新登录');window.location.href='/';</script>"
	end if

	end if

%>

