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

📄 editing.asp

📁 简介:一个程序小巧而功能强大
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<!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" -->
<!--#include file="Includes/inc-common.asp" -->
<!--#include file="Includes/func-aspcode.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>
<%
'Check user is logged in
if session("UserID") = "" then
	strMessage = "You must be logged in to " & Site_Name & " to post a message. Click <a href='default.asp'>here</a> to go back."
	strRedirectURL = "default.asp"
end if

Action = request.querystring("Action")
if Action = "" then
	Action = "Edit"
end if

if Action= "Edit" 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
	
	'Check user has filled text field
	if len(request.form("Text")) < 1 then
		strMessage = "Your post must contain some text. Click <a href='editpost.asp?P="& request.form("PostID") &"'>here</a> to try again."
		strRedirectURL = "editpost.asp?P="& request.form("PostID") 
	end if
	
	'Check topic is being moved to a valid forum
	if instr(1, request.form("ForumID"), "C", 1) = 1 then
		strMessage = "You have attempted to move the selected topic to a category rather than a forum. Click <a href='editpost.asp?P="& request.form("PostID") &"'>here</a> to try again."
		strRedirectURL = "editpost.asp?P="& request.form("PostID") 
	end if

	'Check valid topic has been specified and topic is not closed
	set rsTopicCheck = server.createobject("adodb.recordset")
	sqlTopicCheck = "SELECT Topic_ID, Topic_Status FROM Forum_Topics WHERE Topic_ID = "& clng(request.form("TopicID")) &";"
	rsTopicCheck.open sqlTopicCheck, adoConn, CMDText
	if rsTopicCheck.eof or rsTopicCheck.bof then
		strMessage = "An invalid topic has been specified, if you have followed a valid link please contact the board administrator. Click <a href='default.asp'>here</a> to go back."
		strRedirectURL = "default.asp"
	end if
	if rsTopicCheck("Topic_Status") = 0 then
		strMessage = "The topic that you are trying to edit has been closed by the administrators. Please click <a href='displaytopic.asp?T="& request.form("TopicID") &"'>here</a> to return to the forums."
		strRedirectURL = "displaytopic.asp?T="& request.form("TopicID")
	end if
	rsTopicCheck.close
	set rsTopicCheck = nothing

	'Check Forum Rules
	set rsCheck = server.createobject("adodb.recordset")
	sqlCheck = "SELECT Forum_Allow_Images FROM Forum_Forums WHERE Forum_ID = "& clng(request.form("ForumID")) &";"
	rsCheck.open sqlCheck, adoConn, CMDText
	if not (rsCheck.eof or rsCheck.bof) then
		Allow_Images = rsCheck("Forum_Allow_Images")
	end if
	rsCheck.close
	set rsCheck = nothing

	'Display Error message or continue
	if strMessage <> "" then
	%>
		<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%> // Error</td>
				</tr>
				<tr valign="top" class="body">
				<td align="center">
				<%=strMessage%>
				</td>
				</tr>
			</table>
			</td>
			</tr>
		</table>
	<%
	else
		'Assign variables
		strForumID = clng(request.form("ForumID"))
		strOldForumID = clng(request.form("OldForumID"))
		strTopicID = clng(request.form("TopicID"))
		strPostID = clng(request.form("PostID"))
		strUserName = request.form("UserName")
		strTitle = clean_text(request.form("Title"), 0)
		strText = clean_text(request.form("Text"), Site_Allow_HTML)
		if request.form("bbcode") = 1 and Site_Allow_BB = 1 then
			strText = bbcode(strText, Allow_Images)
		end if
		if request.form("smilies") = 1 then
			strText = replace_smilies(strText)
		end if
		'if were editing the post add edited by tag
		if request.form("ForumID") = request.form("OldForumID") then
			strText = strText & "<BR><BR><i> Last edited by " & session("Username") & "</i>"
		end if
		if request.servervariables("HTTP_X_FORWARDED_FOR") = "" then
			strIPAddress = request.servervariables("REMOTE_ADDR")
		else
			strIPAddress = request.servervariables("HTTP_X_FORWARDED_FOR")
		end If
		if request.form("signature") = 1 and Site_Allow_Signature = 1 then
			strSignature = 1
		else
			strSignature = 0
		end if
		if request.form("Post_Type") <> "" and request.form("Post_Type") <> "9" then
			strTopicType = request.form("Post_Type")
		else
			strTopicType = 1
		end if
		if request.form("Post_Type") = "9" then
			strTopicStatus = 0
		else
			strTopicStatus = 1
		end if
	
		'Update individual post
		set rsPost = server.createobject("adodb.recordset")
		sqlPost = "SELECT * FROM Forum_Posts WHERE Post_ID = "& strPostID &";"
		rsPost.cursortype = 2
		rsPost.locktype = 3
		rsPost.open sqlPost, adoConn, CMDText
		rsPost("Post_Forum_ID") = strForumID
		rsPost("Post_IP") = strIPAddress
		rsPost("Post_Signature") = strSignature
		rsPost("Post_Title") = strTitle
		rsPost("Post_Text") = strText
		if rsPost("Post_Index") = 1 then
			strTopic = true
		end if
		rsPost.update
		rsPost.close
		set rsPost = nothing
		
		'Update Topic Data
		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_Forum_ID") = strForumID
		rsTopic("Topic_Type") = strTopicType
		rsTopic("Topic_Status") = strTopicStatus
		if strTopic = true then
			rsTopic("Topic_Title") = strTitle
		end if
		strPosts = rsTopic("Topic_Replies") + 1
		rsTopic.update
		rsTopic.close
		set rsTopic = nothing
		
		'Check whether the post is being moved and update forum tables where necassary
		if request.form("ForumID") <> request.form("OldForumID")then
		
			'Set Forum_ID to that of the new forum for all posts
			set rsPost = server.createobject("adodb.recordset")
			sqlPost = "UPDATE Forum_Posts SET Post_Forum_ID = "& strForumID &" WHERE Post_Topic_ID = "& strTopicID &";"
			rsPost.cursortype = 2
			rsPost.locktype = 3
			rsPost.open sqlPost, adoConn
			set rsPost = nothing
		
			'Grab the details of the last previous poster in the original 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 = "& strOldForumID &" 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 the original Forum table
			set rsForum = server.createobject("adodb.recordset")
			sqlForum = "SELECT * FROM Forum_Forums WHERE Forum_ID = "& strOldForumID &";"
			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(strPosts)
			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
			
			'Grab the details of the last previous poster in the original 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 = "& strForumID &" 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 = "& strForumID &""
			rsForum.cursortype = 2
			rsForum.locktype = 3
			rsForum.open sqlForum, adoConn, CMDText
			rsForum("Forum_Topics") = rsForum("Forum_Topics") + 1	
			rsForum("Forum_Posts") = rsForum("Forum_Posts") + int(strPosts)
			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
			
		end if
		
		'Update user lastondate session
		session("laston") = site_time
		response.cookies(site_name)("read") = "r"
		
		'Show confirmation message and link to new topic.
		strRedirectURL = "displaytopic.asp?T=" & strTopicID
		%>
		<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 Edited</td>
				</tr>
				<tr valign="top" class="body">
				<td align="center">
				Your message has been successfully edited. Please click <a href="displaytopic.asp?T=<%=strTopicID%>">here</a> to return to the forums.
				</td>
				</tr>
			</table>
			</td>
			</tr>

⌨️ 快捷键说明

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