<!--#INCLUDE FILE="conn.asp" -->
<!--#INCLUDE FILE="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<!--#INCLUDE FILE="inc/char.asp" -->
<%
response.buffer=true
Dim Locat
Locat="学校首页"
Dim ClsID,Degree,ClassName
Dim ClassRs,founderr,JoinRs,Joinclass
ClsID=Request("ClassID")
if not isNumeric(ClsID) Then
		ErrMsg=ErrMsg+"<br>"+"<li>操作失败，您没有输入要浏览的学校的ID！"
		founderr=True
else
ClsID=Clng(ClsID)
Set ClassRs=Conn.Execute("Select classname,passed from class where classid="&ClsID)
if ClassRs.eof and ClassRs.bof Then
		ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您要访问的学校或此学校所属的学校不存在或已被删除。"
		founderr=True
	elseif ClassRs(1)=0 then
	ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您要访问的学校还没有通过管理员的审核,暂时不能访问!"
	founderr=True
	Else
	    
		ClassName=ClassRs(0)
	End if
	Set ClassRs=Nothing
end if

if founderr=True then
Call top(1,1)
Call Error("Information",ErrMsg)
Call footer()
response.end
end if

if membername<>"" Then
Set JoinRs=Conn.Execute("Select isauditing,degree from joinclass where userid='"&membername&"' and isauditing=0 and classid="&ClsID)
	if JoinRs.eof and JoinRs.bof Then
		if sysadmin Then
			Degree=9
		Else
			Joinclass=False
		End if
	Else
	Joinclass=True
	Degree=JoinRs(1)
	End if
	Set JoinRs=Nothing

	dim VisitedClasses,ClassArr,visited
	dim sql

	if Joinclass=True and Degree<>9 Then

		VisitedClasses=Request.cookies("fenglingtxl_520")("visitedclasses")

		ClassArr=Split(VisitedClasses,vbCr)
		visited=False
		for l=0 to UBound(ClassArr)
			if ClsID=ClassArr(l) Then
				visited=True
				Exit for				
			End if
		next

		if visited=True Then
			sql="update joinclass set lastvisit=getdate() where userid='"&membername&"' and classid="&ClsID
			Conn.Execute(sql)
		Else
			sql="update joinclass set visitcount=visitcount+1,lastvisit=getdate() where userid='"&membername&"' and classid="&ClsID
			Conn.Execute(sql)
			sql="update class set visitcount=visitcount+1 where classid="&ClsID
			Conn.Execute(sql)
			Response.cookies("fenglingtxl_520")("visitedclasses")=ClsID&vbCr&VisitedClasses
		End if

	ElseIf Degree=9 then
        Joinclass=True
	else
		Joinclass=False
	End if
else
Joinclass=False
end if
'''''''学校内容开始''''
response.flush
Call top(2,1)
	Dim isAppendShow
	response.write "<table align=center width=100% cellspacing=0 cellpadding=0>"&_
		"<tr><td valign=top>"
	Call ShowClassInfo()
	response.write "</td><td width=1 bgcolor=#cccccc></td><td height=550 width=160 valign=top align=center bgcolor=#f2f8ff background=images/RedBG.gif>"%>
	<!--#INCLUDE FILE="inc/classmenu.asp" -->
	<Script language="javascript" src="inc/PopText.asp"></Script>
	<%Call LastVote():Call OnlineClassmate()
	response.write "</td></tr></table>"


Sub ShowClassInfo()

	Dim Rs
	dim Creator

	Set Rs=Conn.Execute("select isappendshow,regdate,homepage,visitcount,enyear,creator,"&_
		"admin1,admin2,studcount,pronouncement from class where classid="&ClsID)
	isAppendShow=Rs(0)
	Creator=ClassGetRealname(Rs(5))
	if Creator="" Then Creator="不详"
	response.write "<TABLE cellSpacing=0 cellPadding=0 width=100% align=center border=0>"&_
		"<TR><TD vAlign=top width=100% align=middle><BR>"&_
		"<TABLE cellSpacing=0 cellPadding=0 width=560 border=0>"&_
		"<TR><TD nowrap><IMG src=""images/welcome.gif"" align=absmiddle>&nbsp;<font color=#cc0000>"
		if membername<>"" then
		response.write ""&GetRealname(membername)&""
		else
		response.write "客人"
		end if
		response.write "</font>，欢迎您的光临！</TD>"&_
		"<TD valign=middle align=right>"
		if membername<>"" and Joinclass<>True then
		response.write"<a href=""Class_RegClass.asp?action=Join&scID="&ClsID&"""><img src=images/add1.gif alt=""加入此学校"" border=0></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
		end if
		if membername<>"" then
	Call myclasslist()
	else 
	call loginform()
	end if
	response.write "</TD></TR>"&_
		"<TR><TD vAlign=middle colSpan=2 height=30>您是&nbsp;<font color=#cc0000>"&htmlencode(ClassName)&_
		"</font>&nbsp;的第<font color=#cc0000><b>"&Rs(3)&"</b></font>位访问者，您的身份：<font color=#cc0000>"
	if Degree=9 Then 
	Response.write "系统管理员"
	 Elseif Degree="" then 
	 response.write "客人" 
	 else 
	 response.write Grade(Degree,False)
	 end if
	response.write "</font>。<br>本校网址：<a target=_blank href="&schoolmateurl&"Class_index.asp?ClassID="&ClsID&">"&schoolmateurl&"Class_index.asp?ClassID="&ClsID&"</a>&nbsp;&nbsp;<A href=#  onclick=this.style.behavior=""url(#default#homepage)"";this.setHomePage("""&schoolmateurl&"Class_index.asp?ClassID="&ClsID&""")><font color=red>设为首页</font></A>&nbsp;&nbsp;<A href=javascript:window.external.AddFavorite('"&schoolmateurl&"Class_index.asp?ClassID="&ClsID&"','"&htmlencode(ClassName)&"')><font color=red>加入收藏</font></A></TD></TR>"&_
		"<TR><TD  vAlign=top width=153 height=0 colspan=2></TD>"&_
		"</TR></TABLE>"&_
		"<TABLE cellSpacing=0 cellPadding=0 width=550 border=0>"&_
		"<TR><TD vAlign=top height=33><IMG src=""images/class_notice.gif""></TD></TR>"&_
		"<TR><td height=1 background=""images/bg_xu.gif""></td></TR>"&_
		"<tr><td align=center valign=middle height=40>"&StrVar(21)&"</td></tr>"&_
		"<TR><TD class=mp>"
		Call Classbbs()
		response.flush	
	Call remindbirthday()
	response.write "<br><table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"">"&_
  "<tr>"&_
    "<td width=""50%""><img src=images/pronouncement.gif><br><br></td>"&_
   " <td width=""50%""><img src=images/classalbum.gif></td>"&_
  "</tr>"&_
  "<tr><td>"
    if Rs(9)<>"" Then 
		Response.write htmlencode(Rs(9)) 
	Else 
		Response.write StrVar(20)
	End if
	response.write "</td><td><div align=center>"
   Call classnewsphoto()
	response.write "</div></td></tr></table>"
	
	response.write "</TD></TR></TABLE><BR>"&_

		"<TABLE cellSpacing=0 cellPadding=0 width=550 border=0>"&_
		"<TR><TD vAlign=top colspan=2 height=31><IMG src=""images/class_info.gif""></TD></TR>"&_
		"<TR><td colspan=2 height=1 background=""images/bg_xu.gif""></td></TR>"&_
		"<TR height=30 vAlign=bottom><TD width=""50%"">学校名称："&htmlencode(ClassName)&"</TD> "&_
		"<TD width=""50%"" colSpan=2>创校年份："&Rs(4)&"</TD></TR>"&_
		"<TR height=20 vAlign=bottom><TD width=""50%"">注册日期："&Rs(1)&"</TD>"&_
		"<TD width=""50%"" colSpan=2>学校创始人：<a href=""Class_Userinfo.asp?Name="&Rs(5)&""" target=_blank>"&creator&"</a>"&_
		"</TD></TR>"&_
		"<TR height=20 vAlign=bottom><TD width=""50%"">学校成员：<FONT color=#cc0000><B>"&Rs(8)&"</B></FONT> ["&_
		"<A href=""Class_Mate.asp?ClassID="&ClsID&""">查看</A>]</TD>"&_
		"<TD vAlign=bottom width=""50%"" colspan=2>共有相片：<FONT color=#cc0000><B>"&classphotonum&_
		"</B></FONT> [<A href=""Class_Album.asp?ClassID="&clsid&""">查看/添加</A>]</TD></TR>"&_
		"<TR height=20 vAlign=bottom><TD width=""50%"">共有留言：<FONT color=#cc0000><B>"&classliuyannum&"</B></FONT> ["&_
		"<A href=""Class_bbs_index.asp?ClassID="&ClsID&""">查看/添加</A>]</TD>"&_
		"<TD vAlign=bottom width=""50%"" colspan=2>本校教师：<FONT color=#cc0000><B>"&teachercount&_
		"</B></FONT> [<A href=""Class_TeacherList.asp?schoolid="&ClsID&""">查看/添加</A>]</TD></TR>"&_
		"<TR height=20 vAlign=bottom><TD width=""50%"">现任管理员：<a href=""Class_Userinfo.asp?Name="&Rs(6)&""" target=_blank>"&ClassGetRealname(Rs(6))&"</a>&nbsp;<a href=""Class_Userinfo.asp?Name="&Rs(7)&""" target=_blank>"&ClassGetRealname(Rs(7))&"</a>"&_

		"</TD><TD width=""50%"" colSpan=2>附加通信录：<FONT color=#cc0000><B>"&appendcount&"</B></FONT>"&_
		" [<A href=""Class_AppendList.asp?ClassID="&ClsID&""">查看/添加</A>]</TD></TR>"&_
		"<TR height=20 vAlign=bottom><TD width=""50%"">最新加入成员："&LastJoin()&"</TD>"&_
		"<td colspan=2>学校主页：<a href="""&Rs(2)&""" target=_blank>"&htmlencode(Rs(2))&"</td></TR>"
			Call waitpassmember()
	response.write "</TABLE><BR><BR><BR>"
	Set Rs=Nothing
response.flush
End Sub



Sub RemindBirthday()

	Dim BirRs,age
	Set BirRs=Conn.Execute("Select s.userid,s.realname,s.birthday from student s inner join joinclass j on s.userid=j.userid where month(s.birthday)=month(getdate()) and day(s.birthday)=day(getdate()) and j.isauditing=0 and j.classid="&ClsID)
	
	if BirRs.eof and BirRs.bof Then Exit Sub

	Response.write "<br><font color=#cc0000>今天本校过生日的同学：</font>"

	While not BirRs.eof
		age=datediff("yyyy",BirRs(2),date())
		Response.write "<a href=""Class_Userinfo.asp?Action=showdetail&Name="&BirRs(0)&_
			""" target=_blank  title=""祝 "&ClassGetRealname(BirRs(0))&""&age&"岁生日快乐！"">"&ClassGetRealname(BirRs(0))&"</a>&nbsp;&nbsp;"
		BirRs.movenext
	Wend
	Response.write "</font><br>"

	Set BirRs=nothing

End Sub



Sub WaitPassMember()

	Dim WaitRs,WaitSQL
	WaitSQL="Select S.userid,S.realname from student S inner join joinclass J on S.userid=J.userid where J.isauditing=1 and J.classid="&ClsID
	Set WaitRs=Conn.Execute(WaitSQL)

	if WaitRs.eof and WaitRs.bof Then Exit Sub
	Response.write "<tr vAlign=bottom height=20><TD colspan=3><font color=red>未通过审核同学：</font>"

	While not WaitRs.eof
		Response.write "<a href=""Class_Userinfo.asp?Action=showdetail&Name="&WaitRs(0)&_
			""" target=_blank  title=""查看"&ClassGetRealname(WaitRs(0))&"的个人信息！"">"&ClassGetRealname(WaitRs(0))&"</a>&nbsp;&nbsp;"
		WaitRs.movenext
	Wend
	Response.write "</td></TR>"
	Set WaitRs=Nothing

End Sub



Sub OnlineClassmate()

	Dim OnlineRs,OnlineSQL
	OnlineSQL="select S.realname,S.userid from student S inner join (joinclass J inner join online O on O.userid=J.userid) on J.userid=S.userid where J.isauditing=0 and J.classid="&ClsID

	Set OnlineRs=Conn.Execute(OnlineSQL)

	Response.write "<tr><td><BR>"&_
		"<table border=0 cellspacing=1 cellpadding=3 align=center width=""75%"">"

	if not (OnlineRs.eof and OnlineRs.bof) Then
		do until OnlineRs.eof
		Response.write "<tr><td align=right width=""30%""><img src=images/profile.gif></td><td><a href=""Class_Userinfo.asp?Action=showdetail&Name="&OnlineRs(1)&_
		""" target=_blank  title=""查看"&ClassGetRealname(OnlineRs(1))&_
		"的个人信息！"">"&ClassGetRealname(OnlineRs(1))&"</a></td></tr>"
		OnlineRs.movenext
		loop
	End if
	Response.write "</table>"&_
	"</td></tr></table>"
	Set OnlineRs=Nothing

End Sub



Function teachercount()

	dim Rs
	Set Rs=Conn.Execute("Select count(id) from teacher where schoolid="&ClsID&"")
	teachercount=Rs(0)
	set rs=nothing

End Function



Function appendcount()
	dim aRs
	Set aRs=Conn.Execute("Select count(id) from append where classid="&ClsID)
	appendcount=aRs(0)
	set aRs=nothing

End Function



Function LastJoin()

	Dim NewStudentRs
	LastJoin=""

	Set NewStudentRs=Conn.Execute("select top 1 J.userid,S.realname from joinclass J inner join student S "&_
		"on J.userid=S.userid where J.classid="&ClsID&" and J.isauditing=0 order by J.jointime desc")

	if not NewStudentRs.eof Then
		LastJoin="<a target=_blank href=""Class_Userinfo.asp?Name="&NewStudentRs(0)&""" title=""查看"&ClassGetRealname(NewStudentRs(0))&"的个人信息"">"&ClassGetRealname(NewStudentRs(0))&"</a>"
	End if

	set NewStudentRs=nothing
End Function



Sub ClassBbs()
%>
	<TABLE cellSpacing=0 cellPadding=0 width=550 border=0> 
	<TR>
    <TD vAlign=top height=36 colspan=3><a href="Class_bbs_index.asp?ClassID=<%=ClsID%>"><IMG src="images/class_gbook.gif" alt="我要留言！" border="0"></a></TD>
  </TR>
	<TR><td colspan=3 height=1 background="images/bg_xu.gif"></td></TR>
	<TR height=22><TD width=250>&nbsp;帖子标题</TD><TD width=100>| 作者</TD><TD width=160>| 发表时间</TD>	</TR> 
	<TR><TD bgColor=#c4d7e4 colSpan=4 height=1></TD></TR>
	</TABLE>
	<%
	Dim BoardRs,BoardSQL
	Set BoardRs = Server.CreateObject("ADODB.Recordset")
	BoardSQL = "select top 6 userid,title,postid,posttime,mood from Classtopic where classid="&ClsID&" order by lastTime desc"
	BoardRs.Open BoardSQL,Conn,1,1
	Do until BoardRs.eof
	popinfo="作者："&htmlencode(ClassGetRealname(BoardRs(0)))&"  发表于"&BoardRs(3)&"..."
	response.write "<TABLE cellSpacing=0 cellPadding=0 width=550 border=0>"&_
		"<TR vAlign=bottom><TD align=left width=250 height=19>&nbsp;"&_
		"<a href=""Class_bbs_ShowTopic.asp?ClassID="&ClsID&"&Topicid="&BoardRs(2)&""" title="""&popinfo&"""><img src=images/mood/"&BoardRs(4)&".gif border=0>"&htmlencode(left(BoardRs(1),20))&"</a></TD>"&_
		"<TD align=left width=100>&nbsp;&nbsp;"&ClassGetRealname(BoardRs(0))&"</TD>"&_
		"<TD width=160>&nbsp;&nbsp;"&formatdatetime(BoardRs(3),vbShortDate)&"&nbsp;"&_
		formatdatetime(BoardRs(3),vbShortTime)&"</TD></TR></TABLE>"
	BoardRs.movenext
	Loop
	BoardRs.Close
	Set BoardRs=Nothing

End Sub


Sub MyClassList() 

	Dim MyClassSQL,MyClassRs
	MyClassSQL="select C.classid,C.classname from class C inner join joinclass J on C.classid=J.classid "&_
	"where J.userid='"&membername&"' and J.isauditing=0 order by C.classname"
	Set MyClassRs=Conn.Execute(MyClassSQL)
		Response.write "<select name=myclasslist onchange=""location.href='Class_index.asp?ClassID='+options[this.selectedIndex].value"">"
		Response.write "<option value=0>== 我的学校 ==</option>"
		Do until MyClassRs.eof
			Response.write 	"<option value="&MyClassRs(0)&">"&htmlencode(MyClassRs(1))&"</option>"
			MyClassRs.movenext
		Loop
		Response.write "</select>"
	Set MyClassRs=Nothing

End Sub 


Sub LastVote()

	Dim VoteRs,VoteItem
	Dim i
	Set VoteRs=Conn.Execute("Select top 1 VoteTitle,VoteItem,VoteType,VoteID from VoteBox where classid="&ClsID&" order by VoteID desc")
	if not (VoteRs.eof and VoteRs.bof) then
		VoteItem=Split(VoteRs(1),vbCrLf)

		Response.write 	"<script language=JavaScript src=inc/vote.js></script>"&_
			"<tr><td background=images/GreenBG.gif><BR><TABLE width=""90%"" align=center cellspacing=1>"&_
			"<form name=theVote action=""Class_ClassVote.asp?ClassID="&ClsID&""" method=post target=vote onsubmit=""return chkpoll('')"">"&_
			"<input type=hidden name=Action value=Poll>"&_
			"<input type=hidden name=VoteID value="&VoteRs(3)&">"&_
			"<TR><Td align=center><!-- 本校最新调查 --></td></tr>"&_
			"<TR><TD>"&htmlencode(VoteRs(0))&"</td></tr>"&_
			"<tr><td><table border=0 cellspacing=0 cellpadding=0 align=center width=""100%"">"
			
		for i=0 to UBound(VoteItem)
			Response.write "<tr><td>"
			if VoteRs(2)=1 Then
				Response.write "<input type=checkbox name=vote id=vote"&i&" value="&i&">"
			Else
				Response.write "<input type=radio name=vote id=vote"&i&" value="&i&">"
			End if
			Response.write "<label for=vote"&i&">"&htmlencode(VoteItem(i))&"</label></td></tr>"
		next
			
		Response.write 	"</table></td></tr>"&_
			"</TD></TR>"&_
			"<tr><td align=center><INPUT TYPE=submit value=投&nbsp;票 class=button>&nbsp;&nbsp;&nbsp;&nbsp;"&_
			"<INPUT TYPE=button value=结&nbsp;果 onclick=""return seeresult("&ClsID&");"" class=button></td></tr>"&_
			"<tr><td align=center height=30><a href=""Class_ClassVote.asp?ClassID="&ClsID&"&Action=ViewHistory"" targer=_blank><img src=images/go.gif border=0 align=absmiddle width=15 hspace=2>查看以往调查</a></td></tr>"&_
			"</form></TABLE>"&_
			"<img src=images/online.gif>"&_
			"</td></tr>"
	else
	Response.write 	"<tr><td background=images/GreenBG.gif><BR><TABLE width=""90%"" align=center cellspacing=1>"&_
	"<TR><Td align=center>"
	response.write"<DIV align=center><script language=""javascript"" src=""Class_votedy.asp""></script></DIV>"
	response.write"</td></tr><tr><td align=center height=30><a href=""Class_ClassVote.asp?ClassID="&ClsID&"&Action=New"" targer=_blank><img src=images/go.gif border=0 align=absmiddle width=15 hspace=2>发起本校投票</a></td></tr></TABLE>"&_
			"<img src=images/online.gif>"&_
			"</td></tr>"
	end if
	set VoteRs=nothing

End Sub
Sub classnewsphoto()
dim photors,imgTitle,depth
Set photors=Conn.Execute("select top 1 width,height,filename,uptime,depth,visitcount,name,[file],smallfilename from photo where classid="&ClsID&" order by picid desc")
if not (photors.eof and photors.bof) Then
if photors(4)<=8 Then depth=2^(photors(4)) Else depth=photors(4)&"b"

imgTitle="相片提供:"&ClassGetRealname(photors(6))&"&lt;br&gt;"&_
		"上传时间:"&formatdatetime(photors(3),vbShortDate)&"&nbsp;"&formatdatetime(photors(3),vbShortTime)&"&lt;br&gt;"&_
		"人气指数:"&photors(5)&"&lt;br&gt;"&_
		"相片属性:"&photors(0)&"x"&photors(1)&"x"&depth
		
Response.Write "<a href=""Class_Album.asp?ClassID="&ClsID&"""><IMG src="&photors(7)&photors(8)&" title="""&imgTitle&""" border=0 align=center "&sizeadjust(photors(0),photors(1),150)&"></a>"
else
Response.Write "<a href=""Class_Album.asp?ClassID="&ClsID&"""><IMG alt=还没有任何相片:(  src=""images/nopic.gif"" border=0></a>"
end if
set photors=nothing
end sub
Function sizeadjust(byval fotow,byval fotoh,byval shrksize)
	sizeadjust=""
	if fotow="" or fotoh="" Then Exit Function
	if fotow>0 and fotoh>0 Then
		if fotow>shrksize or fotoh>shrksize Then
			if  fotow>=fotoh Then sizeadjust="width="&shrksize Else sizeadjust="height="&shrksize
		End if
	Else
		sizeadjust="width="&shrksize&" height="&shrksize
	End if
End Function

function ClassGetRealname(byval username)
	Dim rSQL,rRs
	ClassGetRealname=""
	if isnull(username) or username="" then exit function
	if joinclass=True then
	rSQL = "select realname from student where userid='"&username&"'"
	set rRs=conn.execute(rSQL)
	if not (rRs.eof and rRs.bof) then
		ClassGetRealname=rRs(0)
	else
		ClassGetRealname=""
	end if
	Set rRs=Nothing
	else 
	ClassGetRealname=username
	end if
end function

Function classPhotoNum() 
	tmprs=Conn.Execute("Select count(picid) from photo where classid="&ClsID) 
    classphotonum=tmprs(0) 
	Set tmprs=Nothing 
	if isnull(classphotonum) Then classphotonum=0 
End Function
Function classliuyanNum() 
	tmprs=Conn.Execute("Select count(postid) from ClassTopicReply where classid="&ClsID) 
    classliuyanNum=tmprs(0) 
	Set tmprs=Nothing 
	if isnull(classliuyanNum) Then classliuyanNum=0 
End Function
sub loginform()
%>
<FORM style="MARGIN: 0px" method="POST" action="Class_Login.asp" name="frmlogin">
    <input type=hidden name=action value=CheckLogin>
	<input name=comeurl type=hidden id="comeurl" value="Class_index.asp?ClassID=<%=ClsID%>">
	用户姓名： 
          <INPUT  onblur="if (value ==''){value='请输入用户名'}" 
                        onmouseover=this.focus() onfocus=this.select() 
                        onclick="if(this.value=='请输入用户名')this.value=''" name=username size=10 maxlength=12 title="忘了用户名请找管理员">
          用户密码： 
          <INPUT name=password type=password size=10 maxlength=12 title="忘了密码请找管理员">
  <INPUT type=submit value=登录 name=submit  class=button> <input type=button value=注册 onClick="location.href='Class_Register.asp'" title=注册校友录 class=button> </FORM>
<%
end sub
%>

<!--#INCLUDE FILE="inc/grade.asp" -->
<%Call footer%>