<!--#INCLUDE FILE="conn.asp" -->
<!--#INCLUDE FILE="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<!--#INCLUDE FILE="inc/char.asp" -->

<%
Dim Locate
Locat="新用户注册"

Select Case Request("action")
Case "agree"
	Call top(1,1)
	Call getlogin()
Case "getloginpass"
Call top(1,1)

if BoolVar(11) then
dim i,passjoin
passjoin=false
for i=1 to ubound(joinquestion)-1
if BoolVar(12) then
'''''
if trim(request.form("answer"&i))<>joinanswer(i) then
ErrMsg = ErrMsg + "<br>" + "<li>问题"&i&"的答案"&i&"输入错误！</li>"
passjoin=false
else
passjoin=true
end if

else
if trim(request.form("answer"&i))=joinanswer(i) then
passjoin=true
elseif trim(request.form("answer"&i))<>"" and trim(request.form("answer"&i))<>joinanswer(i) then
ErrMsg = ErrMsg + "<br>" + "<li>问题"&i&"的答案"&i&"输入错误！</li>"
end if
''''
end if
next
if passjoin=true then
call regform()
else
ErrMsg = ErrMsg + "<br>" + "<li><font Color=red>问题答案输入有误！无法继续注册！</font></li>"
call error("Information",errmsg)
end if
else
Call regform()
end if
	
	case "testname"
	Call pagehead()
	call testname()
Case "save"
	Server.ScriptTimeOut=999999
	Dim userid,userpwd,question,answer,realname
	Dim email,oicq,msn,birthday
	Dim telephone,mobilephone,zipcode,address,maxim,homepage
	%>
	<!--#INCLUDE FILE="inc/chkReginfo.asp"-->
	<!--#INCLUDE FILE="inc/Email.asp" -->
	<%
	Call SaveUserInfo()
Case Else
	Call top(1,1)
	Call Agreement()
End Select

Sub regform()

if not BoolVar(0) Then
	ErrMsg=ErrMsg+"<br><li>系统已设置禁止注册新用户，请与<a href=mailto:"&StrVar(2)&" title="""&StrVar(2)&""">系统管理员联系</a>，QQ:"&StrVar(9)&"！"
	Call Error("Information",ErrMsg)
	Exit Sub
End if
%>
<SCRIPT language=javascript>
function isValidChar(str)
{
var invalidchar= ';|<>`&%,!*(~^)-#? :"/$=\\'+"'"
for(i=0;i<str.length;i++)
 {char=str.charAt(i);
  if(char==" "){return char;}
  if(invalidchar.indexOf(char)>=0){return char;} 
 }
return "";
}


function checkusername(form){

	var userid=form.userid.value;
	if(userid == ""){
		alert("请输入用户名！");
		form.userid.focus();
		return false;
	}

	retval=isValidChar(userid);
	if(retval == " "){
		alert("用户名中不能有空格！");
		form.userid.focus();
		return false;
	}
		
	if(retval != ""){		
		alert ("在用户名中含有非法字符 \""+retval+"\" 请重新输入！");
		form.userid.focus();
		return false;
	}
		

userlength=strlength(userid);
	if(userlength<4||userlength>12){		
		alert ("请输入用户名4-12个字符！");
		form.userid.focus();
		return false;
	}

	return true;
}


function testusername(form) {
	if (checkusername(form)){
		username=form.userid.value;
		openScript("Class_Register.asp?action=testname&username="+username, 210, 110);
}

}

function ShowAdv(ObjBtn)
{
	if(other.style.display == "none")
		{
		other.style.display = "";
		ObjBtn.innerHTML="常规选项(A)<font face=webdings>5</font>";
		}
	else
		{other.style.display = "none";
		ObjBtn.innerHTML="高级选项(A)<font face=webdings>6</font>";
		}
}

function ShowPreview()
{
var selobj=document.userform.face;
var imgobj=document.images['face'];
if(selobj.selectedIndex==0)
	{imgobj.style.visibility="hidden";}
else
	{imgobj.style.visibility="visible";
	imgobj.src="face\/image"+selobj.options[selobj.selectedIndex].value+".gif";
	}
}
</SCRIPT>
<form action="Class_Register.asp" method="post" name="userform" onSubmit="return submitonce(this)">
<input type="hidden" name="action" value="save">
<table border="0" cellPadding="0" cellSpacing="0" width="100%"  bgcolor="<%=bgcolor%>" align=center>
<tr><td>
  <table border="0" 
  cellPadding="5" cellSpacing="1" width="100%"  Class=TableBorder align=center>
          <tr> 
            <th align=center colspan=2>新用户注册</th>
          </tr>
           <tr Class=LightTableBody>
            <td width=40%>用 户 名（<font color="#FF0000">请牢记用户名,勿用怪异符号,勿重复注册!</font>）<BR>
              最短4个字符，最长12个字符</td>
            <td width=60%> 
              <input name="userid" type="text" id="userid" size="20" maxlength="12" title="用户名只能由英文字母、数字、汉字以及下横线组成
            ">
              **&nbsp;&nbsp;
              <INPUT name=testname onclick=javascript:testusername(this.form) type=button value=检测用户名 accesskey="t" class=button></td>
    </tr>
          <tr Class=LightTableBody> 
            <td>真实姓名<BR>
              请如实填写，否则删除帐号</td>
            <td><input name="realname" size="20" maxLength="4"
     > &nbsp;**</td>
          </tr>
		<tr Class=LightTableBody>
            <td>密 
              码<br>
              区分大小写，不少于6个字符
      </td>
      <td><div align="left"><p>
                <input name="userpwd1" type="password" size="20" maxLength="12" 
     >
                &nbsp;**</td>
    </tr>
    <tr Class=LightTableBody>
      <td>密码确认<BR>再输一遍，以便确定！</td>
      <td><div align="left"><p><input name="userpwd2" size="20" type="password" maxLength="12" 
     >&nbsp;**</td>
    </tr>
          <%
Response.write "<tr Class=LightTableBody>"&_
		"<td>您的生日<BR>以公历为准</td>"&_
		"<td nowrap><Select name=year size=1>"

currentyear=cint(year(date()))
startyear=currentyear-50

for i=startyear to currentyear
	Response.write "<option value="&i
	if i=currentyear-19 Then Response.write " selected"
	Response.write ">"&i&"</option>"
next

Response.write "</Select>&nbsp;年&nbsp;<Select name=month size=1>"

for i=1 to 12
	Response.write "<option value="&i
	if i=7 Then Response.write " selected"
	Response.write ">"&i&"</option>"
next

Response.write "</Select>&nbsp;月&nbsp;<Select name=day size=1>"

for i=1 to 31
	Response.write "<option value="&i
	if i=17 Then Response.write " selected"
	Response.write ">"&i&"</option>"
next

Response.write "</Select>&nbsp;日&nbsp;**</td></tr>"

%>
          <tr Class=LightTableBody> 
            <td>电子邮件（<font color="#FF0000">填自己的邮箱哦,方便同学给你发邮件!</font>）<BR>
              请输入您常用的邮件地址！</td>
            <td><input name="email" type=text size="20"> &nbsp;**&nbsp; <input type="checkbox" name="isemailshow" value="0" title=对校外同学保密>
              保密</td>
          </tr>
          <tr Class=LightTableBody> 
            <td>推荐人用户名<BR>
              将使您的推荐人积分增加，没有请保留默认</td>
            <td><input name="recommender" type=text value="godson" size="20"></td>
          </tr>
        </table>

<span id="other" style="DISPLAY: ">
<br><IMG SRC="images/2.gif" WIDTH="60" HEIGHT="9">:::可选用户设置选项:::
        <table border="0" 
  cellPadding="4" cellSpacing="1" width="100%"  Class=TableBorder align=center>
          <tr Class=LightTableBody> 
            <td width=40%>密码提示<br>
              忘记密码时的提示问题。</td>
            <td width=60% colspan="2"><input name="question" size="20"> 
              &nbsp</td>
          </tr>
          <tr Class=LightTableBody> 
            <td>问题答案<br>
              忘记密码的问题答案,用于取回密码。</td>
            <td><input name="answer" size="20"> 
              &nbsp</td>
            <td rowspan="2"><img id=face alt=个人形象代表 width=64 height=64 hspace=2 align=absmiddle style="visibility:hidden"></td>
          </tr>
          <tr Class=LightTableBody> 
            <td>性&nbsp;&nbsp;&nbsp;&nbsp;别</td>
            <td><INPUT type=radio checked value=0 name=sex> <IMG 
      height=27 src="images/Male.gif" width=27 align=absMiddle>男孩 &nbsp;&nbsp;&nbsp;&nbsp; 
              <INPUT type=radio value=1 name=sex> <IMG 
      height=27 src="images/Female.gif" width=27 align=absMiddle>女孩</font></td>
          </tr>
          <tr Class=LightTableBody> 
            <td>头&nbsp;&nbsp;&nbsp;&nbsp;像</td>
            <td colspan="2"><select name=face size=1 onChange="ShowPreview()">
                <option value=0>不使用</option>
                <%
for i=1 to 400
	Response.write "<option value="&i&">Face"&i&"</option>"
next%>
              </Select> &nbsp;[<a href="javascript:openScript('Class_Help.asp?About=portrait',500,500)">头像列表</a>]<input name="userface" type="hidden" id="userface"></td>
          </tr>
          <tr Class=LightTableBody> 
            <td>个人主页</td>
            <td colspan="2"><input name="homepage" size="35" value="http://"> 
              &nbsp; <input type="checkbox" name="ishomepageshow" value="0" title=对校外同学保密>
              保密</td>
          </tr>
          <tr Class=LightTableBody> 
            <td>QQ号码</td>
            <td height="26" colspan="2"><input type="text" name="oicq" size="20"> 
              &nbsp; <input type="checkbox" name="isoicqshow" value="0" title=对校外同学保密>
              保密</td>
          </tr>
          <tr Class=LightTableBody> 
            <td>MSN</td>
            <td height="26" colspan="2"><input type="text" name="msn" size="20"> 
              &nbsp; <input type="checkbox" name="ismsnshow" value="0" title=对校外同学保密>
              保密</td>
          </tr>
          <tr Class=LightTableBody> 
            <td>联系电话<br>
              只能用数字和“-”字符</td>
            <td colspan="2"><input name="telephone" size="20"> </td>
          </tr>
          <tr Class=LightTableBody> 
            <td>手机号码<br></td>
            <td colspan="2"><input name="mobilephone" size="20" maxlength="11"> 
            </td>
          </tr>
		   <tr Class=LightTableBody> 
            <td>所在班级<br></td>
            <td colspan="2"><input name="class" size="40" maxlength="20"> </td>
          </tr>
          <tr Class=LightTableBody> 
            <td>工作单位<br></td>
            <td colspan="2"><input name="workshop" size="40" maxlength="20"> </td>
          </tr>
          <tr Class=LightTableBody> 
            <td maxLength="6">邮政编码</td>
            <td colspan="2"><input name="zipcode" size="20" maxlength=6> </td>
          </tr>
          <tr Class=LightTableBody> 
            <td>通信地址</td>
            <td colspan="2"><input name="address" size="40"> </td>
          </tr>
          <tr Class=LightTableBody> 
            <td>个性签名<br> <BR>
              不能超过8行，<BR>
              支持<a style="color:brown" href="javascript:openScript('Class_Help.asp?about=ubb',670,500)"  style="cursor:help"> 
              UBB </a> 标签，<BR>
              不能多于320个字符</td>
            <td colspan="2" ><textarea name="maxim" rows=6 cols=50></textarea> 
            </td>
          </tr>
        </table>
        </span>
	<table  border="0" 
  cellPadding="0" cellSpacing="1" width="100%"  Class=TableBorder>
    <tr Class=DarkTableBody><td><table border=0 width=100%>
                <tr>
                  <td></td>
                  <td align=center height="22"><button onClick="ShowAdv(this)" style="height:23" accesskey="a">常规选项(A)<font face=webdings>5</font></button>
                    &nbsp;&nbsp;
                    <input type=submit style="height:23" value=提交注册(R) accesskey="r" class=button>
                    &nbsp;&nbsp;</td>
                </tr>
                <tr>
                  <td></td>
                  <td align=LEFT height="22"><p><font color="#FF0000"><strong>注意:</strong>不要重复注册,如果忘记了用户名或密码,请联系管理员找回!一旦使用新的帐号,旧的帐号将被删除,并且相关的的留言和相片等都会被删除,造成学校数据丢失本校友录一律不负责,请各位牢记自己的用户名和密码!谢谢合作!</font></p>
                    </td>
                </tr>
              </table></td>
    </tr>
  </table>
  </td></tr></tbody></table><BR>
</form>

<%
End Sub


Sub agreement()
%>
<br><form action="Class_Register.asp" method="post">
 <table border="0" cellPadding="5"
  cellSpacing="1" width="100%" Class=TableBorder align=center>
    <tr height=20>
      <th align=center><font color="#cc0080"><b>校友录服务条款和声明</b></font> </th></tr> 
	     <tr Class=LightTableBody>
      <td><table width=90% align=center><tr><td class=mp><BR><b>继续注册前请先阅读校友录协议</b><p>
欢迎您加入<%=StrVar(1)%>（<%=StrVar(0)%>）参加交流，为维护网上公共秩序和社会稳定，请您自觉遵守以下条款：<BR><BR>
一、不得利用本站危害国家安全、泄露国家秘密，不得侵犯国家社会集体的和公民的合法权益，不得利用本站制作、复制和传播下列信息： <BR>
　（一）煽动抗拒、破坏宪法和法律、行政法规实施的；<BR>
　（二）煽动颠覆国家政权，推翻社会主义制度的；<BR>
　（三）煽动分裂国家、破坏国家统一的；<BR>
　（四）煽动民族仇恨、民族歧视，破坏民族团结的；<BR>
　（五）捏造或者歪曲事实，散布谣言，扰乱社会秩序的；<BR>
　（六）宣扬封建迷信、淫秽、色情、赌博、暴力、凶杀、恐怖、教唆犯罪的；<BR>
　（七）公然侮辱他人或者捏造事实诽谤他人的，或者进行其他恶意攻击的；<BR>
　（八）损害国家机关信誉的；<BR>
　（九）其他违反宪法和法律行政法规的；<BR>
　（十）进行商业广告行为的。<BR>
二、互相尊重，对自己的言论和行为负责。 <BR>
<p>感谢您的配合，祝您使用愉快！</td></tr></table>

<hr width=90% size=1>

	  <table align=center><tr><td><input type=hidden name=action value=agree><input type="submit" value="同意协议(A)" accesskey="a" class=button>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="我不同意(D)" accesskey="d" class=button onClick="location.href='main.asp'"></td></tr></table><BR>
	  
	  </td></tr> 

  </table></form>
  <%
End Sub


Sub getlogin()
%><br>
<table cellpadding=0 cellspacing=0 border=0 width=760 Class=TableBorder align=center>
<%if not BoolVar(11) then%><form action="Class_Register.asp" method="post"><tr Class=DarkTableBody> 
            <td>&nbsp;</td>
          </tr><tr Class=DarkTableBody><td align=center>
<input type=hidden name=action value=getloginpass>
        <input type="submit" name="Submit" value="下一步">
      </td></tr><tr Class=DarkTableBody> 
            <td>&nbsp;</td>
          </tr></form><%end if%></table>
<%if BoolVar(11) then%>
<form action="Class_Register.asp" method="post"> 
<input type=hidden name=action value=getloginpass>
<table cellpadding=0 cellspacing=0 border=0 width=760 Class=TableBorder align=center>
    <tr>    
        <td>
        <table cellpadding=5 cellspacing=1 border=0 width=100%>
          <tr > 
            <th colspan=3 align=center><font color="#FF6666"><%if BoolVar(12) then%>必须全部回答正确以下问题才可以注册<%else%>任意回答正确以下问题之一才可以注册<%end if%></font> 
            </th>
          </tr>
		   <tr Class=LightTableBody> 
            <td colspan="3">&nbsp;</td>
          </tr>
		  <%for i=1 to ubound(joinquestion)-1%>
		  <tr Class=LightTableBody> 
            <td width="35%">问题<%=i%>：<%=joinquestion(i)%></td>
            <td width="30%">答案<%=i%>：
<INPUT name="answer<%=i%>" type=text id="answer<%=i%>" size="25"></td>
            <td width="35%"><font color="#993300">答案<%=i%>提示：</font><%=joinanswerts(i)%></td>
          </tr>
	  <%next%>
          <tr Class=LightTableBody> 
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr Class=DarkTableBody> 
            <td colspan=3 align=center><input type=submit name="submit" value="提交答案" accesskey="l" class=button style="width:70px"></td>
          </tr>
        </table></td></tr></table>
</form>
<%end if%>
  <%
end sub
sub testname
response.write "<table border=0 width=190 height=100 align=left><tr><td align=left>"
response.write "<table width=90% height=90% align=center><tr><td align=center valign=center>"
username=trim(request("username"))
set tmprs=conn.execute("select userid from [student] where userid='"&username&"'")
if not (tmprs.eof and tmprs.bof) then 
	response.write "此用户名已被注册啦！"
else
	response.write "此用户名还没有注册哦！"
end if
response.write "</td></tr></table>"
response.end 
%>
<%
End Sub


Sub SaveUserInfo()

if not isnull(session("regtime")) and IntVar(11)>0 Then
		if DateDiff("s",session("regtime"),Now()) < cint(IntVar(11)) Then
			ErrMsg=ErrMsg+"<Br>"+"<li>本校友录注册间隔时间为"&IntVar(11)&"秒,请不要重复注册!"
			call top(1,1)
			Call Error("Exclamation",ErrMsg)
			session("regtime")=now()
			Exit Sub
		End if
	End if

	if chkinput=False Then	
		Exit Sub
	End if

	Set rs = Server.CreateObject("ADODB.Recordset")
	rs.Open "student",Conn,1,3
	rs.addnew
	rs("userid") = userid
	rs("userpwd") =userpwd
	if question<>"" then
		rs("question")=question
    end if
	if answer<>"" then
		rs("answer")=answer
	end if
	rs("realname") = realname
	rs("email") = email
	if request("isEmailShow")<>"0" Then
	rs("isEmailShow") = 1
	else
	rs("isEmailShow") = 0
	end if
	if homepage<>"" then 
		rs("homepage")  = homepage
	end if
	if request("ishomepageshow")<>"0" Then
	Rs("ishomepageshow")=1
	else
	Rs("ishomepageshow")=0
	end if
	if oicq<>"" then 
		rs("oicq")  = oicq
	end if
	if request("isoicqshow")<>"0" Then
	Rs("isoicqshow")=1
	else
	Rs("isoicqshow")=0
	end if
	if msn<>"" then 
		rs("msn")  = msn
	end if
	if request("ismsnshow")<>"0" Then
	Rs("ismsnshow")=1
	else
	Rs("ismsnshow")=0
	end if
	if Request.form("face")<>"" and Request.form("face")>0 then
	rs("imageid")= "face/image"&int(Request.form("face"))&".gif"
	end if
	if zipcode<>"" then
		rs("zipcode") = zipcode
	end if
	if address<>"" then 
		rs("address")   = address
	end if
	if telephone<>"" then 
		rs("telephone") = telephone
	end if
	if mobilephone<>"" then 
		rs("mobilephone") = mobilephone
	end if
	if trim(Request.form("workshop"))<>"" then
		rs("workshop") = trim(Request.form("workshop"))
	end if
	if trim(Request.form("class"))<>"" then
		rs("class") = trim(Request.form("class"))
	end if
	rs("birthday")=birthday
	if maxim<>"" then 
		rs("maxim")=maxim
	end if
	rs("point")=PointSet(0)
	rs("sex")=cint(Request.form("sex"))

	rs.update
	rs.close
	Set rs=Nothing

	Conn.Execute("update config Set UserNum=UserNum+1")

	recommender=trim(checkstr(Request("recommender")))
	if recommender<>"" Then 
		Conn.Execute("update student Set point=point+"&PointSet(25)&" where userid='"&recommender&"'")
	End if

'send mail
if BoolVar(18) then
    MailFrom=StrVar(2)
	MailFromName=StrVar(1)
	Mailto=email
	mailtopic="感谢您在"&StrVar(1)&"注册！"
	MailBody=""&realname&"，您好："&vbCrLf&vbCrLf&_
	"欢迎您加入"&StrVar(1)&"，我们将提供给您最好的服务！"&vbCrLf&_
	"校友录地址："&SchoolmateURL&vbCrLf&vbCrLf&string(55,"-")&vbCrLf&_
	"您的注册信息如下："&vbCrLf&_
	"用户名："&userid&""&vbCrLf&_
	"密  码：不发送"&vbCrLf&_
	"您随时可以使用用户资料修改您的密码"&vbCrLf&string(55,"-")&vbCrLf&vbCrLf&_
	"再次感谢您注册本系统，让我们一起来建设这个网上家园！"

	Select Case IntVar(5)
	Case 1
		Call jmail_smtp()
	Case 2
		Call Cdonts()
	Case 3
		Call aspemail()
	Case 4
		Call jmail_msg()
	Case Else
		SendMailStatus=""
	End Select

end if



	'send message
	'sender=StrVar(1)
	title=StrVar(1)&"欢迎您的到来"


	body=StrVar(1)&"全体管理人员欢迎您的到来，如有任何疑问请及时"&vbLf&"[email="&StrVar(2)&"]联系系统管理员[/email]：Email："&StrVar(2)&"，QQ："&StrVar(9)&"。"&vbLf&"如有任何使用上的问题请查看校友录帮助。感谢您注册本系统，"&vbLf&"请遵守本系统的一切规章制度，让我们一起来建设完美和谐的网上家园！"&vbLf&"现在请返回首页点击左边的“注册学校”创建或加入你的学校！"&vbLf&"如果您不加入学校，系统将删除您的帐号！"
	sql="insert into message(incept,sender,title,content,sendtime,flag,issend,delS) values('"&userid&"','"&StrVar(1)&"','"&title&"','"&body&"',getdate(),0,1,2)"
	Conn.Execute(sql)

	userip1 = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
	userip2 = Request.ServerVariables("REMOTE_ADDR")
    if userip1 = ""  then lastip=userip2 else lastip=userip1

	'user logon
	LoginSQL="update student Set point=point+"&PointSet(1)&",lastip='"&lastip&"' where userid='"&userid&"'"
	conn.execute(LoginSQL)
	Response.Cookies("fenglingtxl_520")("usercookies") = 0
	response.cookies("fenglingtxl_520")("username")=userid
	response.cookies("fenglingtxl_520")("password")=userpwd
	response.cookies("fenglingtxl_520")("logintime")=now()
	session("regtime")=now()
	RURL="main.asp"
	Rtitle="注册校友录成功"
	if SendMailStatus="0K" then
		Rmsg="&nbsp;&nbsp;&nbsp;&nbsp;感谢您注册"&StrVar(1)&"！您的注册信息和密码已经发往您的邮箱。"
	end if
	Rmsg=Rmsg&"<br><ul><li><a href=main.asp>返回校友录首页面</a></li></ul>"
	call top(1,1)
	if BoolVar(1) Then	Response.Write "<bgsound src=""sound/logon.wav"" border=0>"
	Redirect 4,RURL,Rtitle,Rmsg

End Sub
%>
<%Call footer%>