📄 forum_posts.asp
字号:
'Redirect to a page asking for the user to enter the forum password
Response.Redirect("insufficient_permission.asp" & strQsSID1)
End If
'If the forum requires a password and a logged in forum code is not found on the users machine then send them to a login page
If strForumPassword <> "" AND (getCookie("fID", "Forum" & intForumID) <> rsCommon("Forum_code") AND getSessionItem("Forum" & intForumID) <> rsCommon("Forum_code")) Then
'Reset Server Objects
rsCommon.Close
Call closeDatabase()
'Redirect to a page asking for the user to enter the forum password
Response.Redirect("forum_password_form.asp?RP=PT&FID=" & intForumID & "&TID=" & lngTopicID & strQsSID3)
End If
'Update no. of views, if not a bot (bots can index a poge 100's of times thus making the view count unreliable
If NOT OSType = "Search Robot" Then
'Read in the number of views for the page form the database
lngNumberOfViews = CLng(rsCommon("No_of_views"))
'Add 1 to the number of views the Topic has had
lngNumberOfViews = lngNumberOfViews + 1
'Write the number of times the Topic has been viewed back to the database
'Initalise the strSQL variable with the SQL string
strSQL = "UPDATE " & strDbTable & "Topic" & strRowLock & " " & _
"SET " & strDbTable & "Topic.No_of_views = " & lngNumberOfViews & " " & _
"WHERE (((" & strDbTable & "Topic.Topic_ID) = " & lngTopicID & "));"
'Set error trapping
On Error Resume Next
'Write to the database
adoCon.Execute(strSQL)
'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.", "update_no._views", "forum_posts.asp")
'Disable error trapping
On Error goto 0
End If
End If
'clean up
rsCommon.Close
'Securtiy check - if this isn't a Priority post and the user is just trying to view a post in a forum they don't have permission to
'then reload the page without the forum ID
If Request.QueryString("PR") = "3" AND NOT intPriority = 3 Then
'Reset Server Objects
Call closeDatabase()
'Redirect back to this page without the forum ID
Response.Redirect("forum_posts.asp?TID=" & lngTopicID & strQsSID3)
End If
'Use the application session to pass around what forum this user is within
Call saveSessionItem("FID", intForumID)
'Intilise SQL query to get all the posts
'Use a LEFT JOIN for the Guest name as there may not be a Guest name and so we want to include null values
strSQL = "" & _
"SELECT " & strDbTable & "Thread.Thread_ID, " & strDbTable & "Thread.Message, " & strDbTable & "Thread.Message_date, " & strDbTable & "Thread.Show_signature, " & strDbTable & "Thread.IP_addr, " & strDbTable & "Thread.Hide, " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.Username, " & strDbTable & "Author.Homepage, " & strDbTable & "Author.Location, " & strDbTable & "Author.No_of_posts, " & strDbTable & "Author.Join_date, " & strDbTable & "Author.Signature, " & strDbTable & "Author.Active, " & strDbTable & "Author.Avatar, " & strDbTable & "Author.Avatar_title, " & strDbTable & "Group.Name, " & strDbTable & "Group.Stars, " & strDbTable & "Group.Custom_stars, " & strDbTable & "GuestName.Name " & _
"FROM (" & strDbTable & "Group INNER JOIN (" & strDbTable & "Author INNER JOIN " & strDbTable & "Thread ON " & strDbTable & "Author.Author_ID = " & strDbTable & "Thread.Author_ID) ON " & strDbTable & "Group.Group_ID = " & strDbTable & "Author.Group_ID) LEFT JOIN " & strDbTable & "GuestName ON " & strDbTable & "Thread.Thread_ID = " & strDbTable & "GuestName.Thread_ID " & _
"WHERE " & strDbTable & "Thread.Topic_ID = " & lngTopicID & " "
'If this isn't a moderator only display hidden posts if the user posted them
If blnModerator = false AND blnAdmin = false Then
strSQL = strSQL & "AND (" & strDbTable & "Thread.Hide = " & strDBFalse & " "
'Don't display hidden posts if guest
If intGroupID <> 2 Then strSQL = strSQL & "OR " & strDbTable & "Thread.Author_ID = " & lngLoggedInUserID
strSQL = strSQL & ") "
End If
strSQL = strSQL & "ORDER BY " & strDbTable & "Thread.Message_date " & strSortBy & ";"
'Set error trapping
On Error Resume Next
'Query the database
rsCommon.Open strSQL, adoCon
'If an error has occurred write an error to the page
If Err.Number <> 0 Then Call errorMsg("An error has occurred while executing SQL query on database.", "get_topic_posts_data", "forum_posts.asp")
'Disable error trapping
On Error goto 0
'If there is a topic in the database then get the post data
If NOT rsCommon.EOF Then
'Read in the topic recordset into an array
sarryPosts = rsCommon.GetRows()
'Clean up
rsCommon.Close
'SQL Query Array Look Up table
'0 = tblThread.Thread_ID,
'1 = tblThread.Message,
'2 = tblThread.Message_date,
'3 = tblThread.Show_signature,
'4 = tblThread.IP_addr,
'5 = tblThread.Hide,
'6 = tblAuthor.Author_ID,
'7 = tblAuthor.Username,
'8 = tblAuthor.Homepage,
'9 = tblAuthor.Location,
'10 = tblAuthor.No_of_posts,
'11 = tblAuthor.Join_date,
'12 = tblAuthor.Signature,
'13 = tblAuthor.Active,
'14 = tblAuthor.Avatar,
'15 = tblAuthor.Avatar_title,
'16 = tblGroup.Name,
'17 = tblGroup.Stars,
'18 = tblGroup.Custom_stars
'19 = tblGuestName.Name
'Count the number of records
intTotalRecords = Ubound(sarryPosts,2) + 1
'Count the number of pages for the topics using '\' so that any fraction is omitted
intTotalRecordsPages = intTotalRecords \ intThreadsPerPage
'If there is a remainder or the result is 0 then add 1 to the total num of pages
If intTotalRecords Mod intThreadsPerPage > 0 OR intTotalRecordsPages = 0 Then intTotalRecordsPages = intTotalRecordsPages + 1
'Get the record poistion to display from
'If the page number to show from is higher than the last page number then the last page number is the highest page
If (intRecordPositionPageNum > intTotalRecordsPages) OR (Request.QueryString("get") = "last") Then
'Set the page position number to the highest page number
intRecordPositionPageNum = intTotalRecordsPages
End If
'If we need to jump straight to a particular post calculate which page to go to
If NOT lngGetPostID = 0 AND NOT intTotalRecordsPages = 1 Then
'Calculate how many posts are before the post we want
For intLoop = 0 to (intTotalRecords - 1)
'If we have found the post then calcualte the page it is on
If CLng(sarryPosts(0,intLoop)) = lngGetPostID Then
'Calculate page number (use FIX to get the whole number)
intRecordPositionPageNum = FIX(intLoop / intThreadsPerPage) + 1
'Exit Loop
Exit For
End If
Next
End If
'Start position
intStartPosition = ((intRecordPositionPageNum - 1) * intThreadsPerPage)
'End Position
intEndPosition = intStartPosition + intThreadsPerPage
'Get the start position
intCurrentRecord = intStartPosition
'Get the last post date to set the read session cookie for the un-read post icon
'If displayed 'Newest Post First' then it will be the first post that has the last post date
If strSortBy = "DESC" Then
dtmLastEntryDate = CDate(sarryPosts(2,0))
'If displayed 'Oldest Post First' it will be the last post that has the last post date
Else
dtmLastEntryDate = CDate(sarryPosts(2,intTotalRecords-1))
End If
'To prevent performance issues, topics are auto closed when they reach xxxx posts
If intTotalRecords > intAutoLockTopicsAmount Then
strSQL = "UPDATE " & strDbTable & "Topic" & strRowLock & " " & _
"SET " & strDbTable & "Topic.Locked = " & strDBTrue & " " & _
"WHERE " & strDbTable & "Topic.Topic_ID = " & lngTopicID & ";"
'Set error trapping
On Error Resume Next
'Write to the database
adoCon.Execute(strSQL)
'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.", "auto_lock_topic", "forum_posts.asp")
'Disable error trapping
On Error goto 0
'Set the locked bulletin to true
blnTopicLocked = True
End If
'Else if no record is retuned we do not want to be displaying a foum title
Else
strSubject = ""
rsCommon.Close
End If
'If we have not yet checked for unread posts since last visit run it now
If Session("dtmUnReadPostCheck") = "" Then
Call UnreadPosts()
'Read in array if at application level
ElseIf isArray(Application("sarryUnReadPosts" & strSessionID)) Then
sarryUnReadPosts = Application("sarryUnReadPosts" & strSessionID)
'Read in the unread posts array
ElseIf isArray(Session("sarryUnReadPosts")) Then
sarryUnReadPosts = Session("sarryUnReadPosts")
End If
'Page to link to for mutiple page (with querystrings if required)
strLinkPage = "forum_posts.asp?TID=" & lngTopicID & "&"
If Request.QueryString("KW") <> "" Then strLinkPage = strLinkPage & "KW=" & Server.URLEncode(Request.QueryString("KW")) & "&"
If Request.QueryString("FID") <> "" Then strLinkPage = strLinkPage & "FID=" & intForumID & "&"
If Request.QueryString("PR") <> "" Then strLinkPage = strLinkPage & "PR=" & CInt(Request.QueryString("PR")) & "&"
'If active users is enabled update the active users application array
If blnActiveUsers Then
'If there are keywords this is a search
If Request.QueryString("KW") <> "" Then
'Call active users function
saryActiveUsers = activeUsers(strTxtViewingTopic & " " & strTxtSearchResults, strSubject, strLinkPage & "PN=" & intRecordPositionPageNum, intForumID)
'Else normal topic
Else
'Call active users function
saryActiveUsers = activeUsers(strTxtViewingTopic, strSubject, strLinkPage & "PN=" & intRecordPositionPageNum, intForumID)
End If
End If
'Set bread crumb trail
'Display the category name
strBreadCrumbTrail = strBreadCrumbTrail & strNavSpacer & "<a href=""default.asp?C=" & intCatID & strQsSID2 & """>" & strCatName & "</a>" & strNavSpacer
'Display if there is a main forum to the sub forums name
If intMasterForumID <> 0 Then strBreadCrumbTrail = strBreadCrumbTrail & "<a href=""forum_topics.asp?FID=" & intMasterForumID & strQsSID2 & """>" & strMasterForumName & "</a>" & strNavSpacer
'Display forum name
If strForumName = "" Then strBreadCrumbTrail = strBreadCrumbTrail & strTxtNoForums Else strBreadCrumbTrail = strBreadCrumbTrail & "<a href=""forum_topics.asp?FID=" & intForumID & strQsSID2 & """>" & strForumName & "</a>"
'Set the status bar tools
'Active Topics Links
strStatusBarTools = strStatusBarTools & " <img src=""" & strImagePath & "active_topics." & strForumImageType & """ alt=""" & strTxtActiveTopics & """ title=""" & strTxtActiveTopics & """ style=""vertical-align: text-bottom"" /> <a href=""active_topics.asp" & strQsSID1 & """>" & strTxtActiveTopics & "</a>"
'If RSS XML enabled then display an RSS button to link to XML file
If blnRSS AND (isNull(strForumPassword) OR strForumPassword = "") AND dtmLastEntryDate > DateAdd("ww", -intRSSLinkDisplayWeeks, now()) Then strStatusBarTools = strStatusBarTools & " <a href=""RSS_post_feed.asp?TID=" & lngTopicID & strQsSID2 & """ target=""_blank""><img src=""" & strImagePath & "rss." & strForumImageType & """ alt=""" & strTxtRSS & ": " & strSubject & """ title=""" & strTxtRSS & ": " & strSubject & """ /></a>"
'Write the HTML head of the page
%><!-- #include file="includes/browser_page_encoding_inc.asp" -->
<title><% = strMainForumName & ": " & strSubject %></title>
<meta name="generator" content="Web Wiz Forums" />
<%
'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
Response.Write("<!--//" & _
vbCrLf & "/* *******************************************************" & _
vbCrLf & "Software: Web Wiz Forums(TM) ver. " & strVersion & "" & _
vbCrLf & "Info: http://www.webwizforums.com" & _
vbCrLf & "Copyright: (C)2001-2008 Web Wiz(TM). All rights reserved" & _
vbCrLf & "******************************************************* */" & _
vbCrLf & "//-->" & vbCrLf)
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
'If RSS Feed is enabled then have an alt link to the XML file for supporting browsers
'Only display if the last post was less than xx weeks ago, to reduce the amount of consumed bandwidth
If blnRSS AND (isNull(strForumPassword) OR strForumPassword = "") AND dtmLastEntryDate > DateAdd("ww", -intRSSLinkDisplayWeeks, now()) Then Response.Write(vbCrLf & "<link rel=""alternate"" type=""application/rss+xml"" title=""RSS 2.0"" href=""RSS_post_feed.asp?TID=" & lngTopicID & strQsSID2 & """ />")
'Display javascript for form checking
If blnActiveMember AND blnForumLocked = false AND blnReply AND (intRecordPositionPageNum = intTotalRecordsPages) Then
%>
<script language="JavaScript">
function CheckForm() {
var errorMsg = '';
var formArea = document.getElementById('frmMessageForm');
<%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -