<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_Popfun.asp -->
<!-- #include file=../inc/bbsmanage_Fun.asp -->
<%
DEF_BBS_HomeUrl = "../../"
Dim GBL_ID
initDatabase
GBL_CHK_TempStr = ""
GBL_ID = checkSupervisorPass

SiteHead(DEF_SiteNameString & " - 管理员")

UserTopicTopInfo
DisplayUserNavigate("清除总固顶状态")%>
<br><br><%
If GBL_CHK_Flag=1 Then
	DeleteAllTopAnnounce
Else%>
	<table width=96%>
	<tr>
		<td>
		<%
		If Request("submitsure")="" 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
		DisplayLoginForm
		Response.Write "</p>"%>
		</td>
	</tr>
	</table>
<%End If
UserTopicBottomInfo
closeDataBase
SiteBottom
If GBL_ShowBottomSure = 1 Then Response.Write GBL_SiteBottomString

Function DeleteAllTopAnnounce

	If Request("submitflag") = "yes" then
		If Request("Reload") = "yes" Then
			ReloadTopAnnounceInfo(0)
			Response.Write "<b><font color=Green Class=GreenFont>总固顶信息完成更新！</font></b>"
		Else
			Con.ExeCute ("delete from LeadBBS_TopAnnounce")
			ReloadOtherTopAnnounce
			GBL_DBNum = GBL_DBNum + 1
			Application.Lock
			Set application(DEF_MasterCookies & "TopAnc") = Nothing
			application(DEF_MasterCookies & "TopAnc") = "yes"
			application(DEF_MasterCookies & "TopAncList") = ""
			Application.UnLock
		
			Response.Write "<b><font color=Green Class=GreenFont>总固顶信息清除完毕并完成更新！</font></b>"
		End If
	Else%>
		<p>
		
				注意：点击开始清除功能将完成以下功能：<br><br>
				&nbsp; &nbsp; &nbsp; 1.解除所有总固顶帖子<br>
				&nbsp; &nbsp; &nbsp; 2.删除可能存在的冗余总固顶数据<br>
				&nbsp; &nbsp; &nbsp; 3.解决因社区意外产生的冗余数据进而不能继续总固顶<br>
				&nbsp; &nbsp; &nbsp; 4.解除所有区固顶帖子<br>
				<p>点击开始更新按钮将完成以下功能:<br><br>
				&nbsp; &nbsp; &nbsp; 1.不清除额外的剩余的总固顶数据<br>
				&nbsp; &nbsp; &nbsp; 2.重新读取总固顶数据
				<br><br>
				<b><font color=ff0000 class=RedFont>确认信息： 真的要进行上述操作么？</font></b><br><br>
				<p>
		<form action=DeleteAllTopAnnounce.asp method=post>
		<input type=hidden name=submitflag value="yes">
		<input type=submit value=点击开始清除 class=fmbtn>
		</form>
		
		<form action=DeleteAllTopAnnounce.asp method=post>
		<input type=hidden name=submitflag value="yes">
		<input type=hidden name=Reload value="yes">
		<input type=submit value=点击开始更新 class=fmbtn>
		</form>
	<%
	End If

End Function

Sub ReloadOtherTopAnnounce

	Dim Rs,SQL,GetData,N
	Set Rs = Con.ExeCute("Select AssortID from LeadBBS_Assort")
	If Not Rs.Eof Then
		GetData = Rs.GetRows(-1)
		Rs.Close
		Set Rs = Nothing
		SQL = Ubound(GetData,2)
		For N = 0 to SQL
			ReloadTopAnnounceInfo(cCur(GetData(0,n)))
		Next
	Else
		Rs.Close
		Set Rs = Nothing
	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
%>