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

📄 pop_delete.asp

📁 代码名称: Snitz Forums 2000 代码语言: 英文 代码类型: 国外代码 运行环境: ASP 授权方式: 免费代码 代码大小: 530kb 代码等级: 3 整
💻 ASP
📖 第 1 页 / 共 3 页
字号:
<%
'#################################################################################
'## Snitz Forums 2000 v3.4.05
'#################################################################################
'## Copyright (C) 2000-05 Michael Anderson, Pierre Gorissen,
'##                       Huw Reddick and Richard Kinser
'##
'## 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 (at your option) 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 our support forums at:
'## http://forum.snitz.com
'##
'## Correspondence and Marketing Questions can be sent to:
'## manderson@snitz.com
'##
'#################################################################################
%>
<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_func_secure.asp" -->
<!--#INCLUDE FILE="inc_sha256.asp"-->
<!--#INCLUDE FILE="inc_header_short.asp" -->
<% 
if Request("CAT_ID") <> "" then
	if IsNumeric(Request("CAT_ID")) = True then Cat_ID = cLng(Request("CAT_ID")) else Cat_ID = 0
end if
if Request("FORUM_ID") <> "" then
	if IsNumeric(Request("FORUM_ID")) = True then Forum_ID = cLng(Request("FORUM_ID")) else Forum_ID = 0
end if
if Request("TOPIC_ID") <> "" then
	if IsNumeric(Request("TOPIC_ID")) = True then Topic_ID = cLng(Request("TOPIC_ID")) else Topic_ID = 0
end if
if Request("REPLY_ID") <> "" then
	if IsNumeric(Request("REPLY_ID")) = True then Reply_ID = cLng(Request("REPLY_ID")) else Reply_ID = 0
end if
if Request("MEMBER_ID") <> "" then
	if IsNumeric(Request("MEMBER_ID")) = True then Member_ID = cLng(Request("MEMBER_ID")) else Member_ID = 0
end if

if (Cat_ID + Forum_ID + Topic_ID + Reply_ID + Member_ID) < 1 then
	Response.Write	"      <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """ color=""" & strHiLiteFontColor & """><b>The URL has been modified!</b></font></p>" & vbNewLine & _
			"      <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHiLiteFontColor & """><b>Possible Hacking Attempt!</b></font></p>" & vbNewLine
	WriteFooterShort
	Response.End
end if

Mode_Type = ChkString(Request("mode"), "SQLString")
strPassword = trim(Request.Form("Pass"))

if request("ARCHIVE") = "true" then
	strActivePrefix = strTablePrefix & "A_"
	ArchiveView = "true"
	ArchiveLink = "ARCHIVE=true&"
else
	strActivePrefix = strTablePrefix
	ArchiveView = ""
	ArchiveLink = ""
end if

select case Mode_Type
	case "DeleteReply"
		strEncodedPassword = sha256("" & strPassword)
		mLev = cLng(ChkUser3(strDBNTFUserName, strEncodedPassword, Reply_ID)) 
		if mLev > 0 then  '## is Member
			if (chkForumModerator(Forum_ID, strDBNTFUserName) = "1") or (mLev = 1) or (mLev = 4) then '## is Allowed
				strSql = "SELECT R_STATUS"
				strSql = strSql & " FROM " & strActivePrefix & "REPLY "
				strSql = strSql & " WHERE REPLY_ID = " & Reply_ID

				set rs = my_Conn.Execute (strSql)

				Reply_Status = rs("R_STATUS")

				rs.close
				set rs = nothing

				'## Forum_SQL - Delete reply
				strSql = "DELETE FROM " & strActivePrefix & "REPLY "
				strSql = strSql & " WHERE REPLY_ID = " & Reply_ID

				my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

				'## Forum_SQL - Get last_post and last_post_author for Topic
				strSql = "SELECT REPLY_ID, R_DATE, R_AUTHOR, R_STATUS"
				strSql = strSql & " FROM " & strActivePrefix & "REPLY "
				strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID & " "
				strSql = strSql & " AND R_STATUS <= 1 "
				strSql = strSql & " ORDER BY R_DATE DESC"

				set rs = my_Conn.Execute (strSql)

				if not(rs.eof or rs.bof) then
					strLast_Post_Reply_ID = rs("REPLY_ID")
					strLast_Post = rs("R_DATE")
					strLast_Post_Author = rs("R_AUTHOR")
				end if
				if (rs.eof or rs.bof) or IsNull(strLast_Post) or IsNull(strLast_Post_Author) then  'topic has no replies
					set rs2 = Server.CreateObject("ADODB.Recordset")

					'## Forum_SQL - Get post_date and author from Topic
					strSql = "SELECT T_AUTHOR, T_DATE "
					strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
					strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID & " "

					set rs2 = my_Conn.Execute (strSql)

					strLast_Post_Reply_ID = 0
					strLast_Post = rs2("T_DATE")
					strLast_Post_Author = rs2("T_AUTHOR")

					rs2.Close
					set rs2 = nothing

				end if

				rs.Close
				set rs = nothing

				'## FORUM_SQL - Decrease count of replies to individual topic by 1
				'## Only if R_STATUS <= 1

				if Reply_Status <= 1 then
					strSql = "UPDATE " & strActivePrefix & "TOPICS "
					strSql = strSql & " SET T_REPLIES = T_REPLIES - 1 "
					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 & ", T_LAST_POST_REPLY_ID = " & strLast_Post_Reply_ID & ""
					strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID

					my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

					'## Forum_SQL - Get last_post and last_post_author for Forum
					strSql = "SELECT TOPIC_ID, T_LAST_POST, T_LAST_POST_AUTHOR, T_LAST_POST_REPLY_ID "
					strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
					strSql = strSql & " WHERE FORUM_ID = " & Forum_ID & " "
					strSql = strSql & " ORDER BY T_LAST_POST DESC"

					set rs = my_Conn.Execute (strSql)

					if not rs.eof then
						strLast_Post = rs("T_LAST_POST")
						strLast_Post_Author = rs("T_LAST_POST_AUTHOR")
						strLast_Post_Topic_ID = rs("TOPIC_ID")
						strLast_Post_Reply_ID = rs("T_LAST_POST_REPLY_ID")
					else
						strLast_Post = ""
						strLast_Post_Author = "NULL"
						strLast_Post_Topic_ID = 0
						strLast_Post_Reply_ID = 0
					end if

					rs.Close
					set rs = nothing

					'## Forum_SQL - Decrease count of total replies in Forum by 1
					'## Only if deleted reply wasn't archived

					if ArchiveView = "" then
						strSql =  "UPDATE " & strTablePrefix & "FORUM "
						strSql = strSql & " SET F_COUNT = F_COUNT - 1 "
						strSql = strSql & ", F_LAST_POST = '" & strLast_Post & "'"
						strSql = strSql & ", F_LAST_POST_AUTHOR = " & strLast_Post_Author
						strSql = strSql & ", F_LAST_POST_TOPIC_ID = " & strLast_Post_Topic_ID
						strSql = strSql & ", F_LAST_POST_REPLY_ID = " & strLast_Post_Reply_ID
						strSql = strSql & " WHERE FORUM_ID = " & Forum_ID

						my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

						'## FORUM_SQL - Decrease count of total replies in Totals table by 1
						strSql = "UPDATE " & strTablePrefix & "TOTALS "
						strSql = strSql & " SET P_COUNT = P_COUNT - 1 "

						my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
					end if
				else
					strSql = "UPDATE " & strActivePrefix & "TOPICS "
					strSql = strSql & " SET T_UREPLIES = T_UREPLIES - 1 "
					strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID

					my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
				end if
				Response.Write	"      <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """><b>Reply Deleted!</b></font></p>" & vbNewLine & _
						"      <script language=""javascript1.2"">self.opener.location.reload();</script>" & vbNewLine
			else
				Response.Write	"      <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """ color=""" & strHiLiteFontColor & """><b>No Permissions to Delete Reply</b></p>" & vbNewLine & _
						"      <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><a href=""JavaScript:onClick=history.go(-1)"">Go Back to Re-Authenticate</a></font></p>" & vbNewLine
			end if
		else
			Response.Write	"      <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """ color=""" & strHiLiteFontColor & """><b>No Permissions to Delete Reply</b></p>" & vbNewLine & _
					"      <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><a href=""JavaScript:onClick=history.go(-1)"">Go Back to Re-Authenticate</a></font></p>" & vbNewLine
		end if
	case "DeleteTopic"
		strEncodedPassword = sha256("" & strPassword)
		mLev = cLng(chkUser5(strDBNTFUserName, strEncodedPassword, Topic_ID))
		if mLev > 0 then  '## is Member
			if (chkForumModerator(Forum_ID, strDBNTFUserName) = "1") or (mLev = 1) or (mLev = 4) then
				delAr = split(Topic_ID, ",")
				for i = 0 to ubound(delAr) 

					'## Forum_SQL - count total number of replies of TOPIC_ID  in Reply table
					set rs = Server.CreateObject("ADODB.Recordset")
					strSql = "SELECT count(REPLY_ID) AS cnt "
					strSql = strSql & " FROM " & strActivePrefix & "REPLY "
					strSql = strSql & " WHERE TOPIC_ID = " & cLng(delAr(i))

					rs.Open strSql, my_Conn
					risposte = rs("cnt")
					rs.close
					set rs = nothing

					'## Forum_SQL - get topic status so you know if the counts need to be updated
					set rs = Server.CreateObject("ADODB.Recordset")
					strSql = "SELECT T_STATUS "
					strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
					strSql = strSql & " WHERE TOPIC_ID = " & cLng(delAr(i))

					rs.Open strSql, my_Conn

					Topic_Status = rs("T_STATUS")

					rs.close
					set rs = nothing

					'## Forum_SQL - Delete the actual topics
					strSql = "DELETE FROM " & strActivePrefix & "TOPICS "
					strSql = strSql & " WHERE TOPIC_ID = " & cLng(delAr(i))
					my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

					'## Forum_SQL - Delete all replys related to the topics
					strSql = "DELETE FROM " & strActivePrefix & "REPLY "
					strSql = strSql & " WHERE TOPIC_ID = " & cLng(delAr(i))
					my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

					'## Forum_SQL - Delete any subscriptions to this topic
					strSql = "DELETE FROM " & strTablePrefix & "SUBSCRIPTIONS "
					strSql = strSql & " WHERE TOPIC_ID = " & cLng(delAr(i))
					my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

					'## Don't update if topic was in archive
					if (Topic_Status <= 1) and (ArchiveView = "") then
						'## Forum_SQL - Get last_post and last_post_author for Forum
						strSql = "SELECT TOPIC_ID, T_LAST_POST, T_LAST_POST_AUTHOR, T_LAST_POST_REPLY_ID"
						strSql = strSql & " FROM " & strTablePrefix & "TOPICS "			
						strSql = strSql & " WHERE FORUM_ID = " & Forum_ID & " "
						strSql = strSql & " ORDER BY T_LAST_POST DESC"

						set rs = my_Conn.Execute (strSql)

						if not rs.eof then
							rs.movefirst
							strLast_Post = rs("T_LAST_POST")
							strLast_Post_Author = rs("T_LAST_POST_AUTHOR")
							strLast_Post_Topic_ID = rs("TOPIC_ID")
							strLast_Post_Reply_ID = rs("T_LAST_POST_REPLY_ID")
						else
							strLast_Post = ""
							strLast_Post_Author = "NULL"
							strLast_Post_Topic_ID = 0
							strLast_Post_Reply_ID = 0
						end if

						rs.Close
						set rs = nothing

						'## Forum_SQL - Update count of replies to a topic in Forum table
						strSql = "UPDATE " & strTablePrefix & "FORUM "
						strSql = strSql & " SET F_COUNT = F_COUNT - " & cLng(risposte) + 1
						strSql = strSql & ", F_TOPICS = F_TOPICS - " & 1				
						strSql = strSql & ", F_LAST_POST = '" & strLast_Post & "' "
						strSql = strSql & ", F_LAST_POST_AUTHOR = " & strLast_Post_Author
						strSql = strSql & ", F_LAST_POST_TOPIC_ID = " & strLast_Post_Topic_ID
						strSql = strSql & ", F_LAST_POST_REPLY_ID = " & strLast_Post_Reply_ID
						strSql = strSql & " WHERE FORUM_ID = " & Forum_ID

⌨️ 快捷键说明

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