<%
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="uc_api/uc_client/client.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/global.css" rel="stylesheet" type="text/css" />
<link href="member/style/member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<script src="js/reg.js" type="text/javascript"></script>
</head>
<body>
<!--#include file="templet/head.htm" -->
<%
dim act,gourl,uc_uid

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")=""
	if(BindUc=true) then
		'在UCenter注册用户信息
		uc_uid = uc_user_register(username,password,email)
		uc_uid =Clng(uc_uid)
		if(uid <= 0) Then 
			if(uc_uid = -1) Then  
				call alertstr("用户名不合法",1)
			 elseif(uc_uid = -2) Then
				call alertstr("包含要允许注册的词语",1)
			 elseif(uc_uid = -3) Then
				call alertstr("用户名已经存在",1)
			 elseif(uc_uid = -4) Then
				call alertstr("Email 格式有误",1)
			 elseif(uc_uid = -5) Then
				call alertstr("Email 不允许注册",1)
			 elseif(uc_uid = -6) Then
				call alertstr("该 Email 已经被注册",1)
			 else 
				'call alertstr("未定义",1)
			End if
		 else 
			'注册成功，设置 Cookie，加密直接用 uc_authcode 函数，用户使用自己的函数			
		End If
	end if
	PassWord=Php_MD5(PassWord)
	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")=""
		rs("City")=""
		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_UserPass")=PassWord
		session("TotCms_UserType")=0
		session("TotCms_UserId")=UserName
		'Response.Cookies("TotCms_Cookie")("UserName")=UserName
		'Response.Cookies("TotCms_Cookie")("UserPass")=PassWord
		'Response.Cookies("TotCms_Cookie")("LastVisite")=now()
		'Response.Cookies("TotBbs_Cookie").path="/"
		'Response.Cookies("TotCms_Cookie").Domain=CookieUrl
		'Response.Cookies("TotCms_Cookie").Expires=Date()+1
		response.Write("<div style=""text-align:center; background-color : #D3E8F2; width:960px; margin:0px auto; line-height:28px;"">成功注册新用户!正在返回注册前页面......</div>")
		if(BindUc=true) then
		response.Redirect("/member/dsnt_api.asp?username="&UserName&"&userpass="&request.Form("PassWord")&"&email="&Email)
		end if
			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" bgcolor="#FFFFFF" class="pformleft">★请仔细填写下面注册信息</td>
    </tr>
    <tr>
      <td width="46%" bgcolor="#FFFFFF" class="pad_5"><strong>用户名</strong>：<br />
        注册用户名长度限制为2－20字符</td>
      <td width="54%" 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 bgcolor="#FFFFFF" class="pad_5"><strong>性别</strong>：<br />
        请选择您的性别</td>
    <td bgcolor="#FFFFFF" class="pformleft"><input type="radio" checked="checked" value="男" name="Sex" />
          男
	        <input type="radio" value="女" name="sex" />
          女</td>
    </tr>   
    <tr>
      <td width="46%" bgcolor="#FFFFFF" class="pad_5"><strong>帐号密码(至少4位)</strong>：<br />
        请输入密码，区分大小写。<br />
        请不要使用任何类似   '*'、' ' 或 HTML 字符</td>
      <td width="54%" 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="46%" bgcolor="#FFFFFF" class="pad_5"><strong>确认密码(至少4位)</strong>：<br />
        请再输一遍确认</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="RePassWord" type="password" id="RePassWord" value="" size="30" maxlength="16" />
      (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="pad_5"><strong>密码问题</strong>：<br />
        忘记密码的提示问题</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="ForAsk" id="ForAsk" size="30" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="pad_5"><strong>问题答案</strong>：<br />
        忘记密码的提示问题答案，用于取回密码</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="ForAnswer" id="ForAnswer" size="30" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="pad_5"><strong>Email地址</strong>：<br />
        请输入有效的邮件地址</td>
      <td 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="46%" bgcolor="#FFFFFF" class="pad_5"><strong>请输入验证码</strong>：</td>
    <td width="54%" 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="templet/root.htm" -->
</body>
</html>
<%
call connclose()
%>