<!--#INCLUDE FILE="conn.asp" -->
<!--#include file="Class_checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<!--#include file="inc/char.asp" -->
<!--#include file="inc/HTMLEncode.asp" -->
<%
locat="学校论坛"
act="主题列表"
	Dim ClsID,Degree,ClassName,bbsrs
	ClsID=Request("ClassID")

Set bbsRs=Conn.Execute("select classname,passed,bbsopen from class where classid="&Clng(ClsID))

if bbsrs.bof and bbsrs.eof then
ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您要访问的学校不存在或已被删除。"
    Call top(1,1)
Call Error("Information",ErrMsg)

elseif bbsrs(1)=0 and not sysadmin then
ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您要访问的学校还没有通过管理员的审核,暂时不能访问!"
Call top(1,1)
	Call Error("Information",ErrMsg)

elseif bbsrs(2)=0 then
if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=Class_Login.asp><font color=red>登录或注册校友录</font></a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
	
Else
	joinstatus=chkjoinclass(ClsID)
	if joinstatus<>"" Then
		Call top(1,1)
		Call Error("Exclamation",joinstatus)
	else
		Call top(2,1)
		call main()
end if
end if
else
classname=bbsrs(0)
Call top(2,1)
call main()
end if
set bbsrs=nothing

sub main()
Dim tl
Dim currentPage,TotalPages
Dim rs,sql
Dim MaxTopicList

MaxTopicList=20

if Request("TimeLimit")="all" Then
	tl=""
ElseIf Request("TimeLimit")="" Then
	tl=""
Else
	limitime=Request("TimeLimit")
	tl=" and T.PostTime>='"&cstr(cdate(now()-limitime))&"'"
End if

Set rs=server.createobject("adodb.recordset")
sql="Select T.PostID,T.UserID,T.Title,T.PostTime,T.hits,T.Replys,T.mood,T.Locked,T.isTop,T.LastReply,T.LastTime,C.realname from ClassTopic T inner join student C on T.userid=C.userid where T.classid="&ClsID&" "&tl&" order by T.istop desc,T.LastTime desc"
rs.open sql,conn,1,1
%>
<br>
<Script language="javascript" src="inc/PopText.asp"></Script>
<table width=100% align=center border=0>
<tr><td align=left height=26 valign=bottom><a href=Class_bbs_NewTopic.asp?Classid=<%=Clsid%>><IMG SRC="IMAGES/newthread.gif" BORDER=0 ALT=""></a></td>
<td align=right valign=bottom>
	<Select name=TimeLimit onChange="document.location.href='Class_bbs_index.asp?Classid=<%=Clsid%>&TimeLimit='+TimeLimit.value;">
	<option value=all <%if limitime="" Then Response.Write "selected"%>>查看所有的主题
	<option value=1 <%if limitime=1 Then Response.Write "selected"%>>查看一天内的主题
	<option value=2 <%if limitime=2 Then Response.Write "selected"%>>查看两天内的主题
	<option value=7 <%if limitime=7 Then Response.Write "selected"%>>查看一星期内的主题
	<option value=15 <%if limitime=15 Then Response.Write "selected"%>>查看半个月内的主题
	<option value=30 <%if limitime=30 Then Response.Write "selected"%>>查看一个月内的主题
	<option value=60 <%if limitime=60 Then Response.Write "selected"%>>查看两个月内的主题
	<option value=180 <%if limitime=180 Then Response.Write "selected"%>>查看半年内的主题
	</Select>
</td></tr></table>
<table width=100% border=0 cellspacing=1 cellpadding=4 Class=TableBorder align=center>
<tr height=23><th width=32 align=center>状态</th><th  align=center width=*> 主 题(点心情符为开新窗浏览)</th>
<th width=80  align=center>作&nbsp;者</th><th width=32 align=center>回复</th><th width=32>浏览</th>
<th align=center>最后发表</th></tr>
<%
if rs.bof and rs.eof Then
%>
<tr Class=DarkTableBody><td colSpan=6 width=100% height=27>本校论坛暂无帖子主题，欢迎发表帖子：）
</td></tr>
</table>
<%

Else

	rs.pagesize=MaxTopicList
	TotalPages=rs.pagecount
	totalrecords=rs.recordcount
	currentPage=Request("Page")
	if currentpage="" or not isinteger(currentpage) Then
		currentpage=1
	elseif cint(currentpage)>TotalPages then
		currentpage=TotalPages
	End if
	currentpage=Clng(currentpage)
	rs.absolutepage=currentpage
	
'''''''''''''''''''''''Call showTopiclist() 
dim i
dim popinfo
dim LastReply,LastPoster,LastReplyID
dim topicname

for i=1 to MaxTopicList
if membername<>"" then
topicname=rs(11)
if len(topicname)=2 Then
topicname=left(topicname,1)&"&nbsp;&nbsp;"&right(topicname,1)
End if
else
topicname=rs(1)
end if

Response.Write "<TR align=middle>"&_
				"<TD Class=DarkTableBody width=32 height=27>"
If rs(8)=1 Then
	Response.Write "<img src=images/folder_top.gif alt=固顶主题>"
ElseIf rs(7)=1 Then
	Response.Write "<img src=images/folder_locked.gif alt=本主题已锁定>"
ElseIf rs(5)>=10 Then
	Response.Write "<img src=images/folder_hot.gif alt=热门主题>"
Else
	Response.Write "<img src=images/folder_general.gif alt=开放主题>"
End if

Response.Write "</TD>"&_
				"<TD align=""left"" bgcolor="&LightTBColor&" onmouseover=""javascript:this.bgColor='"&DarkTBColor&"';"" onmouseout=""javascript:this.bgColor='"&LightTBColor&"';"" width=*><a href=""Class_bbs_ShowTopic.asp?Classid="&Clsid&"&TopicID="&rs(0)&""" target=_blank title=""打开新窗口浏览""><img src=""images/mood/"&rs(6)&".gif"" align=absmiddle border=0></a>"
popinfo="&nbsp;主题："&htmlencode(rs(2))&"<br>&nbsp;作者："&htmlencode(topicname)&"<br>&nbsp;发表于"&rs(3)&"<br>&nbsp;最后跟贴："
if rs(9)<>"" then 
	LastReply=split(rs(9),vbCr)
	popinfo=popinfo&htmlencode(LastReply(1))
	LastPoster=LastReply(0)
	LastReplyID=LastReply(2)
else
	LastPoster=""
	popinfo=popinfo&"......"
end if

Response.Write "<a href=""Class_bbs_ShowTopic.asp?Classid="&Clsid&"&TopicID="&rs(0)&""" title="""&popinfo&""">"&htmlencode(cutstr(rs(2),36))&"</a>"
MaxPostList=Cint(IntVar(8))
Pnum=1
if rs(5)+1>MaxPostList Then
	Response.Write "&nbsp;&nbsp;<font face=Tahoma,Verdana>(</font><img src=images/pagelist.gif hspace=3 align=absmiddle>"
  	if (rs(5)+1) mod MaxPostList=0 Then
     		Pnum= (rs(5)+1)\MaxPostList
  	Else
     		Pnum= (rs(5)+1)\MaxPostList+1
  	End if

	for p=1 to Pnum
	if p<>1 then response.write "&nbsp;"
	Response.Write "<a href=""Class_bbs_ShowTopic.asp?Classid="&Clsid&"&TopicID="&rs(0)&"&Page="&P&"""><font color=brown>"&p&"</font></a>"
	if p>3 and p<>Pnum and p<>Pnum-1 then 
		response.write "...<a href=""Class_bbs_ShowTopic.asp?Classid="&Clsid&"&TopicID="&rs(0)&"&Page="&Pnum&"""><font color=brown>"&pnum&"</font></a>"
		exit for
	end if
	next
	Response.Write "<font face=Tahoma,Verdana>)</font>"

End if
if membername<>"" and membername<>rs(1) then
	if cdate(Request.cookies("fenglingtxl_520")("logintime"))<rs(3) then
		response.write "<img src=""images/topnew.gif"" align=absmiddle alt=新鲜出炉，请多关注！>"
	end if
elseif datediff("d",rs(3),date())=0 and rs(0)=0 then
response.write "<img src=""images/topnew.gif"" align=absmiddle alt=新鲜出炉，请多关注！>"
end if

Response.Write "</TD>"&_
	"<TD Class=DarkTableBody width=80><a href=""Class_Userinfo.asp?Name="&rs(1)&""" target=_blank title=查看其资料>"&htmlencode(topicname)&"</a></TD>"&_
	"<TD Class=LightTableBody width=32>"&rs(5)&"</td>"&_
	"<td Class=LightTableBody width=32>"&rs(4)&"</TD>"&_
	"<TD align=right Class=DarkTableBody width=175><table cellspacing=0 cellpadding=0 align=right><tr><td align=right>&nbsp;"

st=FormatDateTime(rs(10),vbShortDate)&"&nbsp;"&FormatDateTime(rs(10),vbShortTime)

if LastPoster="" Then
	Response.Write "&nbsp;<a href=""Class_bbs_ShowTopic.asp?Classid="&Clsid&"&TopicID="&rs(0)&""">"&st&"</a>&nbsp;<br><font color=gray>No Reply</font>&nbsp;</td><td width=20 align=center><a href=""Class_bbs_ShowTopic.asp?TopicID="&rs(0)&"""><img src=images/lastpost.gif border=0></a></td>"
Else
if membername="" then thisname=LastPoster else thisname=getrealname(LastPoster)
	Response.Write "&nbsp;<a href=""Class_bbs_ShowTopic.asp?Classid="&Clsid&"&TopicID="&rs(0)&"&Page="&Pnum&"#PID"&_
	LastReplyID&""" title=直接跳转到最后回复帖子>"&st&"</a>&nbsp;<br>By&nbsp;<a href=""Class_Userinfo.asp?Name="&_
	LastPoster&""" target=_blank>"&htmlencode(thisname)&"</a>&nbsp;</td><td width=20 align=center><a href=""Class_bbs_ShowTopic.asp?Classid="&Clsid&"&TopicID="&rs(0)&"&Page="&Pnum&"#PID"&LastReplyID&""" title=直接跳转到最后回复帖子><img src=images/lastpost.gif border=0></a></td>"
End if
Response.Write "</tr></table></td></tr>"

rs.movenext
if currentpage=totalpages then
	if rs.eof then exit for
end if
next
Response.Write "</table>"

''''''''''''''''''''''''''Call pagelinks()
Dim p,ii

p=(currentpage-1) \ 8

Response.Write "<table border=0 cellpadding=0 cellspacing=3 width=100% align=center >"&_
	"<tr><td valign=middle nowrap>页次：<B>"& currentPage &"</B>/<strong>"& totalpages &"</strong> 主题数：<b>"&totalrecords&"</b></td>"&_
	"<td valign=middle align=right nowrap><p>分页："
if currentpage=1 then
response.write "<font face=webdings color=gray>9</font> "
else
response.write "<a href=""?Classid="&Clsid&"&Page=1&TimeLimit="&limitime&""" title=首页><font face=webdings>9</font></a> "
end if

if p*8>0 Then 
	Response.Write "<a href=""?Classid="&Clsid&"&Page="&Cstr(p*8)&"&TimeLimit="&limitime&""" title=上八页><font face=webdings>7</font></a> "
end if
for ii=p*8+1 to P*8+8
	   if ii=currentPage Then
		  Response.Write "<font color=gray><B>"&ii&"</B></font> "
	   Else
		  Response.Write "<a href=""?Classid="&Clsid&"&Page="&ii&"&TimeLimit="&limitime&"""><B>"&ii&"</B></a> "
	   End if
	if ii=totalpages Then Exit for
next
if ii<totalpages Then 
	Response.Write "<a href=""?Classid="&Clsid&"&Page="&ii&"&TimeLimit="&limitime&""" title=下八页><font face=webdings>8</font></a> "
end if
if currentpage=totalpages then
	Response.Write "<font face=webdings color=gray>"&chr(58)&"</font>  "   
else
	Response.Write "<a href=""?Classid="&Clsid&"&Page="&totalpages&"&TimeLimit="&limitime&""" title=尾页><font face=webdings>"&chr(58)&"</font></a>  "   
end if
Response.Write "转到第 <select name=""page"" style=""width:35px"" onChange=""location.href='?Classid="&Clsid&"&TimeLimit="&limitime&"&page='+this.options[selectedIndex].value"">"
'dim i
i=1
do while i<=totalpages
             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
	Response.Write "</select> 页"
Response.Write "</td></tr></table>"

''''''''''''''''''''
End if

%>
<BR><BR>
<table cellspacing=1 cellpadding=5 width=100% border=0 align=center Class=TableBorder>
<tr><th align=left><IMG SRC=IMAGES/2.gif WIDTH=60 HEIGHT=9 BORDER=0>:::帖子图例:::</th></tr>
<tr Class=LightTableBody>
	<td><table width=100% align=center><tr>
			<td align=center><img src=images/folder_general.gif> 开放的主题</td>
			<td align=center><img src=images/folder_hot.gif> 回复超过10贴</td>
			<td align=center><img src=images/folder_locked.gif> 锁定的主题</td>
			<td align=center><img src=images/folder_top.gif> 固定顶端的主题 </td>
		</tr></table>
	</td></tr>
</table>
<BR>
<%
end sub

'Sub showTopicList()

'End Sub

'Sub Pagelinks()

'End Sub 

Call footer()
%>