<%@ LANGUAGE="VBSCRIPT" @%> <% OPTION EXPLICIT Response.Buffer = True %> <% '*** Dimension all the variables. Dim ViewLast, Showing Dim objRec Dim strSQL Dim LastHere 'Variables used for paging. Dim intCurrentPage, intCount '*** Open the database. Set objConn = Server.CreateObject ("ADODB.Connection") Set objRec = Server.CreateObject ("ADODB.Recordset") objConn.Open strconnect '*** The table headings, Topic, Author and so on can be used to order the messages (much like an email program) this is the code that does it. dim lastSort, thisSort ' ADD: Remember previous state, and reverse it thisSort = Request.QueryString("orderby") If thisSort <> "" then lastSort = Session("OrderBy") Session("OrderBy") = thisSort End If Select Case Session("Orderby") Case "Topic" objRec.Sort = "MessageTitle ASC" Case "Author" objRec.Sort = "MessageAuthor ASC" Case "LastPost" objRec.Sort = "LastPost DESC" Case "Replies" objRec.Sort = "Replies DESC" Case Else objRec.Sort = "LastPost DESC" Session("OrderBy") = "LastPost" End Select objRec.cursorlocation=aduseclient StrSQL = "SELECT * FROM [Messages]" ' Check whether this is the result of a search ' with a specific dim searchType, searchString searchType = Request.Form("cboSearchType") If left(searchType,7) = "Message" Then searchString = trim(Request.Form("txtSearchString")) Session("txtSearchString") = searchString Session("cboSearchType") = searchType ' Note: Had to change name of form fields in SEARCH.HTM to agree with dabase field names StrSQL = StrSQL & " WHERE [" & searchType & "] LIKE '%" & searchString & "%' ORDER BY LastPost DESC" ' response.write strsql & "
" End If objRec.Open strSQL, objConn, adOpenStatic, adLockReadOnly, adCmdText '*** Function to compare the date of the users last visit with the date of the last post. Function NewMessages(lpost) If datediff("s", LastHere, lpost) > 1 then NewMessages = MBImgNewMessage Else NewMessages = MBImgOldMessage End If End Function '*** Find out when the user was last here so that new messages can be highlighted. LastHere = Request.Cookies("aspmbuser")("Date") Response.Cookies("aspmbuser")("Date") = now() Response.Cookies("aspmbuser").Expires = Date + 365 '*** If they haven't been here before set the LastHere variable to a value that will highlight all messages as being new. if LastHere = "" then LastHere = dateadd("d",-10,now()) End if '*** Has the user just asked to view the messages updated in a certain time period? See select form field. If NOT Request.Form("days") = "" then ViewLast = Request.Form("days") '*** Write this value to the cookie so that next time the reload the page it will remain the same. Response.Cookies("aspmbuser")("ViewLast") = Request.Form("days") '*** If they haven't asked for a new time filter. Else '*** If there is no value in the cookie, show them all the messages for the last two days. If Request.Cookies("aspmbuser")("ViewLast") = "" then ViewLast = "ALL" '*** Otherwise take the value from the cookie. Else ViewLast = Request.Cookies("aspmbuser")("ViewLast") End If End If showing = ViewLast dim showValues, looper, showDaysOptions const showTag = "" If Session("cboSearchType") = "" then If NOT ViewLast = "ALL" then '*** Subtract ViewLast amount of days from the current date. ViewLast = DateAdd("d",ViewLast, Date()) '*** Create a record set with only the fields from the last x days. objRec.Filter = "LastPost >= #" & ViewLast & "#" End If End If dim filtermsg If NOT Session("cboSearchType") = "" Then filtermsg= "

Searched for phrase '" & Session("txtSearchString") & "' in " & Session("cboSearchType") & "
Remove Search Filter

" End If %> <%=MBTitle%> <%=MBPageBody2%> <%=PAGEHEADER%> <%=filtermsg%> <%=FONT1%>
<%=MBImgAddNew%>

   

<% On Error Resume Next If Request.QueryString("page") = "" Then intCurrentPage = 1 Else intCurrentPage = CInt(Request.QueryString("page")) End If objRec.PageSize = 20 If objRec.PageCount > 0 then objRec.AbsolutePage = intCurrentPage Else intCurrentPage = 0 End If Session("CurrentPage") = intCurrentPage Do While objRec.AbsolutePage = intCurrentPage And Not objRec.EOF %> <% objRec.MoveNext Loop '*** Yeah. It's the end of the table. Response.Write "
  Click on...
    - a message topic to view or respond to that message or replies to it
    - a column heading to sort messages by that field
    - 'View Topics' button to return here from any other page
  <%=MBImgTopic%> <%=MBImgAuthor%> <%=MBImgLastPost%>

<%=MBImgReplies%>

<%=NewMessages(objRec("LastPost"))%> <%=FONT1%>

"><%=objRec("MessageTitle")%>

<%=FONT1 & objRec("MessageAuthor")%> <%=FONT1 & objRec("LastPost") %> <%=FONT1 & objRec("Replies")%>
" Response.Write "

" If objRec.PageCount > 1 then 'Print Previous Page if required If intCurrentPage <> 1 then Response.Write "Previous Page" Else Response.Write "Previous Page" End If 'Print direct access page numbers. For intCount = 1 to objRec.PageCount If intCount = 1 then Response.Write " | " End If If intCount = intCurrentPage then Response.Write intCount & " | " Else Response.Write "" & intCount & " | " End If Next 'Print Next Page if required If intCurrentPage <> objRec.PageCount then Response.Write "Next Page" Else Response.Write "Next Page" End If End If Response.Write "

Page " & intCurrentPage & " of " & objRec.PageCount & _ " | Ordered By: " & Session("orderby") & " | " dim msg msg = "Showing topics updated in the last " Select Case Showing Case "-0" msg = "Showing topics updated today." Case "-1" msg = msg & "2 days." Case "-4" msg = msg & "5 days." Case "-9" msg = msg & "10 days." Case "-29" msg = msg & "30 days." Case "-99" msg = msg & "100 days." Case else msg = "Showing all topics." End Select Response.Write "

" '*** Have a tidy. Don't want any of those nasty memory leaks. objRec.Close objConn.Close Set objRec = Nothing Set objConn = Nothing %> <%=PAGEFooter%>

<%=PrintCredit%>

Maintain