⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 board-stats.asp

📁 简介:一个程序小巧而功能强大
💻 ASP
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--#include file="../Includes/site-dataconn.asp" -->
<!--#include file="../Includes/func-common.asp" -->
<!--#include file="../Includes/site-config.asp" -->
<%
Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
<html>

<head>
<title>// <%=Site_Name%> //</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK REL=stylesheet TYPE="text/css" HREF="../Includes/Site-Style.css">
</head>

<body>
	
<%
'Admin Check
if session("admin") <> true then
	response.redirect(Site_Forum_URL & "/default.asp")
end if

Action = request.querystring("Action")
Method = request.querystring("Method")
%>
<table width="100%" height="10" border="0" cellspacing="0" cellpadding="1">
  	<tr valign="top">
    <td width="150">
	<!--#include file="inc-navigation.asp" -->
	</td>
    <td align="center">
	<table border="0" cellspacing="1" cellpadding="2" align="center" class="main">
		<tr valign="middle" class="title">
		<td align="center"><%=Site_Name%> // 论坛整理</td>
		</tr>
		<%
		if Action <> "Update" then
			%>
			<tr valign="top" class="body">
			<td align="left">
			注意:论坛整理中的各项运行都需要消耗比较多的资源,<br>
            所以请你选择论坛访问人数较少的时候进行整理,或者先关闭论坛</td>
			</tr>
			<form action="board-stats.asp?Action=Update" method="post">
			<tr valign="top" class="body">
			<td align="center">
			<input name="Update" type="submit" value="Update">
			</td>
			</tr>
			</form>
			<%
		else
			%>
			<tr valign="top" class="body">
			<td align="left">
			<%
			if Method = "" then	
				'Update global statistics
				set rsStats = server.createobject("adodb.recordset")
				sqlStats = "SELECT COUNT(*) AS Users FROM Forum_Users;"
				rsStats.open sqlStats, adoConn
					glUsers = rsStats("Users")
				rsStats.close
				sqlStats = "SELECT COUNT(*) AS Topics FROM Forum_Topics WHERE Topic_Type <> 0;"
				rsStats.open sqlStats, adoConn
					glTopics = rsStats("Topics")
				rsStats.close
				sqlStats = "SELECT COUNT(*) AS Posts FROM Forum_Posts FP INNER JOIN Forum_Topics FT ON FP.Post_Topic_ID = FT.Topic_ID WHERE Topic_Type <> 0;"
				rsStats.open sqlStats, adoConn
					glPosts = rsStats("Posts")
				rsStats.close				
				set rsStats = nothing
				
				set rsUpdate = server.createobject("adodb.recordset")
				sqlUpdate = "SELECT * FROM Forum_Stats"
				rsUpdate.cursortype = 2
				rsUpdate.locktype = 3
				rsUpdate.open sqlUpdate, adoConn
				if not (rsUpdate.eof or rsUpdate.bof) then
					rsUpdate("Stats_Users") = glUsers
					rsUpdate("Stats_Topics") = glTopics
					rsUpdate("Stats_Posts") = glPosts
					rsUpdate.update
				end if
				rsUpdate.close
				set rsUpdate = nothing
				
				response.write("<div align='center'>Global statistics have succesfully updated. The forum statistics will now be updated in five seconds...</div>")
				response.write("<META HTTP-EQUIV='Refresh' CONTENT='5; URL=board-stats.asp?Action=Update&Method=Forums'>")
			end if
			
			if Method = "Forums" then
				'Update forum statistics
				set rsForums = server.createobject("adodb.recordset")
				sqlForums = "SELECT Forum_ID FROM Forum_Forums ORDER BY Forum_Category_ID ASC, Forum_Order DESC;"
				rsForums.open sqlForums, adoConn, CMDText
				if not (rsForums.eof or rsForums.bof) then
					ForumCnt = rsForums.recordcount
					ForumData = rsForums.getrows()
				else
					ForumCnt = 0
				end if
				
				'Loop through topics from specified forums
				tempCnt = 0
				do until tempCnt = ForumCnt
					set rsTopics = server.createobject("adodb.recordset")
					sqlTopics = "SELECT COUNT(*) AS fTopics FROM Forum_Topics WHERE Topic_Forum_ID = "& ForumData(0, tempCnt) &" AND Topic_Type <> 0"
					rsTopics.open sqlTopics, adoConn
					if not (rsTopics.eof or rsTopics.bof) then
						fTopics = rsTopics("fTopics")
					else
						fTopics = 0
					end if
					
					set rsPosts = server.createobject("adodb.recordset")
					sqlPosts = "SELECT COUNT(*) AS fPosts FROM Forum_Posts FP INNER JOIN Forum_Topics FT ON FP.Post_Topic_ID = FT.Topic_ID WHERE Post_Forum_ID = "& ForumData(0, tempCnt) &" AND Topic_Type <> 0"
					rsPosts.open sqlPosts, adoConn
					if not (rsPosts.eof or rsPosts.bof) then
						fPosts = rsPosts("fPosts")
					else
						fPosts = 0
					end if
				
					set rsUpdate = server.createobject("adodb.recordset")
					sqlUpdate = "SELECT * FROM Forum_Forums WHERE Forum_ID = "& ForumData(0, tempCnt) &";"
					rsUpdate.cursortype = 2
					rsUpdate.locktype = 3
					rsUpdate.open sqlUpdate, adoConn
					if not (rsUpdate.eof or rsUpdate.bof) then
						rsUpdate("Forum_Topics") = fTopics
						rsUpdate("Forum_Posts") = fPosts
						if fTopics = 0 then
							rsUpdate("Forum_Topic_ID") = NULL
							rsUpdate("Forum_Post_Date") = NULL
							rsUpdate("Forum_User_ID") = NULL
							rsUpdate("Forum_User_Name") = NULL
						end if
					end if
					rsUpdate.update
					rsUpdate.close
					set rsUpdate = nothing
					
					tempCnt = tempCnt + 1
				loop
				
				response.write("<div align='center'>Forum statistics have succesfully updated. The topic statistics will now be updated in five seconds...</div>")
				response.write("<META HTTP-EQUIV='Refresh' CONTENT='5; URL=board-stats.asp?Action=Update&Method=Complete'>")
			end if

			if Method = "Complete" then
				response.write("<div align='center'>All forum statistics have been successfully updated. You will now be redirected in five seconds...</div>")
				response.write("<META HTTP-EQUIV='Refresh' CONTENT='5; URL=board-stats.asp'>")
			end if
			%>
			</td>
			</tr>
			<%
		end if
		%>
	</table>
	</td>
  	</tr>
</table>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -