📄 editing.asp
字号:
</table>
<%
end if
end if
if Action = "Delete" then
'Check that the user as come from the editpost page
if instr(1, request.servervariables("HTTP_REFERER"), "?", 1) > 0 then
strReferedBy = left(request.servervariables("HTTP_REFERER"), (instr(1, request.servervariables("HTTP_REFERER"), "?", 1)-1))
else
strReferedBy = request.servervariables("HTTP_REFERER")
end if
strCurrentURL = Site_Forum_URL &"/editpost.asp"
if lcase(strReferedBy) <> lcase(strCurrentURL) then
strMessage = "You have reached this page in error. Click <a href='default.asp'>here</a> if you are not redirected within five seconds."
strRedirectURL = "Default.asp"
end if
if strMessage <> "" then
%>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table border="0" align="center" cellpadding="3" cellspacing="1" class="main">
<tr valign="middle" class="title">
<td align="center"><%=Site_Name%> // Error</td>
</tr>
<tr valign="top" class="body">
<td align="center">
<%=strMessage%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%
else
if request.form("delete") = 1 then
'Check if the selected post is the first one in the topic
set rsCheck = server.createobject("adodb.recordset")
sqlCheck = "SELECT Post_Index FROM Forum_Posts WHERE Post_ID = "& clng(request.form("postid")) &""
rsCheck.open sqlCheck, adoConn, CMDText
strTopic = rsCheck("Post_Index")
rsCheck.close
set rsCheck= nothing
if strTopic = 1 then
'Delete topic and all related posts
'grab stats for the topic
set rsDelete = server.createobject("adodb.recordset")
sqlDelete = "SELECT Topic_Type, Topic_Replies FROM Forum_Topics WHERE Topic_ID = "& clng(request.form("topicid")) &";"
rsDelete.open sqlDelete, adoConn, CMDText
if not (rsDelete.eof or rsDelete.bof) then
strReplies = rsDelete("Topic_Replies") + 1
end if
rsDelete.close
set rsDelete = nothing
'Decrement forum stats
set rsStats = server.createobject("adodb.recordset")
sqlStats = "SELECT * FROM Forum_Stats;"
rsStats.cursortype = 2
rsStats.locktype = 3
rsStats.open sqlStats, adoConn, CMDText
rsStats("Stats_Topics") = rsStats("Stats_Topics") - 1
rsStats("Stats_Posts") = rsStats("Stats_Posts") - (strReplies)
strstPosts = rsStats("Stats_Posts")
rsStats.update
rsStats.close
set rsStats = nothing
'Decrement User post counts
'Grab all of the posters unique ID's
set rsUser = server.createobject("adodb.recordset")
sqlUser = "SELECT Post_User_ID FROM Forum_Posts WHERE Post_Topic_ID = "& clng(request.form("topicid")) &";"
rsUser.open sqlUser, adoConn, CMDText
if not (rsUser.eof or rsUser.bof) then
UserCnt = rsUser.recordcount
UserData = rsUser.getrows()
end if
rsUser.close
set rsUser = nothing
'Loop through the gathered ID's and decrement their post counts
tempCnt = 0
do until tempCnt = UserCnt
set rsUser = server.createobject("adodb.recordset")
sqlUser = "SELECT User_Posts FROM Forum_Users WHERE User_ID = "& UserData(0,tempCnt) &";"
rsUser.cursortype = 2
rsUser.locktype = 3
rsUser.open sqlUser, adoConn, CMDText
if rsUser("User_Posts") > 0 then
rsUser("User_Posts") = rsUser("User_Posts") - 1
end if
rsUser.update
rsUser.close
tempCnt = tempCnt + 1
loop
'Delete topic
set rsDelete = server.createobject("adodb.recordset")
sqlDelete = "DELETE * FROM Forum_Topics WHERE Topic_ID = "& clng(request.form("topicid")) &";"
rsDelete.cursortype = 2
rsDelete.locktype = 3
rsDelete.open sqlDelete, adoConn
set rsdelete = nothing
'Delete posts
set rsDelete = server.createobject("adodb.recordset")
sqlDelete = "DELETE * FROM Forum_Posts WHERE Post_Topic_ID = "& clng(request.form("topicid")) &";"
rsDelete.cursortype = 2
rsDelete.locktype = 3
rsDelete.open sqlDelete, adoConn
set rsdelete = nothing
'Grab the details of the last previous poster
set rsDetails = server.createobject("adodb.recordset")
sqlDetails = "SELECT TOP 1 FP.Post_ID, FP.Post_Topic_ID, FP.Post_Time, FP.Post_User_ID, FU.User_ID, FU.User_Name, FT.Topic_Type FROM Forum_Posts FP, Forum_Users FU, Forum_Topics FT WHERE FP.Post_User_ID = FU.User_ID AND FP.Post_Topic_ID = FT.Topic_ID AND FP.Post_Forum_ID = "& clng(request.form("forumid")) &" AND FT.Topic_Type <> 0 ORDER BY FP.Post_Time DESC"
rsDetails.cursortype = 2
rsDetails.locktype = 3
rsDetails.open sqlDetails, adoConn, CMDText
if rsDetails.eof or rsDetails.bof then
strTopicID = null
strUserID = null
strUserName = null
strTime = null
else
strTopicID = rsDetails("Post_Topic_ID")
strUserID = rsDetails("User_ID")
strUserName = rsDetails("User_Name")
strTime = rsDetails("Post_Time")
end if
rsDetails.close
set rsDetails = nothing
'Update Forum table
set rsForum = server.createobject("adodb.recordset")
sqlForum = "SELECT * FROM Forum_Forums WHERE Forum_ID = "& clng(request.form("forumid")) &";"
rsForum.cursortype = 2
rsForum.locktype = 3
rsForum.open sqlForum, adoConn, CMDText
rsForum("Forum_Topics") = rsForum("Forum_Topics") - 1
if strTopicID = null then
rsForum("Forum_Posts") = 0
else
rsForum("Forum_Posts") = rsForum("Forum_Posts") - int(strReplies)
end if
rsForum("Forum_Post_Date") = strTime
rsForum("Forum_Topic_ID") = strTopicID
rsForum("Forum_User_ID") = strUserID
rsForum("Forum_User_Name") = strUserName
rsForum.update
rsForum.close
set rsForum = nothing
strMessage = "Your message has been sucessfully deleted. As your post was the first post in the topic the has also been deleted. Click <a href='displayforum.asp?F="& clng(request.form("forumid")) &"'>here</a> if you are not forwarded back to the topic within 5 seconds."
strRedirectURL = "displayforum.asp?F=" & clng(request.form("forumid"))
else
'Delete individual post only
'Delete selected post
set rsDelete = server.createobject("adodb.recordset")
sqlDelete = "SELECT * FROM Forum_Posts WHERE Post_ID = "& clng(request.form("PostId")) &""
rsDelete.cursortype = 2
rsDelete.locktype = 3
rsDelete.open sqlDelete, adoConn, CMDText
if not (rsDelete.eof or rsDelete.bof) then
strUser = rsDelete("Post_User_ID")
rsDelete.delete
end if
rsDelete.close
set rsDelete = nothing
'decrement user stats
set rsUser = server.createobject("adodb.recordset")
sqlUser = "SELECT User_Posts FROM Forum_Users WHERE User_ID = "& strUser &";"
rsUser.cursortype = 2
rsUser.locktype = 3
rsUser.open sqlUser, adoConn, CMDText
rsUser("User_Posts") = rsUser("User_Posts") - 1
rsUser.update
rsUser.close
set rsUser = nothing
'Decrement forum stats
set rsStats = server.createobject("adodb.recordset")
sqlStats = "SELECT * FROM Forum_Stats;"
rsStats.cursortype = 2
rsStats.locktype = 3
rsStats.open sqlStats, adoConn, CMDText
rsStats("Stats_Posts") = rsStats("Stats_Posts") - 1
rsStats.update
rsStats.close
set rsStats = nothing
'Grab the details of the previous post in the topic
set rsDetails = server.createobject("adodb.recordset")
sqlDetails = "SELECT TOP 1 FP.Post_ID, FP.Post_Topic_ID, FP.Post_Time, FP.Post_User_ID, FU.User_ID, FU.User_Name FROM Forum_Posts FP, Forum_Users FU WHERE FP.Post_User_ID = FU.User_ID AND FP.Post_Topic_ID = "& clng(request.form("topicid")) &" ORDER BY FP.Post_Time DESC"
rsDetails.cursortype = 2
rsDetails.locktype = 3
rsDetails.open sqlDetails, adoConn, CMDText
strTopicID = rsDetails("Post_Topic_ID")
strUserID = rsDetails("User_ID")
strUserName = rsDetails("User_Name")
strTime = rsDetails("Post_Time")
rsDetails.close
set rsDetails = nothing
'Update Topic table
set rsTopic = server.createobject("adodb.recordset")
sqlTopic = "SELECT * FROM Forum_Topics WHERE Topic_ID = "& strTopicID &";"
rsTopic.cursortype = 2
rsTopic.locktype = 3
rsTopic.open sqlTopic, adoConn, CMDText
rsTopic("Topic_Last_User_ID") = strUserID
rsTopic("Topic_Replies") = rsTopic("Topic_Replies") - 1
rsTopic("Topic_Time") = strTime
rsTopic.update
rsTopic.close
set rsTopic = nothing
'Grab the details of the newest post in the forum.
set rsDetails = server.createobject("adodb.recordset")
sqlDetails = "SELECT TOP 1 FP.Post_ID, FP.Post_Topic_ID, FP.Post_Time, FP.Post_User_ID, FU.User_ID, FU.User_Name, FT.Topic_Type FROM Forum_Posts FP, Forum_Users FU, Forum_Topics FT WHERE FP.Post_User_ID = FU.User_ID AND FP.Post_Topic_ID = FT.Topic_ID AND FP.Post_Forum_ID = "& clng(request.form("forumid")) &" AND FT.Topic_Type <> 0 ORDER BY FP.Post_Time DESC"
rsDetails.cursortype = 2
rsDetails.locktype = 3
rsDetails.open sqlDetails, adoConn, CMDText
if rsDetails.eof or rsDetails.bof then
strTopicID = null
strUserID = null
strUserName = null
strTime = null
else
strTopicID = rsDetails("Post_Topic_ID")
strUserID = rsDetails("User_ID")
strUserName = rsDetails("User_Name")
strTime = rsDetails("Post_Time")
end if
rsDetails.close
set rsDetails = nothing
'Update Forum table
set rsForum = server.createobject("adodb.recordset")
sqlForum = "SELECT * FROM Forum_Forums WHERE Forum_ID = "& clng(request.form("forumid")) &";"
rsForum.cursortype = 2
rsForum.locktype = 3
rsForum.open sqlForum, adoConn, CMDText
rsForum("Forum_Posts") = rsForum("Forum_Posts") - 1
rsForum("Forum_Post_Date") = strTime
rsForum("Forum_Topic_ID") = strTopicID
rsForum("Forum_User_ID") = strUserID
rsForum("Forum_User_Name") = strUserName
rsForum.update
rsForum.close
set rsForum = nothing
'To do decrement users posts
strMessage = "Your message has been successfully deleted. Click <a href='displaytopic.asp?T="& clng(request.form("topicid")) &"'>here</a> if you are not forwarded back to the topic within 5 seconds."
strRedirectURL = "displaytopic.asp?T=" & clng(request.form("topicid"))
end if
end if
%>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table border="0" cellpadding="3" cellspacing="1" align="center" class="main">
<tr valign="middle" class="title">
<td align="center"><%=Site_Name%> // Message Deleted</td>
</tr>
<tr valign="top" class="body">
<td align="center">
<%=strMessage%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%
end if
end if
%>
<META HTTP-EQUIV="Refresh" CONTENT="5; URL=<%=strRedirectURL%>">
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -