<!--#include virtual="/inc/conn.asp"-->
<!--#include virtual="/inc/sitecon.asp"-->
<!--#include virtual="/inc/chkuser.asp"-->
<!--#include virtual="/inc/getip/index.asp"-->
<!--#include virtual="/show/mokuai/sms.asp"-->
<%
'call chkwurl()

'检查是否有中文
function HasChinese(str)
HasChinese = false
dim i
for i=1 to Len(str)
if Asc(Mid(str,i,1)) < 0 then
HasChinese = true
exit for
end if
next
end function


Function RndNumber(Min,Max) 
Randomize 
RndNumber=Int((Max - Min + 1) * Rnd() + Min) 
End Function 
 


'############通用 获取 手机验证码  【买家投诉 买家注册 买家快捷注册 商家重新激活 修改商家支付密码】
if trim(SafeRequest("act"))="huoquyz" then
Mobile=trim(SafeRequest("Mobile"))
jcact=trim(SafeRequest("jcact"))
qact=trim(SafeRequest("qact"))	'商家后台 手机认证

if Mobile<>"" then	'已登录身份 不传递Mobile
	if chktelisok(Mobile)="no" then
	response.Write "telerr"
	response.end
	end if
end if

if jcact="you" then '必须存在
	if Mobile<>"" then
	rs.open "select aytel,iszhuxiao,istelrz from ayname where aytel="&Mobile&" and iszhuxiao=0",conn,1,1
	else
	rs.open "select aynameid,aytel,iszhuxiao,istelrz from ayname where aynameid="&clng(request.Cookies("aynameid"))&" and iszhuxiao=0",conn,1,1
	end if
	if rs.bof and rs.eof then
	response.Write "no"
	response.end
	end if
	Mobile=rs("aytel")
	if qact="telrz" and rs("istelrz")=1 then	'手机认证 检查是否已认证 不能重复认证
	response.Write("chongfu") 
	response.End()
	end if
	rs.close
	
end if

if jcact="noc" then '不能重复 用于注册
	rs.open "select aytel,iszhuxiao from ayname where aytel="&Mobile&" and iszhuxiao=0",conn,1,1
	if not(rs.bof and rs.eof) then
	response.Write "no"
	response.end
	end if
	rs.close
end if

yanzhengma=RndNumber(100000,999999)  '验证序号
yanzhengmamd5=md5(yanzhengma&Mobile&ptjiami)

if request.Cookies("hqtime")<>""  then
	if DateDiff("n",request.Cookies("hqtime"),now())<=1 then 
	response.Write("time") 
	response.End()
	else
		response.Cookies("hqtime")=now()
		if request.Cookies("yzsum")="" then 
		response.Cookies("yzsum")=Mobile
		response.Cookies("yzsum").expires=DateAdd("n",10,now())
		end if
	end if
else
response.Cookies("hqtime")=now()
response.Cookies("yzsum")=Mobile
response.Cookies("yzsum").expires=DateAdd("n",10,now())
end if
				

conn.Execute("Insert Into ayyanzheng(ayyanzhengids,ayyanzhengidc) values('"&yanzhengma&"','"&yanzhengmamd5&"')")

if jcact="tousu" then
call mokuai_sms("IK18","2",Mobile,"投诉密码"&yanzhengma&"(10分钟有效)，用于查询与撤销投诉，请妥善保存。查询地址ikpay.cn/tousu",yanzhengma,"","","")
else
call mokuai_sms("IK01","2",Mobile,"本次的验证码："&yanzhengma&"(10分钟有效)",yanzhengma,"","","")
end if
response.Write "ok"
response.end
end if


'############商家后台 安全验证 获取验证码 包含邮箱验证码  手机验证码##################
if trim(SafeRequest("act"))="huoquyzhoutai" then
fangshi=trim(SafeRequest("fangshi"))

if fangshi="" then
response.Write "no"
response.end
end if

	yanzhengma=RndNumber(100000,999999)    '发送验证码
	'发起获取验证码时间
	if request.Cookies("hqtime")<>""  then
		if DateDiff("n",request.Cookies("hqtime"),now())<=1 then 
		response.Write("time") 
		response.End()
		else
			response.Cookies("hqtime")=now()
			if request.Cookies("yzsum")="" then 
			response.Cookies("yzsum")=now()
			response.Cookies("yzsum").expires=DateAdd("n",10,now())
			end if
		end if
	else
	response.Cookies("hqtime")=now()
	response.Cookies("yzsum")=now()
	response.Cookies("yzsum").expires=DateAdd("n",10,now())
	end if


sql="select aynameid,aymail,aytel from ayname where aynameid="&clng(request.Cookies("aynameid"))&"" 
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.Write "no"
response.end
end if


if fangshi="tel" then
	if chktelisok(rs("aytel"))="no" then
	response.Write "telerr"
	response.end
	end if
	yanzhengmamd5=md5(yanzhengma&rs("aytel")&ptjiami)  '加密验证码
	conn.Execute("Insert Into ayyanzheng(ayyanzhengids,ayyanzhengidc) values('"&yanzhengma&"','"&yanzhengmamd5&"')")
	call mokuai_sms("IK01","2",trim(rs("aytel")),"本次的验证码："&yanzhengma&"(10分钟有效)",yanzhengma,"","","")
end if

if fangshi="mail" then
yanzhengmamd5=md5(yanzhengma&trim(rs("aymail"))&ptjiami)  '加密验证码
conn.Execute("Insert Into ayyanzheng(ayyanzhengids,ayyanzhengidc) values('"&yanzhengma&"','"&yanzhengmamd5&"')")
conn.Execute("Insert Into mailto(mlei,mto,mti,mcon) values('2','"&trim(rs("aymail"))&"','来自-"&webname&"获取验证码','来自-"&webname&"，您的验证码是："&yanzhengma&"')")
end if



rs.close

response.Write "ok"
response.end
end if
'**************************************************************************************************************************************************
'**************************************************************************************************************************************************

'登录状态下获取 邮箱验证码
if SafeRequest("act")="getusermail" then  
yanzhengma=RndNumber(100000,999999)  '验证序号
sql="select * from ayname where aynameid="&clng(request.Cookies("aynameid"))&" and iszhuxiao=0" 
rs.open sql,conn,1,1

'发起获取验证码时间
if request.Cookies("hqtime")<>""  then
	if DateDiff("n",request.Cookies("hqtime"),now())<=1 then 
	response.Write("time") 
	response.End()
	else
		response.Cookies("hqtime")=now()
		if request.Cookies("yzsum")="" then 
		response.Cookies("yzsum")=trim(rs("aymail"))
		response.Cookies("yzsum").expires=DateAdd("n",10,now())
		end if
	
	end if
else
response.Cookies("hqtime")=now()
response.Cookies("yzsum")=trim(rs("aymail"))
response.Cookies("yzsum").expires=DateAdd("n",10,now())
end if
	
yanzhengmamd5=md5(yanzhengma&trim(rs("aymail"))&ptjiami)
conn.Execute("Insert Into ayyanzheng(ayyanzhengids,ayyanzhengidc) values('"&yanzhengma&"','"&yanzhengmamd5&"')")
conn.Execute("Insert Into mailto(mlei,mto,mti,mcon) values('2','"&trim(rs("aymail"))&"','来自-"&webname&"获取验证码','来自-"&webname&"，您的验证码是："&yanzhengma&"')")
rs.close

response.Write("ok") 
response.End()

end if


'**************************************************************************************************************************************************

'找回密码 获取 邮箱验证码
if SafeRequest("act")="huoqumailyz" then  
mail=trim(SafeRequest("mail"))
sql="select * from ayname where aymail='"&trim(mail)&"' and iszhuxiao=0" 
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.Write("no") 
response.End()
end if
rs.close

yanzhengma=RndNumber(100000,999999)  '验证序号
'发起获取验证码时间
if request.Cookies("hqtime")<>""  then
	if DateDiff("n",request.Cookies("hqtime"),now())<=1 then 
	response.Write("time") 
	response.End()
	else
		response.Cookies("hqtime")=now()
		if request.Cookies("yzsum")="" then 
		response.Cookies("yzsum")=trim(mail)
		response.Cookies("yzsum").expires=DateAdd("n",10,now())
		end if
	
	end if
else
response.Cookies("hqtime")=now()
response.Cookies("yzsum")=trim(mail)
response.Cookies("yzsum").expires=DateAdd("n",10,now())
end if
	
yanzhengmamd5=md5(yanzhengma&mail&ptjiami)
conn.Execute("Insert Into ayyanzheng(ayyanzhengids,ayyanzhengidc) values('"&yanzhengma&"','"&yanzhengmamd5&"')")
conn.Execute("Insert Into mailto(mlei,mto,mti,mcon) values('2','"&trim(mail)&"','来自-"&webname&"获取验证码','来自-"&webname&"，您的验证码是："&yanzhengma&"')")
response.Write("ok") 
response.End()
end if
'**************************************************************************************************************************************************

Const stringmodarr = "0123456789"
strlength = Len(stringmodarr)
Randomize timer
For i = 1 To 6 
telsum = telsum&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 

'if SafeRequest("act")="maijtelrenzheng" then 
'aytel=SafeRequest("aytel")
'if trim(aytel)="" then
'response.Write("no") 
'response.End() 
'end if
'sql="select * from aymaiweixin where maitel="&aytel&"" 
'rs.open sql,conn,1,1
'if not(rs.bof and rs.eof) then
'response.Write("you")  
'response.End()
'end if
'rs.close
'response.Cookies("maitelrenzhengsum")=telsum
'call mokuai_sms("IK01","2",trim(aytel),"本次的验证码："&request.Cookies("maitelrenzhengsum")&"(10分钟有效)",request.Cookies("maitelrenzhengsum"),"","","")
'response.Write("ok") 
'response.End()
'end if


'【商家邮箱认证-未用】
if SafeRequest("act")="mailrenzheng" then  

sql="select aymail,aynameid,ismailrz,aymail,iszhuxiao from ayname where aynameid="&clng(request.Cookies("aynameid"))&" and iszhuxiao=0" 
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
	if rs("ismailrz")=1 then
	response.Write("chongfu") 
	response.Cookies("rzmtime")=""
	response.Cookies("mailrenzhengsum")=""
	response.End()
	end if
	aymail=rs("aymail")
else
response.Write("no") 
response.End()
end if
rs.close

if request.Cookies("rzmtime")<>""  then
	if DateDiff("n",request.Cookies("rzmtime"),now())<=1 then
	response.Write("time") 
	response.End()
	else
	response.Cookies("rzmtime")=now()
	end if
else
response.Cookies("rzmtime")=now()
end if

	if trim(aymail)="" then
	response.Write("no") 
	response.End() 
	end if
	
response.Cookies("mailrenzhengsum")=telsum
conn.Execute("Insert Into mailto(mlei,mto,mti,mcon) values('2','"&trim(aymail)&"','来自-"&webname&"获取验证码','来自-"&webname&"，您的验证码是："&request.Cookies("mailrenzhengsum")&"')")
response.Write("ok") 
response.End()
end if




if SafeRequest("act")="regck" then
username=SafeRequest("username")
	if username="" then 
	response.Write("no")
	response.End()
	end if
rs.open "select ayusername,iszhuxiao from ayname where ayusername='"&username&"' and iszhuxiao=0" ,conn,1,3
	if rs.bof and rs.eof then
	response.Write("no")
	rs.close
	else
	response.Write("yes")
	rs.close
	end if
response.End()
end if

if SafeRequest("act")="regcktel" then
Mobiled=SafeRequest("Mobiled")
	if Mobiled="" then 
	response.Write("no")
	response.End()
	end if
rs.open "select aytel,iszhuxiao from ayname where aytel="&Mobiled&" and iszhuxiao=0" ,conn,1,3
	if rs.bof and rs.eof then
	response.Write("yes")
	rs.close
	else
	response.Write("no")
	rs.close
	end if
response.End()
end if


if SafeRequest("act")="regckmail" then
email=SafeRequest("email")
	if email="" then 
	response.Write("no")
	response.End()
	end if
rs.open "select aymail,iszhuxiao from ayname where aymail='"&email&"' and iszhuxiao=0" ,conn,1,3
	if rs.bof and rs.eof then
	response.Write("no")
	rs.close
	else
	response.Write("yes")
	rs.close
	end if
response.End()
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%


if SafeRequestform("act")="logindex" then
	username=trim(SafeRequestform("username"))
	password=trim(SafeRequestform("password"))
	chkcode=SafeRequestform("chkcode")
	cact=SafeRequestform("cact")
	pcurl=SafeRequestform("pcurl")
	lei=SafeRequestform("lei")
	ww=SafeRequestform("ww")
	hh=SafeRequestform("hh")
	
	if HasChinese(username)=true then
	call PopErr2("请正确输入手机号或邮箱登录","/index/log") 
	end if
	
	if trim(pcurl)="" then
		if trim(chkcode)="" then 
		response.Cookies("GetCode")=""
		call PopErr2("验证码输入错误","/index/log") 
		end if
		
		if int(request.Cookies("GetCode"))<>int(trim(chkcode)) then 
		response.Cookies("GetCode")=""
		call PopErr2("验证码输入错误","/index/log") 
		end if
	end if
	
	if instr(1,username,"@")>0 then
	sql="select * from ayname where aymail='"&username&"' and iszhuxiao=0"
	else
		if isNumeric(username)=true then
		sql="select * from ayname where aytel="&username&" and iszhuxiao=0"
		else
		call PopErr2("请使用手机号或邮箱登录！","/index/log") 
		end if
	end if
	
	rs.open sql,conn,1,3
		if not(rs.bof and rs.eof) then
			
			if md5(password)<>trim(rs("aypassword")) then
			conn.Execute("Insert Into aylog(ayloguserid,aylogcon,aylogip,ayipd,aylogleibie,aylogerr) values(0,'"&username&"密码检验失败"&"','"&userinip&"','"&Look_Ip(userinip)&"','1','1')")
			call PopErr2("密码检验失败，请重新输入","/index/log") 
			end if
			
			if cint(rs("ayusersuo"))=1 then 
			rs.close
			call PopErr2("该账户已被锁定","/") 
			end if

			if cint(rs("isjihuo"))=1 then response.Redirect("/index/jihuo")
		
			set rslogck=server.CreateObject("adodb.recordset")
			rslogck.open "select ayshangshenhe,aylog from ayquanju" ,conn,1,1
			if cint(rslogck("ayshangshenhe"))=1 and cint(rs("ayshenhe"))=0 and cint(rs("ayjibie"))<>9 then
				rslogck.close
				rs.close
				call PopErr2("请联系客服专员,激活您的账号","/index/jh") 
			end if
				
			if cint(rs("ayjibie"))<>9 and cint(rslogck("aylog"))=0 then
			rslogck.close
			rs.close
			call PopErr2("目前关闭了用户登录 请联系管理员","/") 
			end if
			rslogck.close
			isyidiip=rs("isyidiip")
			
			dtime=now()
			
			signstr=""
			response.Cookies("aymd5")=trim(rs("aymd5"))
			response.Cookies("useripd")=Look_Ip(userinip)
			response.Cookies("ayjibie")=rs("ayjibie")
			response.Cookies("ayusername")=trim(rs("ayusername"))
			response.Cookies("aynameid")=rs("aynameid") 
			response.Cookies("aytrueuser")=rs("aytrueuser") 
			response.Cookies("aymasterid")=rs("aymasterid")
			response.Cookies("kamiku")=trim(rs("kamiku"))
			response.Cookies("flku")=trim(rs("flku"))
			response.Cookies("spku")=trim(rs("spku"))
			response.Cookies("ddku")=trim(rs("ddku"))
			response.Cookies("cwku")=trim(rs("cwku"))
			response.Cookies("rzku")=trim(rs("rzku"))
			response.Cookies("logdate")=dtime
			
			signstr="ikuserdl"&rs("aynameid")&trim(rs("ayusername"))&rs("ayjibie")&trim(rs("ddku"))&trim(rs("cwku"))&trim(rs("rzku"))&dtime&ptjiami
			signstr=md5(signstr)
			response.Cookies("aysignmd5")=trim(signstr)

			if cint(rs("ayjibie"))=0 then
			response.Cookies("aymd5").expires=DateAdd("m",3,now())
			response.Cookies("useripd").expires=DateAdd("m",3,now())
			response.Cookies("ayjibie").expires=DateAdd("m",3,now())
			response.Cookies("ayusername").expires=DateAdd("m",3,now())
			response.Cookies("aynameid").expires=DateAdd("m",3,now())
			response.Cookies("aytrueuser").expires=DateAdd("m",3,now())
			response.Cookies("aymasterid").expires=DateAdd("m",3,now())
			response.Cookies("kamiku").expires=DateAdd("m",3,now())
			response.Cookies("flku").expires=DateAdd("m",3,now())
			response.Cookies("spku").expires=DateAdd("m",3,now())
			response.Cookies("ddku").expires=DateAdd("m",3,now())
			response.Cookies("cwku").expires=DateAdd("m",3,now())
			response.Cookies("rzku").expires=DateAdd("m",3,now())
			response.Cookies("logdate").expires=DateAdd("m",3,now())
			response.Cookies("aysignmd5").expires=DateAdd("m",3,now())
			else
			response.Cookies("aymd5").expires=DateAdd("n",60,now())
			response.Cookies("useripd").expires=DateAdd("n",60,now())
			response.Cookies("ayjibie").expires=DateAdd("n",60,now())
			response.Cookies("ayusername").expires=DateAdd("n",60,now())
			response.Cookies("aynameid").expires=DateAdd("n",60,now())
			response.Cookies("aytrueuser").expires=DateAdd("n",60,now())
			response.Cookies("aymasterid").expires=DateAdd("n",60,now())
			response.Cookies("kamiku").expires=DateAdd("n",60,now())
			response.Cookies("flku").expires=DateAdd("n",60,now())
			response.Cookies("spku").expires=DateAdd("n",60,now())
			response.Cookies("ddku").expires=DateAdd("n",60,now())
			response.Cookies("cwku").expires=DateAdd("n",60,now())
			response.Cookies("rzku").expires=DateAdd("n",60,now())
			response.Cookies("logdate").expires=DateAdd("n",60,now())
			response.Cookies("aysignmd5").expires=DateAdd("n",60,now())
			end if
			
			rs("aylastdata")=now()
			rs("aylastip")=userinip
			rs("aylogcishu")=ccur(rs("aylogcishu"))+1
			rs.update
			rs.close

			if cint(request.Cookies("ayjibie"))<>0 then
			
				if cint(isyidiip)=1 then
				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
						call gaojiquanxianlog("anquan")
						response.end
						end if
						rsip.close
					
					end if
				end if
				end if
				
			end if

conn.Execute("Insert Into "&request.Cookies("rzku")&"(ayloguserid,aylogcon,aylogip,ayipd,aylogleibie,aylogerr) values("&request.Cookies("aynameid")&",'"&username&"登录"&"','"&userinip&"','"&request.Cookies("useripd")&"','1','0')")


'conn.Execute("Insert Into userlog(userloguser,userlogxiangxi,userlogip,userlogipd,userlogwidth,userlogheight) values("&request.Cookies("aynameid")&",'"&request.serverVariables("HTTP_USER_AGENT")&"','"&userinip&"','"&request.Cookies("useripd")&"','"&ww&"','"&hh&"')")

conn.Execute("Insert Into logsession(aymd5,ip,useripd,ayjibie,ayusername,aynameid,aytrueuser,aymasterid,kamiku,flku,spku,ddku,cwku,rzku,aysignmd5,logdate) values('"&request.Cookies("aymd5")&"','"&userinip&"','"&request.Cookies("useripd")&"',"&request.Cookies("ayjibie")&",'"&request.Cookies("ayusername")&"',"&request.Cookies("aynameid")&",'"&request.Cookies("aytrueuser")&"',"&request.Cookies("aymasterid")&",'"&request.Cookies("kamiku")&"','"&request.Cookies("flku")&"','"&request.Cookies("spku")&"','"&request.Cookies("ddku")&"','"&request.Cookies("cwku")&"','"&request.Cookies("rzku")&"','"&request.Cookies("aysignmd5")&"','"&dtime&"')")

			'if cact="jd" then response.Redirect("/index/jd")

			if cint(request.Cookies("ayjibie"))=0 then
			if trim(pcurl)<>"" then response.Redirect pcurl
			response.Redirect("/u/index")
			else
			response.Redirect("/user/index")
			end if

		
		else


		rs.close
conn.Execute("Insert Into aylog(ayloguserid,aylogcon,aylogip,ayipd,aylogleibie,aylogerr) values(0,'"&username&"未找到该用户名"&"','"&userinip&"','"&Look_Ip(userinip)&"','1','1')")
		call PopErr2("系统未查询到该用户名,或已被删除","/index/log")


	end if
	
end if
%>

<%
conn.close
set conn=nothing
%>