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


Function UpdateUserAnnounce()

	If GBL_CHK_User <> DEF_SupervisorUserName or GBL_UserID = 0 Then Exit Function
	Dim NowID,EndFlag,Temp
	NowID = Left(Request("ID"),14)
	EndFlag = 0
	Dim Rs,SQL
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	Dim AnnounceNum,AnnounceTopic,AnnounceGood,UploadNum
	Dim GetData,N
		SQL = "Select top 100 ID,birthday from LeadBBS_User where ID=" & NowID & " order by id ASC"
		Rs.Open SQL,con,1,1
		If Rs.Eof Then
			EndFlag = 1
			Rs.Close
		Else
			EndFlag = 1
			GetData = Rs.GetRows(-1)
		End If
		Rs.Close
		
		For N = 0 to Ubound(GetData,2)
			Response.Write " " & NowID
			NowID = cCur(GetData(0,N))
			
			SQL = "select count(*) from leadbbs_Upload where UserID=" & NowID
			Rs.Open SQL,con,1,1
			If Not Rs.Eof Then
				UploadNum = Rs(0)
				If isNull(UploadNum) then UploadNum = 0
			Else
				UploadNum = 0
			End If
			Rs.Close
			
			SQL = "select count(*) from leadbbs_announce where UserID=" & NowID
			Rs.Open SQL,con,1,1
			If Not Rs.Eof Then
				AnnounceNum = Rs(0)
				If isNull(AnnounceNum) then AnnounceNum = 0
			Else
				AnnounceNum = 0
			End If
			Rs.Close
			
			SQL = "select count(*) from LeadBBS_Topic where UserID=" & NowID
			Rs.Open SQL,con,1,1
			If Not Rs.Eof Then
				AnnounceTopic = Rs(0)
				If isNull(AnnounceTopic) then AnnounceTopic = 0
			Else
				AnnounceTopic = 0
			End If
			Rs.Close
			
			SQL = "select count(*) from LeadBBS_Topic where GoodFlag=1 and UserID=" & NowID
			Rs.Open SQL,con,1,1
			If Not Rs.Eof Then
				AnnounceGood = Rs(0)
				If isNull(AnnounceGood) then AnnounceGood = 0
			Else
				AnnounceGood = 0
			End If
			Rs.Close
			Con.Execute("Update LeadBBS_User Set AnnounceNum=" & AnnounceNum & ",AnnounceTopic=" & AnnounceTopic & ",AnnounceGood=" & AnnounceGood & ",UploadNum=" & UploadNum & ",points=" & AnnounceNum+AnnounceTopic+AnnounceGood*5 & " Where ID=" & NowID)
			GetUserLevel(NowID)
		Next
	Set Rs = Nothing

End Function


Function GetUserLevel(GBL_ID)

	Dim Temp_N,UserLevel,IP,SessionID,AnnounceNum,Online,Prevtime,OnlineTime,Points
	Dim Rs
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	Rs.Open "Select top 1 UserLevel,AnnounceNum,OnlineTime from LeadBBS_User where id=" & GBL_ID,con,1,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

	For Temp_N = 0 To DEF_UserLevelNum
		If Points >= DEF_UserLevelPoints(Temp_N) Then UserLevel = Temp_N
		If OnlineTime > 30*60 and UserLevel=0 Then UserLevel = 1 '如果经验值大于30并且级数为0则级数改为1
		If OnlineTime > 100*60 and UserLevel<2 Then UserLevel = 2 '如果经验值大于100并且级数<2则级数改为2
		If OnlineTime > 500*60 and UserLevel<3 Then UserLevel = 3 '如果经验值大于500并且级数<3则级数改为3
		If OnlineTime > 1500*60 and UserLevel<4 Then UserLevel = 4 '如果经验值大于2500并且级数<4则级数改为4
		If OnlineTime > 3000*60 and UserLevel<5 Then UserLevel = 5 '如果经验值大于5000并且级数<5则级数改为5
		If OnlineTime > 6000*60 and UserLevel<6 Then UserLevel = 6 '如果经验值大于5000并且级数<6则级数改为6
	Next
	
	GetUserLevel = UserLevel
	Con.Execute("Update LeadBBS_User Set UserLevel=" & UserLevel & " Where ID=" & GBL_ID)

End Function

%>完成