<!--#INCLUDE FILE="setup.asp" -->
<!--#INCLUDE FILE="checkuser.asp" -->
<!--#INCLUDE FILE="theme.asp" -->
<%response.buffer=true
Dim Locat
Locat="班级首页"

Dim ClsID,Degree,ClassName
ClsID=Request("ClassID")

if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=login.asp>登录</a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
ElseIf ChkClass()=False Then
  	ErrMsg=ErrMsg+"<br>"+"<li>对不起，您要访问的班级不存在或者您还没有正式加入这个班级！"
	Call top(1,1)
	Call Error("Exclamation",ErrMsg)
Else
	Call top(2,1)
	Dim isAppendShow
	response.write "<table align=center width=100% cellspacing=0 cellpadding=0>"&_
		"<tr><td valign=top><BR>"
	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="include/classmenu.asp" -->
	<%Call LastVote():Call OnlineClassmate()
	response.write "</td></tr></table>"
End if


Function ChkClass()

	dim VisitedClasses,ClassArr,visited
	dim sql

	if chkjoinclass(ClsID)="" and Degree<>9 Then

		VisitedClasses=Request.cookies("fytxl")("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=now() where userid='"&membername&"' and classid="&ClsID
			Conn.Execute(sql)
		Else
			sql="update joinclass set visitcount=visitcount+1,lastvisit=now() where userid='"&membername&"' and classid="&ClsID
			Conn.Execute(sql)
			sql="update class set visitcount=visitcount+1 where classid="&ClsID
			Conn.Execute(sql)
			Response.cookies("fytxl")("visitedclasses")=ClsID&vbCr&VisitedClasses
		End if

		ChkClass=True
	ElseIf Degree=9 then
		ChkClass=True
	Else
		ChkClass=False
	End if

End Function



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=GetRealname(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=510 border=0>"&_
		"<TR><TD nowrap><IMG src=""images/welcome.gif"" align=absmiddle>&nbsp;"&_
		GetRealname(membername)&"，欢迎您的光临！</TD>"&_
		"<TD valign=middle align=right>"
	Call myclasslist()
	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 "系统管理员"	Else response.write Grade(Degree,False)
	response.write "</font>。</TD></TR>"&_
		"<TR><TD  vAlign=top width=153 height=20 colspan=2></TD>"&_
		"</TR></TABLE>"&_
		"<TABLE cellSpacing=0 cellPadding=0 width=510 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(1)&"落户！::::::::<br></td></tr>"&_
		"<TR><TD class=mp>我们的家园靠我们自己建设，各位同学一定要常来做客，让我们来共同建设好我们的网上新家园!<br>"&_
		"希望大家在同学会玩得开心！如果您在使用上有什么不清楚的地方，请您参看<A 	target=_blank href=""Help.asp"">帮助文件</A>，或者向我们<a href=""mailto:"&StrVar(2)&""">询问</a>！<BR>"
	Call remindbirthday()
	response.write "<br><img src=images/pronouncement.gif><br><br>"
	if Rs(9)<>"" Then 
		Response.write htmlencode(Rs(9)) 
	Else 
		Response.write "共同度过的生活是灿烂的，也是沉重的。<BR>这份灿烂与沉重也是一种生活 <BR>"&_
			"也是一种记忆<BR>至少它是<BR>至少我认为它是“人生大树”上最红的那一片小叶<BR>"&_
			"虽无百花之香，却有其神<BR>虽小，却有其重<BR>愿与诸君佳人共赏，共识之..."
	End if
	response.write "</TD></TR></TABLE><BR>"&_
		"<TABLE cellSpacing=0 cellPadding=0 width=510 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=""Profile.asp?Name="&Rs(5)&"&Action=showdetail"" target=_blank>"&creator&"</a>"&_
		"</TD></TR>"&_
		"<TR height=20 vAlign=bottom><TD width=""50%"">班级成员：<FONT color=#cc0000><B>"&Rs(8)&"</B></FONT> ["&_
		"<A href=""ClassMate.asp?ClassID="&ClsID&""">查看</A>]</TD>"&_
		"<TD vAlign=bottom width=""50%"" colspan=2>本校教师：<FONT color=#cc0000><B>"&teachercount&_
		"</B></FONT> [<A href=""TeacherList.asp"">查看/添加</A>]</TD></TR>"&_
		"<TR height=20 vAlign=bottom><TD width=""50%"">现任管理员："&GetRealname(Rs(6))&"&nbsp;"&GetRealname(Rs(7))&"</TD>"&_
		"<TD width=""50%"" colSpan=2>附加通信录：<FONT color=#cc0000><B>"&appendcount&"</B></FONT>"&_
		" [<A href=""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>"
	Call ClassBoard()
	response.write "</TD></TR></TABLE>"&_
		"<br><BR><BR>"

	Set Rs=Nothing

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(date()) and day(s.birthday)=day(date()) and j.isauditing=False and j.classid="&ClsID)
	
	if BirRs.eof and BirRs.bof Then Exit Sub

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

	While not BirRs.eof
		age=datediff("yyyy",BirRs(2),date())
		Response.write "<a href=""Profile.asp?Action=showdetail&Name="&BirRs(0)&_
			""" target=_blank  title=""祝"&age&"岁生日快乐！"">"&BirRs(1)&"</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=True 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>未通过审核同学："

	While not WaitRs.eof
		Response.write "<a href=""Profile.asp?Action=showdetail&Name="&WaitRs(0)&_
			""" target=_blank  title=""查看"&WaitRs(1)&"的个人信息！"">"&WaitRs(1)&"</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=False 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=""Profile.asp?Action=showdetail&Name="&OnlineRs(1)&_
		""" target=_blank  title=""查看"&OnlineRs(0)&_
		"的个人信息！"">"&OnlineRs(0)&"</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")
	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=false order by J.jointime desc")

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

	set NewStudentRs=nothing
End Function



Sub ClassBoard()
%>
	<TABLE cellSpacing=0 cellPadding=0 width=510 border=0> 
	<TR><TD vAlign=top height=36 colspan=3><IMG src="images/class_gbook.gif"></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 5 S.realname,B.id,B.title,B.signtime from classboard B inner join student S "&_
	"on B.name=S.userid where B.classid="&ClsID&" order by B.id desc"
	BoardRs.Open BoardSQL,Conn,1,1
	Do until BoardRs.eof
	popinfo="作者："&htmlencode(BoardRs(0))&"发表于"&BoardRs(3)&"..."
	response.write "<TABLE cellSpacing=0 cellPadding=0 width=510 border=0>"&_
		"<TR vAlign=bottom><TD align=left width=250 height=19>"&_
		"<a href=""ClassBoard.asp?ClassID="&ClsID&"#"&BoardRs(1)&""" title="""&popinfo&""">&nbsp;"&htmlencode(BoardRs(2))&"</a></TD>"&_
		"<TD align=left width=100>&nbsp;&nbsp;"&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=False order by C.classname"
	Set MyClassRs=Conn.Execute(MyClassSQL)
		Response.write "<select name=myclasslist onchange=""location.href='MyClass.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=script/vote.js></script>"&_
			"<tr><td background=images/GreenBG.gif><BR><TABLE width=""90%"" align=center cellspacing=1>"&_
			"<form name=theVote action=""Poll.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)=True 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=""Poll.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>"
	end if
	set VoteRs=nothing

End Sub

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

%>

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


