<% Option Explicit %> <% '**************************************************************************************** '** Copyright Notice '** '** Web Wiz Guide ASP Discussion Forum '** '** Copyright 2001 Bruce Corkhill All Rights Reserved. '** '** This program is free software; you can redistribute it and/or modify '** it under the terms of the GNU General Public License as published by '** the Free Software Foundation; either version 2 of the License, or '** any later version. '** '** All copyright notices must remain intacked in the scripts and the '** outputted HTML. '** '** You may not pass the whole or any part of this application off as your own work. '** '** All links to Web Wiz Guide must remain in place and the powered by '** logo with link back to Web Wiz Guide must remain visiable when the pages '** are viewed. '** '** This program is distributed in the hope that it will be useful, '** but WITHOUT ANY WARRANTY; without even the implied warranty of '** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '** GNU General Public License for more details. '** '** You should have received a copy of the GNU General Public License '** along with this program; if not, write to the Free Software '** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA '** '** '** 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 '**************************************************************************************** 'Set the response buffer to true as we maybe redirecting and setting a cookie Response.Buffer = True %> Discussion Forum
<% 'If the user has logged in then the Logged In User ID number will be more than 0 If NOT lngLoggedInUserID = 0 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 %>
 " & strTxtWelcome & " " & strLoggedInUsername & "      " & strTxtWelcomeGuest & "      <% = strTxtMembersList %>

<% 'Dimension variables Dim rsForum 'Holds the Recordset for the forum details Dim rsTopicCount 'Holds the Recordset for the count of Topics Dim rsThread 'Holds the recordset for the thread details Dim rsThreadCount 'Holds the recordset for the count of posts Dim rsLatestsPosts 'Holds the latest posts from the database Dim rsNewestAuthor 'Holds the newest forum posts Dim intForumID 'Holds the forum ID number Dim lngTopicID 'Holds the topic id number Dim strForumName 'Holds the forum name Dim strForumDiscription 'Holds the forum description Dim dtmForumStartDate 'Holds the forum start date Dim lngNumberOfTopics 'Holds the number of topics in a forum Dim lngNumberOfPosts 'Holds the number of Posts in the forum Dim lngTotalNumberOfTopics 'Holds the total number of topics in a forum Dim lngTotalNumberOfPosts 'Holds the total number of Posts in the forum Dim intNumberofForums 'Holds the number of forums Dim dtmLastEntryDate 'Holds the date of the last entry to the forum Dim strLastEntryUser 'Holds the the username of the user who made the last entry Dim lngLastEntryUserID 'Holds the ID number of the last user to make and entry Dim blnForumLocked 'Set to true if the forum is locked 'Initialise variables lngTotalNumberOfTopics = 0 lngTotalNumberOfPosts = 0 intNumberofForums = 0 'Craete a recordset to get the forum details Set rsForum = Server.CreateObject("ADODB.Recordset") 'Read the various forums from the database 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT tblForum.* FROM tblForum ORDER BY tblForum.Forum_Order ASC;" 'Query the database rsForum.Open strSQL, strCon 'Check there are forum's to display If rsForum.EOF Then 'If there are no forum's to display then display the appropriate error message Response.Write vbCrLf & "" 'Else there the are forum's to write the HTML to display it the forum names and a discription Else 'Loop round to read in all the forums in the database Do While NOT rsForum.EOF 'Initialise variables lngNumberOfTopics = Null lngNumberOfPosts = Null 'Read in forum details from the database intForumID = CInt(rsForum("Forum_ID")) strForumName = rsForum("Forum_name") strForumDiscription = rsForum("Forum_description") dtmForumStartDate = CDate(rsForum("Date_Started")) blnForumLocked = CBool(rsForum("Locked")) 'Initilaise variables for the information required for each forum dtmLastEntryDate = dtmForumStartDate strLastEntryUser = "Forum Adminstrator" lngLastEntryUserID = 1 'Create a record set object to the Topics held in the database Set rsTopicCount = Server.CreateObject("ADODB.Recordset") 'Get the number of Topics 'Initalise the strSQL variable with an SQL statement to query the database to count the number of topics in the forums strSQL = "SELECT Count(tblTopic.Forum_ID) AS Topic_Count " strSQL = strSQL & "From tblTopic " strSQL = strSQL & "WHERE tblTopic.Forum_ID = " & intForumID & " " strSQL = strSQL & "GROUP BY tblTopic.Forum_ID " 'Query the database rsTopicCount.Open strSQL, strCon 'If there are Topics in the database for the forum then loop through the record set to get the number of replies topics and replies for the forum If NOT rsTopicCount.EOF Then 'Read in the number of Topics lngNumberOfTopics = CLng(rsTopicCount("Topic_Count")) lngTotalNumberOfTopics = lngTotalNumberOfTopics + CLng(rsTopicCount("Topic_Count")) '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 for the date of the last entry and the author for the thread strSQL = "SELECT TOP 1 tblThread.Message_date, tblAuthor.Username, tblAuthor.Author_ID " strSQL = strSQL & "FROM (tblForum INNER JOIN tblTopic ON tblForum.Forum_ID = tblTopic.Forum_ID) INNER JOIN (tblAuthor INNER JOIN tblThread ON tblAuthor.Author_ID = tblThread.Author_ID) ON tblTopic.Topic_ID = tblThread.Topic_ID " strSQL = strSQL & "WHERE tblTopic.Forum_ID = " & intForumID & " " strSQL = strSQL & "ORDER BY tblThread.Message_date DESC;" 'Query the database rsThread.Open strSQL, strCon 'If there are threads for topic then read in the date and author of the last entry If NOT rsThread.EOF Then 'Read in the deatils from the recorset dtmLastEntryDate = CDate(rsThread("Message_date")) strLastEntryUser = rsThread("Username") lngLastEntryUserID = CLng(rsThread("Author_ID")) 'Create a record set object to the to hold the count of posts Set rsThreadCount = Server.CreateObject("ADODB.Recordset") 'Get the number of Posts 'Initalise the strSQL variable with an SQL statement to query the database to count the number of topics in the forums strSQL = "SELECT Count(tblThread.Thread_ID) AS Thread_Count " strSQL = strSQL & "FROM tblTopic INNER JOIN tblThread ON tblTopic.Topic_ID = tblThread.Topic_ID " strSQL = strSQL & "GROUP BY tblTopic.Forum_ID " strSQL = strSQL & "HAVING (((tblTopic.Forum_ID)=" & intForumID & "));" 'Query the database rsThreadCount.Open strSQL, strCon 'Read in the count of the Threads for the forum If NOT rsThreadCount.EOF Then lngNumberOfPosts = CLng(rsThreadCount("Thread_Count")) lngTotalNumberOfPosts = lngTotalNumberOfPosts + CLng(rsThreadCount("Thread_Count")) End If 'Reset server variables rsThreadCount.Close Set rsThreadCount = Nothing End If 'Reset variables rsThread.Close Set rsThread = Nothing End If 'Write the HTML of the forum descriptions and hyperlinks to the forums %> <% 'Count the number of forums intNumberofForums = intNumberofForums + 1 'Close recordsets rsTopicCount.Close Set rsTopicCount = Nothing 'Move to the next database record rsForum.MoveNext Loop End If %>
<% = strTxtForum %> <% = strTxtTopics %> <% = strTxtPosts %> <% = strTxtLastPost %>
" & strTxtNoForums & "
<% 'If the forum is locked show a locked pad lock icon If blnForumLocked = True Then Response.Write (" ") End If %> <% = strForumName %>
<% = strForumDiscription %>
<% If lngNumberOfTopics > 0 Then Response.Write(lngNumberOfTopics) Else Response.Write(" ") End If %> <% If lngNumberOfPosts > 0 Then Response.Write(lngNumberOfPosts) Else Response.Write(" ") End If %> <% = DateFormat(dtmLastEntryDate) %> <% = strTxtAt %> <% = TimeFormat(dtmLastEntryDate) %>
<% = strTxtBy %> <% = strLastEntryUser %>

<% = strTxtLatestForumPosts %>
<% 'Intialise the ADO recordset object Set rsLatestsPosts = Server.CreateObject("ADODB.Recordset") 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT Top 5 tblTopic.Forum_ID, tblTopic.Topic_ID, tblTopic.Subject, tblForum.Password " strSQL = strSQL & "FROM tblForum INNER JOIN tblTopic ON tblForum.Forum_ID = tblTopic.Forum_ID " strSQL = strSQL & "WHERE (((tblForum.Password) Is Null)) " strSQL = strSQL & "ORDER BY tblTopic.Last_entry_date DESC;" 'Query the database rsLatestsPosts.Open strSQL, strCon 'If EOF then display an error message If rsLatestsPosts.EOF Then Response.Write "" & strTxtNoForumPostMade & "" 'If there are pages to display then display them Do while NOT rsLatestsPosts.EOF %> &TopicID=<% = rsLatestsPosts("Topic_ID") %>&PagePosition=1" target="_self" style="font-size: 12px;"> <% = rsLatestsPosts("Subject") %>
<% rsLatestsPosts.MoveNext Loop %>
 
<% 'Get the date and author of the last post 'Createia 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 for the date of the last entry and the author for the thread strSQL = "SELECT TOP 1 tblThread.Message_date, tblAuthor.Username, tblAuthor.Author_ID " strSQL = strSQL & "FROM (tblForum INNER JOIN tblTopic ON tblForum.Forum_ID = tblTopic.Forum_ID) INNER JOIN (tblAuthor INNER JOIN tblThread ON tblAuthor.Author_ID = tblThread.Author_ID) ON tblTopic.Topic_ID = tblThread.Topic_ID " strSQL = strSQL & "ORDER BY tblThread.Message_date DESC;" 'Query the database rsThread.Open strSQL, strCon 'If there are records returned by the database then get there details If NOT rsThread.EOF Then dtmLastEntryDate = CDate(rsThread("Message_date")) strLastEntryUser = rsThread("Username") lngLastEntryUserID = CLng(rsThread("Author_ID")) End If %>
<% = strTxtForumStatistics %>
<% = strTxtThereAre %> <% = lngTotalNumberOfPosts %> <% = strTxtPostsIn %> <% = lngTotalNumberOfTopics %> <% = strTxtTopicsIn %> <% = intNumberofForums %> <% = strTxtForum %>
<% = strTxtLastPostOn %> <% = DateFormat(dtmLastEntryDate) %> <% = strTxtAt %> <% = TimeFormat(dtmLastEntryDate) %>
<% = strTxtLastPostBy %> <% = strLastEntryUser %> <% 'Intialise the ADO recordset object Set rsNewestAuthor = Server.CreateObject("ADODB.Recordset") 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT tblAuthor.Username, tblAuthor.Author_ID " strSQL = strSQL & "FROM tblAuthor " strSQL = strSQL & "ORDER BY tblAuthor.Author_ID DESC;" 'Set the cursor type property of the record set to forward only rsNewestAuthor.CursorType = 1 'Query the database rsNewestAuthor.Open strSQL, strCon 'Display some statistics for the members If NOT rsNewestAuthor.EOF Then %>
<% = strTxtThereAre %> <% = rsNewestAuthor.RecordCount %> <% = strTxtForumMembers %>
<% = strTxtTheNewestForumMember %> ','profile','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=475,height=340')"><% = rsNewestAuthor("Username") %> <% End If %>
<% 'Reset Server Objects Set adoCon = Nothing Set strCon = Nothing rsLatestsPosts.Close Set rsLatestsPosts = Nothing rsForum.Close Set rsForum = Nothing rsThread.Close Set rsThread = Nothing rsNewestAuthor.Close Set rsNewestAuthor = Nothing %>

<% = strTxtCookies %>


<% '***** 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 Guide Discussion Forums") Else Response.Write("
") End If End If '***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ****** %>