<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%

webtitle="新用户注册"
webkeywords="新用户注册"
webdescription="新用户注册|"&webname
%> 

<%dim action
action=FormatSQL(SafeRequest("action",0))
%>

<!--#include file="include/header.asp"--> 

<%
select case action
case ""%> 
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
<TR> <TD HEIGHT="18" ALIGN="center"><br><B><FONT SIZE=2><%=webname%>注册条约</FONT></B></TD></TR> 
<TR> <TD align=center valign="top" style='PADDING-LEFT: 40px;PADDING-right: 40px;'> <%call tiaoyue()%> </TD></TR> 
<TR> <FORM NAME="form1" METHOD="post" ACTION="reg.asp?action=yes"> <TD ALIGN="center"> 
<INPUT TYPE="submit" NAME="Submit4"STYLE="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee" VALUE="我 同 意"> 
&nbsp;&nbsp; <INPUT TYPE="button" NAME="Submit22" VALUE="我 不 同 意" STYLE="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee"ONCLICK="location.href='index.asp'"> 
</TD></FORM></TR> </TABLE>

<%case "yes"%>
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
  <tr> 
    <TD colspan="2" ALIGN="center"><FONT COLOR="#cb6f00">请填写用户信息</FONT></TD>
  </tr>
  <FORM NAME="userinfo" METHOD="post" ACTION="reg.asp?action=save" >
    <TR> 
      <TD align="right"><FONT COLOR="#cb6f00">会员帐户：</FONT></TD>
      <TD width="550"><INPUT NAME="username" TYPE="text" size="15" maxlength="15" >
        由字母、数字、下划线组成（4-16位）。</TD>
    </TR>
    <TR> 
      <TD><div align="right"><FONT COLOR="#cb6f00">密　　码：</FONT></div></TD>
      <TD> <INPUT NAME="UserPassword" type="Password" size="15" maxlength="15">
        由字母、数字、下划线组成（6-16位）。</TD>
    </TR>
    <TR> 
      <TD><div align="right"><FONT COLOR="#cb6f00">确认密码：</FONT> </div></TD>
      <TD> <INPUT NAME="UserPassword1" type="Password" size="15" maxlength="15"> </TD>
    </TR>
    <TR> 
      <TD><div align="right"><FONT COLOR="#cb6f00">电子信箱：</FONT> </div></TD>
      <TD> <INPUT NAME="useremail" TYPE="text" size="15">
        请您务必填写正确的E-mail地址，便于我们与您联系；</TD>
    </TR>
	<TR> 
      <TD><div align="right"><FONT COLOR=#cb6f00>密码提示： </FONT></div></TD>
      <TD> <INPUT NAME="UserQuesion" TYPE="text" size="15" maxlength="15"> </TD>
    </TR>
    <TR> 
      <TD><div align="right"><FONT COLOR=#cb6f00>密码答案： </FONT></div></TD>
      <TD> <INPUT NAME="UserAnswer" TYPE="text" size="15" maxlength="15"> </TD>
    </TR>
    
	<TR> 
      <TD align="right">真实姓名： </TD>
      <TD> <INPUT NAME="realname" TYPE="text" size="15" maxlength="10">
        收货人姓名。</TD>
    </TR>
    <TR> 
      <TD align="right">电话号码： </FONT></TD>
      <TD> <INPUT NAME="Usertel" TYPE="text" size="15" maxlength="15" onkeypress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))">
        请填写正确的号码，以便有急事联系。</TD>
    </TR>
    <TR> 
      <TD align="right">腾讯 Q Q：</TD>
      <TD> <INPUT NAME="userqq" TYPE="text" size="15" maxlength="10" onkeypress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))">
        网上联系</TD>
    </TR>
    <TR> 
      <TD align="right">推 荐 人： </TD>
      <TD> <INPUT NAME="recommender" TYPE="text" size="15" maxlength="15"> </TD>
    </TR>
    <TR> 
      <TD></TD>
      <TD> <INPUT ONCLICK="return check();" TYPE="submit" NAME="Submit3" STYLE="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee"VALUE="提  交" >
        &nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="Submit5" STYLE="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee" value="清  除"> </TD>
    </TR>
  </FORM>
</TABLE>

<%case "save"%> 
<!--#include file="func.asp"--> 
<%call saveuser()%> <%
end select%> 
<!--#include file="include/footer.asp"--> 
<%sub tiaoyue()
set rs=server.CreateObject("adodb.recordset")
rs.Open "select regrule from sdx_other",conn,1,1
response.Write trim(rs("regrule"))
rs.Close
set rs=nothing
end sub

sub saveuser()
dim rsrec,strgift,stradd,strresult
if session("regtimes")=1 then
response.Write "<div align=center><br><br>对不起，您刚注册过用户。<br>请稍后再进行注册！</font></div><br>"
response.End
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select username,useremail from DV_User where username='"&trim(request.form("username"))&"' or useremail='"&trim(request.form("useremail"))&"'",conn,1,1
if not rs.eof and not rs.bof then
call usererr()
rs.close
set rs = nothing
else
rs.close

rs.open "select webimg13 from [config]",conn,1,1
strgift=Clng(rs("webimg13"))
rs.close

stradd=trim(request.form("recommender"))
rs.open "select score from DV_User where username='"&stradd&"' ",conn,1,3
if rs.eof and rs.bof then
strresult="你填写的推荐人还没有被注册"
stradd="sundxshop"
else
strresult="给你的推荐人加了'"& strgift &"'分"
rs("score")=rs("score")+strgift
rs.update
end if
rs.close

rs.open "select * from DV_User",conn,1,3
rs.addnew
rs("username")=trim(request.form("username"))
rs("UserPassword")=md5(trim(request.form("UserPassword")))
rs("useremail")=trim(request.form("useremail"))
rs("UserQuesion")=trim(request.form("UserQuesion"))
rs("UserAnswer")=md5(trim(request.form("UserAnswer")))
rs("recommender")=stradd
rs("realname")=trim(request.form("realname"))
rs("identify")=trim(request.form("identify"))
rs("Usertel")=trim(request.form("Usertel"))
rs("userqq")=trim(request.form("userqq"))
rs("adddate")=now()
rs("Img") = Request.ServerVariables("REMOTE_ADDR")
rs("LastLogin")=now()
rs("score")=webimg7


		rs("UserIM")="||||||||||||||||||"
		rs("titlepic")="level0.gif"
		rs("UserPost")=0
		rs("UserGroupID")=4
		rs("Lockuser")=0
		rs("UserSex")=0
		rs("JoinDate")=NOW()
		rs("UserFace")="Images/userface/image1.gif"
		rs("userclass")="新手上路"
		rs("UserWidth")=32
		rs("UserHeight")=32
		rs("UserLogins")=1
		rs("LastLogin")=NOW()
		rs("userWealth")=100
		rs("userEP")=100
		rs("usercP")=100
		rs("UserInfo")="||||||||||||||||||||||||||||||||||||||||||"
		rs("UserSetting")="1|||0|||0"
		rs("UserPower")=0
		rs("UserDel")=0
		rs("UserIsbest")=0
		rs("UserFav")="陌生人,我的好友,黑名单"
		rs("IsChallenge")=0
		rs("UserLastIP")=Request.ServerVariables("REMOTE_ADDR")
		rs.update
		conn.execute("UpDate Dv_Setup Set Forum_UserNum=Forum_UserNum+1,Forum_lastUser='"&username&"'")
		
rs.close
set rs=nothing
response.Cookies("sundxshop")("username")=trim(request.form("username"))
Response.Cookies("sundxshop").Expires = Now()+1
 %>



<%
MailType = webbj4
smtpserver = webbj7
sendusername = webbj8
sendpassword = webbj9
SendName = webbj3
SendTO = trim(request.form("useremail"))
SendFrom = webbj8
subject="您在"&webname&"的注册信息！"
'发送邮件

Message= "<html>"
Message=message & "<title>注册信息</title>"
Message=message & "<body>"
Message=message & "<TABLE border=0 width='95%' align=center><TBODY><TR>"
Message=message & "<TD valign=middle align=top>"
Message=message & trim(request.form("username"))&"，您好：<br><br>"
Message=message & "欢迎您注册" & webname & "网上商城，我们将提供给您最好的服务！<br>"
Message=message & "下面是您在" & webname & "网上商城的注册信息：<br><br>"
Message=message & "注册名："&trim(request.form("username"))&"<br>"
Message=message &  "密  码："&trim(request.form("UserPassword"))&"<br>"
Message=message & "<br><br>"
Message=message & "<center><a href=http://"& weburl &" target=_blank><font color=red>再次感谢您注册" & webname & "网上商城！</font> </a></center>"
Message=message & "</TD></TR></TBODY></TABLE><br><hr width=95% size=1>"
Message=message & "</html>"
Select Case MailType
Case "Nothing"

Case "CDONTS"
call sendemail(SendFrom,SendTO,smtpserver,sendusername,sendpassword,subject,Message)
Case "Jmail"
call SendJmail(SendFrom,SendTO,smtpserver,sendusername,sendpassword,subject,Message,SendName)

End Select







%>

<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
<tr><td height=100 >
<table width=700 border=0 align=center cellpadding=0 cellspacing=0>
<tr><td height=80><font color=#FF0000>用户注册成功</font><br><br><br>
恭喜<% = request.Cookies("sundxshop")("username") %>，您已注册成为[<% = webname %>]正式用户，请进行下一步操作：<br><br>
·<a href=profile.asp?action=profile>为了方便您的购物，建议您填写详细的收货人资料</a><br>
·<a href=javascript:location.href='payment.asp?action=2'><font color=red>点击返回收银台</font></a> 
</td></tr></table>
</td></tr></table>
<%
end if
end sub

sub usererr() %>
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
<tr><td >
<table width=700 border=0 align=center cellpadding=2 cellspacing=0>
<tr><td><font color=#FF0000>用户注册失败</font><br><br><br><br>
·您输入的用户名或Email地址已经被注册，请选用其他的用户名或者E-mail！<br>
·<a href=javascript:history.go(-1)><font color=red>点击返回上一页</font></a> 
</td></tr></table>
</td></tr></table>
<%
end sub
%> 
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkname(str){
exp=/[^\w]/gi;
if(str.search(exp)!=-1)
{return false;}
return true;
}

function check()
{

   if(checkspace(document.userinfo.username.value)) {
	document.userinfo.username.focus();
    alert("会员帐户不能为空，请重新输入！");
	return false;
  }
 if(!checkname(document.userinfo.username.value)) {
	document.userinfo.username.focus();
    alert("字母、数字、下划线组成，请重新输入！");
	return false;
  }
    if(checkspace(document.userinfo.username.value) || document.userinfo.username.value.length < 4) {
	document.userinfo.username.focus();
    alert("会员帐户必须大于4位，请重新输入！");
	return false;
  }

    if(checkspace(document.userinfo.UserPassword.value) || document.userinfo.UserPassword.value.length < 6) {
	document.userinfo.UserPassword.focus();
    alert("密码长度不能小于6，请重新输入！");
	return false;
  }
    if(document.userinfo.UserPassword.value != document.userinfo.UserPassword1.value) {
	document.userinfo.UserPassword.focus();
	document.userinfo.UserPassword.value = '';
	document.userinfo.UserPassword1.value = '';
    alert("两次输入的密码不同，请重新输入！");
	return false;
  }

 if(document.userinfo.useremail.value.length!=0)
  {
    if (document.userinfo.useremail.value.charAt(0)=="." ||        
         document.userinfo.useremail.value.charAt(0)=="@"||       
         document.userinfo.useremail.value.indexOf('@', 0) == -1 || 
         document.userinfo.useremail.value.indexOf('.', 0) == -1 || 
         document.userinfo.useremail.value.lastIndexOf("@")==document.userinfo.useremail.value.length-1 || 
         document.userinfo.useremail.value.lastIndexOf(".")==document.userinfo.useremail.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.userinfo.useremail.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空！");
   document.userinfo.useremail.focus();
   return false;
   }

}

function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}


function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//-->
</script>
<!--#INCLUDE FILE="include/sendmail1.asp"-->
