<!--#INCLUDE FILE="conn.asp" -->
<!--#INCLUDE FILE="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<!--#INCLUDE FILE="inc/char.asp" -->
<!--#INCLUDE FILE="inc/email.asp" -->
<%Server.ScriptTimeOut=999999%>
<%locat="学校注册"
Call top(1,1)

if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=Class_Login.asp><font color=red>登录或注册校友录</font></a>。"
	Call Error("Information",ErrMsg)
	
Else
	Dim classname
	Select Case Request("action")
	Case "Joinschool"
		Call selclsform()
	Case "Join"
		Dim scID
		Call joinclass()
	Case "Create"
		Call createclass()
	Case "passwordjoin"
		Call chkclspwd()
	Case "exitpass"
		Call ExitPass()
	Case Else
		Call schoolform()
	End Select
End if


Sub joinclass()

	Dim rs,sql

	sql="Select classcount from student where userid='"&membername&"'"
	Set rs=conn.execute(sql)
	if not rs.eof and not sysadmin and rs(0)>=Cint(IntVar(0)) Then
		ErrMsg=ErrMsg+"<br>"+"<li>对不起！每个用户只能注册<font color=brown><strong>"&IntVar(0)&"</strong></font>个学校！"
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

	scID=Clng(Request("scID"))
	sql="Select classid from class where classid="&scID
	Set rs=conn.execute(sql)

	if  rs.eof and rs.bof Then
		ErrMsg=ErrMsg+"<br>"+"<li>"+"您选择的学校不存在！"
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

	sql="Select openlevel from class where classid="&scID
	Set rs=conn.execute(sql)

	openlevel=rs(0)

	if SysAdmin Then openlevel=0

	Select Case openlevel
	Case 0
		Call add2class()
	Case 1
		Call pswform()
	Case 2
		Call waitpass()
	Case 3
		ErrMsg=ErrMsg+"<br><li>学校管理员已经锁定了这个学校，禁止其他用户加入！"
		Call Error("Information",ErrMsg)
	End Select

End Sub

Sub CreateClass()

	Dim rs,sql,classpassed
	Dim FoundErr,ErrMsg
	Dim RestrictWord,i
    dim schooltypeid,schoolprovinceid,schoolareaid
	if chkpost=False Then
		ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法，请不要从校友录外部提交信息。"
		Call Error("Critical",ErrMsg)
		Exit Sub
	End if

	if BoolVar(2)=False Then
		ErrMsg=ErrMsg+"<br>"+"<li>对不起！系统管理员已设置不允许创建新的学校！"
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

	sql="Select classcount from student where userid='"&membername&"'"
	Set rs=conn.execute(sql)
	if not rs.eof and not sysadmin and rs(0)>=Cint(IntVar(0)) Then
		ErrMsg=ErrMsg+"<br>"+"<li>对不起！每个用户只能注册<font color=brown><strong>"&IntVar(0)&"</strong></font>个学校！"
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

    schooltypeid=trim(Request("schooltypeid"))
	schoolprovinceid=trim(Request("schoolprovinceid"))
	schoolareaid=trim(Request("schoolareaid"))
	if schoolprovinceid="" or not isnumeric(schoolprovinceid) then schoolprovinceid=0
    if schooltypeid="" or not isnumeric(schooltypeid) then schooltypeid=0
    if schoolareaid="" or not isnumeric(schoolareaid) then schoolareaid=0
if  schooltypeid=0 Then
		ErrMsg=ErrMsg+"<br>"+"<li>"+"您还没有选择您的学校类型！"
		founderr=True
end if
if  schoolprovinceid=0 Then
		ErrMsg=ErrMsg+"<br>"+"<li>"+"您还没有选择您的学校所在城市！"
        founderr=True
end if
if  schoolareaid=0 Then
		ErrMsg=ErrMsg+"<br>"+"<li>"+"您还没有选择您的学校所在省的地区！"
        founderr=True
end if

	classname=replace(trim(Request.form("classname")),"'","")
	if classname="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>"+"请输入您要创建的学校名称！"
		founderr=True
	ElseIf strlength(classname)<5 or strlength(classname)>25 Then
		ErrMsg=ErrMsg+"<br>"+"<li>"+"请输入学校名称5-25个字符！"
		founderr=True
	Else
	set rs=conn.execute("Select * from class where provinceid="&schoolprovinceid&" And schooltypeid="&schooltypeid&" And areaid="&schoolareaid&" and classname='"&classname&"'")

		If not (rs.EOF and rs.bof) then
		ErrMsg=ErrMsg+"<br>"+"<li>"+"您输入的学校名已经存在，请在直接在学校列表中选择或重新输入其他学校名！"
			founderr=true
		end If
		set rs=nothing
	end If
		if StrVar(3)<>"" then
			RestrictWord=split(StrVar(3),"|")
			for i=0 to ubound(RestrictWord)
				if instr(classname,RestrictWord(i))=0 then
					ErrMsg=ErrMsg+"<br>"+"<li>"+"学校名称必须包含指定的限定词！"
					founderr=True
					exit for
				end if
			next
		else
			sql="Select classid from class where  provinceid="&schoolprovinceid&" And schooltypeid="&schooltypeid&" And areaid="&schoolareaid&" and classname='"&classname&"'"
			Set rs=conn.execute(sql)
			if not (rs.eof and rs.bof) Then
				ErrMsg=ErrMsg+"<br>"+"<li>"+"您输入的学校名已经存在，请在直接在学校列表中选择或重新输入其他学校名！"
				founderr=True
			End if
			Set rs=Nothing
		end if

	if founderr=True Then
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if
	
	
	if BoolVar(17) Then
	classpassed=0
	else
	classpassed=1
	end if
	''''是否将创建学校的用户设为管理员
    if BoolVar(16) then
	sql="insert into class (classname,creator,openlevel,admin1,classphoto,passed,provinceid,areaid,schooltypeid) values('"&classname&"','"&membername&"','"&IntVar(6)&"','"&membername&"',"&IntVar(3)&","&classpassed&","&schoolprovinceid&","&schoolareaid&","&schooltypeid&")"
	else
	sql="insert into class (classname,creator,openlevel,classphoto,passed,provinceid,areaid,schooltypeid) values('"&classname&"','"&membername&"','"&IntVar(6)&"',"&IntVar(3)&","&classpassed&","&schoolprovinceid&","&schoolareaid&","&schooltypeid&")"
	end if
	
	conn.execute(sql)

	sql = "select max(classid) from class"
	Set rs=conn.execute(sql)
	ncid=rs(0)

	'VoteTitle="您在使用风铃校友录后感觉如何？"
	'VoteItem="非常好，我很满意"&vbCrLf&"不错，还可以吧"&vbCrLf&"太一般了"

	'sql="insert into VoteBox (UserName,VoteTitle,VoteItem,VoteType,"&_
	'	"ClassID,Vote) values('"&StrVar(1)&"','"&VoteTitle&"','"&VoteItem&"',0,"&ncid&",'0,0,0')"
	'conn.execute(sql)

	sql="update config set ClassNum=ClassNum+1"
	conn.execute(sql)
	
	sql="update student set classcount=classcount+1,point=point+"&PointSet(10)&" where userid='"&membername&"'"
	conn.execute(sql)

if BoolVar(16) then
	sql="insert into joinclass (userid,classid,jointime,lastvisit,"&_
		"isauditing,degree) values('"&membername&"',"&ncid&",getdate(),getdate(),0,8)"
else
	sql="insert into joinclass (userid,classid,jointime,lastvisit,"&_
		"isauditing,degree) values('"&membername&"',"&ncid&",getdate(),getdate(),0,1)"
		end if
	conn.execute(sql)

	Set rs=Nothing

	rURL="Class_index.asp?ClassID="&ncid
	rtitle="创建学校成功"
	if BoolVar(16) then
    rmsg="并成为该学校的管理员！<br><li>请认真管理您的学校！如不想担任管理员请到申请辞职或将您的职位转交给有兴趣的同学！"
	end if
	if BoolVar(17) then
	rmsg=rmsg&"<br><li>但没有通过系统管理员的审核之前是不能访问的,请等候管理员的审核!"
	rURL="main.asp"
	end if
	rmsg="<li>您已经成功的创建了学校：<font color=brown>"&htmlencode(classname)&"</font>！"&rmsg&"<br>"&_
			"<ul><li><a href="&rURL&">进入学校页面</a>"&_
			"</li></ul>"
	Redirect 10,rurl,rtitle,rmsg

End Sub



Sub ExitPass()

	Dim sql,rs
	Dim FoundErr,ErrMsg

	pclassid=Request.querystring("classid")
	if pclassid<>"" Then pclassid=Clng(pclassid)
    schoolid=request("schoolid")
	sql="Select isauditing from joinclass where userid='"&membername&"' and classid="&pclassid
	Set rs=conn.execute(sql)
	if rs.eof and rs.bof Then
		ErrMsg=ErrMsg+"<br>"+"<li>你没有向学校管理员提出申请加入这个学校!"
		founderr=True
	ElseIf rs(0)=0 Then
		ErrMsg=ErrMsg+"<br>"+"<li>你已经通过学校管理员的审核并成为这个学校的正式成员了！"
		founderr=True
	End if
	Set rs=Nothing

	if founderr=True Then
		Call Error("Information",ErrMsg)
	Else
		sql="update student Set classcount=classcount-1 where userid='"&membername&"'"
		conn.execute(sql)
		
		sql="delete from joinclass where isauditing=1 and classid="&pclassid&" and userid='"&membername&"'"
		conn.execute(sql)	

		stitle="退出审核"
		smsg="你已经成功的退出学校管理员的审核状态！"
		Call success(stitle,smsg)
	End if

End Sub


Sub schoolform()

%>
<%dim schooltypeid,provinceid,areaid
dim rss,sql1,sql2,sql3
provinceid=trim(request("provinceid"))
schooltypeid=trim(request("schooltypeid"))
areaid=trim(request("areaid"))
if provinceid="" or not isnumeric(provinceid) then provinceid=0
if schooltypeid="" or not isnumeric(schooltypeid) then schooltypeid=0
if areaid="" or not isnumeric(areaid) then areaid=0
%>
<br><form name="selsc186" action="Class_RegClass.asp" method="POST" onSubmit="return submitonce(this)">
<input type=hidden name=action value=Joinschool>
  <table width="700" height="133" border="0" align="center" cellpadding="2" cellspacing="0" Class=TableBorder >
    <tr> 
      <th height="30"><div align="center">请选择你所在学校的相关信息</div></th>
    </tr>
    <tr Class=LightTableBody> 
      <td height="100"><%
	  set rss=server.createobject("adodb.recordset")%>
	  <div align="center">学校类型： 
          <select name="schooltypeid" onChange="document.location.href='?areaid=<%=areaid%>&provinceid=<%=provinceid%>&schooltypeid='+this.options[selectedIndex].value;">
            <option value=0>请选择</option>
            <%sql1="select * from schooltype order by schooltypeid"
              rss.open sql1,conn
              while not rss.eof
              selectedseach=""
              if clng(schooltypeid)=clng(rss("schooltypeid")) then
                 selectedseach="selected"
              end if
              %>
            <option <%=selectedseach%> value=<%=rss("schooltypeid")%>><%=rss("schooltypename")%></option>
            <%
               rss.movenext
               wend
               rss.close
              %>
          </select>
          &nbsp;&nbsp;学校所在省： 
          <select name="provinceid" onChange="document.location.href='?areaid=<%=areaid%>&schooltypeid=<%=schooltypeid%>&provinceid='+this.options[selectedIndex].value;">
            <option value=0>请选择</option>
            <%
             sql2="select * from province order by seed "
             rss.open sql2,conn
             while not rss.eof
             selectedseach2=""
             if clng(provinceid)=clng(rss("provinceid")) then
                selectedseach2="selected"
             end if
              %>
            <option <%=selectedseach2%> value="<%=rss("provinceid")%>"><%=rss("provincename")%></option>
            <%
               rss.movenext
               wend
               rss.close
              %>
          </select>
          &nbsp;&nbsp;学校所在地区： 
          <select name="areaid">
            <option value=0>请选择</option>
            <%
             sql3="select * from areainfo where provinceid="&clng(provinceid)&" order by seed "
             rss.open sql3,conn
             while not rss.eof
             selectedseach3=""
             if clng(areaid)=clng(rss("areaid")) then
                selectedseach3="selected"
             end if
              %>
            <option <%=selectedseach3%> value="<%=rss("areaid")%>"><%=rss("areaname")%></option>
            <%
               rss.movenext
               wend
               rss.close
              %>
          </select>
          &nbsp;&nbsp; 
          <input type="submit" value="下一步" accesskey="j" class=button <%if provinceid<=0 or schooltypeid<=0 Then Response.Write("Disabled")%>>
        </div></td>
    </tr>
    <tr Class=LightTableBody>
      <td>&nbsp;</td>
    </tr>
  </table>
</form><br>
<br>
<%
End Sub
Sub selclsform()
dim provinceid,schooltypeid,areaid
provinceid=Request("provinceid")
areaid=Request("areaid")
schooltypeid=Request("schooltypeid")
if provinceid="" or not isnumeric(provinceid) then provinceid=0
if schooltypeid="" or not isnumeric(schooltypeid) then schooltypeid=0
if areaid="" or not isnumeric(areaid) then areaid=0

if  provinceid=0 or areaid=0 or schooltypeid=0 Then
		ErrMsg=ErrMsg+"<br>"+"<li>"+"操作出错，请重新操作！"
		Call Error("Information",ErrMsg)
else
provinceid=clng(provinceid)
areaid=clng(areaid)
schooltypeid=clng(schooltypeid)
%>
	<!--#INCLUDE FILE="inc/popup.inc" -->	
	<form name="selsc1" action="Class_RegClass.asp" method="POST" onSubmit="return submitonce(this)">
  <span lang="zh-cn">&nbsp;&nbsp;&nbsp;&nbsp;可输入学校名称关键字</span>查找<span lang="zh-cn">,比如:<font color="#800080">师范学院、第四中学、理工大学</font></span>&nbsp;&nbsp;&nbsp;&nbsp; 
  <input name="provinceid" type="hidden" id="provinceid" value="<%=provinceid%>">
  <input name="areaid" type="hidden" id="areaid" value="<%=areaid%>">
  <input name="schooltypeid" type="hidden" id="schooltypeid" value="<%=schooltypeid%>">
  <input name="action" type="hidden" id="action" value="Joinschool">
  <input class=smallInput type="text" name="bj" size="20" value="<%=request("bj")%>">
  &nbsp;&nbsp;
<input type="submit" value="查 询" accesskey="j" class=button>
</form>	
	<form name="selsc" action="Class_RegClass.asp" method="POST" onSubmit="return submitonce(this)">
	<input type=hidden name=action value=Join>	
  <TABLE width=95% align=center>
    <TR> 
      <TD align=left><IMG SRC="images/one.gif" WIDTH="16" HEIGHT="16" hspace=3><span style="FONT-SIZE: 10pt">你的学校是下面学校列表中的哪一个？(点击学校名浏览学校信息)</span></TD>
    </TR>
  </TABLE>

	<table border="0" width="95%" Class=TableBorder cellspacing="1" cellpadding="2" align=center>
	<tr height=25>
		<th align="center" width=6%>选择</th>
		<th align="center" width=36%>学&nbsp;校&nbsp;名&nbsp;称</th>
		<th align="center" width=8%>人&nbsp;数</th>
		 <th align="center" colspan=2 width=26%>管&nbsp;理&nbsp;员</th>
		 <th align="center" width=10%>开放等级</th>
		</tr>
<%
bj=trim(request("bj"))
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select classid,classname,admin1,admin2,studcount,openlevel from [class] where provinceid="&provinceid&" and areaid="&areaid&" and schooltypeid="&schooltypeid&" and classname like '%"&bj&"%' order by classid desc"
rs.Open sql,conn,1,1

if rs.eof and rs.bof Then 
	Response.write "<tr Class=LightTableBody><td colspan=6 height=30>&nbsp;&nbsp;目前还没有任何学校噢:(</td></tr>"
Else

	rs.pagesize=20
	maxpages=rs.pagecount

	if isInteger(Request("page")) Then
		currentpage=cint(Request("page"))
	Else 
		CurrentPage=1
	End if

	if currentpage>maxpages Then currentpage=maxpages
	rs.absolutepage=CurrentPage

	for i=1 to 20
		response.write "<tr Class=LightTableBody><td align=center>"&_
			"<input type=Radio name=scId value="&rs(0)&"></td><td>&nbsp;"&_
			"<a target=_blank href=""Class_index.asp?ClassID="&rs(0)&""" title=""浏览"&rs(1)&"学校信息"">"&htmlencode(rs(1))&"</a></td>"&_
			"<td align=center>"&rs(4)&"</td><td width=""13%"">&nbsp;"
		if rs(2)<>"" Then 
			Response.write "<a target=_blank href=""Class_Userinfo.asp?Name="&rs(2)&""" onmouseout=""kill()"" onmouseover=""popup('查看"&rs(2)&"的个人信息！','"&LightTBColor&"')"">"&htmlencode(rs(2))&"</a>"
		end if
		response.write "</td><td>&nbsp;"
		if rs(3)<>"" Then 
			Response.write "<a target=_blank href=""Class_Userinfo.asp?Name="&rs(3)&""" onmouseout=""kill()"" onmouseover=""popup('查看"&rs(3)&"的个人信息！','"&LightTBColor&"')"">"&htmlencode(rs(3))&"</a>"
		end if
		response.write "</td><td align=center>"
		select case rs(5)
		case 0
			  Response.write "<img src=images/open.gif width=16 onmouseout=kill() onmouseover=""popup('该学校完全开放，可以自由加入！','"&LightTBColor&"')"">"
		case 1
			  Response.write "<img src=images/passwd.gif onmouseout=kill() onmouseover=""popup('加入该学校需要向学校管理员索取学校密码！','"&LightTBColor&"')"">"
		case 2
			  Response.write "<img src=images/auditing.gif onmouseout=kill() onmouseover=""popup('你需要通过学校管理员的验证才能加入这个学校！','"&LightTBColor&"')"">"
		case 3
			  Response.write "<img src=images/lock1.gif width=14 onmouseout=kill() onmouseover=""popup('该学校已被管理员锁定，不允许其他人加入！','"&LightTBColor&"')"">"
		End select
		response.write "</td></tr>"
		rs.movenext
		if currentpage=maxpages then
			if rs.eof then exit for
		end if
	next

End if
rs.close
Set rs=Nothing
%>	
    </table>

<TABLE width=95% align=center>
<TR><TD width=100%><table width=100% border=0>
          <tr> 
            <td width="206" align=left nowrap> 
              <%Response.write "页次: "&currentpage&"/"&maxpages&"&nbsp;&nbsp;&nbsp;去第"%>
              <select name="page" style="width:35px" onChange="location.href='?action=Joinschool&provinceid=<%=provinceid%>&areaid=<%=areaid%>&schooltypeid=<%=schooltypeid%>&bj=<%=bj%>&page='+this.options[selectedIndex].value">
                <%
              dim i
             i=1
             do while i<=maxpages
             if i=currentPage then
             response.write("<option selected value="&i&">"&i&"</option>")
             else
             response.write("<option value="&i&">"&i&"</option>")
             end if
             i=i+1
             loop
              %>
              </select>
              页</td>
            <td width="621" align=center> 
              <% if currentpage=0 Then currentpage=1
if not  (currentpage=1 or maxpages=0) Then
	Response.write "　<a href=""?action=Joinschool&provinceid="&provinceid&"&areaid="&areaid&"&schooltypeid="&schooltypeid&"&bj="&bj&"&page="&currentpage-1&"""><img src=images/left.gif border=0>&nbsp;上一页</a>"
End if
		
if not (currentpage=maxpages or maxpages=0) Then
	Response.write "　<a href=""?action=Joinschool&provinceid="&provinceid&"&areaid="&areaid&"&schooltypeid="&schooltypeid&"&bj="&bj&"&page="&currentpage+1&"""><img src=images/right.gif border=0>&nbsp;下一页</a>"
End if
%>
            </td>
            <td align=right width=89><input type="submit" value="加入学校(J)" name="sbmtj" accesskey="j" class=button></td>
          </tr>
        </table></TD>
</TR></TABLE>
</form>

<BR>

<form name="selsc" action="Class_RegClass.asp" method="POST" onSubmit="return submitonce(this)">
<input type=hidden name=action value=Create>
  <TABLE width=95% align=center>
<TR>
      <TD align=left><IMG SRC="images/two.gif" WIDTH="16" HEIGHT="16" hspace=3><span style="FONT-SIZE: 10pt">如果上表中还没有你想要加入的学校，请在下面创建学校：</span></TD>
</TR></TABLE>
<%set rss=server.createobject("adodb.recordset")%>
<table border="0" width="95%" Class=TableBorder cellspacing="1" cellpadding="7" align=center>
<tr Class=LightTableBody>
	<td width="64%" align="center" valign=center>
	学校类型：
	  <select name="schooltypeid" onChange="document.location.href='?action=Joinschool&areaid=<%=areaid%>&provinceid=<%=provinceid%>&schooltypeid='+this.options[selectedIndex].value;">
        <option value="">请选择</option>
        <%sql1="select * from schooltype order by schooltypeid"
              rss.open sql1,conn
              while not rss.eof
              selectedseach=""
              if clng(schooltypeid)=clng(rss("schooltypeid")) then
                 selectedseach="selected"
              end if
              %>
        <option <%=selectedseach%> value=<%=rss("schooltypeid")%>><%=rss("schooltypename")%></option>
        <%
               rss.movenext
               wend
               rss.close
              %>
      </select>&nbsp;&nbsp;学校所在省：
      <select name="schoolprovinceid" onChange="document.location.href='?action=Joinschool&areaid=<%=areaid%>&schooltypeid=<%=schooltypeid%>&provinceid='+this.options[selectedIndex].value;">
        <option value="">请选择</option>
        <%
             sql2="select * from province order by seed "
             rss.open sql2,conn
             while not rss.eof
             selectedseach2=""
             if clng(provinceid)=clng(rss("provinceid")) then
                selectedseach2="selected"
             end if
              %>
        <option <%=selectedseach2%> value="<%=rss("provinceid")%>"><%=rss("provincename")%></option>
        <%
               rss.movenext
               wend
               rss.close
              %>
      </select>&nbsp;&nbsp;学校所在地区：<select name="schoolareaid" onChange="document.location.href='?action=Joinschool&provinceid=<%=provinceid%>&schooltypeid=<%=schooltypeid%>&areaid='+this.options[selectedIndex].value;">
        <option value="">请选择</option>
        <%
             sql3="select * from areainfo where provinceid="&clng(provinceid)&" order by seed "
             rss.open sql3,conn
             while not rss.eof
             selectedseach3=""
             if clng(areaid)=clng(rss("areaid")) then
                selectedseach3="selected"
             end if
              %>
        <option <%=selectedseach3%> value="<%=rss("areaid")%>"><%=rss("areaname")%></option>
        <%
               rss.movenext
               wend
               rss.close
              %>
      </select>
	</td>
	<td width="36%" align="center" valign=center>
学校名称：
  <input name="classname" size="22" maxlength="28">&nbsp;*
	</td>
</tr>
<%Set rss=nothing%>
<tr Class=LightTableBody>
<td colspan=2><table width="668" border=0 cellpadding=3>
          <tr><td width="658" class=mp>为避免出现同一学校多个名称的现象,学校名必须遵守以下规范！<br>
              (1)在学校名中尽量写学校全称,让人一目了然,如"<font color="#FF0000">广东工业大学</font>"<br>
				(2)请用中文,文字之间不要有空格,学校名称长度在5至25个字符之间.<BR>
              (3)如果发现学校名不规范或者重复，请速与<a href=mailto:<%=StrVar(2)%> title=管理员QQ:<%=StrVar(9)%>><font color="#CC0000">管理员联系</font></a>.<br>
				<%if not isnull(StrVar(3)) then%>(4)系统已设定学校名称必须包含以下限定词：<B><%=replace(StrVar(3),"|","</b>,<b>")%></B>。<%end if%><br>
              <%if BoolVar(17) then%>
              <font color="#FF0000">(5)创建后的学校必须经过管理员的审核后才能正常访问!</font><br>
              <%end if%>
              <font color="#FF0000"><strong>注</strong></font>：创建学校后系统会自动<%if BoolVar(16) then%>将你设为该学校的管理员，并<%end if%>设置该学校处于 
              <%if IntVar(6)=0 then%>
              <font color="#FF0000">完全开放状态</font>，任何用户都可以进入！<br>
<%end if%><%if IntVar(6)=2 then%>
              <font color="#FF0000">管理员审核状态</font>，任何用户加入你的学校都必须经过学校管理员的审核才可以进入！<%if BoolVar(16) then%>请你经常访问你的学校，审核要加入你校的同学！<%end if%> 
              <%end if%><%if BoolVar(16) then%>如果你不想使用系统默认的模式，请你创建学校成功后到学校管理那里修改！<br>请认真管理你的学校，如不想担任学校管理员请申请将你的职位转交给有兴趣又认真负责的同学！<%end if%></td>
          </tr></table></td></tr>
</table>

<TABLE width=95% align=center>
<TR><TD align=right><input type="submit" value="创建学校(C)" accesskey="c" class=button onClick="javascript:if(confirm('你确定要创建此学校吗?')){;return true;}else{return false;}"></TD>
</TR></TABLE>
</form>

 <%

end if
End Sub
Sub add2class()

	Dim rs,sql
	sql="Select classid from joinclass where userid='"&membername&"' and classid="&scID
	Set rs=conn.execute(sql)
	if not (rs.eof and rs.bof) Then
		ErrMsg=ErrMsg+"<br><li>您已经加入这个学校了！"
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

	sql="update class Set studcount=studcount+1 where classid="&scID
	conn.execute(sql)
	
	
	sql = "Select classname from class where classid="&scID
	Set rs=conn.execute(sql)
	scname=rs(0)
	Set rs=Nothing

	sql="update student Set classcount=classcount+1,point=point+"&PointSet(10)&" where userid='"&membername&"'"
	conn.execute(sql)
	
	sql="insert into joinclass (userid,classid,jointime,lastvisit,"&_
	"isauditing) values('"&membername&"',"&scID&",getdate(),getdate(),0)"
	conn.execute(sql)

	rURL="Class_index.asp?ClassID="&scID
'if sendmailoption=True Then
if BoolVar(20) and IntVar(5)<>0  then
	sql = "Select realname,email from student where userid='"&membername&"'"
	Set rs=conn.execute(sql)
	studname=rs(0)
	studmail=rs(1)
    Set rs=Nothing
	
	sql="select distinct S.email from student S inner join joinclass J on S.userid=J.userid where J.classid="&scID&" and S.NewMemberFlag=1 and J.userid<>'"&membername&"'"
	Set rs=conn.execute(sql)

	if not rs.eof Then
	mailto=rs(0)
	rs.movenext
	do until rs.eof
		mailto=mailto&","&rs(0)
		rs.movenext
	loop
	Set rs=Nothing

	mailfrom=StrVar(2)
	MailFromName=StrVar(1)
	mailtopic="好消息，贵校（"&scname&"）又增新成员!--"&StrVar(1)
	mailbody="亲爱的同学，您好！"&vbCrLf&vbCrLf&_
	"   贵校（"&scname&"）又有新成员加入："&vbCrLf&vbCrLf&_
	"   姓名："&studname&"("&membername&")"&vbCrLf&_
	"   EMAIL："&studmail&vbCrLf&vbCrLf&_
	"   快快去信给他（她）一声问候吧！"&vbCrLf&vbCrLf&_
	"   学校地址："&SchoolmateURL&rURL&vbCrLf&vbCrLf&_
	string(44,"-")&vbCrLf&space(4)&StrVar(1)&vbCrLf&_
	space(4)&SchoolmateURL&vbCrLf
		select case Cint(IntVar(5))
			case 1
				Call jmail_smtp()		
			case 2
				Call Cdonts()		
			case 3
				Call aspemail()
			case 4
				Call jmail_msg()		
		End select
	End if
	'End if
	end if


	rtitle="注册学校成功"
	rmsg="您已经成功的注册了学校：<font color=brown>"&htmlencode(scname)&"</font>。<br><ul>"&_
			"<li><a href="""&rURL&""">进入学校页面</a></li>"&_
			"</ul>"
	Redirect 3,rurl,rtitle,rmsg

End Sub


Sub WaitPass()
	sql="Select isauditing from joinclass where userid='"&membername&"' and classid="&scID
	Set rs=conn.execute(sql)
	if not rs.eof Then
		if rs(0)=0 Then
			ErrMsg=ErrMsg+"<br><li>您已经加入这个学校，无需再申请加入！"
			founderr=True
		Else
			ErrMsg=ErrMsg+"<br><li>您已经向学校管理员发出加入这个学校的请求，目前仍处于审核之中！"
			founderr=True
		End if
	End if

	if founderr=True Then
		Call Error("Information",ErrMsg)
		Exit Sub
	End if
	sql="update student set classcount=classcount+1 where userid='"&membername&"'"
	conn.execute(sql)
	
	SQL = "select classname from class where classid="&scID
	Set rs=conn.execute(sql)
	scname=rs(0)

dim sender,title,message
lincept=trim(request("incept"))
sender=membername
title=sender+"请求加入你的学校"
message="管理员您好，我要加入"&rs(0)&"，请尽快为我审核通过！多谢..."
sql = "select * from class where classid="&scID
Set rs=conn.execute(sql)
if rs("admin1")<>"" then
sql="insert into message(incept,sender,title,content,sendtime,flag,issend) values('"&rs("admin1")&"','"&sender&"','"&title&"','"&message&"',getdate(),0,1)"
conn.Execute(sql)
end if
if rs("admin2")<>"" then
sql="insert into message(incept,sender,title,content,sendtime,flag,issend) values('"&rs("admin2")&"','"&sender&"','"&title&"','"&message&"',getdate(),0,1)"
conn.Execute(sql)
end if
	sql="insert into joinclass (userid,classid,isauditing) values('"&membername&"',"&scID&",1)"
	conn.execute(sql)

	stitle="发出请求"
	smsg="<li>您已经成功的向<font color=brown>"&htmlencode(scname)&"</font>的学校管理员发出加入学校的请求。"
	smsg=smsg&"<br>但是在没有通过学校管理员的审核前，你暂时还不能访问这个学校"
	Call success(stitle,smsg)

End Sub


Sub pswform()
%><br><br>
<form name="selsc"
    action="Class_RegClass.asp" method="POST">
	<input type=hidden name=Action value=passwordjoin>
	<input type=hidden name="scID" value=<%=scID%>>
	<%sql="Select classpwdtishi from class where classid="&scID
	Set rspp=conn.execute(sql)%>
    <table cellpadding=0 cellspacing=0 border=0 width=90% Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=5 cellspacing=1 border=0 width=100%>
    <tr align="center"> 
      <th width="100%" colspan=2><b>学校注册密码验证</b></td>
    </tr>
    <tr Class=LightTableBody> 
      <td width="40%"  class=mp align=center>请输入学校密码：（请向您校的管理员索取）</font>
      </td><td>&nbsp;&nbsp;<input type=password name=clspwd size=20 title=可以问您校知道密码的同学啊>&nbsp;&nbsp;<%=rspp("classpwdtishi")%></td>
    </tr>
    <tr align="center"> 
      <td width="100%" colspan=2 Class=DarkTableBody>
<input type=submit name=submit value="提交">
      </td>
    </tr>  
    </table>   </td></tr></table></form>
<%
set rspp=nothing
End Sub


Sub chkclspwd()

	if chkpost=False Then
		ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法。"
		Call Error("Critical",ErrMsg)
		Exit Sub
	End if

	clspwd=Request.form("clspwd")
	clspwd=replace(clspwd,"'","")

	scID=Clng(Request.form("scID"))
	sql="Select classpwd from class where classid="&scID
	Set rs=conn.execute(sql)

	if clspwd<>rs("classpwd") Then
		ErrMsg=ErrMsg+"<br><li>学校密码错误！不知道密码，请找学校管理员！"
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if

	Call add2class()

End Sub
%>
<%Call footer%>