<!-- #include file=../inc/BBSsetup.asp -->
<!-- #include file=../inc/Board_Popfun.asp -->
<!-- #include file=../inc/Limit_fun.asp -->
<%
DEF_BBS_HomeUrl = "../"
server.scriptTimeOut = 9999
initDatabase
GBL_CHK_TempStr = ""
siteHead("   转移帖子")
%>
<script language=javascript>
	window.moveTo(window.screen.width/2-225,window.screen.height/2-18);
</script>
<%
UpdateOnlineUserAtInfo GBL_board_ID,"转移帖子"

If GBL_CHK_Flag=1 Then
	If CheckIsCanMoveSure = 1 Then
		DisplayMoveAnnounce
	End If
Else
	If Request("submitflag")="" Then
		Response.Write "<br><b>请先登录</b>"
	Else
		Response.Write "<br><p align=left><font color=ff0000 class=RedFont><b>" & GBL_CHK_TempStr & "</b></font>"
	End If
	Response.Write "</p>"
End If

closeDataBase
SiteBottom_Spend

Function CheckIsCanMoveSure

	If GetBinarybit(GBL_CHK_UserLimit,9) = 1 Then
		Response.Write "错误,权限不足!<br>" & VbCrLf
		CheckIsCanMoveSure = 0
		Exit Function
	End if
	Dim MoveID
	MoveID = Left(Request("MoveID"),14)
	If isNumeric(MoveID) = 0 or inStr(MoveID,",") > 0 or MoveID = "" Then
		Response.Write "错误,要转移的帖子不存在!<br>" & VbCrLf
		CheckIsCanMoveSure = 0
		Exit Function
	End if

	If GBL_CHK_LastWriteTime < DEF_WriteEventSpace Then
		Response.Write "<b><font color=Red Class=RedFont>您的操作太频，请稍候再作提交!</font></b> <br>" & VbCrLf
		CheckIsCanMoveSure = 0
		Exit Function
	End If

	MoveID = cCur(MoveID)
	Dim Rs,SQL
	SQL = "Select top 1 BoardID,ParentID,UserID,RootID from LeadBBS_Announce where id=" & MoveID
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	If Rs.Eof Then
		Response.Write "错误,要转移的帖子不存在!<br>" & VbCrLf
		Rs.Close
		Set Rs = Nothing
		CheckIsCanMoveSure = 0
		Exit Function
	End if

	GBL_Board_ID = cCur(Rs("BoardID"))
	
	If cCur(Rs("ParentID")) <> 0 Then
		Response.Write "要转移的帖子非主题帖子，不能转移!!"
		Rs.Close
		Set Rs = Nothing
		CheckIsCanMoveSure = 0
		Exit Function
	End if
	Rs.Close
	Set Rs = Nothing

	Dim Temp
	Temp = Application(DEF_MasterCookies & "BoardInfo" & GBL_Board_ID)
	If isArray(Temp) = False Then
		ReloadBoardInfo(GBL_Board_ID)
		Temp = Application(DEF_MasterCookies & "BoardInfo" & GBL_Board_ID)
	End If
	If isArray(Temp) = False Then
		Response.Write "论坛发生错误，请联系管理员!<br>" & VbCrLf
		CheckIsCanMoveSure = 0
	End If
	GBL_Board_MasterList = Temp(10,0)
	GBL_Board_BoardLimit = Temp(9,0)

	If GetBinarybit(GBL_Board_BoardLimit,8) = 1 Then
		Response.Write "此版面不允许转移帖子."
		CheckIsCanMoveSure = 0
		Exit Function
	End If

	Set Rs = Nothing
	CheckisBoardMaster
	If GBL_UserID >= 1 and GBL_BoardMasterFlag >= 5 Then
		CheckIsCanMoveSure = 1
	Else
		CheckIsCanMoveSure = 0
		Response.Write "错误,权限不足."
	End If

End Function


Function DisplayMoveAnnounce

	Dim MoveID
	MoveID = Left(Request("MoveID"),14)
	If isNumeric(MoveID) = 0 or inStr(MoveID,",") > 0 or MoveID = "" Then
		Response.Write "错误,请提供要转移的帖子的ID!<br>" & VbCrLf
		Exit Function
	End if

	Dim BoardID2
	BoardID2 = Left(Request("BoardID2"),14)
	If isNumeric(BoardID2) = 0 or inStr(BoardID2,",") > 0 or BoardID2 = "" Then BoardID2 = 0
	BoardID2 = cCur(BoardID2)
	If Request.Form("MoveSureFlag")="dk9@dl9s92lw_SWxl" Then		
		MoveID = cCur(MoveID)
		Dim Rs,SQL
		SQL = "Select top 1 BoardID,ParentID,UserID,RootID,ChildNum,RootIDBak,GoodAssort from LeadBBS_Announce where id=" & MoveID
		Set Rs = Con.ExeCute(SQL)
		GBL_DBNum = GBL_DBNum + 1
		If Rs.Eof Then
			Response.Write "错误,要转移的帖子ID不存在!<br>" & VbCrLf
			Rs.Close
			Set Rs = Nothing
			Exit Function
		End if
		
		Dim BoardID,ParentID,UserID,RootID,ChildNum,RootIDBak,GoodAssort
		BoardID = cCur(Rs(0))
		ParentID = cCur(Rs(1))
		UserID = cCur(Rs(2))
		RootID = cCur(Rs(3))
		ChildNum = cCur(Rs(4))
		RootIDBak = cCur(Rs(5))
		GoodAssort = cCur(Rs(6))
		Rs.Close
		Set Rs = Nothing
		
		Dim BoardName
		Dim Temp
		Temp = Application(DEF_MasterCookies & "BoardInfo" & BoardID)
		If isArray(Temp) = False Then
			ReloadBoardInfo(BoardID)
			Temp = Application(DEF_MasterCookies & "BoardInfo" & BoardID)
		End If
		If isArray(Temp) = False Then
			Response.Write "论坛发生错误，请联系管理员!<br>" & VbCrLf
			Set Rs = Nothing
			Exit Function
		End If
		BoardName = Temp(0,0)
		
		If BoardID2 < 1 Then
			Response.Write "错误,目标论坛不存在!!<br>" & VbCrLf
			Exit Function
		End if
		
		If BoardID2 = BoardID Then
			Response.Write "目标论坛就是主题所在论坛,所以不需要转移!!<br>" & VbCrLf
			Exit Function
		End if
	
		Dim BoardName2,BoardLimit2
		
		Temp = Application(DEF_MasterCookies & "BoardInfo" & BoardID2)
		If isArray(Temp) = False Then
			ReloadBoardInfo(BoardID2)
			Temp = Application(DEF_MasterCookies & "BoardInfo" & BoardID2)
		End If
		If isArray(Temp) = False Then
			If BoardID2 = 444 Then
				Response.Write "论坛回收站未建立，请联系管理员!<br>" & VbCrLf
			Else
				Response.Write "论坛发生错误，请联系管理员!<br>" & VbCrLf
			End If
			Exit Function
		End If
		BoardName2 = Temp(0,0)
		BoardLimit2 = Temp(9,0)
		If GetBinarybit(BoardLimit2,12) = 1 Then
			Response.Write "目标版面<u>属于分类论坛</u>，不允许此操作。" & VbCrLf
			Exit Function
		End If
		
		'注意,没有对下面的语句作专门的索引,当某主题回复帖子巨大时,可能速度会下降得厉害,如果有必要,在数据库中建立相应的索引,但索引多会导致数据库性能下降.
		Dim TodayAnnounce
		Set Rs = Con.ExeCute("select count(*) from LeadBBS_Announce where RootIDBak=" & RootIDBak  & " and ndatetime>" & Left(GetTimeValue(DEF_Now),8) & "000000")
		GBL_DBNum = GBL_DBNum + 1
		If Rs.Eof Then
			TodayAnnounce = 0
		Else
			TodayAnnounce = Rs(0)
			If isNull(TodayAnnounce) Then TodayAnnounce = 0
			TodayAnnounce = cCur(TodayAnnounce)
		End If
		Rs.Close
		Set Rs = Nothing

		'注意,没有对下面的语句作专门的索引,当某主题回复帖子巨大时,可能速度会下降得厉害,如果有必要,在数据库中建立相应的索引,但索引多会导致数据库性能下降.
		Dim GoodNum
		Set Rs = Con.ExeCute("select count(*) from LeadBBS_Announce where RootIDBak=" & RootIDBak & " and GoodFlag=1")
		If Rs.Eof Then
			GoodNum = 0
		Else
			GoodNum = Rs(0)
			If isNull(GoodNum) Then GoodNum = 0
			GoodNum = cCur(GoodNum)
		End If
		Rs.Close
		Set Rs = Nothing

		Con.ExeCute ("Update LeadBBS_Announce Set BoardID=" & BoardID2 & " where BoardID=" & BoardID & " and RootIDBak=" & RootIDBak)
		Con.ExeCute ("Update LeadBBS_Topic Set BoardID=" & BoardID2 & " where ID=" & RootIDBak)
		If GoodAssort > 0 Then
			Con.ExeCute ("Update LeadBBS_Announce Set GoodAssort=0 where ID=" & MoveID)
			Con.ExeCute ("Update LeadBBS_Topic Set GoodAssort=0 where ID=" & MoveID)
		End If
		Con.ExeCute ("Update LeadBBS_TopAnnounce Set BoardID=" & BoardID2 & " where BoardID=" & BoardID & " and RootID=" & RootIDBak)
		If CheckSupervisorUserName = 0 Then
			Con.ExeCute ("Update LeadBBS_Announce Set OtherInfo='这个贴子最后由" & Replace(GBL_CHK_User,"'","''") & "在" & DEF_Now & "从 " & Replace(BoardName,"'","''") & " 转移过来'" & " where ID=" & RootIDBak)
		End If
		'Con.ExeCute ("Update LeadBBS_Boards Set TopicNum=TopicNum-1,AnnounceNum=AnnounceNum-" & ChildNum+1 & ",TodayAnnounce=TodayAnnounce-" & TodayAnnounce & ",GoodNum=GoodNum-" & GoodNum & " where boardID=" & BoardID)
		UpdateBoardAnnounceNum Application(DEF_MasterCookies & "BoardInfo" & BoardID)(28,0),-1,0-ChildNum-1,0-TodayAnnounce,0-GoodNum
		'Con.ExeCute ("Update LeadBBS_Boards Set TopicNum=TopicNum+1,AnnounceNum=AnnounceNum+" & ChildNum+1 & ",TodayAnnounce=TodayAnnounce+" & TodayAnnounce & ",GoodNum=GoodNum+" & GoodNum & " where boardID=" & BoardID2)
		UpdateBoardAnnounceNum Application(DEF_MasterCookies & "BoardInfo" & BoardID2)(28,0),1,ChildNum+1,TodayAnnounce,GoodNum
		'GBL_DBNum = GBL_DBNum + 1
		'GBL_DBNum = GBL_DBNum + 1
		GBL_DBNum = GBL_DBNum + 1
		GBL_DBNum = GBL_DBNum + 1
		GBL_DBNum = GBL_DBNum + 1
		MakeAnnounceTop(MoveID)
		DeleteAllTopData(MoveID)
		UpdateBoardValue(BoardID)
		UpdateBoardValue(BoardID2)
		If inStr(application(DEF_MasterCookies & "TopAncList" & GBL_Board_BoardAssort),"," & MoveID & ",") Then ReloadTopAnnounceInfo(GBL_Board_BoardAssort)
		
		If CheckSupervisorUserName = 0 Then
			Con.ExeCute("Update LeadBBS_User Set LastWriteTime=" & GetTimeValue(DEF_Now) & " where ID=" & GBL_UserID)
			GBL_DBNum = GBL_DBNum + 1
			UpdateSessionValue 13,GetTimeValue(DEF_Now),0
		End If

		Con.ExeCute("insert into LeadBBS_Log(LogType,LogTime,LogInfo,UserName,IP,BoardID) Values(103," & GetTimeValue(DEF_Now) & ",'" & Left("成功转移编号" & MoveID & "，原作者编号" & UserID & "的帖子．原版面编号" & BoardID & "(" & Replace(Replace(htmlencode(BoardName),"\","\\"),"'","''") & ")，目标论坛编号" & BoardID2 & "(" & Replace(Replace(htmlencode(BoardName2),"'","''"),"\","\\") & "．",255) & "','" & Replace(GBL_CHK_User,"'","''") & "','" & Replace(GBL_IPAddress,"'","''") & "'," & GBL_Board_ID & ")")
		GBL_DBNum = GBL_DBNum + 1
		Response.Write "<font color=008800 class=GreenFont>原主题成功转移到" & BoardName2 & "!!</font>" & VbCrLf
		
		If GoodAssort > 0 Then ChangeGoodAssort GoodAssort,0
	Else
		%>
		<form name=DellClientForm action=MoveAnnounce.asp method=post>
			<input type=hidden name=MoveSureFlag value="dk9@dl9s92lw_SWxl">
			<input type=hidden name=MoveID value="<%=MoveID%>">
			<input type=hidden name=BoardID value="<%=GBL_Board_ID%>">
			<%If DEF_EnableDelAnnounce = 0 and BoardID2 = 444 Then%>
			<b>帖子将被转移到回收版面，确认要回收编号为<font color=ff0000 class=RedFont><%=MoveID%></font>的帖子吗？</b>
			<input type=hidden name=BoardID2 value="<%=BoardID2%>">
			<br>
			<%Else%>
			<b>确认要转移编号为<font color=ff0000 class=RedFont><%=MoveID%></font>的帖子吗？</b><br>
请选择目标论坛:<!-- #include file=../inc/incHTM/BoardForMoveList.asp -->
			<%End If%>
			<br><br><input type=submit value=确定 class=fmbtn>
			<input type=button value=取消此操作 onclick="javascript:window.close();" class=fmbtn>
		</form>
		<%
	End If

End Function

Function UpdateBoardValue(BoardID)

	Dim Rs,SQL
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	Dim N,AllMinRootID,AllMaxRootID		
	Set Rs = Con.ExeCute("select Min(RootID) from LeadBBS_Topic where BoardID=" & BoardID)
	GBL_DBNum = GBL_DBNum + 1
	If Rs.Eof Then
		AllMinRootID = 0
	Else
		AllMinRootID = Rs(0)
		If isNull(AllMinRootID) Then AllMinRootID = 0
		AllMinRootID = cCur(AllMinRootID)
	End If
	Rs.Close
	Set Rs = Nothing

	Set Rs = Con.ExeCute("select Max(RootID) from LeadBBS_Topic where BoardID=" & BoardID)
	GBL_DBNum = GBL_DBNum + 1
	If Rs.Eof Then
		AllMaxRootID = 0
	Else
		AllMaxRootID = Rs(0)
		If isNull(AllMaxRootID) Then AllMaxRootID = 0
		AllMaxRootID = cCur(AllMaxRootID)
	End If
	Rs.Close
	Set Rs = Nothing
	
	Dim LastAnnounceID,LastTopicName,LastWriter,LastTime
	Set Rs = Con.ExeCute("Select top 1 ID,title,LastUser,UserName,LastTime,TitleStyle from LeadBBS_Topic where BoardID=" & BoardID & " and RootID<" & DEF_BBS_TOPMinID & " order By RootID DESC")
	GBL_DBNum = GBL_DBNum + 1
	If Rs.Eof Then
		LastAnnounceID = 0
		LastTopicName = ""
		LastTime = 0
		LastWriter = ""
	Else
		LastAnnounceID = Rs(0)
		LastTopicName = Rs(1)
		LastWriter = Rs(2)
		If LastWriter = "" or isNull(LastWriter) Then LastWriter = Rs(3)
		LastTime = cCur(Rs(4))
		If isNull(LastTime) then LastTime = 0
		If Rs(5) = 1 Then LastTopicName = KillHTMLLabel(LastTopicName)
	End If
	Rs.Close
	Set Rs = Nothing
	Con.ExeCute ("Update LeadBBS_Boards Set AllMinRootID=" & AllMinRootID & ",AllMaxRootID=" & AllMaxRootID & ",LastAnnounceID=" & LastAnnounceID & ",LastTopicName='" & Replace(LastTopicName,"'","''") & "',LastWriter='" & Replace(LastWriter,"'","''") & "',LastWriteTime=" & LastTime & " where boardID=" & BoardID)
	GBL_DBNum = GBL_DBNum + 1
	ReloadBoardInfo(BoardID)
	If isArray(application(DEF_MasterCookies & "TopAnc")) Then ReloadTopAnnounceInfo(0)
	

End Function


Function MakeAnnounceTop(AnnounceID)

	Dim Rs,SQL,BoardID,RootID,MaxRootID,RootIDBak
	SQL = "Select top 1 ID,RootID,BoardID,RootIDBak from LeadBBS_Announce where ID=" & AnnounceID
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	If Not Rs.Eof Then
		RootID = cCur(Rs(1))
		BoardID = cCur(Rs(2))
		RootIDBak = cCur(Rs(3))
		Rs.Close
		Set Rs = Nothing
	Else
		Rs.Close
		Set Rs = Nothing
		Exit function
	End If

	'If RootID<DEF_BBS_TOPMinID Then
		Set Rs = Con.ExeCute("Select Max(RootID) from LeadBBS_Topic where BoardID=" & BoardID & " and RootID<" & DEF_BBS_TOPMinID)
		GBL_DBNum = GBL_DBNum + 1
		If Rs.Eof Then
			MaxRootID = 1
		Else
			MaxRootID = Rs(0)
			If isNull(MaxRootID) or MaxRootID="" Then
				MaxRootID=1
			End If
			MaxRootID = cCur(MaxRootID)
		End If
		Rs.Close
		Set Rs = Nothing
		Con.ExeCute(" Update LeadBBS_Announce Set RootID=" & MaxRootID+1 & " where ID=" & RootIDBak)
		Con.ExeCute(" Update LeadBBS_Topic Set RootID=" & MaxRootID+1 & " where ID=" & RootIDBak)
		GBL_DBNum = GBL_DBNum + 2
	'Else
		
	'End If
	UpdateBoardValue(BoardID)

End Function

Function DeleteAllTopData(MoveID)

	Dim Rs,Num
	Dim GetDataTop
	GetDataTop = application(DEF_MasterCookies & "TopAnc")
	If isArray(GetDataTop) = False Then
		If GetDataTop <> "yes" Then
			ReloadTopAnnounceInfo(0)
			GetDataTop = application(DEF_MasterCookies & "TopAnc")
		End If
	End If

	If isArray(GetDataTop) = False Then
		Num = 0
	Else
		Num = Ubound(GetDataTop,2) + 1
	End If

	For Rs = 1 to Num
		If cCur(GetDataTop(0,Rs-1)) = MoveID Then
			Con.ExeCute("Delete from LeadBBS_TopAnnounce Where RootID=" & MoveID)
			GBL_DBNum = GBL_DBNum + 1
			Exit Function
		End If
	Next

	GetDataTop = application(DEF_MasterCookies & "TopAnc" & GBL_Board_BoardAssort)
	If isArray(GetDataTop) = False Then
		If GetDataTop <> "yes" Then
			ReloadTopAnnounceInfo(GBL_Board_BoardAssort)
			GetDataTop = application(DEF_MasterCookies & "TopAnc" & GBL_Board_BoardAssort)
		End If
	End If

	If isArray(GetDataTop) = False Then
		Num = 0
	Else
		Num = Ubound(GetDataTop,2) + 1
	End If

	For Rs = 1 to Num
		If cCur(GetDataTop(0,Rs-1)) = MoveID Then
			Con.ExeCute("Delete from LeadBBS_TopAnnounce Where RootID=" & MoveID)
			GBL_DBNum = GBL_DBNum + 1
			Exit Function
		End If
	Next

End Function

Function UpdateBoardAnnounceNum(BoardList,TopicNum,AnnounceNum,TodayAnnounce,GoodNum)

	Dim SQL,N
	If BoardList = "" or (TopicNum = 0 and AnnounceNum = 0 and TodayAnnounce = 0 and GoodNum = 0) Then Exit Function
	SQL = "Update LeadBBS_Boards Set AnnounceNum=AnnounceNum+" & AnnounceNum & ",AnnounceNum_All=AnnounceNum_All+" & AnnounceNum
	If TopicNum <> 0 Then SQL = SQL & ",TopicNum=TopicNum+" & TopicNum
	If TopicNum <> 0 Then SQL = SQL & ",TopicNum_All=TopicNum_All+" & TopicNum
	If TodayAnnounce <> 0 Then  SQL = SQL & ",TodayAnnounce=TodayAnnounce+" & TodayAnnounce
	If TodayAnnounce <> 0 Then  SQL = SQL & ",TodayAnnounce_All=TodayAnnounce_All+" & TodayAnnounce
	If GoodNum <> 0 Then  SQL = SQL & ",GoodNum=GoodNum+" & GoodNum
	If GoodNum <> 0 Then  SQL = SQL & ",GoodNum_All=GoodNum_All+" & GoodNum
	SQL = SQL & " where BoardID in(" & BoardList & ")"
	Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	BoardList = Split(BoardList,",")
	SQL = Ubound(BoardList,1)
	Dim Temp
	For N = 0 To SQL
		Temp = Application(DEF_MasterCookies & "BoardInfo" & BoardList(N))
		If isArray(Temp) = False Then
			ReloadBoardInfo(BoardList(N))
			Temp = Application(DEF_MasterCookies & "BoardInfo" & BoardList(N))
		End If
		If isArray(Temp) = True Then
			If TopicNum <> 0 Then
				UpdateBoardApplicationInfo BoardList(N),cCur(Temp(5,0))+TopicNum,5
				UpdateBoardApplicationInfo BoardList(N),cCur(Temp(29,0))+TopicNum,29
			End If
			If AnnounceNum <> 0 Then
				UpdateBoardApplicationInfo BoardList(N),cCur(Temp(6,0))+AnnounceNum,6
				UpdateBoardApplicationInfo BoardList(N),cCur(Temp(30,0))+AnnounceNum,30
			End If
			If TodayAnnounce <> 0 Then
				UpdateBoardApplicationInfo BoardList(N),cCur(Temp(18,0))+TodayAnnounce,18
				UpdateBoardApplicationInfo BoardList(N),cCur(Temp(31,0))+TodayAnnounce,31
			End If
			If GoodNum <> 0 Then
				UpdateBoardApplicationInfo BoardList(N),cCur(Temp(13,0))+GoodNum,13
				UpdateBoardApplicationInfo BoardList(N),cCur(Temp(32,0))+GoodNum,32
			End If
		End If
	Next
	'28,T1.ParentBoardStr,29.TopicNum_All,30.AnnounceNum_All,31.TodayAnnounce_All,32.GoodNum_All

End Function

Sub ChangeGoodAssort(ID,ID2)

	If ID = ID2 Then Exit Sub
	Dim TArray,N,Num,NN,ExitN
	TArray = Application(DEF_MasterCookies & "BoardInfo" & GBL_Board_ID & "_TI")
	If isArray(TArray) = False Then
		CheckGoodAssort = 0
		Exit Sub
	End If
	Num = Ubound(TArray,2)
	NN = 0
	ExitN = 2
	If ID = 0 or ID2 = 0 Then ExitN = 1
	For N = 0 To Num
		If ID = cCur(TArray(0,N)) Then
			If cCur(TArray(2,N)) <> 0 Then
				If cCur(TArray(2,N)) = -1 Then
				Else
					TArray(2,N) = cCur(TArray(2,N)) - 1
					TArray(3,N) = 0
					TArray(4,N) = 0
				End If
			End If
			NN = NN + 1
			If NN >= 2 Then Exit For
		End If
		If ID2 = cCur(TArray(0,N)) Then
			If cCur(TArray(2,N)) <> 0 Then
				If cCur(TArray(2,N)) = -1 Then
					TArray(2,N) = 1
				Else
					TArray(2,N) = cCur(TArray(2,N)) + 1
					TArray(3,N) = 0
					TArray(4,N) = 0
				End If
			End If
			TArray(2,N) = 0
			NN = NN + 1
			If NN >= ExitN Then Exit For
		End If
	Next
	If NN > 0 Then
		Application.Lock
		Application(DEF_MasterCookies & "BoardInfo" & GBL_board_ID & "_TI") = TArray
		Application.UnLock
	End If

End Sub

Sub ReloadTopAnnounceInfo(TID)

	If isNumeric(TID) = 0 Then Exit Sub
	TID = Fix(cCur(TID))
	Dim Rs,GetDataTop,TIDStr
	If TID = 0 Then
		TIDStr = ""
	Else
		TIDStr = TID
	End If
	Set Rs = Con.ExeCute("Select RootID,BoardID from LeadBBS_TopAnnounce where TopType=" & TID)
	GBL_DBNum = GBL_DBNum + 1
	If Rs.Eof Then
		Application.Lock
		application(DEF_MasterCookies & "TopAnc" & TIDStr) = "yes"
		application(DEF_MasterCookies & "TopAncList" & TIDStr) = ""
		Application.UnLock
		Rs.Close
		Set Rs = Nothing
		Exit Sub
	Else
		GetDataTop = Rs.GetRows(-1)
		Rs.close
		Set Rs = Nothing
	End If
	
	Dim Temp,N
	Temp = ""
	If cCur(GetDataTop(0,0)) > 0 Then Temp = GetDataTop(0,0)
	For N = 1 to Ubound(GetDataTop,2)
		If cCur(GetDataTop(0,N)) > 0 Then Temp = Temp & "," & GetDataTop(0,N)
	Next
	If Left(Temp,1) = "," Then Temp = Mid(Temp,2)
	If cStr(Temp) <> "" Then
		Set Rs = Con.ExeCute("select top " & Ubound(GetDataTop,2)+1 & " id,ChildNum,Title,FaceIcon,LastTime,Hits,Length,UserName,UserID,RootID,LastUser,NotReplay,GoodFlag,BoardID,TopicType,PollNum,TitleStyle,LastInfo,ndatetime,GoodAssort from LeadBBS_Topic where ID in(" & Temp & ")")
		GBL_DBNum = GBL_DBNum + 1
		If Not Rs.Eof Then
			GetDataTop = Rs.GetRows(-1)
			Rs.Close
			Set Rs = Nothing
			Application.Lock
			application(DEF_MasterCookies & "TopAnc" & TIDStr) = GetDataTop
			Application.UnLock
			Application.Lock
			application(DEF_MasterCookies & "TopAncList" & TIDStr) = "," & Temp & ","
			Application.UnLock
		Else
			Rs.Close
			Set Rs = Nothing
			Application.Lock
			application(DEF_MasterCookies & "TopAnc" & TIDStr) = "yes"
			Application.UnLock
		End If
	Else
		Application.Lock
		application(DEF_MasterCookies & "TopAnc" & TIDStr) = "yes"
		Application.UnLock
	End If

End Sub%>