📄 new_post.asp
字号:
'******************************************
'*** Process New Post ***
'******************************************
'This is a new post so save the new post to the database
If ((strMode = "new" AND (blnPost OR blnPollCreate)) OR (blnReply)) OR (blnAdmin OR blnModerator) Then
'******************************************
'*** Save New Post ***
'******************************************
'Initalise the strSQL variable with an SQL statement to query the database get the message details
'Don't use no lock as we need a clean read when getting the thread ID
strSQL = "SELECT" & strDBTop1 & " " & strDbTable & "Thread.* " & _
"FROM " & strDbTable & "Thread" & strRowLock & " " & _
"ORDER BY " & strDbTable & "Thread.Thread_ID DESC" & strDBLimit1 & ";"
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 threads table
.Open strSQL, adoCon
'Set error trapping
On Error Resume Next
'Insert the new Thread details in the recordset
.AddNew
.Fields("Topic_ID") = lngTopicID
.Fields("Author_ID") = lngLoggedInUserID
.Fields("Message") = strMessage
.Fields("Message_date") = strPostDateTime
.Fields("Show_signature") = blnSignature
.Fields("IP_addr") = getIP()
.Fields("Hide") = blnCheckFirst
'Update the database with the new Thread
.Update
'If an error has occurred write an error to the page
If Err.Number <> 0 Then Call errorMsg("An error has occurred while writing to the database.", "save_new_post_data", "new_post.asp")
'Disable error trapping
On Error goto 0
'Requery cuase Access is so slow (needed to get accurate post count)
.Requery
'Read in the thread ID for the guest posting
lngMessageID = CLng(rsCommon("Thread_ID"))
'Clean up
.Close
End With
'******************************************
'*** Update Topic Last Post Datails ***
'******************************************
'This is a new topic so place the start and last post author ID in the topic table (don't update the no. of replies)
If strMode = "new" Then
'Initalise the SQL string with an SQL update command to update the last author
strSQL = "UPDATE " & strDbTable & "Topic " & strRowLock & " " & _
"SET " & strDbTable & "Topic.Start_Thread_ID=" & lngMessageID & ", " & _
strDbTable & "Topic.Last_Thread_ID=" & lngMessageID & " " & _
"WHERE " & strDbTable & "Topic.Topic_ID=" & lngTopicID & ";"
'Write the updated date of last post to the database
adoCon.Execute(strSQL)
'If the post is displayed update the no. of replies and last author date
ElseIf blnCheckFirst = false Then
'Update the stats fro this topic
Call updateTopicStats(lngTopicID)
End If
'******************************************
'*** Update The Forum stats ***
'******************************************
'Update the forum stats for main page (no. of posts+topics, last post author, and last post date)
If blnCheckFirst = false Then Call updateForumStats(intForumID)
'******************************************
'*** Save the guest username ***
'******************************************
'If this is a guest that is posting then save there name to the db
If lngLoggedInUserID = 2 AND strGuestName <> "" Then
'Initalise the SQL string with an SQL update command to update the date of the last post in the Topic table
strSQL = "INSERT INTO " & strDbTable & "GuestName (" & _
"Name, " & _
"Thread_ID " & _
") " & _
"VALUES " & _
"('" & strGuestName & "', " & _
"'" & lngMessageID & "' " & _
")"
'Write the updated date of last post to the database
adoCon.Execute(strSQL)
End If
'******************************************
'*** Update Author Number of Posts ***
'******************************************
'Initalise the strSQL variable with an SQL statement to query the database to get the number of posts the user has made
strSQL = "SELECT " & strDbTable & "Author.No_of_posts, " & strDbTable & "Group.Special_rank " & _
"FROM " & strDbTable & "Author " & strDBNoLock & ", " & strDbTable & "Group " & strDBNoLock & " " & _
"WHERE " & strDbTable & "Author.Group_ID = " & strDbTable & "Group.Group_ID " & _
"AND " & strDbTable & "Author.Author_ID = " & lngLoggedInUserID & ";"
'Query the database
rsCommon.Open strSQL, adoCon
'If there is a record returned by the database then read in the no of posts and increment it by 1
If NOT rsCommon.EOF Then
'Read in the no of posts the user has made and username
lngNumOfPosts = CLng(rsCommon("No_of_posts"))
'Inrement the number of posts by 1
lngNumOfPosts = lngNumOfPosts + 1
'Initalise the SQL string with an SQL update command to update the number of posts the user has made
strSQL = "UPDATE " & strDbTable & "Author " & strRowLock & " " & _
"SET " & strDbTable & "Author.No_of_posts = " & lngNumOfPosts & " " & _
"WHERE " & strDbTable & "Author.Author_ID = " & lngLoggedInUserID & ";"
'Write the updated number of posts to the database
adoCon.Execute(strSQL)
End If
'******************************************
'*** Update Rank Group ***
'******************************************
'See if the user is a member of a rank group and if so update their group if they have enough posts
'If there is a record returned by the database then see if it is a group that needs updating
If NOT rsCommon.EOF Then
'If a ladder group then see if the group needs updating
If CBool(rsCommon("Special_rank")) = False Then
'Clean up
rsCommon.Close
'Initlise variables
intNewGroupID = intGroupID
'Get the rank group the member should be part of
'Initalise the strSQL variable with an SQL statement to query the database to get the number of posts the user has made
strSQL = "SELECT" & strDBTop1 & " " & strDbTable & "Group.Group_ID " & _
"FROM " & strDbTable & "Group " & strDBNoLock & " " & _
"WHERE (" & strDbTable & "Group.Minimum_posts <= " & lngNumOfPosts & ") AND (" & strDbTable & "Group.Minimum_posts >= 0) " & _
"ORDER BY " & strDbTable & "Group.Minimum_posts DESC" & strDBLimit1 & ";"
'Query the database
rsCommon.Open strSQL, adoCon
'Get the new Group ID
If NOT rsCommon.EOF Then intNewGroupID = CInt(rsCommon("Group_ID"))
'If the group ID is different to the present group one then update it
If intGroupID <> intNewGroupID Then
'Initalise the SQL string with an SQL update command to update group ID of the author
strSQL = "UPDATE " & strDbTable & "Author " & strRowLock & " " & _
"SET " & strDbTable & "Author.Group_ID = " & intNewGroupID & " " & _
"WHERE " & strDbTable & "Author.Author_ID= " & lngLoggedInUserID & ";"
'Write the updated number of posts to the database
adoCon.Execute(strSQL)
End If
End If
End If
'Close the recordset
rsCommon.Close
'******************************************
'*** Send Email Notification **
'******************************************
If blnEmail AND blnCheckFirst = false Then
'**********************************************************
'*** Format the post if it is to be sent with the email **
'**********************************************************
'Set the e-mail subject
strEmailSubject = strMainForumName & " " & strTxtTopicReplyNotification & " : " & decodeString(strSubject)
'If we are to send an e-mail notification and send the post with the e-mail then format the post for the e-mail
If blnSendPost Then
'Format the post to be sent with the e-mail
strPostMessage = "<br /><strong>" & strTxtForum & ":</strong> " & strForumName & _
"<br /><strong>" & strTxtTopic & ":</strong> " & strSubject & _
"<br /><strong>" & strTxtPostedBy & ":</strong> " & strLoggedInUsername & "<br /><br />" & strMessage
'Change the path to the emotion symbols to include the path to the images
strPostMessage = Replace(strPostMessage, "src=""smileys/", "src=""" & strForumPath & "smileys/", 1, -1, 1)
End If
'*******************************************
'*** Send Email Notification ***
'*******************************************
'Initalise the strSQL variable with an SQL statement to query the database get the details for the email
strSQL = "SELECT DISTINCT " & strDbTable & "EmailNotify.Author_ID, " & strDbTable & "Author.Username, " & strDbTable & "Author.Author_email " & _
"FROM " & strDbTable & "Author" & strDBNoLock & ", " & strDbTable & "EmailNotify" & strDBNoLock & " " & _
"WHERE " & strDbTable & "Author.Author_ID = " & strDbTable & "EmailNotify.Author_ID " & _
"AND (" & strDbTable & "EmailNotify.Forum_ID = " & intForumID & " OR " & strDbTable & "EmailNotify.Topic_ID = " & lngTopicID & ") " & _
"AND " & strDbTable & "Author.Author_email Is Not Null " & _
"AND " & strDbTable & "Author.Active=" & strDBTrue & ";"
'Query the database
rsCommon.Open strSQL, adoCon
'If a record is returned by the recordset then read in the details and send the email
Do While NOT rsCommon.EOF
'Read in the details from the recordset for the e-mail
strUserName = rsCommon("Username")
lngEmailUserID = CLng(rsCommon("Author_ID"))
strUserEmail = rsCommon("Author_email")
'If the user wants to be e-mailed and the user has enetered their e-mail and they are not the original topic writter then send an e-mail
If lngEmailUserID <> lngLoggedInUserID AND strUserEmail <> "" Then
'Initailise the e-mail body variable with the body of the e-mail
strEmailMessage = strTxtHi & " " & decodeString(strUserName) & "," & _
"<br /><br />" & strTxtEmailAMeesageHasBeenPosted & " " & strMainForumName & " " & strTxtThatYouAskedKeepAnEyeOn & _
"<br /><br />" & strTxtEmailClickOnLinkBelowToView & " : -" & _
"<br /><a href=""" & strForumPath & "forum_posts.asp?TID=" & lngTopicID & "&PID=" & lngMessageID & "#" & lngMessageID & """>" & strForumPath & "forum_posts.asp?TID=" & lngTopicID & "&PID=" & lngMessageID & "#" & lngMessageID & "</a>" & _
"<br /><br />" & strTxtClickTheLinkBelowToUnsubscribe & " : -" & _
"<br /><a href=""" & strForumPath & "email_notify.asp?TID=" & lngTopicID & "&FID=" & intForumID & "&M=Unsubscribe"">" & strForumPath & "email_notify.asp?TID=" & lngTopicID & "&FID=" & intForumID & "&M=Unsubscribe</a>"
'If we are to send the post then attach it as well
If blnSendPost = True Then strEmailMessage = strEmailMessage & "<br /><br /><hr />" & strPostMessage
'Call the function to send the e-mail
blnEmailSent = SendMail(strEmailMessage, decodeString(strUserName), decodeString(strUserEmail), strMainForumName, decodeString(strForumEmailAddress), decodeString(strEmailSubject), strMailComponent, true)
End If
'Move to the next record in the recordset
rsCommon.MoveNext
Loop
'Close the recordset
rsCommon.Close
End If
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()
'If the sort order has been changed for this sesison then update the Page Number (PN)
If getSessionItem("PD") = "0" Then intReturnPageNum = 1
'Redirect
If blnCheckFirst Then
'If this is a Guest then send them to a page letting them know there post needs to be moderated before being displayed
If intGroupID = 2 Then
Response.Redirect("moderated_post.asp?FID=" & intForumID & "&TID=" & lngTopicID & "&PN=" & intReturnPageNum & strQsSID3 & "&M=" & strMode)
'Redirect to a page letting the user know their post is check first
Else
Response.Redirect("forum_posts.asp?TID=" & lngTopicID & "&PID=" & lngMessageID & "&MF=Y" & strQsSID3 & "#" & lngMessageID)
End If
Else
'Return to the page showing the posts
Response.Redirect("forum_posts.asp?TID=" & lngTopicID & "&PID=" & lngMessageID & strQsSID3 & "#" & lngMessageID)
End If
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -