<!--#include file="conn/conn.asp"-->
<!--#include file="inc/Commoncode.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="API/API_Config.asp"-->
<%Call SQLin()
response.expires = 0
response.expiresabsolute = now() - 0
response.addHeader "pragma","no-cache"
response.addHeader "cache-control","private"
Response.CacheControl = "no-cache"

Function isletternumber(strng)
 isletternumber = false
 Dim regEx, Match ' Create variables.
 Set regEx = New RegExp   ' Create a regular expression object (stupid, huh?)
 regEx.Pattern = "^[A-Za-z0-9]{4,20}$" ' Sets pattern.
 regEx.IgnoreCase = True   ' Set case insensitivity.
 Set Match = regEx.Execute(strng)   ' Execute search.
 if match.count then isletternumber= true
End Function
Function Usertype(LC)
Select Case LC
	Case 1:Usertype="p"
	Case 2:Usertype="c"
	Case 3:Usertype="s"
	Case 4:Usertype="t"
	Case else:Usertype=""
End Select
End Function
Action=trim(Request("Action"))
Select Case Action
	Case "unlogin"
		Call UserUnLogin()
	Case "login"
		Call UserLogin()
	Case "loginout"
		Call UserLoginout()
End Select
Call CloseConn

Sub UserUnLogin()
LoginChannel=Replace(request.querystring("LoginChannel"),"'","")
if Request.Cookies(FRHRCMS)("user_type")<>"" then
	set rs=server.createobject(FR_HR_Rs)
	sql="select * from job_Member where Member_login='"&CheckStr(Request.Cookies(FRHRCMS)("user_login"))&"'"
	rs.open sql,conn,1,3
	if not rs.eof then
		Member_balance=rs("Member_balance")
		Member_integral=rs("Member_integral")
		Member_consumenums=rs("Member_consumenums")
		Member_flag=rs("Member_flag")
		Member_startdate=rs("Member_startdate")
		Member_enddate=rs("Member_enddate")
	end if
	rs.close
	set rs=nothing
	if MainWebCss="Blue.css" then
		Userlink="member/index.asp"
    viewlogin=viewlogin&"<li>欢迎"&left(Request.Cookies(FRHRCMS)("user_login"),10)&"登录使用！<input type='button' name='Submit' value='进入管理中心' class='inputcl' onclick=window.open('"&InstallDir&Userlink&"');  /> <input type='button' name='Submit' value='退 出' class='inputcl' onclick='return loginout();' /></li>"
	else
		viewlogin="<table width='96%' border='0' cellpadding='1' cellspacing='0'>"
		viewlogin=viewlogin&"<tr>"
		viewlogin=viewlogin&"<td align='left'>欢迎"&left(Request.Cookies(FRHRCMS)("user_login"),10)&"登录会员中心！</td>"
		viewlogin=viewlogin&"</tr><tr>"
		viewlogin=viewlogin&"<td align='left'>当前余额："&Member_balance&"元 <a href="&InstallDir&"onlinepay/index.asp target='_blank'><font color='#FF0000'>在线充值</font></a></td>"
		viewlogin=viewlogin&"</tr><tr>"
		viewlogin=viewlogin&"<td align='left'>当前积分："&Member_integral&"个积分</td>"
		viewlogin=viewlogin&"</tr><tr>"
		viewlogin=viewlogin&"<td align='left'>当前点数："&Member_consumenums&"点</td>"
		viewlogin=viewlogin&"</tr><tr>"
		viewlogin=viewlogin&"<td align='left'>当前状态："
		if Member_flag=1 then
		viewlogin=viewlogin&"帐户已审核</td>"
		else
		viewlogin=viewlogin&"帐户未审核</td>"
		end if
		viewlogin=viewlogin&"</tr><tr>"
		viewlogin=viewlogin&"<td align='left'>服务:"&Member_startdate&"到"&Member_enddate&"</td>"
		viewlogin=viewlogin&"</tr><tr>"
		viewlogin=viewlogin&"<td align='center'>"
		Userlink="member/index.asp"
		viewlogin=viewlogin&"<input type='button' name='Submit' value='进入管理中心' class='inputs' onclick=window.open('"&InstallDir&Userlink&"');  />"
		viewlogin=viewlogin&" <input type='button' name='Submit' value='退 出' class='inputs' onclick='return loginout();' /></td>"
		viewlogin=viewlogin&"</tr>"
		viewlogin=viewlogin&"</table>"
	end if
Response.Write("mcenter.innerHTML="""&viewlogin&"""")
end if
End Sub

Sub UserLogin()
LoginChannel=Replace(request.querystring("LoginChannel"),"'","")
'用户登录后检测用户身份
trueIP=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If trueIP="" Then trueIP=Request.ServerVariables("REMOTE_ADDR")
member_login=Replace(trim(request("login")),"'","")
'if not isletternumber(member_login) then
' response.write ("<script language=JavaScript>{alert('用户名：要求为4-20个字母或数字！请重新输入。');history.back();}<//script>")
' response.End 
'end if
member_pwd=Md5(Replace(trim(request("pwd")),"'",""),32)
member_apipwd=Md5(Replace(trim(request("pwd")),"'",""),16)
set rs=server.createobject("ADODB.Recordset")
sql="select * from job_Member where Member_login='"&member_login&"'"
rs.open sql,conn,1,3
if rs.eof then
	rs.close
	set rs=nothing
	CloseConn
	Response.Write ("<script language=JavaScript>{alert('用户名错误，请重新登录！');history.back();}</script>")
	Response.End 
else
	If LoginChannel<>0 and cint(LoginChannel)<>cint(rs("Member_typeid")) and LoginChannel<4 then
		rs.close
		set rs=nothing
		CloseConn
		Response.Write ("<script language=JavaScript>{alert('对不起用户类型不正确，请返"&LoginChannel&gdfgdgfd&"回首页登录！');location.href ='"&InstallDir&"index.asp';}</script>")
		Response.End
	End If
	If member_pwd<>rs("Member_pwd") then
		rs.close
		set rs=nothing
		CloseConn
		Response.Write ("<script language=JavaScript>{alert('密码错误，请重新登录！');history.back();}</script>")
		Response.End 
	Else
	Member_Auditing=rs("Member_Auditing")
	If Member_Auditing<>1 Then
		CloseConn
		response.write("<script>alert('您的帐号还没有通过审核，无法登录！');history.back();</script>")
		response.End()
	End If
	if isnull(rs("Member_LoginIP")) or rs("Member_LoginIP")="" then
	Response.Cookies(FRHRCMS)("LoginIP")=trueIP
	else
	Response.Cookies(FRHRCMS)("LoginIP")=rs("Member_LoginIP")
	end if
	if isnull(rs("Member_logindate")) or rs("Member_logindate")="" then
	Response.Cookies(FRHRCMS)("LoginTimes")=now()
	else
	Response.Cookies(FRHRCMS)("LoginTimes")=rs("Member_logindate")
	end if
	Response.Cookies(FRHRCMS)("user_login")=member_login
	Response.Cookies(FRHRCMS)("user_pass")=member_pwd
	Memberlogintype=rs("Member_typeid")
	if Memberlogintype<>0 and Memberlogintype<>"" then
		if rs("Member_name")<>"" then
			Response.Cookies(FRHRCMS)("user_name")=rs("Member_name")
		end if
		Response.Cookies(FRHRCMS)("user_type")=Usertype(Memberlogintype)&"member"
		Set frs=conn.execute("select Group_Pdianshu,Group_Pintegral from JOB_Group where Group_membertype="&rs("Member_typeid")&" and Group_id="&rs("Member_groupid")&"")
		if not frs.eof then
			Group_dianshus=split(frs("Group_Pdianshu"),",")
			Group_integrals=split(frs("Group_Pintegral"),",")
			FoundErr=True
		end if
		set frs=nothing
	else
		Response.Cookies(FRHRCMS)("user_type")="member"
	end if
	rs("Member_LoginIP")=trueIP
		If IsNumeric(rs("Member_LoginNum")) Then
			rs("Member_LoginNum")=rs("Member_LoginNum")+1
		Else
			rs("Member_LoginNum")=1
		End If
	rs("Member_logindate")=now()
	rs.Update
	End If
	rs.close
	set rs=nothing
	If FoundErr=True Then
		if PayPoint(member_login,Memberlogintype,-Group_dianshus(6),0)=True then
			Call PayLog(member_login,Memberlogintype,"于"&Now()&"登录系统赠点",Group_dianshus(6),0)
			Call IncomeIntegral(member_login,Memberlogintype,-Group_integrals(6))
		end if
	End If
	'输出整合登陆脚本
	If API_Enable Then
		Dim iIndex
		For iIndex = 0 To UBound(ArrUrls)
			Response.Write "<script language=""JavaScript"" src=""" & ArrUrls(iIndex) & "?syskey=" & MD5(member_login&API_SysKey,16) & "&username=" & member_login & "&password=" & member_apipwd & "&savecookie=1""></script>" & vbCrLf
		Next
	End If
	Response.Write ("<script language=JavaScript>{location.href = 'javascript:history.go(-1)';}</script>")
	Response.End
end if
End Sub
Sub UserLoginout()
LoginChannel=Replace(request.querystring("LoginChannel"),"'","")
login = CheckStr(Request.Cookies(FRHRCMS)("user_login"))
If API_Enable Then
	Dim iIndex
	For iIndex = 0 To UBound(ArrUrls)
		Response.Write "<script language=""JavaScript"" src=""" & ArrUrls(iIndex) &"?syskey=" & LCase(MD5(login&API_SysKey,16)) & "&username=" & login &"""></script>"
	Next
End If
Response.Cookies(FRHRCMS)("user_types")=""
Response.Cookies(FRHRCMS)("user_type")=""
Response.Cookies(FRHRCMS)("user_login")=""
Response.Cookies(FRHRCMS)("user_truePWD")=""
Response.Cookies(FRHRCMS)("user_pass")=""
Response.Cookies(FRHRCMS)("user_name")=""
Response.Cookies(FRHRCMS)("self_link")=""
Response.Cookies(FRHRCMS)("self_path")=""
CloseConn
Response.Write ("<script language=JavaScript>{alert('成功退出，“确定”返回！');location.href ='"&InstallDir&"index.asp';}</script>")
Response.End
End Sub%>