<% Option Explicit %> <% '___________________________________________________________________________________________ Response.Buffer = True '___________________________________________________________________________________________ %> :: Discussion Forum ::
<% = 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 'Response.Write vbCrLf & " " Response.Write vbCrLf & "Members |" Response.Write vbCrLf & "Profile | LogOut |" 'Else the user is not logged Else 'Response.Write vbCrLf & " " Response.Write vbCrLf & "Register | Login |" End If '___________________________________________________________________________________________ %>
<% ' '--> '___________________________________________________________________________________________ Dim rsStatisticsTotalMember 'Holds the recordset for the user details.. Dim strNewMemberJoinDate 'Holds the new member Join Date SET rsStatisticsTotalMember = server.CreateObject("ADODB.Recordset") 'Get the last signed up user strSQL = "SELECT Author.Username, Author.Author_ID, " strSQL = strSQL & "Author.Join_Date FROM Author " strSQL = strSQL & "ORDER BY Author.Author_ID DESC;" rsStatisticsTotalMember.Open strSQL, strCon,3 'Display some statistics for the members If NOT rsStatisticsTotalMember.EOF Then strNewMemberJoinDate = rsStatisticsTotalMember("Join_Date") If lngLoggedInUserID = 1 Then Response.Write(vbCrLf & " " & strTxtTotalMember & " " & rsStatisticsTotalMember.RecordCount & " " )'& strTxtForumMembers) END IF Response.Write(vbCrLf & "
" & strTxtTheNewestForumMember & " " & rsStatisticsTotalMember("Username") & "" & " " & strTxtNewMemberJoinDate & DateFormat(strNewMemberJoinDate, saryDateTimeData) & " " & strTxtAt & " " & TimeFormat(strNewMemberJoinDate, saryDateTimeData) ) End If rsStatisticsTotalMember.Close SET rsStatisticsTotalMember = Nothing '___________________________________________________________________________________________ %>
<% Response.Write(strTxtTheTimeNowIs & " " & TimeFormat(now(), saryDateTimeData)) %>.
<% '___________________________________________________________________________________________ 'If this is not the first time the user has visted the site display the last visit time and date If Session("dtmLastVisit") < CDate(Request.Cookies("ForumVisit")("LastVist")) Then Response.Write(strTxtYouLastVisitedOn & " " & DateFormat(Session("dtmLastVisit"), saryDateTimeData) & " " & strTxtAt & " " & TimeFormat(Session("dtmLastVisit"), saryDateTimeData) & ".") End If '___________________________________________________________________________________________ %>
<% '___________________________________________________________________________________________ 'Dimension variables Dim rsCategory 'Holds the categories for the forums Dim rsForum 'Holds the Recordset for the forum details Dim rsCount 'Holds the Recordset for the count of Topics Dim rsThread 'Holds the recordset for the thread details Dim rsStatistics 'Holds the latest posts from the database Dim intForumID 'Holds the forum ID number Dim strCategory 'Holds the category name Dim intCatID 'Holds the id for the category 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 lngLastEntryMessageID 'Holds the message ID of the last entry Dim lngLastEntryTopicID 'Holds the topic ID of the last entry 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 Dim intForumColourNumber 'Holds the number to calculate the table row colour Dim rsFindModName 'recordset to find out the moderator name..to show on the page 'Initialise variables lngTotalNumberOfTopics = 0 lngTotalNumberOfPosts = 0 intNumberofForums = 0 intForumColourNumber = 0 '___________________________________________________________________________________________ '___________________________________________________________________________________________ 'recordset to get the forum details Set rsCategory = Server.CreateObject("ADODB.Recordset") Set rsThread = Server.CreateObject("ADODB.Recordset") '___________________________________________________________________________________________ strSQL = "SELECT Category.Cat_name, Category.Cat_ID " strSQL = strSQL & "FROM Category " strSQL = strSQL & " ORDER BY Category.Cat_order ASC;" '___________________________________________________________________________________________ rsCategory.Open strSQL, strCon 'Check there are categories to display If rsCategory.EOF Then 'If there are no categories to display then display error message Response.Write vbCrLf & "" Else 'recordset to get the forum details Set rsForum = Server.CreateObject("ADODB.Recordset") 'recordset object to the Topics held in the database 'recordset to find out the moderator name..to show on the page Set rsFindModName = Server.CreateObject("ADODB.Recordset") Set rsCount = Server.CreateObject("ADODB.Recordset") 'Loop round to read in all the categories in the database Do While NOT rsCategory.EOF '___________________________________________________________________________________________ 'Get the category name from the database strCategory = rsCategory("Cat_name") 'Get the category ID from the database intCatID = CInt(rsCategory("Cat_ID")) '___________________________________________________________________________________________ 'Display the category name Response.Write vbCrLf & "" '___________________________________________________________________________________________ ' selection of forum strSQL = "SELECT Forum.* FROM Forum " strSQL = strSQL & "WHERE Forum.Cat_ID = " & intCatID & " " strSQL = strSQL & "ORDER BY Forum.Forum_Order ASC;" '___________________________________________________________________________________________ rsForum.Open strSQL, strCon If rsForum.EOF Then 'If there are no forum's to display then display error message Response.Write vbCrLf & "" Else 'Loop round to read in all the forums in the database Do While NOT rsForum.EOF 'Get the row number intForumColourNumber = intForumColourNumber + 1 'Initialise variables lngNumberOfTopics = 0 lngNumberOfPosts = 0 lngLastEntryTopicID = 0 '___________________________________________________________________________________________ '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")) intMemberSecurityLevel = CInt(rsForum(strMemberStatus)) '___________________________________________________________________________________________ 'Initilaise variables for the information required for each forum dtmLastEntryDate = dtmForumStartDate '"Admin" sting writen in this variable strLastEntryUser = strTxtForumAdministrator lngLastEntryUserID = 1 '___________________________________________________________________________________________ 'to get the total topic of the forum.. strSQL = "SELECT Count(Topic.Forum_ID) AS Topic_Count " strSQL = strSQL & "From Topic " strSQL = strSQL & "WHERE Topic.Forum_ID = " & intForumID & " " '___________________________________________________________________________________________ 'Query the database rsCount.Open strSQL, strCon '___________________________________________________________________________________________ 'Read in the number of Topics lngNumberOfTopics = CLng(rsCount("Topic_Count")) lngTotalNumberOfTopics = lngTotalNumberOfTopics + CLng(rsCount("Topic_Count")) '___________________________________________________________________________________________ 'Close the rs rsCount.Close '___________________________________________________________________________________________ strSQL = "SELECT TOP 1 Thread.Thread_ID, Thread.Message_date, " strSQL = strSQL & "Thread.Topic_ID, Author.Username, Author.Author_ID " strSQL = strSQL & "FROM (Forum INNER JOIN Topic ON Forum.Forum_ID = Topic.Forum_ID) " strSQL = strSQL & "INNER JOIN (Author INNER JOIN Thread ON Author.Author_ID = Thread.Author_ID) " strSQL = strSQL & "ON Topic.Topic_ID = Thread.Topic_ID " strSQL = strSQL & "WHERE Topic.Forum_ID = " & intForumID & " " strSQL = strSQL & "ORDER BY Thread.Message_date DESC;" '___________________________________________________________________________________________ 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 lngLastEntryMessageID = CLng(rsThread("Thread_ID")) lngLastEntryTopicID = CLng(rsThread("Topic_ID")) dtmLastEntryDate = CDate(rsThread("Message_date")) strLastEntryUser = rsThread("Username") lngLastEntryUserID = CLng(rsThread("Author_ID")) '___________________________________________________________________________________________ strSQL = "SELECT Count(Thread.Thread_ID) AS Thread_Count " strSQL = strSQL & "FROM Topic INNER JOIN Thread ON Topic.Topic_ID = Thread.Topic_ID " strSQL = strSQL & "GROUP BY Topic.Forum_ID " strSQL = strSQL & "HAVING (((Topic.Forum_ID)=" & intForumID & "));" '___________________________________________________________________________________________ 'Query the database rsCount.Open strSQL, strCon '___________________________________________________________________________________________ 'Get the thread count lngNumberOfPosts = CLng(rsCount("Thread_Count")) lngTotalNumberOfPosts = lngTotalNumberOfPosts + CLng(rsCount("Thread_Count")) '___________________________________________________________________________________________ 'Reset server variables rsCount.Close End If 'Reset variables rsThread.Close 'Write the HTML of the forum descriptions and hyperlinks to the forums %> <% 'Count the number of forums intNumberofForums = intNumberofForums + 1 'Move to the next database record rsForum.MoveNext 'Loop back round for next forum 'this is the end of Forum loop Loop End If 'Close recordsets rsForum.Close 'Move to the next database record rsCategory.MoveNext 'Loop back round for next category 'this is the end of main category loop Loop End If 'Release server variables rsCategory.Close Set rsCategory = Nothing Set rsForum = Nothing Set rsCount = Nothing Set rsThread = Nothing '___________________________________________________________________________________________ %>
  <% = strTxtForum %> <% = strTxtModerator %> <% = strTxtTopics %> <% = strTxtPosts %> <% = strTxtLastPost %>
" & strTxtNoForums & "
" & strCategory & "
" & strTxtNoForums & "
<% '___________________________________________________________________________________________ 'If the user has no access to a forum diplay a no access icon If intMemberSecurityLevel = 3 AND blnModerator = False AND NOT lngLoggedInUserID = 1 Then 'Response.Write (" ") 'this show on page no access error 'Response.Write vbCrLf & strTxtNoAccess Response.Write("") 'If the forum requires a password diplay the password icon ElseIf NOT rsForum("Password") = "" Then 'Response.Write (" ") 'this show the password required...txt 'Response.Write vbCrLf & strTxtPasswordRequired Response.Write("") 'If the forum is read only and has new posts show the locked new posts icon ElseIf CDate(Session("dtmLastVisit")) < dtmLastEntryDate AND (CBool(rsForum("Locked")) = True OR intMemberSecurityLevel = 2) AND lngLoggedInUserID > 1 AND blnModerator = False Then 'Response.Write (" ") 'this show the forum is readonly new replies 'Response.Write vbCrLf & strTxtReadOnlyNewReplies Response.Write("") 'If the forum is read only show the locked new posts icon ElseIf CBool(rsForum("Locked")) = True OR intMemberSecurityLevel = 2 AND lngLoggedInUserID > 1 AND blnModerator = False Then 'Response.Write (" ") 'this shows read only with no new replies 'Response.Write vbCrLf & strTxtReadOnly Response.Write("") 'If the forum has new posts show the new posts icon ElseIf CDate(Session("dtmLastVisit")) < dtmLastEntryDate Then Response.Write (" ") 'this shows open the forum new reply 'Response.write vbCrLf & strTxtOpenForumNewReplies 'If the forum is open but with no new replies Else Response.Write (" ") 'this show open forum no new reply 'Response.write vbCrLf & strTxtOpenForum End If '___________________________________________________________________________________________ %> <% '___________________________________________________________________________________________ 'If the forum is locked and the user is admin let them unlock it If blnForumLocked = True AND lngLoggedInUserID = 1 Then 'Response.Write (" ") Response.Write (" (UnLock)") 'If the forum is not locked and this is the admin then let them lock it ElseIf blnForumLocked = False AND lngLoggedInUserID = 1 Then 'Response.Write (" ") Response.Write (" (Lock)") End If '___________________________________________________________________________________________ %> <% = strForumName %>
<% = strForumDiscription %>
<% '___________________________________________________________________________________________ 'got the moderators names DIM strModeratorName 'find out the moderator name of the respective forum '___________________________________________________________________________________________ strSQL = "SELECT Author.Username FROM Moderator " strSQL = strSQL & "INNER JOIN Author ON Author.Author_ID " strSQL = strSQL & "= Moderator.Author_ID " strSQL = strSQL & "WHERE Moderator.Forum_ID = " & intForumID & " " '___________________________________________________________________________________________ rsFindModName.Open strSQL, strCon IF NOT rsFindModName.EOF THEN while not rsFindModName.EOF if trim(strModeratorName) <> trim(rsFindModName("Username")) then strModeratorName = strModeratorName & rsFindModName("Username") & ", " end if rsFindModName.MoveNext wend strModeratorName = mid(strModeratorName,1,len(strModeratorName)-2) response.write strModeratorName strModeratorName = "" ELSE 'Response.Write " " END IF 'Close the rs rsFindModName.Close '___________________________________________________________________________________________ %> <% 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, saryDateTimeData) & " " & strTxtAt & " " & TimeFormat(dtmLastEntryDate, saryDateTimeData) %>
<% = strTxtBy %>  <% If lngLoggedInUserID = 1 Then %> <% = strLastEntryUser %> <% ELSE %> <% = strLastEntryUser %> <% END IF %>   <% = strTxtViewLastPost %>

<% 'this is done because of forum statistic off mode If lngLoggedInUserID = 1 Then %> <% END IF %>
<% = strTxtLatestForumPosts %>
<% '___________________________________________________________________________________________ 'Get the latest forum posts 'Intialise the ADO recordset object Set rsStatistics = Server.CreateObject("ADODB.Recordset") 'Cursor type to one to count rsStatistics.CursorType = 1 '___________________________________________________________________________________________ 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT Top 10 Topic.Forum_ID, Topic.Topic_ID, Topic.Subject, Forum.Password, Forum.Cat_ID, Forum." & strMemberStatus & " " strSQL = strSQL & "FROM Forum INNER JOIN Topic ON Forum.Forum_ID = Topic.Forum_ID " strSQL = strSQL & "WHERE ((Forum.Password) Is Null) " '___________________________________________________________________________________________ 'As long as the user is not the admin don't display a post unless they have permission to view it If lngLoggedInUserID <> 1 Then strSQL = strSQL & " AND (Forum." & strMemberStatus & " < 3) " End If strSQL = strSQL & "ORDER BY Topic.Last_entry_date DESC;" rsStatistics.Open strSQL, strCon 'If EOF then display an error message If rsStatistics.EOF Then Response.Write "" & strTxtNoForumPostMade & "" 'If there are pages to display then display them Do while NOT rsStatistics.EOF %> &FID=<% = trim(rsStatistics("Forum_ID")) %>&TID=<% = rsStatistics("Topic_ID") %>&PP=1" target="_self"><% = rsStatistics("Subject") %>
<% rsStatistics.MoveNext Loop 'Close the recordset rsStatistics.Close %>
<% '___________________________________________________________________________________________ 'Get the date and author of the last post strSQL = "SELECT TOP 1 Thread.Message_date, Author.Username, Author.Author_ID " strSQL = strSQL & "FROM (Forum INNER JOIN Topic ON Forum.Forum_ID = Topic.Forum_ID) INNER JOIN (Author INNER JOIN Thread ON Author.Author_ID = Thread.Author_ID) ON Topic.Topic_ID = Thread.Topic_ID " strSQL = strSQL & "ORDER BY Thread.Message_date DESC;" '___________________________________________________________________________________________ 'Query the database rsStatistics.Open strSQL, strCon 'If there are records returned by the database then get there details If NOT rsStatistics.EOF Then dtmLastEntryDate = CDate(rsStatistics("Message_date")) strLastEntryUser = rsStatistics("Username") lngLastEntryUserID = CLng(rsStatistics("Author_ID")) End If %>
<% = strTxtForumStatistics %>
<% Response.Write(vbCrLf & " " & strTxtThereAre & " " & lngTotalNumberOfPosts & " " & strTxtPostsIn & " " & lngTotalNumberOfTopics & " " & strTxtTopicsIn & " " & intNumberofForums & " " & strTxtForum) Response.Write(vbCrLf & "
" & strTxtLastPostOn & " " & DateFormat(dtmLastEntryDate, saryDateTimeData) & " " & strTxtAt & " " & TimeFormat(dtmLastEntryDate, saryDateTimeData)) Response.Write(vbCrLf & "
" & strTxtLastPostBy & " " & strLastEntryUser & "") 'Close the recordset rsStatistics.Close 'Get the last signed up user ' strSQL = "SELECT Author.Username, Author.Author_ID " ' strSQL = strSQL & "FROM Author " ' strSQL = strSQL & "ORDER BY Author.Author_ID DESC;" ' 'Query the database ' rsStatistics.Open strSQL, strCon ' ' 'Display some statistics for the members '' If NOT rsStatistics.EOF Then ' Response.Write(vbCrLf & "
" & strTxtThereAre & " " & rsStatistics.RecordCount & " " & strTxtForumMembers) ' Response.Write(vbCrLf & "
" & strTxtTheNewestForumMember & " " & rsStatistics("Username") & "") ' End If 'Close the recordset ' rsStatistics.Close '___________________________________________________________________________________________ 'Get the number of active users strSQL = "SELECT Count(ActiveUser.Author_ID) AS ActiveUser From ActiveUser;" '___________________________________________________________________________________________ rsStatistics.Open strSQL, strCon 'Read in the active users from the recordset intActiveUsers = CInt(rsStatistics("ActiveUser")) rsStatistics.Close '___________________________________________________________________________________________ 'Get the number of active guests strSQL = "SELECT Count(ActiveUser.Author_ID) AS ActiveUser From ActiveUser WHERE ActiveUser.Author_ID=2;" '___________________________________________________________________________________________ rsStatistics.Open strSQL, strCon,3 'Read in the active guests from the recordset intActiveGuests = CInt(rsStatistics("ActiveUser")) 'To save another database hit we can get the number of members online by taking the number of guest away from the total active users intActiveMembers = intActiveUsers - intActiveGuests rsStatistics.Close Set rsStatistics = Nothing Response.Write(vbCrLf & "
" & strTxtOnThisSiteThereAre & " " & intActiveUsers & " " & strTxtActiveUsers & ", " & intActiveGuests & " " & strTxtGuestsAnd & " " & intActiveMembers & " " & strTxtMembers & "") IF NOT strActiveUserNames = "" THEN strActiveUserNames = mid(strActiveUserNames,1,len(strActiveUserNames)-2) Response.Write(vbCrLf & "
" & strTxtActiveUsersAre & "
") Response.Write(vbCrLf & strActiveUserNames) END IF %>
<% 'Reset Server Objects Set adoCon = Nothing Set strCon = Nothing %>