<% Option Explicit %> <% '**************************************************************************************** '** Copyright Notice '** '** Web Wiz Guide - Web Wiz Forums '** '** Copyright 2001-2002 Bruce Corkhill All Rights Reserved. '** '** This program is free software; you can modify (at your own risk) any part of it '** under the terms of the License that accompanies this software and use it both '** privately and commercially. '** '** All copyright notices must remain in tacked in the scripts and the '** outputted HTML. '** '** You may use parts of this program in your own private work, but you may NOT '** redistribute, repackage, or sell the whole or any part of this program even '** if it is modified or reverse engineered in whole or in part without express '** permission from the author. '** '** You may not pass the whole or any part of this application off as your own work. '** '** All links to Web Wiz Guide and powered by logo's must remain unchanged and in place '** and must remain visible when the pages are viewed unless permission is first granted '** by the copyright holder. '** '** This program is distributed in the hope that it will be useful, '** but WITHOUT ANY WARRANTY; without even the implied warranty of '** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER '** WARRANTIES WHETHER EXPRESSED OR IMPLIED. '** '** You should have received a copy of the License along with this program; '** if not, write to:- Web Wiz Guide, PO Box 4982, Bournemouth, BH8 8XP, United Kingdom. '** '** '** No official support is available for this program but you may post support questions at: - '** http://www.webwizguide.info/forum '** '** Support questions are NOT answered by e-mail ever! '** '** For correspondence or non support questions contact: - '** info@webwizguide.com '** '** or at: - '** '** Web Wiz Guide, PO Box 4982, Bournemouth, BH8 8XP, United Kingdom '** '**************************************************************************************** Response.Buffer = True 'Dimension variables 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 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("ThreadPage") = "" 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("ThreadPage")) End If 'Read in the Forum ID to display the Topics for intForumID = CInt(Request.QueryString("ForumID")) lngTopicID = CLng(Request.QueryString("TopicID")) intTopicPageNumber = CInt(Request.QueryString("PagePosition")) 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 'Create a record set object to the Threads held in the database Set rsThread = Server.CreateObject("ADODB.Recordset") 'Initalise the strSQL variable with an SQL statement to query the database get the thread details If strDatabaseType = "SQLServer" Then strSQL = "EXECUTE wwfSpThreadDetails @lngTopicID = " & lngTopicID Else strSQL = "SELECT tblTopic.Forum_ID, tblThread.*, tblAuthor.Username, tblAuthor.Homepage, tblAuthor.Location, tblAuthor.No_of_posts, tblAuthor.Join_date, tblAuthor.Signature, tblAuthor.Active, tblAuthor.Status, tblAuthor.Avatar, tblTopic.Subject, tblTopic.Locked, tblTopic.Priority, tblTopic.No_of_views " strSQL = strSQL & "FROM tblTopic INNER JOIN (tblAuthor INNER JOIN tblThread ON tblAuthor.Author_ID = tblThread.Author_ID) ON tblTopic.Topic_ID = tblThread.Topic_ID " strSQL = strSQL & "WHERE (((tblThread.Topic_ID)=" & lngTopicID & ")) " strSQL = strSQL & "ORDER by tblThread.Message_date ASC;" End If 'Set the cursor type property of the record set to dynamic so we can naviagate through the record set rsThread.CursorType = 1 'Query the database 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 tblTopic SET " strSQL = strSQL & "tblTopic.No_of_views=" & lngNumberOfViews strSQL = strSQL & " WHERE (((tblTopic.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 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 'Initalise the strSQL variable with an SQL statement to query the database If strDatabaseType = "SQLServer" Then strSQL = "EXECUTE wwfSpForumsAllWhereForumIs @intForumID = " & intForumID Else strSQL = "SELECT tblForum.Forum_name, tblForum.Password, tblForum.Forum_code, tblForum.Locked FROM tblForum WHERE Forum_ID = " & intForumID & ";" End If '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?ReturnPage=Thread&ForumID=" & intForumID & "&TopicID=" & lngTopicID End If 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 %> Discussion Forum: <% = strSubject %>
<% = strTxtWelcome & " " & strLoggedInUsername %> <% '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 & " " 'Else the user is not logged Else 'Display a " & strTxtWelcome & " guset message with the option to login or register Response.Write vbCrLf & " " End If %> <% = strTxtSearchTheForum %> <% = strTxtMembersList %>
<% '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 Response.Write vbCrLf & " " & strTxtAllForums & "
" Response.Write vbCrLf & "  " & strForumName & "" 'If the forum is locked show a locked pad lock icon If blnForumLocked = True Then Response.Write (" ( " & strTxtForumLocked & ")") End If 'If this is the results of a search have a link back to the serach results If Request.QueryString("ReturnPage") = "Search" Then %>
       &TopicID=<% = Request.QueryString("TopicID") %>&SearchPagePosition=<% = Request.QueryString("SearchPagePosition") %>&search=<% = Server.URLEncode(Request.QueryString("search")) %>&searchMode=<% = Request.QueryString("searchMode") %>&searchIn=<% = Request.QueryString("searchIn") %>&forum=<% = Request.QueryString("forum") %>&searchSort=<% = Request.QueryString("searchSort") %>&ThreadPage=<% = intRecordPositionPageNum %>" target="_self"><% = strTxtSearchResults %> <% 'If this is a link from an active topic page then link back to it ElseIf Request.QueryString("ReturnPage") = "Active" Then %>
        " target="_self"><% = strTxtActiveTopics %> <% End If End If %>
 <% 'If the user is the forum admin or a moderator then let them move the topic to another forum If lngLoggedInUserID = 1 OR blnModerator = True Then %>
<% = strTxtMoveTopic %><% End If %>
<% '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 & "") '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 & "" End If %>
<% = strTxtSubjectFolder %> <% = strTxtTopic & ": " & strSubject %><% 'If the topic is locked then have a locked icon If blnTopicLocked = True Then Response.Write (" ( " & strTxtTopicLocked & ")") End If %>") Else 'Display images with links to reply to post or post a new topic Response.Write (vbCrLf & "") End If Response.Write("  
<% 'Intialise the ADO recordset object Set rsModerator = Server.CreateObject("ADODB.Recordset") 'If there are threads display them If NOT rsThread.EOF Then 'Loop round to read in all the thread's in the database For intRecordLoopCounter = 1 to intThreadsPerPage 'Initilise moderator variable blnIsModerator = False 'If there are no reacrds left exit for loop If rsThread.EOF Then Exit For 'Calculate the thread number intThreadNo = intThreadNo + 1 'Read in threads details for the topic from the database lngMessageID = CLng(rsThread("Thread_ID")) strMessage = rsThread("Message") strUsername = rsThread("Username") lngUserID = CLng(rsThread("Author_ID")) dtmTopicDate = CDate(rsThread("Message_date")) strAuthorHomepage = rsThread("Homepage") strAuthorLocation = rsThread("Location") dtmAuthorRegistration = CDate(rsThread("Join_date")) lngAuthorNumOfPosts = CLng(rsThread("No_of_posts")) intStatus = CInt(rsThread("Status")) strAuthorAvatar = rsThread("Avatar") strAuthorSignature = rsThread("Signature") strAuthorIP = rsThread("IP_addr") 'Make search words in the subject highlighted For intHighlightLoopCounter = 0 To UBound(sarySearchWord) 'Replace the search words with highlited ones strMessage = Replace(strMessage, sarySearchWord(intHighlightLoopCounter), "" & sarySearchWord(intHighlightLoopCounter) & "", 1, -1, 1) Next 'If the users account is not active make there account level guest If CBool(rsThread("Active")) = False Then intStatus = 0 'SQL query to see if this person moderates this forum If strDatabaseType = "SQLServer" Then strSQL = "EXECUTE wwfSpCheckUserIsModerator @lngUserID = " & lngUserID & ", @intForumID = " & intForumID Else strSQL = "SELECT TOP 1 tblModerator.Moderator_ID FROM tblModerator " strSQL = strSQL & "WHERE tblModerator.Author_ID=" & lngUserID & " AND (tblModerator.Forum_ID=" & intForumID & " OR tblModerator.Forum_ID=0);" End If 'Query the database rsModerator.Open strSQL, strCon 'If a record is returned then this user moderates this forum :) If NOT rsModerator.EOF Then blnIsModerator = True 'Get rid of them objects rsModerator.Close 'Turn the members status number returned from the database into a string value Select Case intStatus 'Guest status Case 0 strStatus = "" & strTxtGuest & "
" 'Standard member status Case 1 strStatus = "" & strTxtStandardMember & "
" 'Super member status Case 2 strStatus = "" & strTxtGoldMember & "
" 'Power member status Case 3 strStatus = "" & strTxtPlatinumMember & "
" End select 'If the user is admin or this forums moderator then display so If blnIsModerator = True Then strStatus = "" & strTxtForumModerator & "
" If lngUserID = 1 Then strStatus = "" & strTxtForumAdmin & "
" 'If the user wants there signature shown then attach it to the message If rsThread("Show_signature") = True AND strAuthorSignature <> "" Then strMessage = strMessage & "

-----------------
" & strAuthorSignature & "" End If 'If no location is given then display a not given for the location If strAuthorLocation = "" Then strAuthorLocation = " " %>
<% Response.Write(strTxtMessageBy & " " & strUsername & " " & strTxtOn & " " & DateFormat(dtmTopicDate, saryDateTimeData) & " " & strTxtAt & " " & TimeFormat(dtmTopicDate, saryDateTimeData)) & "" 'If the user is the admin or moderatir then display the authors IP If (lngLoggedInUserID = 1 OR blnModerator = True) AND strAuthorIP <> "" Then Response.Write(" - " & strTxtIP & " " & strAuthorIP) Else Response.Write(" - " & strTxtIPLogged) End If Response.Write("") %>
<% = strTxtView %> <% = strUsername %>'s <% = strTxtProfile %> &date=DESC&ReturnPage=Thread&ForumID=<% = intForumID %>&TopicID=<% = lngTopicID %>&PagePosition=<% = intTopicPageNumber %>&ThreadPage=<% = intRecordPositionPageNum %>&ThreadPos=<% = intTotalNumOfPages %>"><% = strTxtSearchForPosts %> <% = strUsername %> <% 'If the user has a hompeage put in a link button If strAuthorHomepage <> "" Then %> <% = strTxtVisit & " align="absmiddle"> <% End If 'If the topic is not locked put in a link for someone to quote this message If blnTopicLocked = False OR (blnTopicLocked = True AND lngLoggedInUserID = 1) Then %> <% = strTxtQuote %> <% = strUsername %> <% End If 'If the private msg's are on then display a link to enable use to send them a msg If blnPrivateMessages = True Then %> <% = strTxtSendPrivateMessage %> <% = strTxtAddToBuddyList %> <% End If 'If the logged in user is the person who posted the message or the forum administrator/moderator then allow them to edit or delete the message If (lngLoggedInUserID = lngUserID OR lngLoggedInUserID = 1 OR blnModerator = True) AND (blnForumLocked = False OR lngLoggedInUserID = 1) AND (blnActiveMember = True) AND (NOT lngLoggedInUserID = 2) AND (blnTopicLocked = False OR lngLoggedInUserID = 1) AND ((intPriority <> 3 OR intThreadNo <> 1) OR lngLoggedInUserID = 1) Then 'Check the time limit on editing posts has not expired If DateDiff("n", dtmTopicDate, now()) < intDeletePostsTimeLimit OR (lngLoggedInUserID = 1 OR blnModerator = True) Then Response.Write("") Response.Write(VbCrLf & "") End If End If 'If the user is the forum admin or a moderator then let them move the topic to another forum If lngLoggedInUserID = 1 OR blnModerator = True Then %> <% = strTxtMovePost %> <% End If %>
<% 'If the user has an avatar then display it If blnAvatar = True AND strAuthorAvatar <> "" Then Response.Write(" ") Response.Write("") Response.Write("") End If %>
<% = strUsername %>
<% = strStatus %>
<% = strAuthorLocation %>
<% = DateFormat(dtmAuthorRegistration, saryDateTimeData) %>
<% = lngAuthorNumOfPosts %> <% = strTxtPosts %>
<% = strMessage %>

<% 'Move to the next database record rsThread.MoveNext Next End If 'get rid of server objects Set rsModerator = Nothing rsForum.Close Set rsForum = Nothing rsThread.Close Set rsThread = Nothing 'Set up an achor Response.Write("
") 'If the user has logged in then display a form so they can post a thread unless there are more thread pages If (NOT lngLoggedInUserID = 0 AND blnNoThread = False AND blnActiveMember = True AND (blnForumLocked = False OR lngLoggedInUserID = 1) AND (blnTopicLocked = False OR lngLoggedInUserID = 1)) AND (intRecordPositionPageNum = intTotalNumOfPages) Then %>
<% = strTxtPostReply %>
<% 'See if the users browser is Internet Explorer and not the Mac version If InStr(1, Request.ServerVariables("HTTP_USER_AGENT"), "MSIE", 1) > 0 AND InStr(1, Request.ServerVariables("HTTP_USER_AGENT"), "MAC", 1) = 0 AND InStr(1, Request.ServerVariables("HTTP_USER_AGENT"), "Opera", 1) = 0 AND blnIEEditor = True Then 'See if the users version on Internet Explorer is 5 or above If Trim(Mid(Request.ServerVariables("HTTP_USER_AGENT"), CInt(inStr(1, Request.ServerVariables("HTTP_USER_AGENT"), "MSIE", 1)+5), 1)) => 5 Then 'Open the message form for Internet Explorer users 5 and above %><% Else 'Open up the mesage form for IE 4 and below users %><% End If 'Open up the massge form for all other browser users Else %><% End If %>
<% End If %>
<% 'Display message if the users forum membership is suspended If blnActiveMember = False AND (intRecordPositionPageNum = intTotalNumOfPages) Then %>

<% = strTxtSorryNoReply %>
<% = strTxtForumMembershipSespended %>

<% 'Display message if the forum is locked ElseIf blnForumLocked = True AND (intRecordPositionPageNum = intTotalNumOfPages) Then %>

<% = strTxtSorryNoReply %>
<% = strTxtThisForumIsLocked %>

<% 'Display message if the topic is locked ElseIf blnTopicLocked = True AND (intRecordPositionPageNum = intTotalNumOfPages) Then %>

<% = strTxtSorryNoReply %>
<% = strTxtThisTopicIsLocked %>

<% 'Display message if the user is a guest or not logged in ElseIf lngLoggedInUserID = 0 AND (intRecordPositionPageNum = intTotalNumOfPages) Then %>

<% = strTxtPostAReplyRegister %> <% = strTxtLogin %>
<% = strTxtNeedToRegister %> <% = strTxtSmRegister %>

<% End If %>
<% 'If there is more than 1 page of topics then dispaly drop down list to the other threads If intTotalNumOfPages > 1 Then 'Display an image link to the last topic Response.Write vbCrLf & " " End If '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 'Display images with links to reply to post or post a new topic Response.Write(vbCrLf & "") '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 & "" End If 'Clear server objects Set adoCon = Nothing Set strCon = Nothing %>
" & strTxtPage Response.Write vbCrLf & " " & strTxtOf & " " & intTotalNumOfPages & "") 'Only show the post reply link button on pages without the reply box as some people seem to think this button should actually post the forum!!! If intRecordPositionPageNum <> intTotalNumOfPages Then Response.Write("") End If Response.Write(vbCrLf & " 
<% = strTxtPrintVersion %> <% = strTxtPrintVersion %> <% 'If the user has logged in then the Logged In and the e-mail is on then display a link to allow the user to e-mail topic to a friend If NOT lngLoggedInUserID = 0 AND blnEmail = True AND blnActiveMember = True Then %>  <% = strTxtEmailTopic %> <% = strTxtEmailTopic %> <% End If %>

<% '***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ****** If blnLCode = True Then If blnTextLinks = True Then Response.Write("Powered by Web Wiz Forums version 6.32") Else Response.Write("") End If Response.Write("
Copyright ©2001-2002 Web Wiz Guide") End If '***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ****** %>