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

📄 forum_topics.asp

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

'Sort the direction of db results
If Request.QueryString("OB") = "desc" Then
	strSortDirection = "asc"
	strSortBy = strSortBy & "DESC"
Else
	strSortDirection = "desc"
	strSortBy = strSortBy & "ASC"
End If

'If this is the first time it is run the we want dates DESC
If Request.QueryString("OB") = "" AND Request.QueryString("SO") = "" Then
	strSortDirection = "asc"
	strSortBy = strDbTable & "Topic.Last_Thread_ID DESC"
End If



'Read in all the topics for this forum and place them in an array
strSQL = "" & _
"SELECT "
If strDatabaseType = "SQLServer" OR strDatabaseType = "Access" Then
	strSQL = strSQL & " TOP " & intMaxResults & " "
End If
strSQL = strSQL & _
" " & strDbTable & "Topic.Topic_ID, " & strDbTable & "Topic.Poll_ID, " & strDbTable & "Topic.Moved_ID, " & strDbTable & "Topic.Subject, " & strDbTable & "Topic.Icon, " & strDbTable & "Topic.Start_Thread_ID, " & strDbTable & "Topic.Last_Thread_ID, " & strDbTable & "Topic.No_of_replies, " & strDbTable & "Topic.No_of_views, " & strDbTable & "Topic.Locked, " & strDbTable & "Topic.Priority, " & strDbTable & "Topic.Hide, " & strDbTable & "Thread.Message_date, " & strDbTable & "Thread.Message, " & strDbTable & "Thread.Author_ID, " & strDbTable & "Author.Username, LastThread.Message_date, LastThread.Author_ID, LastAuthor.Username, " & strDbTable & "Topic.Event_date, " & strDbTable & "Topic.Event_date_end " & _
"FROM " & strDbTable & "Topic" & strDBNoLock & ", " & strDbTable & "Thread" & strDBNoLock & ", " & strDbTable & "Thread AS LastThread" & strDBNoLock & ", " & strDbTable & "Author" & strDBNoLock & ", " & strDbTable & "Author AS LastAuthor" & strDBNoLock & " " & _
"WHERE ("

'Do the table joins
strSQL = strSQL & " " & strDbTable & "Thread.Author_ID = " & strDbTable & "Author.Author_ID " & _
	"AND LastThread.Author_ID = LastAuthor.Author_ID " & _
	"AND " & strDbTable & "Topic.Start_Thread_ID = " & strDbTable & "Thread.Thread_ID " & _
	"AND " & strDbTable & "Topic.Last_Thread_ID = LastThread.Thread_ID "

'If there is a date to show topics with then apply it to the SQL query
If intShowTopicsFrom <> 0 Then

	strSQL = strSQL & "AND ((LastThread.Message_date > "

	'If Access use # around dates, other DB's use ' around dates
	If strDatabaseType = "Access" Then
		strSQL = strSQL & "#"
	Else
		strSQL = strSQL & "'"
	End If

	'Initialse the string to display when active topics are shown since
	Select Case intShowTopicsFrom
		Case 1
			strShowTopicsFrom = strTxtLastVisitOn & " " & DateFormat(dtmLastVisitDate) & " " & strTxtAt & " " & TimeFormat(dtmLastVisitDate)
			strShowTopicsDate = internationalDateTime(dtmLastVisitDate)
		Case 2
			strShowTopicsFrom = strTxtYesterday
			strShowTopicsDate = internationalDateTime(DateAdd("d", -1, now()))
		Case 3
			strShowTopicsFrom = strTxtLastTwoDays
			strShowTopicsDate = internationalDateTime(DateAdd("d", -2, now()))
		Case 4
			strShowTopicsFrom = strTxtLastWeek
			strShowTopicsDate = internationalDateTime(DateAdd("ww", -1, now()))
		Case 5
			strShowTopicsFrom = strTxtLastMonth
			strShowTopicsDate = internationalDateTime(DateAdd("m", -1, now()))
		Case 6
			strShowTopicsFrom = strTxtLastTwoMonths
			strShowTopicsDate = internationalDateTime(DateAdd("m", -2, now()))
		Case 7
			strShowTopicsFrom = strTxtLastSixMonths
			strShowTopicsDate = internationalDateTime(DateAdd("m", -6, now()))
		Case 8
			strShowTopicsFrom = strTxtLastYear
			strShowTopicsDate = internationalDateTime(DateAdd("yyyy", -1, now()))
	End Select


	'If SQL server remove dash (-) from the ISO international date to make SQL Server safe
	If strDatabaseType = "SQLServer" Then strShowTopicsDate = Replace(strShowTopicsDate, "-", "", 1, -1, 1)

	'Place into SQL query
	strSQL = strSQL & strShowTopicsDate

	'If Access use # around dates, other DB's use ' around dates
	If strDatabaseType = "Access" Then
		strSQL = strSQL & "#"
	Else
		strSQL = strSQL & "'"
	End If

	strSQL = strSQL & ") OR (" & strDbTable & "Topic.Priority > 0)) "
	
	
	
End If

'Select which topics to get
strSQL = strSQL & "AND (" & strDbTable & "Topic.Priority = 3 " & _
		"OR " & strDbTable & "Topic.Moved_ID = " & intForumID & " " & _
		"OR " & strDbTable & "Topic.Forum_ID = " & intForumID & ") " & _
	") "

'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 & "Topic.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

'Order by
strSQL = strSQL & "ORDER BY " & strDbTable & "Topic.Priority DESC, " & strSortBy & " "

'mySQL limit operator
If strDatabaseType = "mySQL" Then
	strSQL = strSQL & " LIMIT " & intMaxResults
End If
strSQL = strSQL & ";"



'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_topics_data", "forum_topics.asp")

'Disable error trapping
On Error goto 0




'SQL Query Array Look Up table
'0 = tblTopic.Topic_ID
'1 = tblTopic.Poll_ID
'2 = tblTopic.Moved_ID
'3 = tblTopic.Subject
'4 = tblTopic.Icon
'5 = tblTopic.Start_Thread_ID
'6 = tblTopic.Last_Thread_ID
'7 = tblTopic.No_of_replies
'8 = tblTopic.No_of_views
'9 = tblTopic.Locked
'10 = tblTopic.Priority
'11 = tblTopic.Hide
'12 = tblThread.Message_date
'13 = tblThread.Message,
'14 = tblThread.Author_ID,
'15 = tblAuthor.Username,
'16 = LastThread.Message_date,
'17 = LastThread.Author_ID,
'18 = LastAuthor.Username
'19 = tblTopic.Event_date
'20 = tblTopic.Event_date_end



'Read in some details of the topics
If NOT rsCommon.EOF Then

	'Read in the Topic recordset into an array
	sarryTopics = rsCommon.GetRows()

	'Count the number of records
	intTotalRecords = Ubound(sarryTopics,2) + 1

	'Count the number of pages for the topics using FIX so that we get the whole number and  not any fractions
	intTotalRecordsPages = FIX(intTotalRecords / intTopicPerPage)

	'If there is a remainder or the result is 0 then add 1 to the total num of pages
	If intTotalRecords Mod intTopicPerPage > 0 OR intTotalRecordsPages = 0 Then intTotalRecordsPages = intTotalRecordsPages + 1

	'Start position
	intStartPosition = ((intRecordPositionPageNum - 1) * intTopicPerPage)

	'End Position
	intEndPosition = intStartPosition + intTopicPerPage

	'Get the start position
	intCurrentRecord = intStartPosition
End If

'Close the recordset
rsCommon.Close



'Read the various forums from the database
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "" & _
"SELECT " & strDbTable & "Forum.Forum_ID, " & strDbTable & "Forum.Forum_name, " & strDbTable & "Forum.Forum_description, " & strDbTable & "Forum.No_of_topics, " & strDbTable & "Forum.No_of_posts, " & strDbTable & "Author.Username, " & strDbTable & "Forum.Last_post_author_ID, " & strDbTable & "Forum.Last_post_date, " & strDbTable & "Forum.Password, " & strDbTable & "Forum.Locked, " & strDbTable & "Forum.Hide, " & strDbTable & "Permissions.View_Forum, " & strDbTable & "Forum.Last_topic_ID, " & strDbTable & "Topic.Subject " & _
"FROM (((" & strDbTable & "Category INNER JOIN " & strDbTable & "Forum ON " & strDbTable & "Category.Cat_ID = " & strDbTable & "Forum.Cat_ID) LEFT JOIN " & strDbTable & "Topic ON " & strDbTable & "Forum.Last_topic_ID = " & strDbTable & "Topic.Topic_ID) INNER JOIN " & strDbTable & "Author ON " & strDbTable & "Forum.Last_post_author_ID = " & strDbTable & "Author.Author_ID) INNER JOIN " & strDbTable & "Permissions ON " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Permissions.Forum_ID " & _
"WHERE " & strDbTable & "Forum.Sub_ID = " & intForumID & " " & _
	"AND (" & strDbTable & "Permissions.Author_ID = " & lngLoggedInUserID & " OR " & strDbTable & "Permissions.Group_ID = " & intGroupID & ") " & _
"ORDER BY " & strDbTable & "Forum.Forum_Order, " & strDbTable & "Permissions.Forum_ID;"


'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_sub_forum_data", "forum_topics.asp")

'Disable error trapping
On Error goto 0

'If there are sub forums to dsiplay, then display them
If NOT rsCommon.EOF Then

	'Read in the sub forum details into an array
	sarrySubForums = rsCommon.GetRows()
End If

'Close the recordset
rsCommon.Close





'Use the application session to pass around what forum this user is within
Call saveSessionItem("FID", intForumID)



'Page to link to for mutiple page (with querystrings if required)
strLinkPage = "forum_topics.asp?FID=" & intForumID & "&amp;"






'If active users is enabled update the active users application array
If blnActiveUsers Then
	'Call active users function
	saryActiveUsers = activeUsers(strTxtViewingIndex, strForumName, "forum_topics.asp?FID=" & intForumID, 0)
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

'Modertor Tools
If blnAdmin OR blnModerator Then
	strStatusBarTools = strStatusBarTools & "&nbsp;&nbsp;<span id=""modTools"" onclick=""showDropDown('modTools', 'modToolsMenu', 120, 0);"" class=""dropDownPointer""><img src=""" & strImagePath & "moderator_tools." & strForumImageType & """ alt=""" & strTxtModeratorTools & """ title=""" & strTxtModeratorTools & """ style=""vertical-align: text-bottom"" /> " & strTxtModeratorTools & "</span>" & _
	"<div id=""modToolsMenu"" class=""dropDownMenu"">" & _
	"<a href=""pre_approved_topics.asp" & strQsSID1 & """><div>" & strTxtHiddenTopics & "</div></a>" & _
	"<a href=""resync_post_count.asp?FID=" & intForumID & strQsSID2 & """><div>" & strTxtResyncTopicPostCount & "</div></a>"
	
	'Lock or un-lock forum if admin
	If blnAdmin AND blnForumLocked Then
		strStatusBarTools = strStatusBarTools & "<a href=""lock_forum.asp?mode=UnLock&amp;FID=" & intForumID & strQsSID2 & """><div>" & strTxtUnForumLocked & "</div></a>"
	Else
		strStatusBarTools = strStatusBarTools & "<a href=""lock_forum.asp?mode=Lock&amp;FID=" & intForumID & strQsSID2 & """><div>" & strTxtLockForum & "</div></a>"
	End If
	
	strStatusBarTools = strStatusBarTools & "</div>"
End If


'Topic Options drop down
strStatusBarTools = strStatusBarTools & "&nbsp;&nbsp;<span id=""forumOptions"" onclick="""
'If we need a subscription link then include a call to the ajax function
If blnEmail AND blnLoggedInUserEmail AND intGroupID <> 2 AND blnActiveMember Then strStatusBarTools = strStatusBarTools & "getAjaxData('ajax_email_notify.asp?FID=" & intForumID & "&amp;PN=" & intRecordPositionPageNum & strQsSID2 & "', 'ajaxEmailSub');"
	
strStatusBarTools = strStatusBarTools & "showDropDown('forumOptions', 'optionsMenu', 132, 0);"" class=""dropDownPointer""><img src=""" & strImagePath & "forum_options." & strForumImageType & """ alt=""" & strTxtForumOptions & """ title=""" & strTxtForumOptions & """ style=""vertical-align: text-bottom"" /> <a href=""#"">" & strTxtForumOptions & "</a></span>" & _
"<div id=""optionsMenu"" class=""dropDownStatusBar"">" & _
"<a href=""new_topic_form.asp?FID=" & intForumID & strQsSID2 & """ rel=""nofollow""><div>" & strTxtCreateNewTopic & "</div></a>"

'If the user can create a poll disply a create poll link
If blnPollCreate Then strStatusBarTools = strStatusBarTools & "<a href=""new_poll_form.asp?FID=" & intForumID & strQsSID2 & """ rel=""nofollow""><div>" & strTxtCreateNewPoll & "</div></a>"

'Display option to subscribe or un-subscribe to forum
If blnEmail AND blnLoggedInUserEmail AND intGroupID <> 2 AND blnActiveMember Then strStatusBarTools = strStatusBarTools & "<span id=""ajaxEmailSub""></span>"

strStatusBarTools = strStatusBarTools & "</div>"

⌨️ 快捷键说明

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