<!-- #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
	If Request("submitflag") = "yes" then
		RepairSite
	Else
		%><form action=RepairSite.asp method=post><p><br>
			注意：此功能将完成以下功能：<br><br>
			&nbsp; &nbsp; &nbsp; 1.重新统计每个版面(包括隐藏版面)的在线人数<br>
			&nbsp; &nbsp; &nbsp; 2.重新统计总在线人员<br>
			&nbsp; &nbsp; &nbsp; 3.重新统计论坛注册用户数量<br>
			&nbsp; &nbsp; &nbsp; 4.重新统计论坛上传附件数量<br>
			&nbsp; &nbsp; &nbsp; 5.<font color=Blue class=BlueFont>修复公告内容</font><br>
			&nbsp; &nbsp; &nbsp; 6.<font color=Blue class=BlueFont>修复版面专题区</font><br>
			<input type="hidden" name="submitflag" value="yes">
			<br>
			<b><font color=ff0000 class=RedFont>确认信息： 真的要开始修复上述数据么？</font></b><br><br>
			<br><input class=fmchkbox type="checkbox" name="repairFlag" value="yes" checked>选中则自动修复每个版面的在线人数，否则仅作查看
			<p>
			<input type=submit value="点击开始修复" class=fmbtn>
			<p><a href=../User/ClearOnlineUser.asp>如果需要清除所有的在线人员名单，请点击这里</a>
			</form>
		<%
	End If
Else%>
	<table width=96%>
	<tr>
	<td>
	<%
	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
	DisplayLoginForm
	Response.Write "</p>"%>
	</td>
	</tr>
	</table>
<%End If
UserTopicBottomInfo
closeDataBase
SiteBottom
If GBL_ShowBottomSure = 1 Then Response.Write GBL_SiteBottomString


Function RepairSite

	Dim repairFlag
	repairFlag = Request("repairFlag")
	If repairFlag <> "yes" Then repairFlag = ""
	Dim Rs
	Dim UploadNum,UserCount
	Response.Write "<br>"
	Set Rs = Con.ExeCute("select count(*) from LeadBBS_User")
	If Rs.Eof Then
		UserCount = 0
	Else
		UserCount = Rs(0)
		If isNull(UserCount) Then UserCount = 0
		UserCount = cCur(UserCount)
	End If
	Rs.Close
	Set Rs = Nothing

	Set Rs = Con.ExeCute("select count(*) from LeadBBS_Upload")
	If Rs.Eof Then
		UploadNum = 0
	Else
		UploadNum = Rs(0)
		If isNull(UploadNum) Then UploadNum = 0
		UploadNum = cCur(UploadNum)
	End If
	Rs.Close
	Set Rs = Nothing

	Con.ExeCute ("Update LeadBBS_SiteInfo Set UserCount=" & UserCount & ",UploadNum=" & UploadNum)
	ReloadStatisticData

	Response.Write "<br>注册用户数量及上传文件数量重新统计完成！"
	SetActiveUserCount
	Response.Write "<br>论坛总在线人数重新统计完成．"

	Dim GetData
	Set Rs = Con.ExeCute("Select BoardID from LeadBBS_Boards")
	If Not Rs.Eof Then
		GetData = Rs.GetRows(-1)
		Rs.Close
		Set Rs = Nothing
	Else
		Rs.Close
		Set Rs = Nothing
		Exit Function
	End If
	
	Dim N,m,i
	m = Ubound(GetData,2)
	For N = 0 to m
		Set Rs = Con.ExeCute("Select count(*) from LeadBBS_OnlineUser Where AtBoardID=" & GetData(0,n))
		If Rs.Eof Then
			i = 0
		Else
			i = Rs(0)
			If isNull(i) Then i = 0
			i = cCur(i)
		End If
		Rs.Close
		Set Rs = Nothing
		ReloadBoardInfo(GetData(0,n))
		ReloadTopicAssort(GetData(0,n))
		Response.Write "<br>版面号" & GetData(0,n) & "在线人数，原先" & Application(DEF_MasterCookies & "BDOL" & GetData(0,n)) & "人，实际在线" & i & "人"
		If repairFlag = "yes" then
			Application.Lock
			Application(DEF_MasterCookies & "BDOL" & GetData(0,n)) = i
			Application.UnLock
		End If
	Next
	Response.Write "<p>重新统计版面在线人数完成．．"
	ReloadPubMessageInfo
	Response.Write "<p>修复公告内容完成．"
	If repairFlag <> "yes" then Response.Write "<font color=Red Class=RedFont>但并没有重新完成版面在线人数的更新．</font>"

End Function

Sub ReloadTopicAssort(BoardID)

	Dim Rs
	Set Rs = Con.ExeCute("select ID,AssortName,0,0,0 from LeadBBS_GoodAssort where BoardID=" & BoardID & " Order by BoardID,OrderID")
	GBL_DBNum = GBL_DBNum + 1
	If Not Rs.Eof Then
		Application.Lock
		Application(DEF_MasterCookies & "BoardInfo" & BoardID & "_TI") = Rs.GetRows(-1)
		Application.UnLock
	Else
		Application.Lock
		Set Application(DEF_MasterCookies & "BoardInfo" & BoardID & "_TI") = Nothing
		Application(DEF_MasterCookies & "BoardInfo" & BoardID & "_TI") = "yes"
		Application.UnLock
	End If
	Rs.Close
	Set Rs = Nothing

End Sub
%>