<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_Popfun.asp -->
<!-- #include file=../../inc/Ubbcode.asp -->
<!-- #include file=../inc/bbsmanage_Fun.asp -->
<%
Rem -------------------------------------------------------
Rem ------------此程序用来修复表LeadBBS_Announce-----------
Rem ------------中RootMaxID和RootMinID字段-----------------
Rem ------------更新时间漫长，建议先到后台关闭论坛---------
Rem -------------------------------------------------------

DEF_BBS_HomeUrl = "../../"
server.scripttimeout=99999
initDatabase
UpdatePrintContentColumn
CloseDatabase

Function UpdatePrintContentColumn()
	
	If CheckSupervisorUserName = 0 or GBL_UserID = 0 Then Exit Function

	If Request.Form("SureFlag") <> "E72ksiOkw2" Then
		%>
			<p><form action=UpdateRootMaxMinAnnounceID.asp method=post>
			<b><font color=ff0000 class=RedFont>确定此操作吗?<br>
			<br>
			<input type=hidden name=SureFlag value="E72ksiOkw2">
			
			<input type=submit value=确定进行 class=fmbtn>
			</form>
		<%
	Else
		Dim TempAT,T
		Dim NowID,EndFlag,SQL,Rs
		NowID = 0
		EndFlag = 0
		
		Dim RootMaxID,RootMinID,ChildNum
		Dim N,GetData
	
		Dim RecordCount,CountIndex
		SQL = "Select count(*) from [LeadBBS_Topic]"
		Set Rs = Con.ExeCute(SQL)
		If Rs.Eof Then
			RecordCount = 0
		Else
			RecordCount = Rs(0)
			If isNull(RecordCount) Then RecordCount = 0
		End If
		Rs.Close
		Set Rs = Nothing
		If RecordCount < 1 Then RecordCount = 1
		CountIndex = 0
		%>
		<p style="font-size:9pt">下面开始修复论坛主题信息，共有<%=RecordCount%>个主题待更新
	
		<table width="400" border="0" cellspacing="1" cellpadding="1">
			<tr> 
				<td bgcolor=000000>
		<table width="400" border="0" cellspacing="0" cellpadding="1">
			<tr> 
				<td bgcolor=ffffff height=9><img src=../../images/vote.gif width=0 height=16 id=img1 name=img1 align=absmiddle></td></tr></table>
		</td></tr></table> <span id=txt1 name=txt1 style="font-size:9pt">0</span><span style="font-size:9pt">%</span>
		<%
		Response.Flush
		Do while EndFlag = 0
			SQL = "Select top 100 ID,ID,BoardID,ChildNum from LeadBBS_Topic where ID>" & NowID & " order by ID ASC"
			Set Rs = Con.ExeCute(SQL)
			GBL_DBNum = GBL_DBNum + 1
			If Rs.Eof Then
				EndFlag = 1
				Rs.Close
				Set Rs = Nothing
				Exit Do
			Else
				GetData = Rs.GetRows(-1)
				Rs.Close
				Set Rs = Nothing
			End If
			For N = 0 to Ubound(GetData,2)
				'If cCur(GetData(3,n)) > 0 Then
					SQL = "select max(ID) from LeadBBS_Announce where RootIDBak=" & GetData(1,n)
					Set Rs = Con.ExeCute(SQL)
					GBL_DBNum = GBL_DBNum + 1
					If Not Rs.Eof Then
						RootMaxID = Rs(0)
						If IsNull(RootMaxID) then RootMaxID = GetData(1,n)
					Else
						RootMaxID = GetData(1,n)
					End if
					Rs.Close
					Set Rs = Nothing
					SQL = "select Min(ID) from LeadBBS_Announce where RootIDBak=" & GetData(1,n)
					Set Rs = Con.ExeCute(SQL)
					GBL_DBNum = GBL_DBNum + 1
					If Not Rs.Eof Then
						RootMinID = Rs(0)
						If IsNull(RootMinID) then RootMinID = GetData(1,n)
					Else
						RootMinID = GetData(1,n)
					End if
					Rs.Close
					Set Rs = Nothing
						
					SQL = "select count(*) from LeadBBS_Announce where RootIDBak=" & GetData(1,n)
					Set Rs = Con.ExeCute(SQL)
					If Not Rs.Eof Then
						ChildNum = Rs(0)
						If IsNull(ChildNum) then ChildNum = 0
					Else
						ChildNum = 0
					End if
					Rs.Close
					Set Rs = Nothing
					If ChildNum > 0 Then ChildNum = ChildNum - 1
					Con.Execute("Update LeadBBS_Announce set ChildNum=" & ChildNum & ",RootMaxID=" & RootMaxID &_
						",RootMinID=" & RootMinID &_
						" where ID=" & GetData(0,n))
					Con.Execute("Update LeadBBS_Topic set ChildNum=" & ChildNum & ",RootMaxID=" & RootMaxID &_
						",RootMinID=" & RootMinID &_
						" where ID=" & GetData(0,n))
					GBL_DBNum = GBL_DBNum + 2
				'Else
				'	Con.Execute("Update LeadBBS_Announce set ChildNum=0,RootMaxID=" & GetData(0,n) &_
				'			",RootMinID=" & GetData(0,n) & _
				'			" where ID=" & GetData(0,n))
				'	GBL_DBNum = GBL_DBNum + 1
				'End If
				'Response.Write " " & NowID
				NowID = GetData(1,n)
	
				CountIndex = CountIndex + 1
				If (CountIndex mod 100) = 0 Then
					Response.Write "<script>img1.width=" & Fix((CountIndex/RecordCount) * 400) & ";" & VbCrLf
					Response.Write "txt1.innerHTML=""" & FormatNumber(CountIndex/RecordCount*100,4,-1) & """;" & VbCrLf
					Response.Write "img1.title=""(" & CountIndex & ")"";</script>" & VbCrLf
					Response.Flush
				End If
			Next
		Loop
		%>
		<script>img1.width=400;
		txt1.innerHTML="100";</script>
		<%
	End If

End Function
%>完成