% '############################################################################### '## Copyright (C) 2000 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 '############################################################################### %> <% Server.ScriptTimeout = 90 ' -- Declare the variables and initialize them with the values from either the querystring (1st time ' -- into the form) or the form (all other times through the form) ' -- Mode - 1 = Approve, 2 = Hold, 3 = Reject Dim Mode, ModLevel, CatID, ForumID, TopicID, ReplyID, Password, Result, Comments CatID = Request("CAT_ID") ForumID = Request("FORUM_ID") TopicID = Request("TOPIC_ID") ReplyID = Request("REPLY_ID") Comments = Request.Form("COMMENTS") ' Mode: 1 = Approve, 2 = Hold, 3 = Reject Mode = Request("MODE") if Mode = "" then Mode = 0 end if ' Set the ModLevel for the operation If Mode > 0 then If CatID = "0" or CatID = "" then ModLevel = "BOARD" Elseif ForumID = "0" or ForumID = "" then ModLevel = "CAT" Elseif TopicID = "0" or TopicID = "" then ModLevel = "FORUM" Elseif ReplyId = "0" or ReplyID = "" then ModLevel = "TOPIC" Elseif ReplyId = "X" then ModLevel = "ALLPOSTS" Else ModLevel = "REPLY" End if End if ' ## If logging in, use the value from the form, otherwise use the value in the cookie/session variable. If Request("UserCheck") = "Y" then strDBNTUserName = Request.Form("Name") Password = Request.Form("Password") Response.Write "Name = " & strDBNTUserName & ", pword = " & Password & vbNewline else strDBNTUserName = Request.Cookies(strUniqueID &"User")("Name") Password = Request.Cookies(strUniqueID & "User")("Pword") if strAuthType = "nt" then strDBNTUserName = Session(strCookieURL & "userID") end if end if ' ## Check the permissions before allowing processing to continue..... mlev = cint(chkUser(strDBNTUserName, Password)) if mlev = 0 then LoginForm elseif Mode = "" or Mode = 0 then ModeForm else if ModLevel = "BOARD" or ModLevel = "CAT" then if mlev < 4 then Response.Write "
Only Admins May " if Mode = 1 then Result = "Approve " elseif Mode = 2 then Result = "Hold " else Result = "Reject " end if if ModLevel = "BOARD" then Result = Result & "All Topics and Replies for the Forum. " else Response.Write "the Topics and Replies for this Category " end if Response.Write Result & "
" & vbNewline LoginForm elseif Mode = 1 or Mode = 2 then Approve_Hold else Delete end if else ' -- Not an admin or moderator. Can't do... if mlev < 4 and chkforumModerator(ForumID, strDBNTUserName) <> "1" then Response.Write "Only Admins and Moderators May " if Mode = 1 then Result = "Approve " elseif Mode = 2 then Result = "Hold " else Result = "Reject " end if if ModLevel = "FORUM" then Result = Result & "All Topics and Replies for the Forum. " elseif ModLevel = "TOPIC" then Result = Result & "this Topic. " elseif ModLevel = "ALLPOSTS" then Result = Result & "All Posts for this Topic. " else Result = Result & "this Reply. " end if Response.Write Result & "
" & vbNewline LoginForm elseif Mode = 1 or Mode = 2 then ' -- Do the approval/Hold Approve_Hold else Delete end if end if end if %> <% sub Approve_Hold ' Loop through the topic table to determine which records need to be updated. if ModLevel <> "Reply" then strSql = "SELECT T.CAT_ID, " strSql = strSql & "T.FORUM_ID, " strSql = strSql & "T.TOPIC_ID, " strSql = strSql & "T.T_LAST_POST as Post_Date, " strSql = strSql & "M.M_NAME, " strSql = strSql & "M.MEMBER_ID " strSql = strSql & " FROM " & strTablePrefix & "TOPICS T, " strSql = strSql & strMemberTablePrefix & "MEMBERS M" strSql = strSql & " WHERE (T.T_STATUS = 2 OR T.T_STATUS = 3) " strSql = strSql & " AND T.T_AUTHOR = M.MEMBER_ID" ' Set the appropriate level of moderation based on the passed mode. if ModLevel <> "BOARD" then if Modlevel = "CAT" then strSql = strSql & " AND T.CAT_ID = " & CatID elseif Modlevel = "FORUM" then strSql = strSql & " AND T.FORUM_ID = " & ForumID else strSql = strSql & " AND T.TOPIC_ID = " & TopicID end if end if set rsLoop = my_Conn.Execute (strSql) if rsLoop.EOF or rsLoop.BOF then ' Do nothing - No records meet this criteria else do until rsLoop.EOF LoopCatID = rsLoop("CAT_ID") LoopForumID = rsLoop("FORUM_ID") LoopTopicID = rsLoop("TOPIC_ID") LoopMemberID = rsLoop("MEMBER_ID") LoopMemberName = rsLoop("M_NAME") LoopPostDate = rsLoop("POST_DATE") strSql = "UPDATE " & strTablePrefix & "TOPICS " strSql = strSql & " Set " & strTablePrefix & "TOPICS.T_STATUS = " if Mode = 1 then StrSql = StrSql & " 1" else StrSql = StrSql & " 3" end if strSql = strSql & " WHERE " & strTablePrefix & "TOPICS.CAT_ID = " & LoopCatID strSql = strSql & " AND " & strTablePrefix & "TOPICS.Forum_ID = " & LoopForumID strSql = strSql & " AND " & strTablePrefix & "TOPICS.Topic_ID = " & LoopTopicID my_Conn.Execute strSql ' -- If approving, make sure to update the appropriate counts.. if Comments <> "" then Send_Comment_Email LoopMemberName, LoopMemberID, LoopCatID, LoopForumID, LoopTopicID, 0 end if if Mode = 1 then doPCount doTCount UpdateForum "Topic", LoopForumID, LoopMemberID, LoopPostDate UpdateUser LoopMemberID, LoopPostDate ProcessSubscriptions LoopMemberID, LoopCatID, LoopForumID, LoopTopicID end if rsLoop.MoveNext loop end if rsLoop.Close set rsLoop = nothing end if ' Update the replies if appropriate strSql = "SELECT R.CAT_ID, " & _ "R.FORUM_ID, " & _ "R.TOPIC_ID, " & _ "R.REPLY_ID, " & _ "R.R_DATE as Post_Date, " & _ "M.M_NAME, " & _ "M.MEMBER_ID " & _ " FROM " & strTablePrefix & "REPLY R, " & _ strMemberTablePrefix & "MEMBERS M" & _ " WHERE R.R_Status = 2 " & _ " AND R.R_AUTHOR = M.MEMBER_ID " if ModLevel <> "BOARD" then If ModLevel = "CAT" then strSql = strSql & " AND R.CAT_ID = " & CatID elseif ModLevel = "FORUM" then strSql = strSql & " AND R.FORUM_ID = " & ForumID elseif ModLevel = "TOPIC" or ModLevel = "ALLPOSTS" then strSql = strSql & " AND R.TOPIC_ID = " & TopicID else strSql = strSql & "AND R.REPLY_ID = " & ReplyID end if end if set rsLoop = my_Conn.Execute (strSql) if rsLoop.EOF or rsLoop.BOF then ' Do nothing - No records matching the criteria were found else do until rsLoop.EOF LoopMemberName = rsLoop("M_NAME") LoopMemberID = rsLoop("MEMBER_ID") LoopCatID = rsLoop("CAT_ID") LoopForumID = rsLoop("FORUM_ID") LoopTopicID = rsLoop("TOPIC_ID") LoopReplyID = rsLoop("REPLY_ID") LoopPostDate = rsLoop("POST_DATE") StrSql = "UPDATE " & strTablePrefix & "REPLY " StrSql = StrSql & " Set " & strTablePrefix & "REPLY.R_STATUS = " if Mode = 1 then StrSql = StrSql & " 1" else StrSql = StrSql & " 3" end if StrSql = StrSql & " WHERE " & strTablePrefix & "REPLY.REPLY_ID = " & LoopReplyID my_Conn.Execute strSql if Comments <> "" then Send_Comment_Email LoopMemberName, LoopMemberID, LoopCatID, LoopForumID, LoopTopicID, LoopReplyID end if if Mode = 1 then doPCount UpdateTopic LoopTopicID, LoopMemberID, LoopPostDate UpdateForum "Post", LoopForumID, LoopMemberID, LoopPostDate UpdateUser LoopMemberID, LoopPostDate ProcessSubscriptions MemberID, LoopCatID, LoopForumID, LoopTopicID end if rsLoop.MoveNext loop end if rsLoop.Close set rsLoop = nothing ' ## Build final result message If ModLevel = "BOARD" then Result = "All Topics and Replies have " Elseif ModLevel = "CAT" then Result = "All Topics and Replies in this Category have " Elseif ModLevel = "FORUM" then Result = "All Topics and Replies in this Forum have " Elseif ModLevel = "TOPIC" then Result = "This Topic has " Elseif ModLevel = "ALLPOSTS" then Result = "All posts for this topic have " Else Result = "This Reply has " End if If Mode = 2 then Result = Result & " Been Placed on Hold." Elseif Mode = 3 then Result = Result & " Been Deleted." Else Result = Result & " Been Approved." End if Response.Write "" & Result & "
" & vbNewline Response.Write "(Remember to Refresh your" & " Browser)
" & vbNewline end sub sub Delete ' Loop through the topic table to determine which records need to be updated. if ModLevel <> "Reply" then strSql = "SELECT T.CAT_ID, " strSql = strSql & "T.FORUM_ID, " strSql = strSql & "T.TOPIC_ID, " strSql = strSql & "T.T_LAST_POST as Post_Date, " strSql = strSql & "M.M_NAME, " strSql = strSql & "M.MEMBER_ID " strSql = strSql & " FROM " & strTablePrefix & "TOPICS T, " strSql = strSql & strMemberTablePrefix & "MEMBERS M" strSql = strSql & " WHERE (T.T_STATUS = 2 OR T.T_STATUS = 3) " strSql = strSql & " AND T.T_AUTHOR = M.MEMBER_ID" ' Set the appropriate level of moderation based on the passed mode. if ModLevel <> "BOARD" then if Modlevel = "CAT" then strSql = strSql & " AND T.CAT_ID = " & CatID elseif Modlevel = "FORUM" then strSql = strSql & " AND T.FORUM_ID = " & ForumID else strSql = strSql & " AND T.TOPIC_ID = " & TopicID end if end if set rsLoop = my_Conn.Execute (strSql) if rsLoop.EOF or rsLoop.BOF then ' Do nothing - No records meet this criteria else do until rsLoop.EOF LoopCatId = rsLoop("CAT_ID") LoopForumID = rsLoop("FORUM_ID") LoopTopicID = rsLoop("TOPIC_ID") LoopMemberName = rsLoop("M_NAME") LoopMemberID = rsLoop("MEMBER_ID") if Comments <> "" then Send_Comment_Email LoopMemberName, LoopMemberID, LoopCatID, LoopForumID, LoopTopicID, 0 end if StrSql = "DELETE FROM " & strTablePrefix & "TOPICS " StrSql = StrSql & " WHERE " & strTablePrefix & "TOPICS.CAT_ID = " & LoopCatID StrSql = StrSql & " AND " & strTablePrefix & "TOPICS.Forum_ID = " & LoopForumID StrSql = StrSql & " AND " & strTablePrefix & "TOPICS.Topic_ID = " & LoopTopicID my_Conn.Execute strSql ' -- If approving, make sure to update the appropriate counts.. rsLoop.MoveNext loop end if rsLoop.Close set rsLoop = nothing End if ' Update the replies if appropriate strSql = "SELECT R.CAT_ID, " & _ "R.FORUM_ID, " & _ "R.TOPIC_ID, " & _ "R.REPLY_ID, " & _ "R.R_DATE as Post_Date, " & _ "M.M_NAME, " & _ "M.MEMBER_ID " & _ " FROM " & strTablePrefix & "REPLY R, " & strMemberTablePrefix & "MEMBERS M" & _ " WHERE (R.R_Status = 2 OR R.R_Status = 3) " & _ " AND R.R_AUTHOR = M.MEMBER_ID " if ModLevel <> "BOARD" then If ModLevel = "CAT" then strSql = strSql & " AND R.CAT_ID = " & CatID elseif ModLevel = "FORUM" then strSql = strSql & " AND R.FORUM_ID = " & ForumID elseif ModLevel = "TOPIC" then strSql = strSql & " AND R.TOPIC_ID = " & TopicID else strSql = strSql & "AND R.REPLY_ID = " & ReplyID end if end if set rsLoop = my_Conn.Execute (strSql) if rsLoop.EOF or rsLoop.BOF then ' Do nothing - No records matching the criteria were found else do until rsLoop.EOF if Comments <> "" then Send_Comment_Email rsLoop("M_NAME"), rsLoop("MEMBER_ID"), rsLoop("CAT_ID"), rsLoop("FORUM_ID"), rsLoop("TOPIC_ID"), rsLoop("REPLY_ID") end if StrSql = "DELETE FROM " & strTablePrefix & "REPLY " StrSql = StrSql & " WHERE " & strTablePrefix & "REPLY.REPLY_ID = " & rsLoop("REPLY_ID") my_Conn.Execute strSql rsLoop.MoveNext loop end if rsLoop.Close set rsLoop = nothing ' ## Build final result message If ModLevel = "BOARD" then Result = "All Topics and Replies have " Elseif ModLevel = "CAT" then Result = "All Topics and Replies in this Category have " Elseif ModLevel = "FORUM" then Result = "All Topics and Replies in this Forum have " Elseif ModLevel = "TOPIC" then Result = "This Topic has " Elseif ModLevel = "ALLPOSTS" then Result = "All posts for this topic have " Else Result = "This Reply has " End if If Mode = 2 then Result = Result & " Been Placed on Hold." ElseIf Mode = 3 then Result = Result & " Been Deleted." Else Result = Result & " Been Approved." End if Response.Write "" & Result & "
" & vbNewline Response.Write "(Remember to Refresh your" & " Browser)
" & vbNewline end sub ' ## LoginForm - This is just the form which is used to login if the person is ' ## not logged in or does not have access to do the moderation. sub LoginForm Response.Write "" & vbNewline end Sub ' ## ModeForm - This is the form which is used to determine exactly what the admin/moderator wants ' ## to do with the posts he is working on. sub ModeForm Response.Write "" & vbNewline end Sub ' ## UpdateForum - This will update the forum table by adding to the total ' ## posts (and total topics if appropriate), ' ## and will also update the last forum post date and poster if ' ## appropriate. sub UpdateForum(UpdateType, ForumID, MemberID, PostDate) dim UpdateLastPost ' -- Check the last date/time to see if they need updating. strSql = " SELECT " & strTablePrefix & "FORUM.F_LAST_POST " strSql = strSql & " FROM " & strTablePrefix & "FORUM " strSql = strSql & " WHERE " & strTablePrefix & "FORUM.FORUM_ID = " & ForumID set RsCheck = my_Conn.Execute (strSql) if rsCheck("F_LAST_POST") < PostDate then UpdateLastPost = "Y" end if rsCheck.Close set rsCheck = nothing strSql = "UPDATE " & strTablePrefix & "FORUM " strSql = strSql & " SET " & strTablePrefix & "FORUM.F_COUNT = " & strTablePrefix & "FORUM.F_COUNT + 1, " strSql = strSql & strTablePrefix & "FORUM.F_TOPICS = " & strTablePrefix & "FORUM.F_TOPICS + 1 " if UpdateLastPost = "Y" then strSql = strSql & ", " & strTablePrefix & "FORUM.F_LAST_POST = '" & PostDate & "'" strSql = strSql & ", " & strTablePrefix & "FORUM.F_LAST_POST_Author = " & MemberID end if strSql = strSql & " WHERE " & strTablePrefix & "FORUM.FORUM_ID = " & ForumID my_Conn.Execute (strSql) end sub ' ## UpdateTopic - This will update the T_REPLIES field (and the T_LAST_POST & T_LAST_POSTER if applicable) ' ## for the appropriate topic sub UpdateTopic(TopicID, MemberID, PostDate) dim UpdateLastPost ' -- Check the last date/time to see if they need updating. strSql = " SELECT " & strTablePrefix & "TOPICS.T_LAST_POST " strSql = strSql & " FROM " & strTablePrefix & "TOPICS " strSql = strSql & " WHERE " & strTablePrefix & "TOPICS.TOPIC_ID = " & TopicID set RsCheck = my_Conn.Execute (strSql) if rsCheck("T_LAST_POST") < PostDate then UpdateLastPost = "Y" end if rsCheck.Close set rsCheck = nothing strSql = "UPDATE " & strTablePrefix & "TOPICS " strSql = strSql & " SET " & strTablePrefix & "TOPICS.T_REPLIES = " & strTablePrefix & "TOPICS.T_REPLIES + 1 " if UpdateLastPost = "Y" then strSql = strSql & ", " & strTablePrefix & "TOPICS.T_LAST_POST = '" & PostDate & "'" strSql = strSql & ", " & strTablePrefix & "TOPICS.T_LAST_POST_AUTHOR = " & MemberID end if strSQL = strSQL & " WHERE " & strTablePrefix & "TOPICS.TOPIC_ID =" & TopicID 'Response.Write "strSql = " & strSql my_Conn.Execute (strSql) end sub ' ## UpdateUser - This will update the members table by adding to the total ' ## posts (and total topics if appropriate), and will also update ' ## the last forum post date and poster if appropriate. sub UpdateUser(MemberID, PostDate) dim UpdateLastPost ' -- Check to see if this post is the newest one for the member... strSql = " SELECT " & strMemberTablePrefix & "MEMBERS.M_LASTPOSTDATE " strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS.MEMBER_ID = " & MemberID set RsCheck = my_Conn.Execute (strSql) if RsCheck("M_LASTPOSTDATE") < PostDate then UpdateLastPost = "Y" end if rsCheck.Close set rsCheck = nothing strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET " & strMemberTablePrefix & "MEMBERS.M_POSTS = (" & strMemberTablePrefix & "MEMBERS.M_POSTS + 1)" if UpdateLastPost = "Y" then strSql = strSql & ", " & strMemberTablePrefix & "MEMBERS.M_LASTPOSTDATE = '" & PostDate & "'" end if strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS.MEMBER_ID = " & MemberID my_Conn.Execute (strSql) end sub '## Send_Comment_Email - This sub will send and email to the poster and tell them what the moderator '## or Admin did with their posts. sub Send_Comment_Email (MemberName, MemberID, CatID, ForumID, TopicID, ReplyID) ' -- Get the Admin/Moderator MemberID AdminModeratorID = getMemberNumber(strDBNTUserName) ' -- Get the Admin/Moderator Name AdminModeratorName = getMemberName(AdminModeratorID) ' -- Get the Admin/Moderator Email StrSql = "SELECT M_EMAIL FROM " & strMemberTablePrefix & "MEMBERS" & _ " WHERE MEMBER_ID = " & AdminModeratorID set rsSub = my_Conn.Execute (strSql) if rsSub.EOF or rsSub.BOF then exit sub else AdminModeratorEmail = rsSub("M_EMAIL") end if ' -- Get the Category Name and Forum Name StrSql = "SELECT C.CAT_NAME, F.F_SUBJECT " & _ " FROM " & strTablePrefix & "CATEGORY C, " & strTablePrefix & "FORUM F" & _ " WHERE C.CAT_ID = " & CatID & " AND F.FORUM_ID = " & ForumID set rsSub = my_Conn.Execute (strSql) if RsSub.Eof or RsSub.BOF then ' Do Nothing -- Should never happen else CatName = rsSub("CAT_NAME") ForumName = rsSub("F_SUBJECT") end if ' -- Get the topic title StrSql = "SELECT T.T_SUBJECT FROM " & strTablePrefix & "TOPICS T" & _ " WHERE T.TOPIC_ID = " & TopicId set rsSub = my_Conn.Execute (strSql) if rsSub.EOF or rsSub.BOF then TopicName = "" else TopicName = rsSub("T_SUBJECT") end if rsSub.Close set rsSub = Nothing StrSql = "SELECT M_EMAIL FROM " & strMemberTablePrefix & "MEMBERS" & _ " WHERE MEMBER_ID = " & MemberID set rsSub = my_Conn.Execute (strSql) if rsSub.EOF or rsSub.BOF then exit sub else MemberEmail = rsSub("M_EMAIL") end if strRecipientsName = MemberName strRecipients = MemberEmail strMessage = "Hello " & MemberName & "." & vbNewline & vbNewline & _ " You made a " if Reply = 0 then strMessage = strMessage & "post " else strMessage = strMessage & "reply to the post " end if strMessage = strMessage & "in the " & ForumName & " forum entitled " & _ TopicName & ". " & AdminModeratorName & " has decided to " if Mode = 1 then strMessage = strMessage & "approve your post " elseif Mode = 2 then strMessage = strMessage & "place your post on hold " else strMessage = strMessage & "reject your post " end if strMessage = strMessage & " for the following reason: " & vbNewline & vbNewline & _ Comments & vbNewline & vbNewline & _ "If you have any questions, please contact " & AdminModeratorName & _ " at " & AdminModeratorEmail %> <% end sub %>