<!--#include file="Dal.asp"-->
<%
Response.Addheader "Content-Type","text/html; charset=utf-8"  
Response.Expires = 0 
Response.Expiresabsolute = Now() - 1 
Response.AddHeader "pragma","no-cache" 
Response.AddHeader "cache-control","private" 
Response.CacheControl = "no-cache" 

Sub CheckOpenReg()
	if CBool(SysConfig("i_Sys_Config_OpenReg")) then Rws  "alert('网站已关闭对外注册功能!');history.back();":Rend
End Sub

Sub CheckVCode()
	if(request.form("Vcode")="") then Rws "alert('尚未填写验证码!');history.back();":Rend
	if(UCASE(request.form("Vcode"))<>UCASE(session("Vcode"))) then Rws "alert('验证码错误!');history.back();":Rend
End Sub

Function CheckSub(vreg,str,msg)
	if not ValidReg(str,vreg) then Rws "alert('"&msg&"!');history.back();":Rend
	CheckSub = str
End Function

Function CheckSub2(vreg,str,msg)
	if not ValidReg(str,vreg) then Rw "alert('"&msg&"!');":Rend
	CheckSub2 = str
End Function

Function CheckRepeatUserName(str)
	RS_End
	set RS=DB_CONN.EXECUTE("select count(*) from [i_User_Info] where [i_User_Name]='"&str&"'")
	if RS(0)>0 then 
		CheckRepeatUserName = false
	else
		CheckRepeatUserName = true
	end if
End Function

Function CheckRepeatMail(str)
	RS_End
	set RS=DB_CONN.EXECUTE("select count(*) from [i_User_Info] where [i_User_Mail]='"&str&"'")
	if RS(0)>0 then 
		CheckRepeatMail = false
	else
		CheckRepeatMail = true
	end if
End Function

Function CheckRepeatNick(str)
	RS_End
	set RS=DB_CONN.EXECUTE("select count(*) from [i_User_Info] where [i_User_NickName]='"&str&"'")
	if RS(0)>0 then 
		CheckRepeatNick = false
	else
		CheckRepeatNick = true
	end if
End Function


Function Auto_Login2()
	if Session(Session_UserID_Arg)<>"" then Exit Function
	if Request.Cookies("ishow")("iUserName")="" or Request.Cookies("ishow")("iUserPass")="" then Exit Function
	dim t_UserName,t_UserPass,t_UserMail,t_AutoLogin,t_GoUrl,t_PayNum,t_IncomeNum
	t_UserName = Get_SafeStr(Request.Cookies("ishow")("iUserName")) '验证账号
	t_UserPass = Get_SafeStr(Request.Cookies("ishow")("iUserPass")) '验证密码
	RS_End
	RS.OPEN "select top 1 * from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where [i_User_Name]='"&t_UserName&"' and [i_User_Pass]='"&MD5(t_UserPass)&"'" , DB_CONN , 1 , 3
	if RS.recordcount>0 then
		if RS("i_User_IsLock")=1 then Exit Function
		'登录成功
		RS("i_User_Online")=1
		RS("i_User_LastLoginTime")=now()
		RS("i_User_LoginIP")=get_IP()
		RS.Update()
		Session(Session_UserID_Arg)=RS("i_User_ID")
		Session(Session_UserName_Arg)=RS("i_User_Name")
		Session(Session_UserNickName_Arg)=RS("i_User_NickName")
		Session(Session_UserSex_Arg)=RS("i_User_Sex")
		Session(Session_UserClass_Arg)=RS("i_User_Class")
		Session(Session_UserFace_Arg)=RS("i_User_Face")
		Session(Session_RoomID_Arg)=RS("i_Sys_Room_ID")
		Session(Session_LogIP_Arg)=get_IP()
		Session(Session_LogTime_Arg)=now()
		t_PayNum = RS("i_User_PayNum")
		t_IncomeNum = RS("i_User_IncomeNum")
		Session(Session_UserPaymentLevel_Arg)=GetUserPaymentLevelInfo(t_PayNum,"i_User_PaymentLevel_Style")
		Session(Session_UserIncomeLevel_Arg)=GetUserInComeLevelInfo(t_IncomeNum,"i_User_InComeLevel_Style")
	end if
	RS_End
End Function

Function Auto_Login()
	if Session(Session_UserID_Arg)<>"" then Exit Function
	if Request.Cookies("ishow")("iUserName")="" or Request.Cookies("ishow")("iUserPass")="" then RW "alert('您尚未登录或登录已超时!');location.href='/i/"&SysConfig("i_Sys_Config_TemplatePath")&"/Login.html';":Rend:Exit Function
	dim t_UserName,t_UserPass,t_UserMail,t_AutoLogin,t_GoUrl,t_PayNum,t_IncomeNum
	t_UserName = Get_SafeStr(Request.Cookies("ishow")("iUserName")) '验证账号
	t_UserPass = Get_SafeStr(Request.Cookies("ishow")("iUserPass")) '验证密码
	RS_End
	RS.OPEN "select top 1 * from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where [i_User_Name]='"&t_UserName&"' and [i_User_Pass]='"&MD5(t_UserPass)&"'" , DB_CONN , 1 , 3
	if RS.recordcount>0 then
		if RS("i_User_IsLock")=1 then Rend
		'登录成功
		RS("i_User_Online")=1
		RS("i_User_LastLoginTime")=now()
		RS("i_User_LoginIP")=get_IP()
		RS.Update()
		Session(Session_UserID_Arg)=RS("i_User_ID")
		Session(Session_UserName_Arg)=RS("i_User_Name")
		Session(Session_UserNickName_Arg)=RS("i_User_NickName")
		Session(Session_UserSex_Arg)=RS("i_User_Sex")
		Session(Session_UserClass_Arg)=RS("i_User_Class")
		Session(Session_UserFace_Arg)=RS("i_User_Face")
		Session(Session_RoomID_Arg)=RS("i_Sys_Room_ID")
		Session(Session_LogIP_Arg)=get_IP()
		Session(Session_LogTime_Arg)=now()
		t_PayNum = RS("i_User_PayNum")
		t_IncomeNum = RS("i_User_IncomeNum")
		Session(Session_UserPaymentLevel_Arg)=GetUserPaymentLevelInfo(t_PayNum,"i_User_PaymentLevel_Style")
		Session(Session_UserIncomeLevel_Arg)=GetUserInComeLevelInfo(t_IncomeNum,"i_User_InComeLevel_Style")
	end if
	RS_End
	'Rend
End Function

Function get_IP() 
	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") 
	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 
	get_IP = Trim(Mid(strIPAddr, 1, 30)) 
End Function
%>


