% '################################################################################# '## Copyright (C) 2000-01 Michael Anderson and Pierre Gorissen '## '## This program is free software; you can redistribute it and/or '## modify it under the terms of the GNU General Public License '## as published by the Free Software Foundation; either version 2 '## of the License, or any later version. '## '## All copyright notices regarding Snitz Forums 2000 '## must remain intact in the scripts and in the outputted HTML '## The "powered by" text/logo with a link back to '## http://forum.snitz.com in the footer of the pages MUST '## remain visible when the pages are viewed on the internet or intranet. '## '## This program is distributed in the hope that it will be useful, '## but WITHOUT ANY WARRANTY; without even the implied warranty of '## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '## GNU General Public License for more details. '## '## You should have received a copy of the GNU General Public License '## along with this program; if not, write to the Free Software '## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. '## '## Support can be obtained from support forums at: '## http://forum.snitz.com '## '## Correspondence and Marketing Questions can be sent to: '## reinhold@bigfoot.com '## '## or '## '## Snitz Communications '## C/O: Michael Anderson '## PO Box 200 '## Harpswell, ME 04079 '################################################################################# %> <% If Session(strCookieURL & "Approval") = "15916941253" Then %> <% intStep = Request.QueryString("Step") if intStep = "" or IsNull(intStep) then intStep = 1 else intStep = CInt(intStep) end if if intStep < 4 then Response.write "" else Response.write "" end if %>
All Forums Admin Section Update Forum Counts |
Updating Counts Step <%= intStep %> of 4 |
|
Topics: | " & vbNewline Response.Write ""
'## Forum_SQL - Get contents of the Forum table related to counting
strSql = "SELECT FORUM_ID, F_TOPICS FROM " & strTablePrefix & "FORUM WHERE F_TYPE <> 1 "
rs.Open strSql, my_Conn
rs.MoveFirst
i = 0
do until rs.EOF
i = i + 1
'## Forum_SQL - count total number of topics in each forum in Topics table
strSql = "SELECT count(FORUM_ID) AS cnt "
strSql = strSql & " FROM " & strTablePrefix & "TOPICS "
strSql = strSql & " WHERE FORUM_ID = " & rs("FORUM_ID")
strSql = strSql & " AND T_STATUS <= 1 "
rs1.Open strSql, my_Conn
if rs1.EOF or rs1.BOF then
intF_TOPICS = 0
else
intF_TOPICS = rs1("cnt")
end if
rs1.close
'## Forum_SQL - count total number of topics in each forum in A_Topics table
strSql = "SELECT count(FORUM_ID) AS cnt "
strSql = strSql & " FROM " & strTablePrefix & "A_TOPICS "
strSql = strSql & " WHERE FORUM_ID = " & rs("FORUM_ID")
strSql = strSql & " AND T_STATUS <= 1 "
rs1.Open strSql, my_Conn
if rs1.EOF or rs1.BOF then
intF_A_TOPICS = 0
else
intF_A_TOPICS = rs1("cnt")
end if
rs1.close
strSql = "UPDATE " & strTablePrefix & "FORUM "
strSql = strSql & " SET F_TOPICS = " & intF_TOPICS
strSql = strSql & " , F_A_TOPICS = " & intF_A_TOPICS
strSql = strSql & " WHERE FORUM_ID = " & rs("FORUM_ID")
my_conn.execute(strSql)
rs.MoveNext
Response.Write "."
if i = 80 then
Response.Write " " & vbNewline i = 0 end if loop rs.Close Response.Write " | " & vbNewline
Response.Write "
Topic Replies: | " & vbNewline Response.Write ""
'## Forum_SQL
strSql = "SELECT TOPIC_ID, T_REPLIES FROM " & strTablePrefix & "TOPICS"
strSql = strSql & " WHERE " & strTablePrefix & "TOPICS.T_STATUS <= 1"
rs.Open strSql, my_Conn
i = 0
do until rs.EOF
i = i + 1
'## Forum_SQL - count total number of replies in Topics table
strSql = "SELECT count(REPLY_ID) AS cnt "
strSql = strSql & " FROM " & strTablePrefix & "REPLY "
strSql = strSql & " WHERE TOPIC_ID = " & rs("TOPIC_ID")
strSql = strSql & " AND R_STATUS <= 1 "
rs1.Open strSql, my_Conn
if rs1.EOF or rs1.BOF or (rs1("cnt") = 0) then
intT_REPLIES = 0
set rs2 = Server.CreateObject("ADODB.Recordset")
'## Forum_SQL - Get post_date and author from Topic
strSql = "SELECT T_AUTHOR, T_DATE "
strSql = strSql & " FROM " & strTablePrefix & "TOPICS "
strSql = strSql & " WHERE TOPIC_ID = " & rs("TOPIC_ID") & " "
strSql = strSql & " AND T_STATUS <= 1"
rs2.Open strSql, my_Conn
if not(rs2.eof or rs2.bof) then
strLast_Post = rs2("T_DATE")
strLast_Post_Author = rs2("T_AUTHOR")
else
strLast_Post = ""
strLast_Post_Author = ""
end if
rs2.Close
set rs2 = nothing
else
intT_REPLIES = rs1("cnt")
'## Forum_SQL - Get last_post and last_post_author for Topic
strSql = "SELECT R_DATE, R_AUTHOR "
strSql = strSql & " FROM " & strTablePrefix & "REPLY "
strSql = strSql & " WHERE TOPIC_ID = " & rs("TOPIC_ID") & " "
strSql = strSql & " AND R_STATUS <= 1"
strSql = strSql & " ORDER BY R_DATE DESC"
set rs3 = my_Conn.Execute (strSql)
if not(rs3.eof or rs3.bof) then
rs3.movefirst
strLast_Post = rs3("R_DATE")
strLast_Post_Author = rs3("R_AUTHOR")
else
strLast_Post = ""
strLast_Post_Author = ""
end if
rs3.close
set rs3 = nothing
end if
strSql = "UPDATE " & strTablePrefix & "TOPICS "
strSql = strSql & " SET T_REPLIES = " & intT_REPLIES
if strLast_Post <> "" then
strSql = strSql & ", T_LAST_POST = '" & strLast_Post & "'"
if strLast_Post_Author <> "" then
strSql = strSql & ", T_LAST_POST_AUTHOR = " & strLast_Post_Author
end if
end if
strSql = strSql & " WHERE TOPIC_ID = " & rs("TOPIC_ID")
my_conn.execute(strSql)
rs1.Close
rs.MoveNext
Response.Write "."
if i = 80 then
Response.Write " " & vbNewline i = 0 end if loop rs.Close Response.Write " | " & vbNewline
Response.Write "
Forum Replies: | " & vbNewline Response.Write ""
'## Forum_SQL - Get values from Forum table needed to count replies
strSql = "SELECT FORUM_ID, F_COUNT FROM " & strTablePrefix & "FORUM WHERE F_TYPE <> 1 "
rs.Open strSql, my_Conn, 2, 2
do until rs.EOF
'## Forum_SQL - Count total number of Replies
strSql = "SELECT Sum(" & strTablePrefix & "TOPICS.T_REPLIES) AS SumOfT_REPLIES, Count(" & strTablePrefix & "TOPICS.T_REPLIES) AS cnt "
strSql = strSql & " FROM " & strTablePrefix & "TOPICS "
strSql = strSql & " WHERE " & strTablePrefix & "TOPICS.FORUM_ID = " & rs("FORUM_ID")
strSql = strSql & " AND " & strTablePrefix & "TOPICS.T_STATUS <= 1"
rs1.Open strSql, my_Conn
if rs1.EOF or rs1.BOF then
intF_COUNT = 0
intF_TOPICS = 0
else
intF_COUNT = rs1("cnt") + rs1("SumOfT_REPLIES")
intF_TOPICS = rs1("cnt")
end if
if IsNull(intF_COUNT) then intF_COUNT = 0
if IsNull(intF_TOPICS) then intF_TOPICS = 0
rs1.close
'## Forum_SQL - Count total number of Archived Replies
strSql = "SELECT Sum(" & strTablePrefix & "A_TOPICS.T_REPLIES) AS SumOfT_REPLIES, Count(" & strTablePrefix & "A_TOPICS.T_REPLIES) AS cnt "
strSql = strSql & " FROM " & strTablePrefix & "A_TOPICS "
strSql = strSql & " WHERE " & strTablePrefix & "A_TOPICS.FORUM_ID = " & rs("FORUM_ID")
strSql = strSql & " AND " & strTablePrefix & "A_TOPICS.T_STATUS <= 1"
rs1.Open strSql, my_Conn
if rs1.EOF or rs1.BOF then
intF_A_COUNT = 0
intF_A_TOPICS = 0
else
intF_A_COUNT = rs1("cnt") + rs1("SumOfT_REPLIES")
intF_A_TOPICS = rs1("cnt")
end if
if IsNull(intF_A_COUNT) then intF_A_COUNT = 0
if IsNull(intF_A_TOPICS) then intF_A_TOPICS = 0
rs1.close
'## Forum_SQL - Get last_post and last_post_author for Forum
strSql = "SELECT T_LAST_POST, T_LAST_POST_AUTHOR "
strSql = strSql & " FROM " & strTablePrefix & "TOPICS "
strSql = strSql & " WHERE FORUM_ID = " & rs("FORUM_ID") & " "
strSql = strSql & " AND " & strTablePrefix & "TOPICS.T_STATUS <= 1"
strSql = strSql & " ORDER BY T_LAST_POST DESC"
set rs2 = my_Conn.Execute (strSql)
if not (rs2.eof or rs2.bof) then
strLast_Post = rs2("T_LAST_POST")
strLast_Post_Author = rs2("T_LAST_POST_AUTHOR")
else
strLast_Post = ""
strLast_Post_Author = ""
end if
rs2.Close
set rs2 = nothing
strSql = "UPDATE " & strTablePrefix & "FORUM "
strSql = strSql & " SET F_COUNT = " & intF_COUNT
strSql = strSql & ", F_TOPICS = " & intF_TOPICS
strSql = strSql & ", F_A_COUNT = " & intF_A_COUNT
strSql = strSql & ", F_A_TOPICS = " & intF_A_TOPICS
if strLast_Post <> "" then
strSql = strSql & ", F_LAST_POST = '" & strLast_Post & "' "
if strLast_Post_Author <> "" then
strSql = strSql & ", F_LAST_POST_AUTHOR = " & strLast_Post_Author
end if
end if
strSql = strSql & " WHERE FORUM_ID = " & rs("FORUM_ID")
my_conn.execute(strSql)
rs.MoveNext
Response.Write "."
if i = 80 then
Response.Write " " & vbNewline i = 0 end if loop rs.Close Response.Write " | " & vbNewline
Response.Write "
Totals: | " & vbNewline Response.Write ""
'## Forum_SQL - Total of Topics
strSql = "SELECT Sum(" & strTablePrefix & "FORUM.F_TOPICS) "
strSql = strSql & " AS SumOfF_TOPICS "
strSql = strSql & ", Sum(" & strTablePrefix & "FORUM.F_A_TOPICS) "
strSql = strSql & " AS SumOfF_A_TOPICS "
strSql = strSql & " FROM " & strTablePrefix & "FORUM WHERE F_TYPE <> 1 "
rs.Open strSql, my_Conn
Response.Write "Total Topics: " & RS("SumOfF_TOPICS") & " " & vbNewline Response.Write "Archived Topics: " & RS("SumOfF_A_TOPICS") & " " & vbNewline '## Forum_SQL - Write total Topics to Totals table strSql = "UPDATE " & strTablePrefix & "TOTALS " strSql = strSql & " SET T_COUNT = " & rs("SumOfF_TOPICS") strSql = strSql & " , T_A_COUNT = " & rs("SumOfF_A_TOPICS") rs.Close my_Conn.Execute strSql '## Forum_SQL - Total all the replies for each topic strSql = "SELECT Sum(" & strTablePrefix & "FORUM.F_COUNT) " strSql = strSql & " AS SumOfF_COUNT " strSql = strSql & ", Sum(" & strTablePrefix & "FORUM.F_A_COUNT) " strSql = strSql & " AS SumOfF_A_COUNT " strSql = strSql & " FROM " & strTablePrefix & "FORUM WHERE F_TYPE <> 1 " set rs = my_Conn.Execute (strSql) 'rs.Open strSql, my_Conn if rs("SumOfF_COUNT") <> "" then Response.Write "Total Posts: " & RS("SumOfF_COUNT") & " " & vbNewline strSumOfF_COUNT = rs("SumOfF_COUNT") else Response.Write "Total Posts: 0 " & vbNewline strSumOfF_COUNT = "0" end if if rs("SumOfF_A_COUNT") <> "" then Response.Write "Total Archived Posts: " & RS("SumOfF_A_COUNT") & " " & vbNewline strSumOfF_A_COUNT = rs("SumOfF_A_COUNT") else Response.Write "Total Posts: 0 " & vbNewline strSumOfF_A_COUNT = "0" end if '## Forum_SQL - Write total replies to the Totals table strSql = "UPDATE " & strTablePrefix & "TOTALS " strSql = strSql & " SET P_COUNT = " & strSumOfF_COUNT strSql = strSql & " , P_A_COUNT = " & strSumOfF_A_COUNT rs.Close my_Conn.Execute strSql '## Forum_SQL - Total number of users strSql = "SELECT Count(MEMBER_ID) " strSql = strSql & " AS CountOf " strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS" rs.Open strSql, my_Conn Response.Write "Registered Users: " & RS("Countof") & " " & vbNewline '## Forum_SQL - Write total number of users to Totals table strSql = " UPDATE " & strTablePrefix & "TOTALS " strSql = strSql & " SET U_COUNT = " & cint(RS("Countof")) rs.Close my_Conn.Execute strSql Response.Write " | " & vbNewline
Response.Write "
" & vbNewline Response.Write " Count Update Complete | " & vbNewline
Response.Write " |
" & vbNewline Response.Write " Back to Admin Home | " & vbNewline
Response.Write "