<!--#include virtual="/inc/md52.asp"-->

<%
'商户检测登录状态
sub logname(jb)
	islog="no"
	
	if request.Cookies("aymd5")="" then call PopErr2("会话超时ERR1，请重新登录","/index/exit")
	if request.Cookies("useripd")="" then call PopErr2("会话超时ERR2，请重新登录","/index/exit")
	if request.Cookies("ayjibie")="" then call PopErr2("会话超时ERR3，请重新登录","/index/exit")
	if request.Cookies("ayusername")="" then call PopErr2("会话超时ERR4，请重新登录","/index/exit")
	if request.Cookies("aynameid")="" then call PopErr2("会话超时ERR5，请重新登录","/index/exit")
	if request.Cookies("aytrueuser")="" then call PopErr2("会话超时ERR6，请重新登录","/index/exit")
	if request.Cookies("aymasterid")="" then call PopErr2("会话超时ERR7，请重新登录","/index/exit")
	if request.Cookies("kamiku")="" then call PopErr2("会话超时ERR8，请重新登录","/index/exit")
	if request.Cookies("flku")="" then call PopErr2("会话超时ERR9，请重新登录","/index/exit")
	if request.Cookies("spku")="" then call PopErr2("会话超时ERR10，请重新登录","/index/exit")
	if request.Cookies("ddku")="" then call PopErr2("会话超时ERR11，请重新登录","/index/exit")
	if request.Cookies("cwku")="" then call PopErr2("会话超时ERR12，请重新登录","/index/exit")
	if request.Cookies("rzku")="" then call PopErr2("会话超时ERR13，请重新登录","/index/exit")
	if request.Cookies("logdate")="" then call PopErr2("会话超时ERR14，请重新登录","/index/exit")
	if request.Cookies("aysignmd5")="" then call PopErr2("会话超时ERR15，请重新登录","/index/exit")
		
	'登陆session检测
	set rssion=server.CreateObject("adodb.recordset")
	rssion.open "select top 1 * from logsession where aysignmd5='"&request.Cookies("aysignmd5")&"' order by logid desc",conn,1,1
	if not(rssion.bof and rssion.eof) then
		if DateDiff("n",rssion("logdate"),now())>60 then 
		call PopErr2("会话超时ERR16，请重新登录","/index/exit")
		response.end
		end if
	else
	call PopErr2("会话超时ERR17，请重新登录","/index/exit")
	response.end
    end if
	rssion.close
	
	yanzhengstr="ikuserdl"&request.Cookies("aynameid")&trim(request.Cookies("ayusername"))&request.Cookies("ayjibie")&request.Cookies("ddku")&request.Cookies("cwku")&request.Cookies("rzku")&request.Cookies("logdate")&ptjiami
	yanzhengstr=md5(yanzhengstr)
	if trim(yanzhengstr)<>request.Cookies("aysignmd5") then
	call PopErr2("会话超时ERR18，请重新登录","/index/exit")
	response.end
	end if
	
	userjb=split(jb,",")
	For sum=0 To Ubound(userjb) 
	if clng(userjb(sum))=clng(request.Cookies("ayjibie")) then islog="yes"
	next

	if islog="no" then 
	call PopErr2("会话超时ERR19，请重新登录","/index/exit")
	response.end
	end if
	
end sub

'买家检测登录状态
sub lognamemai(jb)
	islog="no"
	
	if request.Cookies("aymd5")="" then call PopErr2("会话超时ERR1，请重新登录","/index/exit")
	if request.Cookies("useripd")="" then call PopErr2("会话超时ERR2，请重新登录","/index/exit")
	if request.Cookies("ayjibie")="" then call PopErr2("会话超时ERR3，请重新登录","/index/exit")
	if request.Cookies("ayusername")="" then call PopErr2("会话超时ERR4，请重新登录","/index/exit")
	if request.Cookies("aynameid")="" then call PopErr2("会话超时ERR5，请重新登录","/index/exit")
	if request.Cookies("aytrueuser")="" then call PopErr2("会话超时ERR6，请重新登录","/index/exit")
	if request.Cookies("aymasterid")="" then call PopErr2("会话超时ERR7，请重新登录","/index/exit")
	if request.Cookies("kamiku")="" then call PopErr2("会话超时ERR8，请重新登录","/index/exit")
	if request.Cookies("flku")="" then call PopErr2("会话超时ERR9，请重新登录","/index/exit")
	if request.Cookies("spku")="" then call PopErr2("会话超时ERR10，请重新登录","/index/exit")
	if request.Cookies("ddku")="" then call PopErr2("会话超时ERR11，请重新登录","/index/exit")
	if request.Cookies("cwku")="" then call PopErr2("会话超时ERR12，请重新登录","/index/exit")
	if request.Cookies("rzku")="" then call PopErr2("会话超时ERR13，请重新登录","/index/exit")
	if request.Cookies("logdate")="" then call PopErr2("会话超时ERR14，请重新登录","/index/exit")
	if request.Cookies("aysignmd5")="" then call PopErr2("会话超时ERR15，请重新登录","/index/exit")
	
	yanzhengstr="ikuserdl"&request.Cookies("aynameid")&trim(request.Cookies("ayusername"))&request.Cookies("ayjibie")&request.Cookies("ddku")&request.Cookies("cwku")&request.Cookies("rzku")&request.Cookies("logdate")&ptjiami
	yanzhengstr=md5(yanzhengstr)
	if trim(yanzhengstr)<>request.Cookies("aysignmd5") then
	call PopErr2("会话超时ERR18，请重新登录","/index/exit")
	response.end
	end if
	
	userjb=split(jb,",")
	For sum=0 To Ubound(userjb) 
	if clng(userjb(sum))=clng(request.Cookies("ayjibie")) then islog="yes"
	next

	if islog="no" then 
	call PopErr2("会话超时ERR19，请重新登录","/index/exit")
	response.end
	end if
	
end sub

'支付密码验证
sub chkyanzheng(str)
	if request.Cookies("yanzheng")="" then response.Redirect("/user/chk?tourl="&str&"")
	if md5("chaku"&request.Cookies("aynameid")&ptjiami)<>request.Cookies("yanzheng") then response.Redirect "/index/exit"
end sub

'支付密码验证 老版会员中心
sub chkyanzhengold(str)
	if request.Cookies("yanzheng")="" then response.Redirect("/userold/chk?tourl="&str&"")
	if md5("chaku"&request.Cookies("aynameid")&ptjiami)<>request.Cookies("yanzheng") then response.Redirect "/index/exit"
end sub

'高级权限验证 修改支付密码
sub gaojiquanxian(str)
	if request.Cookies("gaojiyzm")="" then response.Redirect("/user/userrz?tourl="&str&"")
	
	set rsgj=server.CreateObject("adodb.recordset")
	rsgj.open "select top 1 aynameid,aymail,aytel from ayname where aynameid="&clng(request.Cookies("aynameid"))&"" ,conn,1,1
	if not(rsgj.bof and rsgj.eof) then
	aymail=trim(rsgj("aymail"))
	aytel=trim(rsgj("aytel"))
	else
	response.Redirect "/index/exit"
	end if
	rsgj.close
	
	if md5("gj"&request.Cookies("aynameid")&aymail&aytel&ptjiami)<>request.Cookies("gaojiyzm") then response.Redirect "/index/exit"
end sub

'高级权限验证 老版 修改支付密码
sub gaojiquanxian_old(str)
	if request.Cookies("gaojiyzm")="" then response.Redirect("/userold/userrz?tourl="&str&"")
	
	set rsgj=server.CreateObject("adodb.recordset")
	rsgj.open "select top 1 aynameid,aymail,aytel from ayname where aynameid="&clng(request.Cookies("aynameid"))&"" ,conn,1,1
	if not(rsgj.bof and rsgj.eof) then
	aymail=trim(rsgj("aymail"))
	aytel=trim(rsgj("aytel"))
	else
	response.Redirect "/index/exit"
	end if
	rsgj.close
	
	if md5("gj"&request.Cookies("aynameid")&aymail&aytel&ptjiami)<>request.Cookies("gaojiyzm") then response.Redirect "/index/exit"
end sub

'高级权限验证 异地登录
sub gaojiquanxianlog(str)
	if request.Cookies("gaojiyzm")="" then response.Redirect("/user/userrz_log?tourl="&str&"")
	
	set rsgj=server.CreateObject("adodb.recordset")
	rsgj.open "select top 1 aynameid,aymail,aytel from ayname where aynameid="&clng(request.Cookies("aynameid"))&"" ,conn,1,1
	if not(rsgj.bof and rsgj.eof) then
	aymail=trim(rsgj("aymail"))
	aytel=trim(rsgj("aytel"))
	else
	response.Redirect "/index/exit"
	end if
	rsgj.close
	
	if md5("gj"&request.Cookies("aynameid")&aymail&aytel&ptjiami)<>request.Cookies("gaojiyzm") then response.Redirect "/index/exit"
end sub

'高级权限验证 老版 异地登录
sub gaojiquanxianlog_old(str)
	if request.Cookies("gaojiyzm")="" then response.Redirect("/userold/userrz_log?tourl="&str&"")
	
	set rsgj=server.CreateObject("adodb.recordset")
	rsgj.open "select top 1 aynameid,aymail,aytel from ayname where aynameid="&clng(request.Cookies("aynameid"))&"" ,conn,1,1
	if not(rsgj.bof and rsgj.eof) then
	aymail=trim(rsgj("aymail"))
	aytel=trim(rsgj("aytel"))
	else
	response.Redirect "/index/exit"
	end if
	rsgj.close
	
	if md5("gj"&request.Cookies("aynameid")&aymail&aytel&ptjiami)<>request.Cookies("gaojiyzm") then response.Redirect "/index/exit"
end sub


'异地登录IP检查
sub chkip()

	lastip=lastuserip(request.Cookies("aynameid")) 
	if trim(lastip)<>"null" then
		if trim(lastip)<>trim(request.Cookies("useripd")) then

			set rsip=server.CreateObject("adodb.recordset")
			sqlip="select aykxuid,aykxipd from aykexinip where aykxuid="&request.Cookies("aynameid")&" and aykxipd='"&trim(request.Cookies("useripd"))&"'" 
			rsip.open sqlip,conn,1,1
			if rsip.bof and rsip.eof then
			response.Cookies("gaojiyzm")="" 
			response.Redirect("/user/userrz_log?tourl="&str&"")
			end if
			rsip.close

			'if request.Cookies("gaojiyzm")="" then response.Redirect("/user/userrz_log?tourl="&str&"")
			
			'set rsgj=server.CreateObject("adodb.recordset")
			'rsgj.open "select top 1 aynameid,aymail,aytel from ayname where aynameid="&clng(request.Cookies("aynameid"))&"" ,conn,1,1
			'if not(rsgj.bof and rsgj.eof) then
			'aymail=trim(rsgj("aymail"))
			'aytel=trim(rsgj("aytel"))
			'else
			'response.Redirect "/index/exit"
			'end if
			'rsgj.close
			
			'if md5("gj"&request.Cookies("aynameid")&aymail&aytel&ptjiami)<>request.Cookies("gaojiyzm") then response.Redirect "/index/exit"

		end if
	end if

end sub


'管理员身份验证
sub lognameadmin()
	if request.Cookies("adminpass")="" or request.Cookies("aysignmd5")="" then response.Redirect("/"&adminaddress&"/logadminpass.asp")
	if request.Cookies("ayadminnameid")="" then response.Redirect("/"&adminaddress&"/logadminpass.asp")
	if request.Cookies("ayadminjibie")="" then response.Redirect(weburl)
	if cint(request.Cookies("ayadminjibie"))<>9 then response.Redirect(weburl)
	
	gjyanzhengstr="ikuserdl"&request.Cookies("aynameid")&trim(request.Cookies("ayusername"))&request.Cookies("ayjibie")&request.Cookies("ddku")&request.Cookies("cwku")&request.Cookies("rzku")&ptjiami
	gjyanzhengstr=md5(gjyanzhengstr)
	if trim(gjyanzhengstr)<>request.Cookies("aysignmd5") then
	response.Redirect("/index/exit")
	response.end
	end if
end sub

'管理后台 核心功能权限验证
sub lognamecode()
rs.open "select ayisquan from ayquanju",conn,1,1
ayisquan=rs("ayisquan")
rs.close
if cint(ayisquan)=1 then 
if request.Cookies("adminpasscode")="" then 
response.Redirect("/"&adminaddress&"/logadmincode.asp")
response.End()
end if
end if
end sub

'管理后台 客服专员权限验证
Function logquanxian(foye,isexit)
set rsqx=server.CreateObject("adodb.recordset")
logquanxian=0
if request.Cookies("aymasterid")="" then 
response.Redirect("/")
response.End()
end if
if cint(request.Cookies("aymasterid"))<>9 then
rsqx.open "select aymasterjid,aymasterqx from aymaster where aymasterjid="&request.Cookies("aymasterid")&"" ,conn,1,1
	if not(rsqx.bof and rsqx.eof) then 
		if trim(rsqx("aymasterqx"))<>"" then
			str=split(trim(rsqx("aymasterqx")),"|")
			For sum=0 To Ubound(str) 
				if instr(1,str(sum),foye)>0 then
				str2=split(str(sum),",")
				logquanxian=str2(1)
				end if
			next
		end if
		if isexit=1 then
			if cint(logquanxian)=0 then 
			response.Redirect("/")
			response.End()
			end if
		end if
	end if
	rsqx.close
end if
if cint(request.Cookies("aymasterid"))=9 then logquanxian=1
end Function

'管理后台 客服专员 栏目权限验证
Function cqx(zid,quanxian)
cqx=0
if quanxian<>"" then
	str=split(quanxian,"|")
	For sum=0 To Ubound(str) 
		if instr(1,str(sum),zid)>0 then
		str2=split(str(sum),",")
		cqx=str2(1)
		end if
	next
end if
End Function

'通过mcode 生成权限 需重新调试
function chkmcode(id,mcode,yurl,ip) 
if trim(id)="" or trim(mcode)="" or trim(yurl)="" or trim(ip)="" then
response.Write "参数错误"
response.End()
end if
set chk=server.CreateObject("adodb.recordset")
chk.open "select aynameid,aymd5,ayjibie,ayusername,aytrueuser,aymasterid,kamiku,flku,spku,ddku,cwku,rzku from ayname where aynameid="&id&"",conn,1,1
if not(chk.eof) then
	signstr=""
	response.Cookies("aymd5")=trim(chk("aymd5"))
	response.Cookies("useripd")=trim(ip)
	response.Cookies("ayjibie")=chk("ayjibie")
	response.Cookies("ayusername")=trim(chk("ayusername"))
	response.Cookies("aynameid")=chk("aynameid") 
	response.Cookies("aytrueuser")=chk("aytrueuser") 
	response.Cookies("aymasterid")=chk("aymasterid")
	response.Cookies("kamiku")=trim(chk("kamiku"))
	response.Cookies("flku")=trim(chk("flku"))
	response.Cookies("spku")=trim(chk("spku"))
	response.Cookies("ddku")=trim(chk("ddku"))
	response.Cookies("cwku")=trim(chk("cwku"))
	response.Cookies("rzku")=trim(chk("rzku"))
	if isnull(trim(rs("kfwxopenid")))=false and trim(rs("kfwxopenid"))<>"" then
	kfopenid=trim(rs("kfwxopenid"))
	nickname=trim(rs("aytrueuser"))
	elseif isnull(trim(rs("kfqqopenid")))=false and trim(rs("kfqqopenid"))<>"" then
	kfopenid=trim(rs("kfqqopenid"))
	nickname=trim(rs("aytrueuser"))
	end if
	signstr="ikuserdl"&chk("aynameid")&trim(chk("ayusername"))&chk("ayjibie")&trim(chk("ddku"))&trim(chk("cwku"))&trim(chk("rzku"))&ptjiami
	signstr=md5(signstr)
	if trim(signstr)<>trim(mcode) then
	response.Write "出现签名错误"
	response.End()
	end if
	response.Cookies("aysignmd5")=trim(signstr)
	response.Cookies("yurl")=trim(yurl)
else
response.Write "参数错误"
response.End()
end if 
chk.close
end function
%>