<%
Option Explicit
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<!--#include file="inc/config.asp" -->
<!--#include file="inc/conn.asp" -->
<!--#include file="inc/function.asp" -->
<!--#include file="inc/md5.asp" -->
<!--#include file="inc/sql_filter.asp" -->
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员注册</title>
<link href="style/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<script src="js/reg.js" type="text/javascript"></script>
<style type="text/css">
.pad_5{ padding-left:10px; line-height:20px;}
.pformleft{ padding-left:10px;}
</style>

</head>
<body>
<!--#include file="head.asp" -->
<%
dim act,gourl

act=request.QueryString("act")
gourl=request.QueryString("gourl")
if(request.QueryString("gourl")<>"") then
	gourl=request.QueryString("gourl")
elseif(request.ServerVariables("HTTP_REFERER")<>"") then
	gourl=request.ServerVariables("HTTP_REFERER")
else
	gourl="/"
end if
if(act<>"" and act="reg") then
	if(isSelfRefer()) then
	else
		call alertstr("禁止外部提交",2)
	end if
	dim rs,UserName,PassWord,RePassWord,Sex,Email,ForAsk,ForAnswer,CheckCode,UIP,IsExits
	UserName=replaceBadChar(request.Form("UserName"))
	PassWord=trim(request.Form("PassWord"))
	RePassWord=trim(request.Form("RePassWord"))
	Sex=replaceBadChar(request.Form("Sex"))
	Email=replaceBadChar(request.Form("Email"))
	ForAsk=replaceBadChar(request.Form("ForAsk"))
	ForAnswer=replaceBadChar(request.Form("ForAnswer"))
	CheckCode=request.Form("CheckCode")
	if CheckCode <> CStr(Session("GetCode"))  then 
		call alertstr("错误：\n验证码错误",1)
	end if
	if CheckCode= "" then
		call alertstr("错误：\n验证码错误",1)
	elseif Session("GetCode") = "9999" then
		Session("GetCode")=""
	elseif Session("GetCode") = "" then
		call alertstr("错误：\n验证码错误",1)
	elseif cstr(Session("GetCode"))<>cstr(Trim(CheckCode)) then
		call alertstr("错误：\n您输入的确认码和系统产生的不一致，请重新输入。\n返回后请刷新登录页面后重新输入正确的信息",2)		
	end if
	Session("GetCode")=""
	PassWord=Md5(PassWord,32)
	UIP=GetIp()	
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from t_member_p where UserId='"&UserName&"' or Email='"&Email&"'",conn,3,3
	if not rs.eof then
		IsExits=true
	else
		rs.addnew
		rs("UserId")=UserName
		rs("Email")=Email
		rs("UserName")=UserName
		rs("IdCard")=""
		rs("BornDate")=""
		rs("Sex")=Sex
		rs("Age")=0
		rs("Province")="0"
		rs("City")="0"
		rs("Education")=""
		rs("Profession")=""
		rs("InCome")=""
		rs("Tel")=""
		rs("Mobile")=""
		rs("QQ")=""
		rs("MSN")=""
		rs("HomePage")=""
		rs("Address")=""
		rs("PostCode")=""
		rs("Photo")="/images/nophoto.gif"
		rs("Demons")=""
		rs.update
		IsExits=false
	end if
	rs.close
	set rs=nothing
	if (IsExits=false) then
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select * from t_member where UserId='"&UserName&"'",conn,3,3
		if(rs.eof or rs.bof) then
			rs.addnew
			rs("UserType")=0
			rs("UserId")=UserName
			rs("UserPass")=PassWord			
			rs("PassAsk")=ForAsk
			rs("PassAnswer")=ForAnswer	
			rs("Email")=Email		
			rs("RegIp")=UIP
			rs("RegDate")=now()			
			rs("LoginNum")=0
			rs("LastLoginIp")=UIP
			rs("LastLoginDate")=now()
			rs("IsLocked")=0
			rs("GoldMoney")=0.00
			rs("Score")=100
			rs("IsCheck")=1
			rs("UserLevel")=0
			rs.update
		end if
		rs.close
		set rs=nothing
		Session("TotCms_UserName")=UserName
		Session("TotCms_UserType")=0
		response.Write("<div style=""text-align:center; background-color : #D3E8F2; width:960px; margin:0px auto; line-height:28px;"">成功注册新用户!正在返回注册前页面......</div>")
			response.Write("<meta http-equiv=""Refresh"" content=""1;URL="&gourl&""" />")
	else
		Response.Write("<script>alert(""此用户或邮箱已存在，请换一个用户名或邮箱试试!"");history.back();</script>")		
	end if
else
%>
<form id="form1" name="form1" method="post" action="?act=reg&gourl=<%=server.URLEncode(gourl)%>" onsubmit="return check(this)">
  <table width="960" align="center" cellpadding="0" cellspacing="1" bgcolor="#fff0cf" class="tableborder">
    <tr align="middle">
      <th colspan="2" class="pad_10">会员注册</th>
    </tr>
    <tr>
      <td height="22" colspan="2" align="center" bgcolor="#FFFFFF" class="pformleft">★请仔细填写下面注册信息</td>
    </tr>
    <tr>
      <td width="35%" align="left" bgcolor="#FFFFFF" class="pad_5"><strong>用户名</strong>：<br />
        注册用户名长度限制为2－20字符</td>
      <td width="65%" align="left" bgcolor="#FFFFFF" class="pformleft"><input name="UserName" id="UserName" size="30" maxlength="20" onblur="checkUser(this)" />
        (<span class="style3">*</span>)<span id="userMsg"></span></td>
    </tr>    
    <tr>
      <td align="left" bgcolor="#FFFFFF" class="pad_5"><strong>性别</strong>：<br />
        请选择您的性别</td>
    <td align="left" bgcolor="#FFFFFF" class="pformleft"><input type="radio" checked="checked" value="男" name="Sex" />
          男
	        <input type="radio" value="女" name="sex" />
          女</td>
    </tr>   
    <tr>
      <td width="35%" align="left" bgcolor="#FFFFFF" class="pad_5"><strong>帐号密码(至少4位)</strong>：<br />
        请输入密码，区分大小写。<br />
        请不要使用任何类似   '*'、' ' 或 HTML 字符</td>
      <td width="65%" align="left" bgcolor="#FFFFFF" class="pformleft"><input name="PassWord" type="password" id="PassWord" value="" size="30" maxlength="16" />
      (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td width="35%" align="left" bgcolor="#FFFFFF" class="pad_5"><strong>确认密码(至少4位)</strong>：<br />
        请再输一遍确认</td>
      <td align="left" bgcolor="#FFFFFF" class="pformleft"><input name="RePassWord" type="password" id="RePassWord" value="" size="30" maxlength="16" />
      (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td align="left" bgcolor="#FFFFFF" class="pad_5"><strong>密码问题</strong>：<br />
        忘记密码的提示问题</td>
      <td align="left" bgcolor="#FFFFFF" class="pformleft"><input name="ForAsk" id="ForAsk" size="30" /></td>
    </tr>
    <tr>
      <td align="left" bgcolor="#FFFFFF" class="pad_5"><strong>问题答案</strong>：<br />
        忘记密码的提示问题答案，用于取回密码</td>
      <td align="left" bgcolor="#FFFFFF" class="pformleft"><input name="ForAnswer" id="ForAnswer" size="30" /></td>
    </tr>
    <tr>
      <td align="left" bgcolor="#FFFFFF" class="pad_5"><strong>Email地址</strong>：<br />
        请输入有效的邮件地址</td>
      <td align="left" bgcolor="#FFFFFF" class="pformleft"><input name="Email" id="Email" size="30" maxlength="50" onblur="checkEmailExits(this)" />          
      (<span class="style3">*</span>)
	  <span id="emailMsg"></span></td>
    </tr>
	<tr>
      <td width="35%" align="left" bgcolor="#FFFFFF" class="pad_5"><strong>请输入验证码</strong>：</td>
    <td width="65%" height="35" align="left" bgcolor="#FFFFFF" class="pformleft">
          <input size="5" name="CheckCode" />          
          <% = GetCode() %>
          (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#FFFFFF" class="row4"><div align="center">
        <input type="submit" name="Submit" value="注 册" />
        <input type="reset" name="Submit2" value="重 写" />
      </div></td>
    </tr>
  </table>
</form>
<%
	end if
%>
<!--#include file="root.asp" -->
</body>
</html>
<%
call connclose()
%>