% Option Explicit %> <% '___________________________________________________________________________________________ Response.Buffer = True 'Dimension variables Dim rsGetCategoryName 'Holds the database recordset variable for the Category Name Dim rsForum 'Holds the Database Recordset Variable for the topic details Dim rsThread 'Holds the database recordset variable for the thread Dim intForumID 'Holds the forum ID number Dim intCategoryID 'Holds the forum ID number Dim strCategoryName 'Holds the Category Name Dim strForumName 'Holds the 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 dtmTopicDate 'Holds the date the thread was made Dim strMessage 'Holds the message body of the thread 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 blnNoThread 'Set to true if there is no thread to view 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 strPostPage 'Holds the page the form is posted to Dim intRecordPositionPageNum 'Holds the recorset page number to show the Threads for Dim intTotalNumOfPages 'Holds the number of pages Dim intRecordLoopCounter 'Holds the loop counter numeber Dim intThreadPageLoopCounter 'Loop counter for other thread page link Dim intTotalNumOfThreads '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 intHighlightLoopCounter 'Loop counter to loop through words and hightlight them 'Initialise variables strMode = "reply" lngMessageID = 0 intForumID = 0 lngTopicID = 0 intThreadNo = 0 blnNoThread = False blnIsModerator = False '___________________________________________________________________________________________ '___________________________________________________________________________________________ 'If this is the first time the page is displayed then the Forum Thread record position is set to page 1 If Request.QueryString("THP") = "" 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("THP")) End If 'Read in the Forum ID to display the Topics for intCategoryID = trim(CInt(Request.QueryString("CID"))) intForumID = trim(CInt(Request.QueryString("FID"))) lngTopicID = trim(CLng(Request.QueryString("TID"))) intTopicPageNumber = trim(CInt(Request.QueryString("PP"))) strSearchKeywords = Trim(Mid(Request.QueryString("search"), 1, 35)) 'If there is no Topic ID then redirect the user to the main forum page If lngTopicID = 0 Then Response.Redirect "Default.asp" 'Filter the search words with the same filters as the text is saved with strSearchKeywords = formatSQLInput(strSearchKeywords) strSearchKeywords = formatInput(strSearchKeywords) 'Split up the keywords to be searched sarySearchWord = Split(Trim(strSearchKeywords), " ") '___________________________________________________________________________________________ '___________________________________________________________________________________________ 'Get the threads from the database 'record set object to the Threads held in the database Set rsThread = Server.CreateObject("ADODB.Recordset") 'query the database get the thread details strSQL = " SELECT Topic.Forum_ID, Thread.*, Author.Username, Author.Homepage, " strSQL = strSQL & " Author.Location, Author.No_of_posts, Author.Join_date, " strSQL = strSQL & " Author.Signature, Author.Active, Author.Status, Author.Avatar," strSQL = strSQL & " Topic.Subject, Topic.Locked,Topic.Priority, Topic.No_of_views " strSQL = strSQL & " FROM Topic INNER JOIN (Author INNER JOIN Thread " strSQL = strSQL & " ON Author.Author_ID = Thread.Author_ID)" strSQL = strSQL & " ON Topic.Topic_ID = Thread.Topic_ID " strSQL = strSQL & " WHERE (((Thread.Topic_ID)=" & lngTopicID & ")) " strSQL = strSQL & " ORDER by Thread.Message_date ASC; " rsThread.CursorType = 1 rsThread.Open strSQL, strCon 'Set the number of records to display on each page rsThread.PageSize = intThreadsPerPage '___________________________________________________________________________________________ 'If there is no topic in the database then display the appropraite mesasage If rsThread.EOF Then 'If there are no thread's to display then display the appropriate error message strSubject = strTxtNoThreads blnNoThread = True 'Else there are records returned by the database Else 'Count the number of pages there are in the recordset calculated by the PageSize attribute set by admin intTotalNumOfPages = rsThread.PageCount 'Get the total amount of threads in the topic intTotalNumOfThreads = rsThread.RecordCount '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 highers page If (intRecordPositionPageNum > intTotalNumOfPages) OR (Request.QueryString("get") = "last") Then 'Set the page number to show from rsThread.AbsolutePage = intTotalNumOfPages 'Set the page position number to the highest page number intRecordPositionPageNum = intTotalNumOfPages 'Else the page number to show from is the requested page number Else rsThread.AbsolutePage = intRecordPositionPageNum End If 'Read in the number of views for the page form the database lngNumberOfViews = CLng(rsThread("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 Topic SET " strSQL = strSQL & "Topic.No_of_views=" & lngNumberOfViews strSQL = strSQL & " WHERE (((Topic.Topic_ID)=" & lngTopicID & "));" 'Write to the database adoCon.Execute(strSQL) 'Read in the thread subject forum ID and where the topic is locked strSubject = rsThread("Subject") blnTopicLocked = CBool(rsThread("Locked")) intPriority = CInt(rsThread("Priority")) 'If the priority of the post is not for all forums then get the Forum ID from the database for this topic 'when further improve then unselect these lines. 'If intPriority <> 1 Then ' intForumID = Cint(rsThread("Forum_ID")) 'End If End If 'Create a recordset to get the forum details Set rsForum = Server.CreateObject("ADODB.Recordset") 'Read in the forum name from the database strSQL = "SELECT Forum.Forum_name, Forum.Password, Forum.Forum_code, Forum.Locked FROM Forum WHERE Forum_ID = " & intForumID & ";" 'Query the database rsForum.Open strSQL, strCon 'If there is a record returned by the recordset then check to see if you need a password to enter it If NOT rsForum.EOF Then 'Read in forum details from the database strForumName = rsForum("Forum_name") 'Read in wether the forum is locked or not blnForumLocked = CBool(rsForum("Locked")) '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 NOT rsForum("Password") = "" and NOT Request.Cookies("PrForum")("Forum" & intForumID) = rsForum("Forum_code") Then 'Reset Server Objects rsThread.Close Set rsThread = Nothing rsForum.Close Set rsForum = Nothing Set adoCon = Nothing Set strCon = Nothing 'Redirect to a page asking for the user to enter the forum password Response.Redirect "forum_password_form.asp?CID=" & trim(intCategoryID) & "&RP=Thread&FID=" & intForumID & "&TID=" & lngTopicID End If End If 'recordset to get the name of the category from the catageory table Set rsGetCategoryName = Server.CreateObject("ADODB.Recordset") 'for Access.. 'strSQL = "SELECT Category.Cat_Name FROM Category INNER JOIN Forum ON Category.Cat_ID = Forum.Cat_ID where Category.Cat_ID = " & intCategoryID & ";" 'for Sql Server strSQL = "SELECT Category.Cat_Name FROM Forum INNER JOIN Category ON Category.Cat_ID = Forum.Cat_ID where Category.Cat_ID = " & intCategoryID & ";" rsGetCategoryName.Open strSQL, strCon if Not rsGetCategoryName.EOF then strCategoryName = rsGetCategoryName("Cat_name") end if 'If the forum level for the user on this forum is 2 (read only) set the forum to be locked If (intMemberSecurityLevel = 2 AND blnModerator = False AND NOT lngLoggedInUserID = 1) AND (lngLoggedInUserID > 0) Then blnForumLocked = True %>
| <% = strTxtWelcome & " " & strLoggedInUsername %> |
<%
If lngLoggedInUserID = 1 Then Response.Write vbCrLf & ""& strTxtAdmin & " |"
Response.Write vbCrLf & "Search |"
'If the user has logged in then the Logged In User ID number will not be 0 and not 2 for the guest account
If NOT lngLoggedInUserID = 0 AND NOT lngLoggedInUserID = 2 Then
'Dispaly a " & strTxtWelcome & " message to the user in the top bar
'Response.Write vbCrLf & " |
|
<%
'Check there is a forum to display
If rsForum.EOF Then
'If there is no forum to display then display the appropriate error message
Response.Write vbCrLf & " " & strTxtNoForums & "" 'Else there the is a forum then write the HTML to display it the forum names and a discription Else 'Write the HTML of the forum descriptions as hyperlinks to the forums 'this response display the main heading of a company.. Response.Write vbCrLf & " " 'this response display the main category of Forums Response.Write vbCrLf & " " 'this response display the Forum Response.Write vbCrLf & " " 'this response display the thread name... Response.Write vbCrLf & " |
<% ' %> |
|
<%
''If the topic is locked then have a locked icon
'If blnTopicLocked = True Then
' Response.Write (" ( |
<%
'If the user has logged in then the Logged In User ID number will be more than 0
If NOT lngLoggedInUserID = 0 AND blnActiveMember = True Then
'If the reply box is on the same page shorten the reply link
If intRecordPositionPageNum = intTotalNumOfPages Then
'Display images with links to reply to post or post a new topic
'Response.Write (vbCrLf & "Post Reply ") Response.Write vbCrLf & " | Post Reply | " Else 'Display images with links to reply to post or post a new topic ' ' Response.Write (vbCrLf & "Post Reply ") 'Response.Write vbCrLf & " | Post Reply | " Response.Write vbCrLf & "Post Reply | " End If 'Response.Write(" New Topic") 'Else the user is not logged Else 'Display images with links to reply to post or post a new topic but get redirected to a login screen if user is not logged in Response.Write vbCrLf & "Post Reply | " End If %>
|
||||||||||||||||
<% = strTxtSorryNoReply %>
<% = strTxtForumMembershipSespended %>
<% = strTxtSorryNoReply %>
<% = strTxtThisForumIsLocked %>
<% = strTxtSorryNoReply %>
<% = strTxtThisTopicIsLocked %>
|
<% = strTxtPostAReplyRegister %> <% = strTxtLogin %> |
| <% = strTxtNeedToRegister %> <% = strClickHereIfNotRegistered %> |
| <% 'If there is more than 1 page of topics then dispaly the other threads If intTotalNumOfPages > 1 Then Response.Write vbCrLf & " | "
'Loop round to display links to all the other pages
For intThreadPageLoopCounter = 1 to intTotalNumOfPages
If intThreadPageLoopCounter = intRecordPositionPageNum Then
Response.Write vbCrLf & "" & intThreadPageLoopCounter & ""
ELSE
Response.Write vbCrLf & "" & intThreadPageLoopCounter & ""
END IF
Next
response.Write vbCrLf & " | "
End If
'Clear server objects
Set adoCon = Nothing
Set strCon = Nothing
%>