<!-- #include file=../inc/BBSSetup.asp -->
<!-- #include file=../inc/Board_Popfun.asp -->
<%
DEF_BBS_HomeUrl = "../"
OpenDatabase
If Request.QueryString("t") = "1" Then
	DisplayTopicAssort
Else
	DisplayUserOnline
End If
Dim ID

Function DisplayUserOnline

	ID = Left(Request.QueryString("id"),14)

	If isNumeric(ID) = False Then ID = 0
	ID = Fix(cCur(ID))
	
	%>
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<meta http-equiv="Content-Language" content="zh-cn">
<body>

<script language=javascript>
var tempstr="";
parent.document.LeadImg<%=ID%>.loaded="yes";
<%DisplayAnnouncesSplitPages(ID)%>
parent.LeadTD<%=ID%>.innerHTML = tempstr;
</script>
<BODY></BODY></HTML>
<%

End Function

Function DisplayAnnouncesSplitPages(Form_RootID)

	Dim RootID,TopicSortID,Temp1
	Dim SQLEndString,Upflag,WhereFlag
	RootID=cCur(Form_RootID)
	TopicSortID = Left(Request.QueryString("TopicSortID"),14)
	If isNumeric(TopicSortID) = 0 Then TopicSortID = 0
	TopicSortID = cCur(TopicSortID)
	If TopicSortID < 0 Then TopicSortID = 0
	Dim Rs,SQL
	Dim ALL_FirstTopicSortID,ALL_LastTopicSortID

	Dim ALL_Count
	SQL = "Select ParentID,ChildNum,RootMaxID,RootMinID,BoardID from LeadBBS_Announce where ID=" & RootID
	Set Rs = Con.ExeCute(SQL)
	If Not Rs.Eof Then
		If cCur(Rs(0)) <> 0 Then
			Rs.Close
			Set Rs = Nothing
			Exit Function
		End If
		ALL_Count = cCur(Rs(1))
		ALL_FirstTopicSortID = cCur(Rs(3))
		ALL_LastTopicSortID = cCur(Rs(2))
		GBL_Board_ID = cCur(Rs(4))
	Else
		ALL_Count = 0
		Rs.Close
		Set Rs = Nothing
		Exit Function
	End If
	Rs.Close
	Set Rs = Nothing

	WhereFlag = 0

	Upflag = Request("Upflag")
	If Upflag<>"1" and Upflag<>"0" Then Upflag="0"
	If Upflag="0" and TopicSortID>=ALL_LastTopicSortID Then TopicSortID = ALL_LastTopicSortID-1
	If Upflag="1" and TopicSortID<=ALL_FirstTopicSortID Then TopicSortID = ALL_FirstTopicSortID+1
	Dim HaveTopicSortIDFlag
	Dim FirstTopicSortID,LastTopicSortID
	Dim GetData
	
	If RootID<>0 Then
		If ALL_Count<DEF_MaxListNum Then
			If DEF_EnableTreeView = 1 then
				SQLEndString = " Where boardid=" & GBL_board_ID & " and RootIDBak=" & RootID & " order by ID ASC"
			Else
				SQLEndString = " Where RootIDBak=" & RootID & " order by ID ASC"
			End If
		Else
			If Upflag="0" Then
				If WhereFlag = 1 Then
					SQLEndString = " where boardid=" & GBL_board_ID
					WhereFlag = 1
					SQLEndString = SQLEndString & " and (RootIDBak=" & RootID & " and ID>" & TopicSortID & ")"
				Else
					SQLEndString = SQLEndString & " Where (RootIDBak=" & RootID & " and ID>" & TopicSortID & ")"
					WhereFlag = 1
				End If
			Else
				If WhereFlag = 1 Then
					SQLEndString = " where boardid=" & GBL_board_ID
					WhereFlag = 1
					SQLEndString = SQLEndString & " and (RootIDBak=" & RootID & " and ID<" & TopicSortID & ")"
				Else
					SQLEndString = SQLEndString & " where (RootIDBak=" & RootID & " and ID<" & TopicSortID & ")"
					WhereFlag = 1
				End If
			End If

			If Upflag="0" Then
				SQLEndString = SQLEndString & " order by ID ASC"
			Else
				SQLEndString = SQLEndString & " order by ID DESC"
			End If
		End If
		SQL = "Select top " & DEF_MaxListNum & " id,Title,ndatetime,UserName,UserID,TitleStyle from LeadBBS_Announce " & SQLEndString
		Set Rs = Con.ExeCute(SQL)
		GBL_DBNum = GBL_DBNum + 1
		If Not Rs.Eof Then
			HaveTopicSortIDFlag = 1
			GetData = Rs.GetRows(-1)
		Else
			HaveTopicSortIDFlag = 0
		End If
		Rs.Close
		Set Rs = Nothing
	Else
		HaveTopicSortIDFlag = 0
	End If

	If HaveTopicSortIDFlag = 1 Then
		Temp1 = Ubound(GetData,2)
		FirstTopicSortID = cCur(GetData(0,0))
		LastTopicSortID = cCur(GetData(0,Temp1))

		If FirstTopicSortID>LastTopicSortID Then
			SQL = LastTopicSortID
			LastTopicSortID = FirstTopicSortID
			FirstTopicSortID = SQL
		End If
	Else
		Temp1 = 0
	End If

	If ALL_Count>=DEF_MaxListNum Then
	SQL = "?BoardID=" & GBL_board_ID
	If ID <> 0 Then SQL = SQL & "&ID=" & Form_RootID
	Dim PageSplitString
	PageSplitString = "<tr bgcolor=" & DEF_BBS_LightestColor & " height=25 class=TBBG9><td colspan=5><img src=" & DEF_BBS_HomeUrl & "images/null.gif width=2 height=3><br>&nbsp; &nbsp; "
	If FirstTopicSortID<=ALL_FirstTopicSortID Then
		PageSplitString = PageSplitString & "<font color=888888 class=GrayFont>首页</font>"
		PageSplitString = PageSplitString & " <font color=888888 class=GrayFont>上页</font>"
	Else
		PageSplitString = PageSplitString & "<a href=SmallList.asp" & SQL & " target=hiddenframe>首页</a>"
		PageSplitString = PageSplitString & " <a href=SmallList.asp" & SQL & "&RootID=" & RootID & "&TopicSortID=" & FirstTopicSortID & "&Upflag=1 target=hiddenframe>上页</a>"
	End If

	If LastTopicSortID>=ALL_LastTopicSortID Then
		PageSplitString = PageSplitString & " <font color=888888 class=GrayFont>下页</font>"
		PageSplitString = PageSplitString & " <font color=888888 class=GrayFont>尾页</font>"
	Else
		PageSplitString = PageSplitString & " <a href=SmallList.asp" & SQL & "&RootID=" & RootID & "&TopicSortID=" & LastTopicSortID & " target=hiddenframe>下页</a>"
		PageSplitString = PageSplitString & " <a href=SmallList.asp" & SQL & "&Upflag=1&TopicSortID=" & ALL_LastTopicSortID+1 & " target=hiddenframe>尾页</a>"
	End If
	Rs = Temp1
	If HaveTopicSortIDFlag = 1 Then Rs = Rs+1
	PageSplitString = PageSplitString & " 相关帖共有<b>" & ALL_Count &"</b>帖 此页<b>" & Rs & "</b>帖 每页<b>" & DEF_MaxListNum & "</b>帖 执行时间" & fix(abs(CDBL(Timer)*1000 - DEF_PageExeTime1*1000)) & "毫秒"
	PageSplitString = PageSplitString & "</td></tr>"
	End If

	Dim For1,For2,StepValue
	%>
	tempstr+="<table width=100% border=0 cellspacing=1 cellpadding=1 align=center>";
	<%
	If HaveTopicSortIDFlag = 1 Then
		If Upflag="0" Then
			For1 = 0
			For2 = Temp1
			StepValue = 1
		Else
			For1 = Temp1
			For2 = 0
			StepValue = -1
		End If
		DisplayAnnounceData For1,For2,StepValue,GetData
		Response.Write "tempstr+=""" & PageSplitString & """;" & VbCrLf
	End If
	Response.Write "tempstr+=""</table>"";" & VbCrLf

	Set Rs = Nothing

End Function

Function DisplayAnnounceData(For1,For2,StepValue,GetData)

	Dim N,Temp
	For N = For1 to For2 Step StepValue
		If ID <> cCur(GetData(0,N)) Then
			Response.Write "tempstr+=""<tr><td align=left>"";" & VbCrLf	
			If N = For2 Then
				Response.Write "tempstr+=""&nbsp; &nbsp; └"";" & VbCrLf
			Else
				Response.Write "tempstr+=""&nbsp; &nbsp; ├"";" & VbCrLf
			End If
			Response.Write "tempstr+="" <a href=" & DEF_BBS_HomeUrl & "Announce/Announce2.asp?BoardID=" & GBL_Board_ID & "&ID=" & GetData(0,N) & ">"";" & VbCrLf
		Else
			Response.Write "tempstr+=""&nbsp; &nbsp; &nbsp;<font color=Gray class=GrayFont>"";" & VbCrLf
		End If
		If GetData(5,n) <> 1 and Len(GetData(1,N))>DEF_BBS_DisplayTopicLength Then GetData(1,N) = Left(GetData(1,N),DEF_BBS_DisplayTopicLength-3) & "..."
		If GetData(5,n) <> 1 Then GetData(1,n) = Replace(GetData(1,n) & "","<","&lt;")
		GetData(1,n) = DisplayAnnounceTitle(GetData(1,n),GetData(5,n))
		If GetData(5,n) >=60 Then
			GetData(1,n) = "<font color=gray class=GrayFont>帖子等待审核中...</font>"
			GetData(5,n) = 1
		End If
		GetData(1,n) = Replace(Replace(GetData(1,N) & "","\","\\"),"""","\""")
		If Left(GetData(1,n),3) = "re:" Then GetData(1,n) = Mid(GetData(1,n),4)
		Response.Write "tempstr+=""" & GetData(1,n) & """;" & VbCrLf
		If ID <> cCur(GetData(0,N)) Then
			Response.Write "tempstr+=""</a>"";" & VbCrLf
		Else
			Response.Write "tempstr+=""</font>"";" & VbCrLf
		End If
		If cCur(GetData(4,N)) > 0 Then
			Response.Write "tempstr+="" [<a href=" & DEF_BBS_HomeUrl & "User/LookUserInfo.asp?ID=" & GetData(4,N) & ">" & GetData(3,N) & "</a> "";" & VbCrLf
		Else
			Response.Write "tempstr+="" [" & GetData(3,N) & " "";" & VbCrLf
		End If
		Temp = RestoreTime(GetData(2,N))
		If DateDiff("d",Temp,DEF_Now)<1 Then Response.Write "tempstr+="" <font color=990000 class=RedFont>"";" & VbCrLf
		Response.Write "tempstr+=""" & Temp & "]</td></tr>"";" & VbCrLf
	Next

End Function

Function DisplayTopicAssort

	%>
	
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<meta http-equiv="Content-Language" content="zh-cn">
<body>

<script language=javascript>
var tempstr="";
parent.document.followImg1.loaded="yes";
<%DisplayTopicAssortString%>
parent.followTd1.innerHTML = tempstr;
</script>
<BODY></BODY></HTML>
	<%

End Function

Sub DisplayTopicAssortString

	Dim TArray,N,Num
	TArray = Application(DEF_MasterCookies & "BoardInfo" & GBL_Board_ID & "_TI")
	If isArray(TArray) = False Then Exit Sub
	Num = Ubound(TArray,2)
	If GBL_TableHeadString <> "" Then
		Response.Write "tempstr+=""<table width=100% border=0 cellspacing=0 cellpadding=0 align=center><tr><td>" & GBL_TableHeadString & "</td></tr></table>"";" & VbCrLf
	End If
	Response.Write "tempstr+=""<table width=100% border=0 cellspacing=0 cellpadding=0 align=center bgcolor=" & DEF_BBS_DarkColor & " class=TBone>"";" & VbCrLf
	Response.Write "tempstr+=""<tr><td>"";" & VbCrLf
	Response.Write "tempstr+=""<table width=100% border=0 cellspacing=1 cellpadding=3 align=center bgcolor=" & DEF_BBS_LightColor & " class=TBBG1>"";" & VbCrLf
	For N = 0 To Num
		Response.Write "tempstr+=""<tr height=20 bgcolor=" & DEF_BBS_LightestColor & " class=TBBG9 height=25>"";" & VbCrLf
		Response.Write "tempstr+=""<td width=25% >&nbsp;<a href=EBoard.asp?BoardID=" & GBL_Board_ID & "&E=1&EID=" & TArray(0,N) & "><img src=../images/folder.gif width=16 height=16 align=absmiddle border=0>" & TArray(1,N) & "</a></td>"";" & VbCrLf
		N = N + 1
		If N <= Num Then
			Response.Write "tempstr+=""<td width=25% >&nbsp;<a href=EBoard.asp?BoardID=" & GBL_Board_ID & "&E=1&EID=" & TArray(0,N) & "><img src=../images/folder.gif width=16 height=16 align=absmiddle border=0>" & TArray(1,N) & "</a></td>"";" & VbCrLf
		Else
			Response.Write "tempstr+=""<td width=25% > &nbsp;</td>"";" & VbCrLf
		End If
		N = N + 1
		If N <= Num Then
			Response.Write "tempstr+=""<td width=25% >&nbsp;<a href=EBoard.asp?BoardID=" & GBL_Board_ID & "&E=1&EID=" & TArray(0,N) & "><img src=../images/folder.gif width=16 height=16 align=absmiddle border=0>" & TArray(1,N) & "</a></td>"";" & VbCrLf
		Else
			Response.Write "tempstr+=""<td width=25% > &nbsp;</td>"";" & VbCrLf
		End If
		N = N + 1
		If N <= Num Then
			Response.Write "tempstr+=""<td width=25% >&nbsp;<a href=EBoard.asp?BoardID=" & GBL_Board_ID & "&E=1&EID=" & TArray(0,N) & "><img src=../images/folder.gif width=16 height=16 align=absmiddle border=0>" & TArray(1,N) & "</a></td>"";" & VbCrLf
		Else
			Response.Write "tempstr+=""<td width=25% > &nbsp;</td>"";" & VbCrLf
		End If
		Response.Write "tempstr+=""</tr>"";" & VbCrLf
	Next%>
	tempstr+="</td></tr></table>";
	tempstr+="</table>";
	<%If GBL_TableBottomString <> "" Then
		%>tempstr+="<table width=<%=DEF_BBS_ScreenWidth%> border=0 cellspacing=0 cellpadding=0 align=center><tr><td><%=GBL_TableBottomString%></td></tr></table>";
		<%
	End If%>
	<%

End Sub%>