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

📄 forum_posts.asp

📁 简单的asp论坛源码系统,很适用于初学者!界面简洁,功能齐全
💻 ASP
📖 第 1 页 / 共 4 页
字号:
<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="common.asp" -->
<!--#include file="functions/functions_date_time_format.asp" -->
<!--#include file="functions/functions_format_post.asp" -->
<!--#include file="includes/emoticons_inc.asp" -->
<%
'****************************************************************************************
'**  Copyright Notice    
'**
'**  Web Wiz Forums(TM)
'**  http://www.webwizforums.com
'**                            
'**  Copyright (C)2001-2008 Web Wiz(TM). All Rights Reserved.
'**  
'**  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS UNDER LICENSE FROM 'WEB WIZ'.
'**  
'**  IF YOU DO NOT AGREE TO THE LICENSE AGREEMENT THEN 'WEB WIZ' IS UNWILLING TO LICENSE 
'**  THE SOFTWARE TO YOU, AND YOU SHOULD DESTROY ALL COPIES YOU HOLD OF 'WEB WIZ' SOFTWARE
'**  AND DERIVATIVE WORKS IMMEDIATELY.
'**  
'**  If you have not received a copy of the license with this work then a copy of the latest
'**  license contract can be found at:-
'**
'**  http://www.webwizguide.com/license
'**
'**  For more information about this software and for licensing information please contact
'**  'Web Wiz' at the address and website below:-
'**
'**  Web Wiz, Unit 10E, Dawkins Road Industrial Estate, Poole, Dorset, BH15 4JD, England
'**  http://www.webwizguide.com
'**
'**  Removal or modification of this copyright notice will violate the license contract.
'**
'****************************************************************************************




'*************************** SOFTWARE AND CODE MODIFICATIONS **************************** 
'**
'** MODIFICATION OF THE FREE EDITIONS OF THIS SOFTWARE IS A VIOLATION OF THE LICENSE  
'** AGREEMENT AND IS STRICTLY PROHIBITED
'**
'** If you wish to modify any part of this software a license must be purchased
'**
'****************************************************************************************




Response.Buffer = True

'Make sure this page is not cached
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 2
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "No-Store"





'Dimension variables
Dim sarryPosts			'Holds the posts recordset
Dim strForumName		'Holds the forum name
Dim intCatID			'Holds the cat ID
Dim strCatName			'Holds the cat name
Dim intMasterForumID		'Holds the main forum ID
Dim strMasterForumName		'Holds the main forum name
Dim lngTopicID			'Holds the topic number
Dim strSubject			'Holds the topic subject
Dim strUsername 		'Holds the Username of the thread
Dim lngUserID			'Holds the ID number of the user
Dim dtmPostDate			'Holds the date the thread was made
Dim strMessage			'Holds the post to display
Dim strTopicIcon		'Holds the topic icon
Dim lngMessageID		'Holds the message ID number
Dim strAuthorHomepage		'Holds the homepage of the Username if it is given
Dim strAuthorLocation		'Holds the location of the user if given
Dim strAuthorAvatar		'Holds the authors avatar
Dim strAuthorSignature		'Holds the authors signature
Dim lngAuthorNumOfPosts		'Holds the number of posts the user has made to the forum
Dim dtmAuthorRegistration	'Holds the registration date of the user
Dim lngNumberOfViews		'Holds the number of times the topic has been viewed to save back to the database
Dim intStatus			'Holds the users interger status
Dim strStatus			'Holds the users status
Dim strMode			'Holds the mode of the page that is being passed
Dim intTopicPageNumber		'Holds the topic page position to link back to
Dim blnIsModerator		'Set to true if the user who posted the message is a forum moderator
Dim blnForumLocked		'Set to true if the forum is locked
Dim blnTopicLocked		'set to true if the topic is locked
Dim intThreadNo			'Holds the number of threads in the topic
Dim intPriority			'Holds the priority level of the topic
Dim intRecordPositionPageNum	'Holds the recorset page number to show the Threads for
Dim intTotalRecordsPages	'Holds the number of pages
Dim intTopicPageLoopCounter	'Loop counter for other thread page link
Dim intTotalRecords		'Holds the total number of therads in this topic
Dim strAuthorIP			'Holds the authors IP
Dim strSearchKeywords		'Holds the keywords to search for
Dim sarySearchWord		'Array to hold the search words
Dim strGroupName		'Holds the authors group name
Dim intRankStars		'Holds the number of stars for the group
Dim strRankCustomStars		'Holds custom stars for the user group
Dim lngPollID			'Holds the poll ID
Dim blnPollNoReply		'Set to true if users can't reply to a poll
Dim blnBannedIP			'Set to true if the user is using a banned IP
Dim dtmLastEntryDate		'Holds the date of the last post entry to the topic
Dim intIndexPosition		'Holds the idex poistion in the emiticon array
Dim intNumberOfOuterLoops	'Holds the outer loop number for rows
Dim intLoop			'Holds the loop index position
Dim intInnerLoop		'Holds the inner loop number for columns
Dim strMemberTitle		'Holds the members title
Dim blnIsUserOnline		'Set to true if the user is online
Dim blnHidePost			'Set to true if post is hidden
Dim strPostTableRowClass	'Post row colour
Dim intStartPosition		'Holds the start poition for records to be shown
Dim intEndPosition		'Holds the end poition for records to be shown
Dim intCurrentRecord		'Holds the current records for the posts
Dim strGuestUsername		'Holds the Guest Username if it is a guest posting
Dim blnHideTopic		'Set to true if topic is hidden
Dim lngGetPostID		'Holds the post to go straight to
Dim strSortBy			'Holds the direction the posts are listed in
Dim strPostTableSideClass	'Holds the post message side column css class
Dim strPostTableTopClass	'Holds the post table top details
Dim dtmEventDate		'Holds the date if this is a calendar event
Dim dtmEventDateEnd		'Holds the date if this is a calendar event
Dim intPageLinkLoopCounter	'Loop counter for page links include
Dim intPostRowsSpan		'Holds the rowspam number for post table formatting
Dim strForumPassword		'Holds the forum password
Dim intUnReadForumPostsLoop	'Loop counter for unread loop array
Dim intAutoLockTopicsAmount	'Holds the amount topics are auto closed at
Dim blnUnreadPost		'Set to true if the post is un-read



'Initialise variables
strMode = "reply"
lngMessageID = 0
lngGetPostID = 0
intForumID = 0
lngTopicID = 0
intThreadNo = 0
blnIsModerator = False
blnPollNoReply = False
blnBannedIP = False
blnHidePost = False
intPriority = 0
blnHideTopic = False
blnUnreadPost = False
intAutoLockTopicsAmount = 15000 'Topics with more than 15,000 posts are auto locked as users with higher amounts have reported performance and database issues


'See if the user is using a banned IP address
If bannedIP() Then
	'If the user is using a banned IP then set the banned IP variable to true and active member variable to false
	blnBannedIP = True
End If


'If this is the first time the page is displayed then the Forum Thread record position is set to page 1
If isNumeric(Request.QueryString("PN")) = false Then
	intRecordPositionPageNum = 1
ElseIf Request.QueryString("PN") < 1 Then
	intRecordPositionPageNum = 1
'Else the page has been displayed before so the Forum Thread record postion is set to the Record Position number
Else
	intRecordPositionPageNum = CInt(Request.QueryString("PN"))
End If


'Read in the Topic ID for the topic to display
If isNumeric(Request.QueryString("TID")) Then lngTopicID = CLng(Request.QueryString("TID")) Else lngTopicID = 0

'If there is no Topic ID then redirect the user to the main forum page
If lngTopicID = 0 Then

	'Clean up
	Call closeDatabase()

	'Redirect
	Response.Redirect("default.asp" & strQsSID1)
End If




'Read in the post ID if we are going straight to a post
If isNumeric(Request.QueryString("PID")) Then lngGetPostID = CLng(Request.QueryString("PID"))
	
'Fix for stupid IE 6 redirect bug (IE SUCKS!!!) MS have fixed this for IE7
If lngGetPostID = 0 AND Request.QueryString("PID") <> "" Then
	'Remove the '#' hash anchor mark IE 6 includes in the string when doing a redirect (IE SUCKS!!)
	If InStr(Request.QueryString("PID"), "#") Then lngGetPostID = CLng(Mid(Request.QueryString("PID"), 1, InStr(Request.QueryString("PID"), "#")-1))
End If




'Read in the keywords if comming from a search
strSearchKeywords = Trim(Mid(Request.QueryString("KW"), 1, 35))


'Split up the keywords to be searched
sarySearchWord = Split(Trim(strSearchKeywords), " ")






'Sort the direction of db results from session
If Request.QueryString("OB") = "DESC" Then
	strSortBy = "DESC"
ElseIf Request.QueryString("OB") = "ASC" Then
	strSortBy = "ASC"
ElseIf getSessionItem("OB") = "DESC" Then
	strSortBy = "DESC"
Else
	strSortBy = "ASC"
End If

'Save the sort results order to app session
If isNumeric(Request.QueryString("OB")) AND Request.QueryString("OB") <> "" Then Call saveSessionItem("OB", Request.QueryString("OB"))







'If this is a top priority post across all forums then read in the forum ID form the querystring and ingnore the real topic forum ID
If Request.QueryString("PR") = "3" Then intForumID = Cint(Request.QueryString("FID"))


strSQL = "" & _
"SELECT" & strDBTop1 & " " & strDbTable & "Category.Cat_ID, " & strDbTable & "Category.Cat_name, " & strDbTable & "Forum.Forum_ID AS ForumID, " & strDbTable & "Forum.Sub_ID, " & strDbTable & "Forum.Forum_name, " & strDbTable & "Forum2.Forum_name AS Main_forum, " & strDbTable & "Forum.Password, " & strDbTable & "Forum.Forum_code, " & strDbTable & "Forum.Locked AS forumLocked, " & strDbTable & "Topic.Poll_ID, " & strDbTable & "Topic.Subject, " & strDbTable & "Topic.Icon, " & strDbTable & "Topic.Locked AS topicLocked, " & strDbTable & "Topic.Priority, " & strDbTable & "Topic.No_of_views, " & strDbTable & "Topic.Hide, " & strDbTable & "Topic.Event_date, " & strDbTable & "Topic.Event_date_end, " & strDbTable & "Permissions.*  " & _
"FROM " & strDbTable & "Category" & strDBNoLock & ", " & strDbTable & "Forum" & strDBNoLock & ", " & strDbTable & "Forum AS " & strDbTable & "Forum2" & strDBNoLock & ", " & strDbTable & "Permissions" & strDBNoLock & ", " & strDbTable & "Topic" & strDBNoLock & " " & _
"WHERE " & strDbTable & "Category.Cat_ID = " & strDbTable & "Forum.Cat_ID " & _
	"AND " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Permissions.Forum_ID "
'Get the forum ID from the topic table
If intForumID = 0 Then
	strSQL = strSQL  & _
	"AND " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Topic.Forum_ID "
'Else this is a priority post so get the forum ID from the querystring (security built in later to make sure the user is not trying to view a post they shouldn't)
Else
	strSQL = strSQL & "" & _
	"AND " & strDbTable & "Forum.Forum_ID = " & intForumID & " "

End If
	strSQL = strSQL & "" & _
	"AND (" & strDbTable & "Forum.Forum_ID = " & intForumID & " OR " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Topic.Forum_ID) " & _
	"AND (" & strDbTable & "Forum.Sub_ID = " & strDbTable & "Forum2.Forum_ID OR (" & strDbTable & "Forum.Sub_ID = 0 AND " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Forum2.Forum_ID)) " & _
	"AND " & strDbTable & "Topic.Topic_ID = " & lngTopicID & " " & _
	"AND (" & strDbTable & "Permissions.Author_ID = " & lngLoggedInUserID & " OR " & strDbTable & "Permissions.Group_ID = " & intGroupID & ") " & _
"ORDER BY " & strDbTable & "Forum.Sub_ID, " & strDbTable & "Forum.Forum_Order, " & strDbTable & "Permissions.Author_ID DESC" & strDBLimit1 & ";"


'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_forum_data", "forum_posts.asp")

'Disable error trapping
On Error goto 0


'If there is no record returended then set a message to say that
If rsCommon.EOF Then

	'If there are no thread's to display then display the appropriate error message
	strSubject = strTxtNoThreads



'Else get the details of the forum, permissions, and topic details
Else

	'Read in forum details from the database
	intForumID = Cint(rsCommon("ForumID"))
	intCatID = CInt(rsCommon("Cat_ID"))
	strCatName = rsCommon("Cat_name")
	strForumName = rsCommon("Forum_name")
	strMasterForumName = rsCommon("Main_forum")
	intMasterForumID = CLng(rsCommon("Sub_ID"))
	blnForumLocked = CBool(rsCommon("forumLocked"))
	blnHideTopic = CBool(rsCommon("Hide"))
	If isDate(rsCommon("Event_date")) Then dtmEventDate = CDate(rsCommon("Event_date"))
	If isDate(rsCommon("Event_date_end")) Then dtmEventDateEnd = CDate(rsCommon("Event_date_end"))

	'Read in the forum permissions
	blnRead = CBool(rsCommon("View_Forum"))
	blnPost = CBool(rsCommon("Post"))
	blnReply = CBool(rsCommon("Reply_posts"))
	blnEdit = CBool(rsCommon("Edit_posts"))
	blnDelete = CBool(rsCommon("Delete_posts"))
	blnPriority = CBool(rsCommon("Priority_posts"))
	blnPollCreate = CBool(rsCommon("Poll_create"))
	blnVote = CBool(rsCommon("Vote"))
	blnModerator = CBool(rsCommon("Moderate"))
	blnCheckFirst = CBool(rsCommon("Display_post"))
	strForumPassword = rsCommon("Password")

	'Read in the topic details
	lngPollID = CLng(rsCommon("Poll_ID"))
	strSubject = rsCommon("Subject")
	strTopicIcon = rsCommon("Icon")
	blnTopicLocked = CBool(rsCommon("topicLocked"))
	intPriority = CInt(rsCommon("Priority"))

	'Clean up input to prevent XXS hack
	strSubject = formatInput(strSubject)

	'If the user has no read writes then kick them out
	If blnRead = False Then

		'Reset Server Objects
		rsCommon.Close
		Call closeDatabase()

⌨️ 快捷键说明

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