forums
forums kodu <% Option Explicit %> <% Response.Buffer = True 'Dimension variables Dim rsForum 'Holds the recordset of the forum password Dim strPassword 'Holds the forum password Dim blnAutoLogin 'Holds whether the user wnats to be automactically logged in Dim intForumID 'Holds the forum ID Dim strForumCode 'Holds the users ID code Dim strReturnPage 'Holds the page to return to Dim strReturnPageProperties 'Holds the properties of the return page 'Get the forum page to return to Select Case Request.QueryString("ReturnPage") Case "Topic" 'Read in the forum and topic to return to strReturnPage = "display_forum_topics.asp" strReturnPageProperties = "?ReturnPage=" & Request.QueryString("ReturnPage") & "&ForumID=" & CInt(Request.QueryString("ForumID")) & "&PagePosition=" & CInt(Request.QueryString("PagePosition")) 'Read in the thread and forum to return to Case "Thread" strReturnPage = "display_topic_threads.asp" strReturnPageProperties = "?ReturnPage=" & Request.QueryString("ReturnPage") & "&ForumID=" & CInt(Request.QueryString("ForumID")) & "&TopicID=" & CLng(Request.QueryString("TopicID")) & "&PagePosition=" & CInt(Request.QueryString("PagePosition")) 'Read in the active topic page to return to Case "Active" strReturnPage = "active_topics.asp" strReturnPageProperties = "?PagePosition=" & CInt(Request.QueryString("PagePosition")) 'Else return to the forum main page Case Else strReturnPage = "default.asp" strReturnPageProperties = "?ForumID=0" End Select 'Read in the forum id number intForumID = CInt(Request.QueryString("ForumID")) 'Read in the users details from the form strPassword = Trim(Mid(Request.Form("password"), 1, 15)) blnAutoLogin = CBool(Request.Form("AutoLogin")) 'If user has eneterd a password make sure it is correct If NOT strPassword = "" Then '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 strSQL = "SELECT tblForum.Password, tblForum.Forum_code FROM tblForum WHERE Forum_ID = " & intForumID 'Query the database rsForum.Open strSQL, adoCon 'If the query has returned a value to the recordset then check the password is correct If NOT rsForum.EOF Then 'Check the password is correct, if it is get the user ID and set a cookie If strPassword = rsForum("Password") Then 'Read in the users ID number and whether they want to be automactically logged in when they return to the forum strForumCode = rsForum("Forum_code") 'Write a cookie with the Forum ID number so the user logged in throughout the forum 'Write the cookie with the name Forum containing the value Forum Code number Response.Cookies("PrForum")("Forum" & intForumID) = strForumCode 'If the user has selected to be remebered when they next login then set the expiry date for the cookie for 1 year If blnAutoLogin = True Then 'Set the expiry date for 1 year (365 days) 'If no expiry date is set the cookie is deleted from the users system 20 minutes after they leave the forum Response.Cookies("PrForum").Expires = Now() + 365 End If 'Reset Server Objects Set adoCon = Nothing Set strCon = Nothing Set rsForum = Nothing 'Redirect the user back to the forum page they have just come from Response.Redirect strReturnPage & strReturnPageProperties End If End If End If 'Reset Server Objects Set adoCon = Nothing Set strCon = Nothing Set rsForum = Nothing %><% = strTxtForumLogin %>
<% 'If the user has unsuccesfully tried logging in before then display a password incorrect error If NOT strPassword = "" Then %>
<% = strTxtForumPasswordIncorrect %> <% = strTxtPleaseTryAgain %> |
<% = strTxtForumMembersList %>
<%
'If the user has not logged in dispaly an error message
If lngLoggedInUserID = 0 Then
Response.Write vbCrLf & "" & strTxtMustBeRegistered & "
" Response.Write vbCrLf & "
"
'If the user has logged in then read in the members from the database and dispaly them
Else
'Intialise the ADO recordset object
Set rsMembers = Server.CreateObject("ADODB.Recordset")
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblAuthor.Author_ID, tblAuthor.Username, tblAuthor.Homepage, tblAuthor.No_of_posts, tblAuthor.Join_date, tblAuthor.Status, tblAuthor.Active "
strSQL = strSQL & "FROM tblAuthor "
strSQL = strSQL & "WHERE (((tblAuthor.Username) Like '" & strSearchCriteria & "%')) "
strSQL = strSQL & "ORDER BY tblAuthor." & strSortBy & ";"
'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
rsMembers.CursorType = 1
'Query the database
rsMembers.Open strSQL, adoCon
'Set the number of records to display on each page
rsMembers.PageSize = 25
'If there are no memebers to display then show an error message
If rsMembers.EOF Then
Response.Write "" & strTxtSorryYourSearchFoundNoMembers & ""
'If there is a recordset returned by the query then read in the details
Else
'Set the page number to display records for
rsMembers.AbsolutePage = intRecordPositionPageNum
'Count the number of members there are in the database by returning the number of records in the recordset
intTotalNumMembers = rsMembers.RecordCount
'Count the number of pages there are in the database calculated by the PageSize attribute set above
intTotalNumMembersPages = rsMembers.PageCount
'Display the HTML for the total number of pages and total number of records in the database for the users
Response.Write vbCrLf & " "
Response.Write vbCrLf & "
"
Response.Write vbCrLf & "
" %>
" Response.Write vbCrLf & "
" 'If we are showing all the forum memebers then display how many members there are If Request.QueryString("find") = "" Then Response.Write vbCrLf & " " & strTxtThereAre & " " & intTotalNumMembers & " " & strTxtForumMembersOn & " " & intTotalNumMembersPages & " " & strTxtPageYouAerOnPage & " " & intRecordPositionPageNum 'Else display how many results were fround from the search Else Response.Write vbCrLf & " " & strTxtYourSearchMembersFound & " " & intTotalNumMembers & " " & strTxtMatches End If Response.Write vbCrLf & " | " Response.Write vbCrLf & "
" %>