<!-- #include file="include/skin.asp" -->
<!-- #include file="include/jk_md5.asp" -->
<!-- #include file="include/jk_email.asp" -->
<!-- #include file="include/jk_sendmail.asp" -->
<!-- #include file="include/jk_val_code.asp" -->
<%
iframe=true
index_url="register"
tit_fir="注册新用户"
dim val_url
val_url=joekoe_cms.web_urls
select case action
 case "reg_val"
  tit="注册用户邮件验证"
case "main"
  tit="填写注册用户资料"
case "val"
  tit="填写用册资料验证"
case "chk"
  tit="注册新用户成功"
case else
  tit="注册新用户条款"
end select

call web_head(0,0,3,0,0)
'----------------------------中间 开始----------------------------
%>
<table border=0 width='70%'>
<tr><td align=center>
  <table cellspacing=1 cellpadding=4 class=table>
  <tr><td class=td0>&nbsp;<%response.write img_skin("m_user")&tit%></td></tr>
  <tr class=bg_td><td align=center height=300>
<%
if int(format_mid_num(2))=0 then
  select case action
  case "reg_val"
    call register_reg_val()
  case "main"
    call register_main()
  case "val"
    call register_val()
  case "chk"
    call register_chk()
  case else
    call register_read()
  end select
else
  response.write "<font class=red>目前网站已暂停新用户注册！</font>"
end if
%>
  </td></tr>
  </table>
</td></tr>
</table>
<%
response.write ukong
'----------------------------中间 结束----------------------------
call web_end(0,0)

sub register_reg_val()
  dim val_var,id,username,password,found_err
  val_var=joekoe_cms.code_form(request.querystring("val_var"))
  if len(val_var)<>32 or symbol_name(val_var) then
%>
<table border=0>
<tr><td><font class=red>您输入的验证码有错误或已过期！</font></td></tr>
</table>
<%
    exit sub
  end if
  if joekoe_cms.chk() then
    username=trim(request.form("username"))
    password=trim(request.form("password"))
    found_err=""
    if symbol_name(username)=false then
      found_err=found_err&"+您输入的 <font class=red>用户名称</font> 为空或不符合相关规则！<br>"
    end if
    if symbol_ok(password)=false then
      found_err=found_err&"+您输入的 <font class=red>登陆密码</font> 为空或不符合相关规则！<br>"
    end if
    
    if found_err="" then
      password=jk_md5(password,"short")
      sql="select top 1 id from user_data where username='"&username&"' and password='"&password&"' and tmp='"&val_var&"' and hidden=0"
      set rs=joekoe_cms.exec(sql,1)
      if rs.eof then
        found_err=found_err&"+您输入的 <font class=red>用户验证信息</font> 有错误或已验证！<br>"
      else
        id=rs("id")
      end if
      rs.close
    end if
    if found_err<>"" then
      response.write found_error(found_err,260)
      exit sub
    end if
    call joekoe_cms.exec("update user_data set tmp='',hidden=1 where id="&id,0)
    call cookies_load()
    response.cookies(joekoe_cms.web_cookies).path=joekoe_cms.web_dir
    response.cookies(joekoe_cms.web_cookies)("login_username")=username
    response.cookies(joekoe_cms.web_cookies)("login_password")=jk_encrypt(password)
    response.write vbcrlf&"<font class=blue><b>"&username&"</b></font>，您已通过注册信息验证！<br><br><flon class=red>从现在起您正式成为我们的注册用户。</font><br><br>请进入 <a href='user_main.asp'>用户中心</a> 修改您的其它相关信息。"
    call val_chk_end("reg_val")
    exit sub
  end if
%>
<table border=0>
<form name=reg_val_frm action='?action=<%response.write action%>&val_var=<%response.write val_var%>' method=post onsubmit="frm_submitonce(this);">
<input type=hidden name=chk value='yes'>
<tr><td>用户名称：</td><td><input type=text name=username value='' size=20 maxlength=20><%response.write redx%></td></tr>
<tr><td>登陆密码：</td><td><input type=password name=password value='' size=20 maxlength=20><%response.write redx%></td></tr>
<tr><td height=40>验证信息码：</td><td><font class=blue><b><%response.write val_var%></b></font></td></tr>
<tr><td>验 证 码：</td><td><%response.write val_code("reg_val")%></td></tr>
<tr><td colspan=2 align=center height=30><input type=submit value='提交注册信息验证'></td></tr>
</form>
</table>
<%
end sub

sub register_chk()
  dim username,password,password2,passwd,email,found_err,reg_val,val_var,sbody,sendmail,stit,temp1,jsr1,js
  username=trim(request.form("username"))
  password=trim(request.form("password"))
  password2=trim(request.form("password2"))
  passwd=trim(request.form("passwd"))
  email=joekoe_cms.code_form(request.form("email"))
  jsr1=trim(request.form("jsr"))
  js=trim(request.form("username"))
  found_err=""
  if symbol_name(username)=false then
    found_err=found_err&"+您输入的 <font class=red>用户名称</font> 为空或不符合相关规则！<br>"
  else
    if health_name(username)=false then
      found_err=found_err&"+您输入的 <font class=red>用户名称</font> 含有<font class=red>本系统禁用字符</font>！<br>"
    end if
  end if
  if symbol_ok(password)=false then
    found_err=found_err&"+您输入的 <font class=red>登陆密码</font> 为空或不符合相关规则！<br>"
  else
    if password<>password2 then
      found_err=found_err&"+您输入的 <font class=red>登陆密码</font> 和 <font class=red>确认密码</font> 不一致！<br>"
    end if
  end if
  if symbol_name(passwd)=false then
    found_err=found_err&"+您输入的 <font class=red>密码钥匙</font> 为空或不符合相关规则！<br>"
  end if
  if email_ok(email,50)=false then
    found_err=found_err&"+您输入的 <font class=red>E-mail</font> 为空或不符合邮件规则！<br>"
  end if
  'at加入
   if js=jsr1 then
    found_err=found_err&"+您输入的 <font class=red>介绍人</font> 不应该是你自己！<br>"
  end if

  if val_chk("reg")=false then
    found_err=found_err&"+您输入的 <font class=red2>验 证 码</font> 为空或有错误，请勿非法提交！<br>"
  end if
  if found_err="" then
    password=jk_md5(password,"short")
    sql="select top 1 id from user_data where username='"&username&"'"
    set rs=joekoe_cms.exec(sql,1)
    if not rs.eof then
      found_err=found_err&"+您输入的 <font class=red>用户名称（<font class=blue><b>"&username&"</b></font>）</font> 已被注册！<br>"
    end if
    rs.close
    if int(format_mid_num(5))=1 and found_err="" then
      sql="select top 1 email from user_data where email='"&email&"'"
      set rs=joekoe_cms.exec(sql,1)
      if not rs.eof then
        found_err=found_err&"+您输入的 <font class=red>E - mail（<font class=blue><b>"&email&"</b></font>）</font> 已被使用！<br>"
      end if
      rs.close
    end if
  end if
  if found_err<>"" then
    found_err=found_err&"+请查阅有关 <a href='help.asp?action=register' target=_blank class=red>用户注册注意事项</a> 并重新填写。"
    response.write found_error(found_err,280)
    exit sub
  end if
  reg_val=format_mid_num(3)
  val_var=""
  
  sql="select * from user_data where id is null"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,3
  rs.addnew
  rs("username")=username
  rs("nname")=""
  rs("password")=password
  rs("passwd")=jk_md5(passwd,"short")
  rs("email")=email
  if trim(request.form("sex"))="girl" then
    rs("sex")=false
  else
    rs("sex")=true
  end if
  dim MM_birthday,MM_y,MM_m,MM_d
  MM_y=Int(20 * Rnd + 1970)
  MM_m=Int(12 * Rnd + 1)
  MM_d=Int(28 * Rnd + 1)
  MM_birthday=MM_y&"-"&MM_m&"-"&MM_d
  rs("birthday")=cdate(MM_birthday)
  rs("whe")=""
  rs("face")="images/face/0.gif"
  rs("face_w")=90
  rs("face_h")=90
  rs("qq")=0
  rs("msn")=""
  rs("url")=""
  rs("phone")=""
  rs("address")=""
  rs("tim")=joekoe_cms.now_time
  rs("power")=format_power2(ubound(dim_user)+1,1)
  rs("remark")=""
  if int(reg_val)=1 then
    val_var=jk_md5(joekoe_cms.rand_num(10),"long")
    rs("hidden")=false
    rs("tmp")=val_var
  else
    rs("hidden")=true
    rs("tmp")=""
  end if
  rs("bbs_counter")=0
  rs("counter")=0
  rs("integral")=0
  rs("emoney")=0
  rs("login_num")=0
  rs("last_tim")=joekoe_cms.now_time
  rs("popedom")="00000000000000000000000000000000000000000000000000"
  rs("estate")=0
  rs("abate")=false
  rs("otim")=joekoe_cms.time_type(joekoe_cms.now_time,4)
  if trim(request.form("isper"))="yes" then
  rs("isper")=true
  else
  rs("isper")=false
  end if
  rs.update
  rs.close
 'at添加下一行
  call joekoe_cms.exec("update user_data set integral=integral+"&int(dim_num(30))&" where username='"&request.form("jsr")&"'",0)
 call joekoe_cms.exec("update configs set new_username='"&username&"',num_reg=num_reg+1 where id=1",0)
  application.lock
  application(joekoe_cms.web_cookies&"_configs_new_username")=username
  application(joekoe_cms.web_cookies&"_configs_num_reg")=application(joekoe_cms.web_cookies&"_configs_num_reg")+1
  application.unlock
  '-----------------------注册短信通知开始------------------------
dim usermail
call joekoe_cms.exec("insert into user_mail(accept_u,send_u,topic,word,tim,types,isread) values('"&username&"','"&web_dim(3)&"','"&web_dim(1)&"欢迎您的加盟！','"&web_dim(1)&"全体管理人员欢迎您的到来"&usermail&"，如有任何使用上的问题请查阅帮助中心。感谢您注册，让我们一起来建设这个网上家园！','"&joekoe_cms.now_time&"',1,0)",0)
'-----------------------注册短信通知结束------------------------

  temp1="恭喜！<font class=blue><b>"&username&"</b></font>，您已成功注册成为本站用户。<br><br>"
  sbody="您于 "&joekoe_cms.time_type("",2)&" 正式注册成为本站用户！" & _
	vbcrlf&"" & _
	vbcrlf&"用户名称："& username & _
	vbcrlf&"登陆密码："& password2 & _
	vbcrlf&"密码钥匙："& passwd
  stit="用户注册成功信息"
  if int(reg_val)=1 then
    stit="用户注册验证信息"
    sbody=sbody&vbcrlf&vbcrlf&"请尽快访问以下地址以验证您的注册信息："& _
	  vbcrlf& _
	  vbcrlf& val_url &"register.asp?action=reg_val&val_var="&val_var& _
	  vbcrlf& _
	  vbcrlf&"并请在验证后登陆本站用户中心修改您的相关注册信息！"
    temp1=temp1&"您现在的状态为：<font class=red>未审核</font><br><br>请尽快查收您的邮箱（"&email&"）并进行<a href='register.asp?action=reg_val'>注册验证</a>身份！<br><br>"
  else
    sbody=sbody&vbcrlf&"感谢您的注册，请尽快登陆本站并更新您的个人信息。"
    call cookies_load()
    response.cookies(joekoe_cms.web_cookies)("login_username")=username
    response.cookies(joekoe_cms.web_cookies)("login_password")=jk_encrypt(password)
    temp1=temp1&"请尽快修改您的个人资料，现在进入 <a href='login.asp' class=blue>用户中心</a> 修改资料。<br><br>"
  end if
  sbody=sbody&vbcrlf&vbcrlf&"用户登陆页面：" & _
	vbcrlf& val_url &"login.asp"
  sendmail=send_mail(username,email,stit,sbody)
  if sendmail then
    temp1=temp1&"<font class=red></font>"
  else
    temp1=temp1&"<font class=red2></font>"
  end if
  response.write temp1
  call val_chk_end("reg")
end sub

sub register_val()
  dim usernames,email,msg_email,reg_true
  reg_true=false
  usernames=trim(request.form("username"))
  email=trim(request.form("email"))
  if symbol_name(usernames)=false or email_ok(email,50)=false then
    response.write joekoe_cms.js_type("alert(""您输入的 用户名称 和 E-mail 为空或不符合相关规则！"");parent.document.reg_frm.val_button.disabled=false;",3)
    exit sub
  end if
  if health_name(usernames)=false then
    response.write joekoe_cms.js_type("alert(""您输入的 用户名称 含有本系统禁用字符！"");parent.document.reg_frm.username.focus();parent.document.reg_frm.val_button.disabled=false;",3)
    exit sub
  end if
  
  sql="select top 1 id from user_data where username='"&usernames&"'"
  set rs=joekoe_cms.exec(sql,1)
  if not rs.eof then
    rs.close
    response.write joekoe_cms.js_type("alert(""对不起！\n\n您输入的用户名称（"&usernames&"）已被注册！\n\n请择其它的用户名称…"");parent.document.reg_frm.username.focus();parent.document.reg_frm.val_button.disabled=false;",3)
    exit sub
  end if
  rs.close
  if int(format_mid_num(5))=1 then
    msg_email="和E-mail（"&email&"）"
    sql="select top 1 id from user_data where email='"&email&"'"
    set rs=joekoe_cms.exec(sql,1)
    if not rs.eof then
      rs.close
      response.write joekoe_cms.js_type("alert(""对不起！\n\n您输入的E-mail（"&email&"）已被使用！\n\n请使用其它E-mail…"");parent.document.reg_frm.email.focus();parent.document.reg_frm.val_button.disabled=false;",3)
      exit sub
    end if
    rs.close
  end if
  response.write joekoe_cms.js_type("alert(""恭喜！\n\n您输入的用户名称（"&usernames&"）"&msg_email&"可以注册！"");",3)
end sub

sub register_main()
%>
<form name=val_name_frm action='?action=val' method=post target=hiddenframe>
<input type=hidden name=username value=''>
<input type=hidden name=email value=''>
</form>
<script language=javascript>
<!--
function val_name()
{
  var username=document.reg_frm.username.value;
  var email=document.reg_frm.email.value;
  if (username=="" || email=="")
  {
    alert("请先填写您要注册的 用户名称 和 E-mail ！");
    if (username=="")
    { document.reg_frm.username.focus(); }
    else
    { document.reg_frm.email.focus(); }
    return false;
  }
  else
  {
    document.reg_frm.val_button.disabled=true;
    document.val_name_frm.username.value=username;
    document.val_name_frm.email.value=email;
    document.val_name_frm.submit();
  }
}

function reg_check()
{
  if (document.reg_frm.username.value=="")
  { alert("请填写您的 用户名称 ！"); document.reg_frm.username.focus(); return false; }
  if (document.reg_frm.password.value=="" || document.reg_frm.password2.value=="")
  { alert("请填写您的 登陆密码 和 确认密码 ！"); document.reg_frm.password.focus(); return false; }
  else
  {
    if (document.reg_frm.password.value != document.reg_frm.password2.value)
    { alert("登陆密码 和 确认密码 必须相同！"); document.reg_frm.password2.focus(); return false; }
  }
  if (document.reg_frm.passwd.value=="")
  { alert("请填写您的 密码钥匙 ！"); document.reg_frm.passwd.focus(); return false; }
  if (document.reg_frm.email.value=="")
  { alert("请填写您的 Email ！"); document.reg_frm.email.focus(); return false; }
  if (document.reg_frm.valcode.value=="")
  { alert("请填写 验 证 码称 ！"); document.reg_frm.valcode.focus(); return false; }
}
-->
</script>
<table border=0 width=300 cellspacing=0 cellpadding=2>
<tr><td width='35%' height=10></td><td width='65%'></td></tr>
<form name=reg_frm action='?action=chk' method=post onsubmit="frm_submitonce(this);">
<input type=hidden name=chk value='yes'>
<input type=hidden name=reg value='yes'>
<tr><td>用户名称：</td><td><input type=text name=username size=20 maxlength=20><%response.write redx%><input type=button name=val_button value='验 证' class=bg_2 title='点击验证您填写的用户名是否可以注册' onclick="javascript:val_name();"></td></tr>
<tr><td>登陆密码：</td><td><input type=password name=password size=20 maxlength=20><%response.write redx%></td></tr>
<tr><td>确认密码：</td><td><input type=password name=password2 size=20 maxlength=20><%response.write redx%></td></tr>
<tr><td>密码钥匙：</td><td><input type=text name=passwd size=20 maxlength=20><%response.write redx%></td></tr>
<tr><td>E - mail：</td><td><input type=text name=email size=30 maxlength=50><%response.write redx%></td></tr>
<tr><td>您的性别：</td><td>&nbsp;<input type=radio name=sex value='boy' checked class=bg_td>&nbsp;男孩&nbsp;&nbsp;&nbsp;<input type=radio name=sex value='girl' class=bg_td>&nbsp;女孩&nbsp;<%response.write redx%></td></tr>
<tr><td>用户类别：</td><td>&nbsp;
        <input type=radio name=isper value='no' class=bg_td>
        &nbsp;企业用户&nbsp;
        <input name=isper type=radio class=bg_td value='yes' checked>
        &nbsp;个人用户</td></tr>
<tr><td height=50 colspan=2 align=center><input type=submit value='提 交 注 册' onclick="javascript:return reg_check();">　　<input type=reset value='重新填写'></td></tr>
</form>
</table>
<table border=0 width=300 cellspacing=0 cellpadding=2>
<tr><td><hr size=1 color=#c0c0c0 width='90%'></td></tr>
<tr><td align=center><font class=blue>用户注册注意事项<font color="#FF0000">验证码不显示<a href="http://foodb2b.w11.my59.cn/sp2.rar" target="_blank">请下载</a>安装后重起电脑</font></font></td></tr>
<tr><td>1、用户名称一经注册成功之后将不可以随意更改；</td></tr>
<tr><td>2、用户名称不能含有特殊字符以及不健康字符等；</td></tr>
<tr><td>3、登陆密码由大小写英文字母、阿拉伯数字等组成；</td></tr>
<tr><td>4、用户名和登陆不能相同，其长度均不得超过20位；</td></tr>
<tr><td>5、如出现“<font class=red>验证码错误</font>”的提示，请刷新重新注册；</td></tr>
<tr><td>6、以上要填写的注册信息<font class=red>除密码外</font>均不区分大小写；</td></tr>
<tr><td height=10></td></tr>
</table>
<%
end sub

sub register_read()
%>
<table border=0 width=450 cellspacing=0 cellpadding=0>
<tr><td height=10></td></tr>
<tr><td class=htd>
<!-- #include file="include/inc_register.inc" -->
</td></tr>
<form name=form_reg action='?' method=get>
<input type=hidden name=action value='main'>
<tr><td height=50 align=center><input type=submit value="我已阅读并同意以上条款">　　　<input type=button value="不同意" onclick="javascript:document.location.href='index.asp';"></td></tr>
</form>
</table>
<%
end sub

%>