<!-- #include file=../../inc/BBSSetup.asp -->
<!-- #include file=../../inc/Board_Popfun.asp -->
<%
'----------------------------------------------------------------------------------------
'----- LeadBBS主题帖子调用(2003-7-2)
'----- 调用举例: <script language=javascript src=http://安装目录/other/Article/topic.asp?BoardID=1&Number=20&StrLen=12&NewWindow=yes></script>
'----- 表示显示版面ＩＤ号为1的版面的最新20条主题，主题字数超过12个字节的以12字节显示(一个汉字为两个字节)
'----- 参数：BoardID 版面ＩＤ号，如果不指定，则表示调用论坛最新10条主题
'----- Number：显示记录条数，最多允许调用100条，不指定默认调用10条主题
'----- StrLen：有的帖子主题可能太长，为了美化显示效果，限制显示主题的字节长度
'----- NewWindow：在新窗口中打开请设置为yes，其它表示否
'----- PithFlag：是否调用精华，1-表示仅调用精华帖(可以加上BoardID限制调用版面)
'----------------------------------------------------------------------------------------
'----- 调用某专题区最新主题
'----- <script language=javascript src=http://安装目录/other/Article/topic.asp?GoodAssort=10&Number=20&StrLen=12&NewWindow=yes></script>
'----- 参数：GoodAssort，指专题区编号
'----------------------------------------------------------------------------------------
Dim HomeUrl
HomeUrl = "http://"&Request.ServerVariables("server_name")
If Request.ServerVariables("SERVER_PORT") <> "80" Then HomeUrl = HomeUrl & ":" & Request.ServerVariables("SERVER_PORT")
HomeUrl = Lcase(HomeUrl & Request.Servervariables("SCRIPT_NAME"))
HomeUrl = Replace(HomeUrl,"other/article/topic.asp","")

DEF_BBS_HomeUrl = "../../"
Const LMT_MaxDisplayAnnounce = 100
OpenDatabase
DisplayAnnounceList
closeDataBase

Function DisplayAnnounceList

	Dim BoardID,ListNum,StrLen,GoodAssort
	BoardID = Left(Request.QueryString("BoardID"),14)
	ListNum = Left(Request.QueryString("Number"),14)
	StrLen = Left(Request.QueryString("StrLen"),14)
	GoodAssort = Left(Request.QueryString("GoodAssort"),14)
	If isNumeric(StrLen) = False or StrLen = "" Then StrLen = 20
	StrLen = Fix(cCur(StrLen))
	If isNumeric(ListNum) = False or ListNum = "" Then ListNum = 10
	If isNumeric(BoardID) = False Then BoardID = 0
	BoardID = Fix(cCur(BoardID))
	If isNumeric(GoodAssort) = False Then GoodAssort = 0
	GoodAssort = Fix(cCur(GoodAssort))

	ListNum = Fix(cCur(ListNum))
	If ListNum < 1 or ListNum > 100 Then ListNum = 10
	If StrLen < 1 or StrLen > 255 Then StrLen = 255
	If GoodAssort < 1 Then GoodAssort = 0
	
	Dim NewWindow
	NewWindow = Request.QueryString("NewWindow")
	If NewWindow <> "yes" Then
		NewWindow = ""
	Else
		NewWindow = " target=_blank"
	End If

	Dim Rs,SQL
	Set rs = Server.CreateObject("ADODB.Recordset")

	If GoodAssort > 0 Then
		SQL = "select TOP " & ListNum & " ID,Title,TitleStyle,BoardID from LeadBBS_Topic Where GoodAssort=" & GoodAssort & " Order by ID DESC"
	Else
		If Request.QueryString("PithFlag") = "1" Then
			If BoardID = 0 Then
				SQL = "select TOP " & ListNum & " ID,Title,TitleStyle,BoardID from LeadBBS_Topic Where GoodFlag=1 Order by ID DESC"
			Else
				SQL = "select TOP " & ListNum & " ID,Title,TitleStyle,BoardID from LeadBBS_Topic Where GoodFlag=1 and BoardID=" & BoardID & " Order by ID DESC"
			End If
		Else
			If BoardID = 0 Then
				SQL = "select TOP " & ListNum & " ID,Title,TitleStyle,BoardID from LeadBBS_Topic Order by ID DESC"
			Else
				SQL = "select TOP " & ListNum & " ID,Title,TitleStyle,BoardID from LeadBBS_Topic Where BoardID=" & BoardID & " Order by RootID DESC"
			End If
		End If
	End If
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	Dim Num
	Dim GetData
	If Not rs.Eof Then
		GetData = Rs.GetRows(-1)
		Num = Ubound(GetData,2)
	Else
		Num = -1
	End If
	Rs.close
	Set Rs = Nothing
	Response.Write "document.write("""
	'Response.Write "执行时间" & fix(abs(CDBL(Timer)*1000 - DEF_PageExeTime1)) & "ms 数据库" & GBL_DBNum & "次<br>"
	For SQL = 0 to Num
		If GetData(2,SQL) = 1 Then GetData(1,SQL) = KillHTMLLabel(GetData(1,SQL))
		If Len(GetData(1,SQL)) > StrLen/2 Then
			If StrLength(GetData(1,SQL)) > StrLen Then
				GetData(1,SQL) = LeftTrue(GetData(1,SQL),StrLen - 3) & "..."
			End If
		End If
		Response.Write "<li><a href=" & HomeUrl & "announce/announce.asp?BoardID=" & GetData(3,SQL) & "&id=" & GetData(0,SQL) & NewWindow & ">" & Replace(htmlencode(GetData(1,SQL)),"\","\\") & "</a></li>"
	Next
	Response.Write """);"

End Function%>