<%
Const DEF_BBS_MaxListPage = 5

Function DisplayAnnouncesSplitPages

	Dim FullTextKey,Key
	Key = Request("key")
	Dim N
	FullTextKey = key
	If key <> "" Then
		Dim Noise_Chinese
		Noise_Chinese = Array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","`","[","]","{","}",";",":","""","'",",","<",">",".","/","\","|","?","_","about","1","2","3","4","5","6","7","8","9","0","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","after","all","also","an","and","another","any","are","as","at","be","because","been","before","being","between","both","but","by","came","can","come","could","did","do","each","for","from","get","got","had","has","have","he","her","here","him","himself","his","how","if","in","into","is","it","like","make","many","me","might","more","most","much","must","my","never","now","of","on","only","or","other","our","out","over","said","same","see","should","since","some","still","such","take","than","that","the","their","them","then","there","these","they","this","those","through","to","too","under","up","very","was","way","we","well","were","what","where","which","while","who","with","would","you","your","的","一","不","在","人","有","是","为","以","于","上","他","而","后","之","来","及","了","因","下","可","到","由","这","与","也","此","但","并","个","其","已","无","小","我","们","起","最","再","今","去","好","只","又","或","很","亦","某","把","那","你","乃","它")

		FullTextKey = Replace(FullTextKey,"!"," ")
		FullTextKey = Replace(FullTextKey,"]"," ")
		FullTextKey = Replace(FullTextKey,"["," ")
		FullTextKey = Replace(FullTextKey,")"," ")
		FullTextKey = Replace(FullTextKey,"("," ")
		FullTextKey = Replace(FullTextKey,"　"," ")
		FullTextKey = Replace(FullTextKey,"-"," ")
		FullTextKey = Replace(FullTextKey,"/"," ")
		FullTextKey = Replace(FullTextKey,"+"," ")
		FullTextKey = Replace(FullTextKey,"="," ")
		FullTextKey = Replace(FullTextKey,","," ")
		FullTextKey = Replace(FullTextKey,"'"," ")
	
		For N = 0 To Ubound(Noise_Chinese,1)
			If FullTextKey=Noise_Chinese(N) Then
				GBL_CHK_TempStr = "你输入的搜索词<font color=ff0000 class=RedFont>" & htmlencode(Noise_Chinese(N)) & "</font>属于忽略词，系统已经忽略搜索过程。"
				Exit for
			End If
		Next
		
		Dim I,IFlag,TempKey
		If key<>"" then
			TempKey = split(FullTextKey," ")
			FullTextKey = ""
			for N = 0 to ubound(TempKey)
				IFlag = 1
				For I = 0 To Ubound(Noise_Chinese,1)
					If TempKey(N)=Noise_Chinese(I) Then
						'Response.Write "<br>忽略" & TempKey(N)
						IFlag = 0
						Exit for
					End If
				Next
				If IFlag = 1 and TempKey(N)<>"" Then FullTextKey = FullTextKey & TempKey(N) & " and "
			Next
			If Right(FullTextKey,5) = " and " Then FullTextKey = Left(FullTextKey,Len(FullTextKey) - 5)
		End If
	End If
	
	GBL_CHK_TempStr = ""
	Dim Mode
	Mode = Left(Request("Mode"),14)
	If Mode <> "0" and Mode <> "1" and Mode <> "2" and Mode <> "3" Then Mode = "0"
	Mode = cCur(Mode)
	If Key <> "" and DEF_BBS_SearchMode = 1 Then
		Select Case Mode
			'按作者
			Case 1: CloseDatabase
					Response.Redirect "../User/UserAnc.asp?name=" & urlencode(key)
			'按帖子主题
			Case Else: 
					If Replace(key,"ギ","") = "" Then
						GBL_CHK_TempStr = "请输入搜索关键词！"
					Else
						key = Replace(key,"ギ","")
					End If
					SQLendString = " where title like'%" & Replace(key,"'","''") & "%'"
					WhereFlag = 1
		End Select
	Else
		If DEF_BBS_SearchMode = 0 Then
			GBL_CHK_TempStr = "社区不允许搜索！"
		ElseIf key <> "" Then
			GBL_CHK_TempStr = "输入搜索关键词属于忽略词,请重新输入！"
		Else
			GBL_CHK_TempStr = "请输入搜索关键词！"
		End If
	End If

	Dim Rs,SQL,Temp
	Dim ALL_FirstRootID,ALL_LastRootID

	Dim SQLEndString,WhereFlag,OrderColumn,BoardUrlString
	BoardUrlString = "Search.asp"

	Dim page,first

	page = Left(Request("page"),14)
	If isNumeric(page)=0 Then page=0
	page = cCur(page)
	If page < 1 Then
		first = 0
	Else
		first=page*DEF_MaxListNum+1
	End If

	Dim GetData_2
	
	Dim RecordCount,ThisPageNum
	RecordCount = -1
	If Key <> "" and DEF_BBS_SearchMode = 1 Then
		If Replace(key,"ギ","") = "" Then
			GBL_CHK_TempStr = "请输入搜索关键词！"
		End If
		SQL = "select top " & DEF_MaxListNum * DEF_BBS_MaxListPage & " id,ParentID,ChildNum,Layer,Title,FaceIcon,LastTime,Hits,Length,UserName,UserID,RootID,TopicSortID,LastUser,NotReplay,GoodFlag,BoardID,TopicType,PollNum,TitleStyle from LeadBBS_Announce " & SQLEndString
		If first > 0 Then SQL = SQL & " and ID>" & first
	End If
	If GBL_CHK_TempStr = "" Then
		Set Rs = Server.CreateObject("ADODB.RecordSet")
		Rs.Open SQL,con,1,1
	Else
		If GBL_ShowBottomSure = 0 Then GBL_SiteBottomString = ""%>
		<table width="100%" border="0" cellspacing="1" cellpadding="3" align="center">
		<tr bgcolor=<%=DEF_BBS_LightColor%> class=TBBG1>
			<td>&nbsp;<%=GBL_CHK_TempStr%></td>
		</tr></table><%
		Exit Function
	End If
	If Not Rs.Eof Then
		If RecordCount = -1 Then
			RecordCount = Rs.RecordCount
			If RecordCount = -1 Then
				For N = 1 to first
					If Not Rs.Eof Then
						Rs.MoveNext
					Else
						Exit For
					End If
				Next
			Else
				If first > RecordCount Then first = RecordCount - DEF_MaxListNum
				If first>0 and first <= RecordCount Then Rs.absoluteposition = first
			End If
		Else
			If first > RecordCount Then first = RecordCount - DEF_MaxListNum
			For N = 1 to first
				Rs.MoveNext
			Next
		End If
		GetData_2 = Rs.GetRows(DEF_MaxListNum+1)
		ThisPageNum = Ubound(GetData_2,2) + 1
		Rs.Close
	Else
		RecordCount = 0
		ThisPageNum = 0
		Rs.Close
	End If
	If ThisPageNum > RecordCount Then RecordCount = ThisPageNum
	Set Rs = Nothing

	SQL = "?key=" & urlencode(Request("key"))
	SQL = SQL & "&mode=" & urlencode(Request("mode"))
	Dim PageSplitString

	PageSplitString = "<tr bgcolor=" & DEF_BBS_LightestColor & " height=25 class=TBBG9><td colspan=5><img src=..images/null.gif width=2 height=3><br>&nbsp;"
	
	'If page > 0 Then
	'	PageSplitString = PageSplitString & "<a href=Search.asp" & SQL & ">首页</a>"
	'Else
	'	PageSplitString = PageSplitString & "<font color=888888 class=GrayFont>首页</font>"
	'End If
	'If RecordCount > DEF_MaxListNum Then
	'	PageSplitString = PageSplitString & " <a href=Search.asp" & SQL & "&page=" & page + 1 & ">下一页</a>"
	'End If
	
	PageSplitString = PageSplitString & " 转到第"
	page = fix(page)
	If RecordCount > DEF_MaxListNum Then
		Temp = Page + 2
	Else
		Temp = Page + 1
	End If
	If Temp >= DEF_BBS_MaxListPage Then Temp = DEF_BBS_MaxListPage
	For N = 1 to Temp
		If N = page+1 Then
			PageSplitString = PageSplitString & " <font color=888888 class=GrayFont>" & N & "</font>"
		Else
			PageSplitString = PageSplitString & " <a href=Search.asp" & SQL & "&page=" & N-1 & ">" & N & "</a>"
		End If
	Next
	PageSplitString = PageSplitString & " 页"

	PageSplitString = PageSplitString & " 此页<b>" & ThisPageNum & "</b>条 每页<b>" & DEF_MaxListNum + 1 & "</b>条"
	PageSplitString = PageSplitString & "</td></tr>"
	If ThisPageNum < DEF_MaxListNum and GBL_ShowBottomSure = 0 Then GBL_SiteBottomString = ""
	%>
	<table width="100%" border="0" cellspacing="1" cellpadding="3" align="center">
	<%=PageSplitString%>
	<tr height=20 bgcolor=<%=DEF_BBS_LightDarkColor%> align=center class=TBHead2>
		<td width=20 align=center><img src=<%=DEF_BBS_HomeUrl%>images/null.gif width=2 height=2><br><b><font color=ffffff class=HeadFont>ID</font></b></td>
		<td align=left><img src=<%=DEF_BBS_HomeUrl%>images/null.gif width=300 height=2><br>&nbsp;<b><font color=ffffff class=HeadFont>主题</font></b></td>
		<td width=84><img src=<%=DEF_BBS_HomeUrl%>images/null.gif width=2 height=2><br><b><font color=ffffff class=HeadFont>作者</font></b></td>
		<td width=50 align=center><img src=<%=DEF_BBS_HomeUrl%>images/null.gif width=2 height=2><br><b><font color=ffffff title="回复/点击" class=HeadFont>人气</font></b></td>
		<td width=210 align=left><img src=<%=DEF_BBS_HomeUrl%>images/null.gif width=5 height=2><br><img src=<%=DEF_BBS_HomeUrl%>images/null.gif width=3 height=2><b><font color=ffffff class=HeadFont>　　最后更新　　| 回复人</font></b></td>
	</tr><%
	DisplayAnnounceData 0,ThisPageNum-1,1,GetData_2,0
	Response.Write PageSplitString
	Response.Write "</table>"

	Set Rs = Nothing

End Function

Function DisplayAnnounceData(For1,For2,StepValue,GetData,AllFlag)
	
	Dim AnnounceUrlString
	AnnounceUrlString = "Announce2.asp"

	Dim N,Temp,Temp1
	For N = For1 to For2 Step StepValue
		Response.Write "<tr align=center height=25"

		Response.Write " bgcolor=" & DEF_BBS_LightestColor
		Response.Write " class=TBBG9><td>"
		
		If GetData(17,n) = 80 Then
			If cCur(GetData(18,N)) >= 20 Then
				Temp = "vthot"
			Else
				Temp = "vt"
			End If
		Else
			If cCur(GetData(2,N)) >= 20 Then
				Temp = "hot"
			Else
				Temp = "tpc"
			End If			
		End If
		If GetData(14,n) = 1 Then Temp = Temp & "lock"
		Response.Write "<img src=../images/" & GBL_DefineImage & Temp & ".gif align=absbottom width=18 height=18 title=""编号" & GetData(0,N) & """>"
		Response.Write "</td><td align=left>"

		Rem 不显示Layer值
		'If GetData(3,N)>DEF_BBS_MaxLayer Then GetData(3,N)=10
		'Response.Write Replace(string((GetData(3,N)-1),"-"),"-","<ul>")
		Response.Write "<img src=../images/" & GBL_DefineImage & "bf/face" & GetData(5,N) & ".gif align=absbottom width=20 height=20>"

		GetData(8,N) = cCur(GetData(8,N))
		If GetData(8,N) > 1024 Then
			GetData(8,N) = cLng(GetData(8,N)/1024) & " KB"
		Else
			GetData(8,N) = GetData(8,N) & " 字节"
		End If

		If cCur(GetData(1,n)) = 0 Then
			AnnounceUrlString = "Announce.asp"
		Else
			AnnounceUrlString = "Announce2.asp"
		End If
		Response.Write " <a href=../Announce/" & AnnounceUrlString & "?BoardID=" & GetData(16,N) & "&ID=" & GetData(0,N) & " title=""" & GetData(8,N) & """"
		If AllFlag = 1 Then
			Response.Write " target=_blank>"
		Else
			Response.Write ">"
		End If

		GetData(2,N) = cCur(GetData(2,N))
		Temp1 = Fix((GetData(2,N)+1)/DEF_TopicContentMaxListNum)
		If ((GetData(2,N)+1) mod DEF_TopicContentMaxListNum) > 0 Then Temp1 = Temp1 + 1
		If GetData(2,N)>=DEF_TopicContentMaxListNum Then
			Temp = DEF_BBS_DisplayTopicLength - (Len(Temp1) + 3)
		Else
			Temp = DEF_BBS_DisplayTopicLength
		End If
		
		'If GetData(15,n) = True or GetData(15,n) = 1 Then Temp = Temp - 3
		
		If left(GetData(4,N),3) = "re:" and GetData(4,N) <> "re:" Then GetData(4,N) = Mid(GetData(4,N),4)
		If GetData(19,n) <> 1 and strLength(GetData(4,N))>Temp Then GetData(4,N) = LeftTrue(GetData(4,N),Temp-3) & "..."
		Response.Write DisplayAnnounceTitle(GetData(4,n),GetData(19,n))
		Response.Write "</a>"

		If GetData(2,N)>=DEF_TopicContentMaxListNum Then
			Response.Write " [<a href=../Announce/Announce.asp?BoardID=" & GetData(16,N) & "&ID=" & GetData(0,N) & "&AUpflag=1&ANum=1>" & Temp1 & "</b></a>]"
		End If

		'If GetData(15,n) = 1 or GetData(15,n) = True Then
		'	Response.Write "<img src=../images/" & GBL_DefineImage & "jh1.GIF border=0 title=精华帖子 align=absbottom width=16 height=16>"
		'End If

		GetData(10,N) = cCur(GetData(10,N))
		If GetData(10,N) > 0 Then
			Response.Write "</td><td><a href=../User/LookUserInfo.asp?ID=" & GetData(10,N) & ">" & htmlencode(GetData(9,N)) & "</a></td><td>"
		Else
			Response.Write "</td><td>" & htmlencode(GetData(9,N)) & "</td><td>"
		End If

		If isNull(GetData(18,N)) Then GetData(18,N) = 0
		If GetData(17,n) = 80 Then
			Response.Write "共" & cCur(GetData(18,N)) & "票"
		Else
			Response.Write GetData(2,N) & "/" & GetData(7,N)
		End If
		Response.Write "</td><td width=210 align=left>&nbsp;"
		Temp = RestoreTime(GetData(6,N))
		If DateDiff("d",Temp,DEF_Now)<1 Then Response.Write "<font color=990000 class=RedFont>"
		If GetData(13,n) = "" or isNull(GetData(13,n)) Then
			Response.Write Left(Temp,16) & " | --------</td></tr>"
		Else
			If GetData(10,N) <> "游客" Then
				Response.Write Left(Temp,16) & " | <a href=" & DEF_BBS_HomeUrl & "User/LookUserInfo.asp?name=" & urlencode(GetData(13,N)) & ">" & htmlencode(GetData(13,n)) & "</a></td></tr>"
			Else
				Response.Write Left(Temp,16) & " | " & htmlencode(GetData(13,n)) & "</td></tr>"
			End If
		End if
	Next

End Function
%>