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

📄 edit_post.asp

📁 简单的asp论坛源码系统,很适用于初学者!界面简洁,功能齐全
💻 ASP
📖 第 1 页 / 共 2 页
字号:

	'If there is no	poll question then there initilise the error variable
	If strPollQuestion = ""	Then strReturnCode = "noPoll"

	'Clean up poll question
	strPollQuestion	= removeAllTags(strPollQuestion)


	'Loop through and read in the poll question
	For intPollChoice = 1 To intMaxPollChoices

		'ReDimension the array for the correct number of choices
		'ReDimensioning	arrays is bad for performance but usful	in this	for what I need	it for
		ReDim Preserve saryPollChoice(intPollChoice)

		'Read in the poll choice
		saryPollChoice(intPollChoice) =	Trim(Mid(Request.Form("choice" & intPollChoice), 1, 60))

		'If there is nothing in	position 1 and 2 set a return error code
		If intPollChoice < 2 AND saryPollChoice(intPollChoice) = "" Then strReturnCode = "noPoll"


		'Clean up input
		saryPollChoice(intPollChoice) =	removeAllTags(saryPollChoice(intPollChoice))
	Next
End If





'******************************************
'***	     Filter Bad	Words	      *****
'******************************************

'Initalise the SQL string with a query to read in all the words	from the smut table
strSQL = "SELECT " & strDbTable & "Smut.* " & _
"FROM " & strDbTable & "Smut " & strDBNoLock & ";"

'Open the recordset
rsCommon.Open strSQL, adoCon

'Loop through all the words to check for
Do While NOT rsCommon.EOF

	'Put the bad word into a string	for imporoved perfoamnce
	strBadWord = rsCommon("Smut")
	strBadWordReplace = rsCommon("Word_replace")

	'Replace the swear words with the words	in the database	the swear words
	strSubject = Replace(strSubject, strBadWord, strBadWordReplace,	1, -1, 1)
	strMessage = Replace(strMessage, strBadWord, strBadWordReplace,	1, -1, 1)

	'If this is a poll run the poll	choices	through	the bad	word filter as well
	If strMode = "poll" Then

		'Clean up the poll question
		strPollQuestion	= Replace(strPollQuestion, strBadWord, strBadWordReplace, 1, -1, 1)

		'Loop though and check all the strings in the Poll array
		For intPollChoice = 1 To UBound(saryPollChoice)
			saryPollChoice(intPollChoice) =	Replace(saryPollChoice(intPollChoice), strBadWord, strBadWordReplace, 1, -1, 1)
		Next
	End If

	'Move to the next word in the recordset
	rsCommon.MoveNext
Loop

'Reset server varaible
rsCommon.Close




'**********************************************
'***  If input problems	send to	error page  ***
'**********************************************

'If there is a return code then	this post is not valid so redirect to error page
If strReturnCode <> "" Then

	'Clean up
	Call closeDatabase()

	'Redirect to error page
	Response.Redirect("not_posted.asp?mode=" & strReturnCode &  strQsSID3)
End If







'******************************************
'***	    Edit Post Update		***
'******************************************


'If we are to show who edit the post and time then contantinet it to the end of the message
If blnShowEditUser Then
	strMessage = strMessage & "<edited><editID>" & strLoggedInUsername & "</editID><editDate>" & internationalDateTime(Now()) &  "</editDate></edited>"
End If


'Initalise the strSQL variable with an SQL statement to	query the database get the message details
strSQL = "SELECT " & strDbTable & "Thread.Thread_ID, " & strDbTable & "Thread.Author_ID, " & strDbTable & "Thread.Message, " & strDbTable & "Thread.Show_signature, " & strDbTable & "Thread.IP_addr, " & strDbTable & "Thread.Hide " & _
"FROM	" & strDbTable & "Thread" & strRowLock & " " & _
"WHERE " & strDbTable & "Thread.Thread_ID = " & lngMessageID & ";"


'Set the cursor	type property of the record set	to Dynamic so we can navigate through the record set
rsCommon.CursorType = 2

'Set the Lock Type for the records so that the record set is only locked when it is updated
rsCommon.LockType = 3

'Open the author table
rsCommon.Open strSQL, adoCon


'Only update the post if this is a moderator, forum admin, or the person who posted
If (blnAdmin OR blnModerator) OR (CLng(rsCommon("Author_ID")) = lngLoggedInUserID) Then
	

	'If this is a normal user let 'em know their post needs to be checked first before it is displayed (if hidden)
	If blnAdmin = false OR blnModerator = false Then blnCheckFirst = CBool(rsCommon("Hide"))

	'Enter the updated post	into the recordset
	rsCommon.Fields("Message") = strMessage
	rsCommon.Fields("Show_signature") = CBool(blnSignature)
	'Only update the IP address if this is not the admin
	If blnAdmin = False Then rsCommon.Fields("IP_addr") = getIP()

	'Update	the database
	rsCommon.Update

	'Close rs
	rsCommon.Close

'Else the user does not have permission to edit this post/topic/poll, so kick 'em
Else

	'Reset Server Objects
	rsCommon.Close
	Call closeDatabase()


	'Redirect to a page asking for the user to enter the forum password
	Response.Redirect("insufficient_permission.asp" & strQsSID1)
End If









'********************************************
'***		  Edit Poll		  ***
'********************************************

'If this is a poll then save the poll to the database
If strMode = "editPoll" AND lngPollID > 0 Then

	'********************************************
	'***	     Update poll question		  ***
	'********************************************

	'Initalise the SQL string with a query to get the poll last poll details to get the poll ID number in next (use nolock as this is a new insert so a dirty read is OK)
	strSQL = "SELECT " & strDbTable & "Poll.* " & _
	"FROM " & strDbTable & "Poll" & strRowLock & " " & _
	"WHERE " & strDbTable & "Poll.Poll_ID=" & lngPollID & ";"

	With rsCommon
		'Set the cursor	type property of the record set	to Dynamic so we can navigate through the record set
		.CursorType = 2

		'Set the Lock Type for the records so that the record set is only locked when it is updated
		.LockType = 3

		'Open the poll table
		.Open strSQL, adoCon

		'Update	recordset
		.Fields("Poll_question") = strPollQuestion
		.Fields("Multiple_votes") = blnMultipleVotes
		.Fields("Reply") = blnPollReply

		'Update	the database with the new poll question
		.Update

		'Clean up
		.Close
	End With


	'********************************************
	'***	      Update poll choices	  ***
	'********************************************

	'Initalise the SQL string with a query to get the choice 
	strSQL = "SELECT " & strDbTable & "PollChoice.Poll_ID, " & strDbTable & "PollChoice.Choice " & _
	"FROM " & strDbTable & "PollChoice" & strRowLock & " " & _
	"WHERE " & strDbTable & "PollChoice.Poll_ID=" & lngPollID & ";"

	With rsCommon
		'Set the cursor	type property of the record set	to Dynamic so we can navigate through the record set
		.CursorType = 2

		'Set the Lock Type for the records so that the record set is only locked when it is updated
		.LockType = 3

		'Open the author table
		.Open strSQL, adoCon
		
		intPollChoice = 0

		'Add the new poll choices to recordset
		Do While NOT .EOF
			
			'Move to next poll choice
			If intPollChoice < UBound(saryPollChoice) Then intPollChoice = intPollChoice + 1
		
			'Update	recordset
			.Fields("Choice") = saryPollChoice(intPollChoice)
			
			'Update	the database with the poll choices (bad place to do it but this prevents errors)
			.Update
			
			'Move to next record
			.MoveNext
		Loop

		'Clean up
		.Close
	End With

	'Change	the mode to editTopic to save any updated topic subject
	strMode = "editTopic"
End If






'******************************************
'***	     Edit Topic	Update		***
'******************************************

'If the	post is	the first in the thread	then update the	topic details
If strMode = "editTopic" Then

	'Initalise the SQL string with a query to get the Topic	details
	strSQL = "SELECT " & strDbTable & "Topic.Subject, " & strDbTable & "Topic.Icon, " & strDbTable & "Topic.Priority, " & strDbTable & "Topic.Event_date, " & strDbTable & "Topic.Event_date_end " & _
	"FROM " & strDbTable & "Topic" & strRowLock & " " & _
	"WHERE " & strDbTable & "Topic.Topic_ID=" & lngTopicID & ";"

	With rsCommon
		'Set the cursor	type property of the record set	to Dynamic so we can navigate through the record set
		.CursorType = 2

		'Set the Lock Type for the records so that the record set is only locked when it is updated
		.LockType = 3

		'Open the author table
		.Open strSQL, adoCon

		'Update	the recorset
		.Fields("Subject") = strSubject
		If blnTopicIcon Then .Fields("Icon") = strTopicIcon
		.Fields("Priority") = intPriority
		'If Calendar events allowed save
		If blnCalendar AND blnEvents Then .Fields("Event_date") = dtmEventDate
		If blnCalendar AND blnEvents Then .Fields("Event_date_end") = dtmEventDateEnd

		'Update	the database with the new topic	details
		.Update

		'Clean up
		.Close
	End With
End If







'**********************************************************
'***	     Update Email Notify if this is a reply	***
'**********************************************************

'Delete	or Save	email notification for the user, if email notify is enabled

If blnEmail = True Then

	'Initalise the SQL string with a query to get the email	notify details
	strSQL = "SELECT " & strDbTable & "EmailNotify.*  " & _
	"FROM	" & strDbTable & "EmailNotify" & strRowLock & " " & _
	"WHERE " & strDbTable & "EmailNotify.Author_ID=" & lngLoggedInUserID & " "  & _
		"AND " & strDbTable & "EmailNotify.Topic_ID=" & lngTopicID & ";"


	With rsCommon

		'Set the cursor	type property of the record set	to Dynamic so we can navigate through the record set
		.CursorType = 2

		'Set the Lock Type for the records so that the record set is only locked when it is updated
		.LockType = 3

		'Query the database
		.Open strSQL, adoCon


		'If the	user no-longer wants email notification	for this topic then remove the entry form the db
		If blnEmailNotify = False AND NOT .EOF Then

			'Delete	the db entry
			.Delete

		'Else if this is a new post and	the user wants to be notified add the new entry	to the database
		ElseIf blnEmailNotify = True AND .EOF Then

			'Add new rs
			.AddNew

			'Create	new entry
			.Fields("Author_ID") = lngLoggedInUserID
			.Fields("Topic_ID") = lngTopicID

			'Upade db with new rs
			.Update
		End If

		'Clean up
		.Close

	End With
End If




'******************************************
'***	    Clean up objects		***
'******************************************

'Reset Server Objects
Call closeDatabase()


'Redirect
If blnCheckFirst Then	
	'Redirect to a page letting the user know their post is check first
	Response.Redirect("forum_posts.asp?TID=" & lngTopicID &	"&PN=" & intReturnPageNum & "&MF=Y" & strQsSID3)
Else
	'Return	to the page showing the	posts
	Response.Redirect("forum_posts.asp?TID=" & lngTopicID &	"&PN=" & intReturnPageNum & strQsSID3)
End If
%>

⌨️ 快捷键说明

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