<!--#include virtual="/show/indexhead.asp"-->
<!--#include virtual="/inc/md52.asp"-->
<!--#include virtual="/inc/getip/index.asp"-->

<%
'买家注册
if SafeRequestform("act")="reginbuy" then
call chkwurl()

Const stringmodarr = "0123456789abcdefghijklmnopqrstuvwxyz"
Const stringmodarr2 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
regstr=Right((year(Now())),2)&Right(("00"&Month(Now())),2)&Right(("00"&Day(Now())),2)&Right(("00"&hour(Now())),2)&Right(("00"&minute(Now())),2)&Right(("00"&second(Now())),2)
strlength = Len(stringmodarr)
strlength2 = Len(stringmodarr2)
Randomize timer
For i = 1 To 20 
sumstr = sumstr&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 
For i = 1 To 4 
sumstr2 = sumstr2&Mid(stringmodarr2,Int(Rnd * strlength2 + 1),1)  
Next
username="IK"&regstr&sumstr2  '商户名


Mobile=SafeRequestform("Mobile")
chkcode=SafeRequestform("chkcode")
chkcodetel=SafeRequestform("chkcodetel")

if left(Mobile,3)="170" or left(Mobile,3)="171" then call PopErr("该手机号段禁止使用！")
if left(Mobile,3)="145" or left(Mobile,3)="146" or left(Mobile,3)="147" then call PopErr("该手机号段禁止使用！")

if chkcode="" then 
call PopErr("请填写右侧验证码！") 
response.End()
end if

if request.Cookies("GetCode")="" then 
call PopErr("右侧验证码生成错误！") 
response.End()
end if

if int(request.Cookies("GetCode"))<>int(trim(chkcode)) then 
call PopErr("右侧验证码输入错误！") 
response.End()
end if


if request.Cookies("yzsum")="" then 
call PopErr("手机验证码生成错误！") 
response.End()
end if

tomd5yzm=md5(chkcodetel&Mobile&ptjiami)

sql="select * from ayyanzheng where ayyanzhengids='"&chkcodetel&"' and ayyanzhengidc='"&tomd5yzm&"'" 
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.Cookies("yzsum")=""
call PopErr("验证码错误,请检查手机号和验证码是否正确")
end if
rs.close

rs.open "select ayreg,flku,spku,ddku,cwku,rzku,kamishuju from ayquanju",conn,1,1
ayreg=rs("ayreg")
kamishuju=trim(rs("kamishuju"))
flku=trim(rs("flku"))
spku=trim(rs("spku"))
ddku=trim(rs("ddku"))
cwku=trim(rs("cwku"))
rzku=trim(rs("rzku"))
rs.close

if cint(ayreg)=0 then 
call PopErr("目前已关闭了买家注册 请联系管理人员")
response.End()
end if


password1=SafeRequestform("pass1") 

if trim(password1)="" then call PopErr("请设置密码！")


'fanstr=nofan
'jstr=split(fanstr,",")
'for mysum=0 to ubound(jstr)
'	if trim(jstr(mysum))=trim(username) then
'	call PopErr("该商户名禁止使用，请更换")
'	response.End()
'	end if
'next

rs.open "select * from ayname where aytel="&Mobile&"" ,conn,1,3
if not(rs.bof and rs.eof) then
call PopErr("该手机号已被注册，请使用其他手机号码")
end if
rs.addnew
rs("ayusername")=username
rs("aypassword")=md5(password1)
rs("ayjibie")=0
rs("aydata")=now()
rs("ayip")=userinip 
rs("ayyue")=0
rs("ayxiaofei")=0
rs("ayusersuo")=0
rs("suijimd5")=sumstr
rs("kamiku")=kamishuju
rs("flku")=flku
rs("spku")=spku
rs("ddku")=ddku
rs("cwku")=cwku
rs("rzku")=rzku
rs("isjiekou")="1|1|1|1|1|1"
rs("aytel")=Mobile
rs("istelrz")=1

rs("aytrueuser")=Mobile

rs.update  
rs.close

response.Cookies("yzsum")=""

rs.open "select * from ayname where ayusername='"&username&"'" ,conn,1,3
shouyaoid=rs("aynameid")
rs("aymd5")=mid(md5(rs("aynameid")),17,8) 
			
			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)
			
rs.update
rs.close

			
			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("aysignmd5").expires=DateAdd("m",3,now())
			response.Cookies("logdate").expires=DateAdd("m",3,now())


conn.Execute("Insert Into aylog(ayloguserid,aylogcon,aylogip,ayipd,aylogleibie,aylogerr) values('0','"&Mobile&"买家regbuy注册成功"&"','"&userinip&"','"&Look_Ip(userinip)&"','2','0')")

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&"')")

call PopErr2("注册成功！","/u/index")

end if
%>

<script language=javascript>
function refreshImage(img)
{
    var imageUrl = '/inc/code/'; 
    img.src = imageUrl + '?' + Math.random();
}

var xmlhttp;
try
{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch (e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch (e){try{xmlhttp=new XMLHttpRequest();}catch (e){}}}

function huoqu()
{
		
   var Mobile=document.getElementById("Mobile").value
   if (Mobile==""){alert('请填写手机号码');return false;}
   
	var regu =/^[1][3-9][0-9]{9}$/; 
	var re = new RegExp(regu); 
	if (re.test(Mobile)){}else{alert('请正确填写手机号码');return false;} 
   
   xmlhttp.open("get","/index/checkuser?Mobile="+ Mobile +"&act=huoquyz&jcact=noc&t=" +  new Date().getTime());
   
   xmlhttp.onreadystatechange=function()
   {
		 if(4==xmlhttp.readyState) 
		 {
			   if(200==xmlhttp.status)
			   { 
			   		//alert(xmlhttp.responseText);
					if (xmlhttp.responseText=="ok"){alert('验证码已发送，请注意查收');RemainTime();return false;}
					if (xmlhttp.responseText=="no"){alert('该手机号已被注册，请使用其他手机号码');return false;}
					if (xmlhttp.responseText=="time"){alert('请再一分钟后尝试重新发送验证码');return false;}
					if (xmlhttp.responseText=="telerr"){alert('请使用正常手机号码');return false;}
			   }
			   else
			   {
				alert('网络链接失败');
				return false;
			   }
		 }
   }
   xmlhttp.send(null);  
   return false;
}



function chkreg()
{

	if(form1.pass1.value==""){alert("请设置一个登录密码");return false;}
	if(form1.Mobile.value==""){alert("请填写手机号码");return false;}
	if(form1.chkcodetel.value==""){alert("请填写手机验证码");return false;}
	if(form1.chkcode.value==""){alert("请填写右侧的验证码");return false;}
}


var CID = "endtime2";
var iTime = "60"; //秒

function RemainTime()
{
   
   
	document.getElementById(CID).disabled="disabled";
    var iDay,iHour,iMinute,iSecond;
    var sDay="",sHour="",sMinute="",sSecond="",sTime="";
    if (iTime >= 0)
    {
        iDay = parseInt(iTime/24/3600);if (iDay > 0){sDay = iDay + "天";}
        iHour = parseInt((iTime/3600)%24);if (iHour > 0){sHour = iHour + "小时";}
        iMinute = parseInt((iTime/60)%60);if (iMinute > 0){sMinute = iMinute + "分钟";}
        iSecond = parseInt(iTime%60);
		
        if (iSecond >= 0){sSecond = iSecond + "秒";}
        if ((sDay=="")&&(sHour=="")){sTime= sMinute+sSecond;}else{sTime=sDay+sHour+sMinute+sSecond;}
		
		if(iTime==0){sTime="获取验证码";document.getElementById(CID).disabled="";}else{Account = setTimeout("RemainTime()",1000);}
       	iTime=iTime-1;
    }
    else
    {
       iTime = "61";    //设置+1
	   RemainTime();
    }

    document.getElementById(CID).value = sTime;
}
</script>


<style type="text/css">
.btnFn1 {cursor:pointer!important;cursor:hand;  height:30px; width:101px; padding:3px 5px 0 0; }
.btnFn2 {cursor:pointer!important;cursor:hand;  height:30px; width:101px; padding:3px 5px 0 0; font-weight:bold; }
</style>
<div class="mian">
<div class="regbox conter">
<div class="nyclassbt01 conter">注册成为买家&nbsp;&nbsp;<span style="font-size:16px;"><a href="reg">(或:商家注册)</a></span></div>
<form action="" method="post" id="form1" onSubmit="return chkreg()">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">


  <tr>
    <td width="280" height="50" class="regtext">手机号码：</td>
    <td width="303"><input name="Mobile" type="text" class="reginput" id="Mobile" maxlength="11"></td>
    <td width="452"><input type="button" class="btnFn1" id="endtime2" value="获取验证码" onClick="huoqu()"></td>
  </tr>
  <tr>
    <td height="50" class="regtext">手机验证码：</td>
    <td><input name="chkcodetel" type="text" class="reginput" id="chkcodetel" maxlength="6"></td>
    <td><div id="pass1d" class="regts" ><span id="pass1s"> 请输入手机收到的验证码</span></div></td>
  </tr>
  <tr>
    <td height="50" class="regtext">设置密码：</td>
    <td><input name="pass1" id="pass1" type="password" class="reginput" onBlur="return passone(this.value);" maxlength="15"></td>
    <td><div id="pass1d" class="regts" ><span id="pass1s"> 请设置密码(6~15个字符)</span></div></td>
  </tr>
  <tr>
    <td height="50" class="regtext">验证码：</td>
    <td><input name="chkcode" type="text" class="reginput" id="chkcode" maxlength="4"></td>
    <td><img src="/inc/code/" alt="点击刷新验证码" style="cursor:pointer" border=0 onClick="refreshImage(this);"/></td>
  </tr>
  <tr>
    <td height="69" class="regtext">&nbsp;</td>
    <td align="left"><input style="cursor:pointer" name="tijiao" type="submit" class="logindlreg" id="tijiao" value="注册成为买家"></td>
    <td>
    <input name="act" type="hidden" id="act" value="reginbuy">
    </td>
  </tr>
  <tr>
    <td height="69" class="regtext">&nbsp;</td>
    <td align="left"><a href="reg">[其他相关：注册成为商家]</a></td>
    <td>&nbsp;</td>
  </tr>
  </table>
</form>
<br>

</div>
</div>



<!--#include virtual="/show/indexfoot.asp"-->