<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_Popfun.asp -->
<!-- #include file=../../inc/Ubbcode.asp -->
<!-- #include file=../../inc/Constellation2.asp -->
<!-- #include file=../inc/bbsmanage_Fun.asp -->
<%
DEF_BBS_HomeUrl = "../../"
server.scriptTimeOut = 99999
Rem -------------------------------------------------------
Rem ------------重算所有用户帖子数量-----------------------
Rem -------------------------------------------------------
initDatabase
UpdateUserAnnounce
CloseDatabase


Function UpdateUserAnnounce()

	If CheckSupervisorUserName = 0 or GBL_UserID = 0 Then Exit Function
	If Request.Form("SureFlag") <> "E72ksiOkw2" Then
		%>
			<p><form action=UpdateUserAnnounce.asp method=post>
			<b><font color=ff0000 class=RedFont>确定此操作吗?<br>
			<br>
			<input type=hidden name=SureFlag value="E72ksiOkw2">
			<input type=hidden name=RecordCount value="<%=Request("ReCount")%>">
			
			<input type=submit value=确定进行 class=fmbtn>
			</form>
		<%
	Else
		Dim NowID,EndFlag,Temp
		NowID = 0
		EndFlag = 0
		Dim Rs,SQL
		Dim AnnounceNum,AnnounceTopic,AnnounceGood,UploadNum
		Dim GetData,N
		
		Dim ReCount
		ReCount = Request.QueryString("ReCount")
		If ReCount <> "1" Then ReCount = ""
	
		Dim RecordCount,CountIndex
		SQL = "Select count(*) from [LeadBBS_User]"
		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,birthday from LeadBBS_User 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
				Exit do
			Else
				GetData = Rs.GetRows(-1)
			End If
			Rs.Close
			Set Rs = Nothing
			
			For N = 0 to Ubound(GetData,2)
				NowID = cCur(GetData(0,N))
				
				SQL = "select count(*) from leadbbs_Upload where UserID=" & NowID
				Set Rs = Con.ExeCute(SQL)
				GBL_DBNum = GBL_DBNum + 1
				If Not Rs.Eof Then
					UploadNum = Rs(0)
					If isNull(UploadNum) then UploadNum = 0
				Else
					UploadNum = 0
				End If
				Rs.Close
				Set Rs = Nothing
				
				SQL = "select count(*) from leadbbs_announce where UserID=" & NowID
				Set Rs = Con.ExeCute(SQL)
				GBL_DBNum = GBL_DBNum + 1
				If Not Rs.Eof Then
					AnnounceNum = Rs(0)
					If isNull(AnnounceNum) then AnnounceNum = 0
				Else
					AnnounceNum = 0
				End If
				Rs.Close
				Set Rs = Nothing
				
				SQL = "select count(*) from LeadBBS_Topic where UserID=" & NowID
				Set Rs = Con.ExeCute(SQL)
				GBL_DBNum = GBL_DBNum + 1
				If Not Rs.Eof Then
					AnnounceTopic = Rs(0)
					If isNull(AnnounceTopic) then AnnounceTopic = 0
				Else
					AnnounceTopic = 0
				End If
				Rs.Close
				Set Rs = Nothing
				
				SQL = "select count(*) from LeadBBS_Topic where GoodFlag=1 and UserID=" & NowID
				Set Rs = Con.ExeCute(SQL)
				GBL_DBNum = GBL_DBNum + 1
				If Not Rs.Eof Then
					AnnounceGood = Rs(0)
					If isNull(AnnounceGood) then AnnounceGood = 0
				Else
					AnnounceGood = 0
				End If
				Rs.Close
				Set Rs = Nothing
				If ReCount <> "1" Then
					Con.Execute("Update LeadBBS_User Set AnnounceNum=" & AnnounceNum & ",AnnounceTopic=" & AnnounceTopic & ",AnnounceGood=" & AnnounceGood & ",UploadNum=" & UploadNum & " Where ID=" & NowID)
				Else
					Con.Execute("Update LeadBBS_User Set AnnounceNum=" & AnnounceNum & ",AnnounceTopic=" & AnnounceTopic & ",AnnounceGood=" & AnnounceGood & ",UploadNum=" & UploadNum & ",points=" & DEF_BBS_AnnouncePoints*(AnnounceNum + AnnounceTopic)+AnnounceGood*5 & " Where ID=" & NowID)
				End If
				GBL_DBNum = GBL_DBNum + 1
				'GetUserLevel(NowID)
	
				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

Function GetUserLevel(GBL_ID)

	Dim Temp_N,UserLevel,IP,SessionID,AnnounceNum,Online,Prevtime,OnlineTime,Points,UserLevel_Old
	Dim Rs
	Set Rs = Con.ExeCute("Select top 1 UserLevel,AnnounceNum,OnlineTime from LeadBBS_User where id=" & GBL_ID)
	GBL_DBNum = GBL_DBNum + 1
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		Exit Function
	End If
	UserLevel = Rs(0)
	Points = cCur(Rs(1))
	OnlineTime = cCur(Rs(2))
	Rs.Close
	Set Rs = Nothing
	UserLevel_Old = UserLevel

	For Temp_N = 0 To DEF_UserLevelNum
		If Points >= DEF_UserLevelPoints(Temp_N) Then UserLevel = Temp_N
	Next

	GetUserLevel = UserLevel
	If UserLevel_Old <> UserLevel Then Con.Execute("Update LeadBBS_User Set UserLevel=" & UserLevel & " Where ID=" & GBL_ID)

End Function
%>完成