<%@ Language=VBScript %> <%Option Explicit%> <%Response.Buffer=True%> <% Dim strSql Dim adoRs Dim lngMessageId Dim lngBoardId Dim lngBoardName Dim intBoardScopeStatus Dim blnUserValidated Dim blnTrackedThread Dim strThreadBlockColor Dim strEmailNotification Dim lngEditId Dim strPostReply Dim bytArchives If intLoginStatus = 0 And bytAdmAllowGuestView = 0 Then Response.Redirect "index.asp" End If lngEditId = -1 strPostReply = "  [Post Reply]" lngMessageId = Trim(Request.QueryString("id") & "") If lngMessageId = "" Then Set adoConn = Nothing Response.Redirect "index.asp" ElseIf IsNumeric(lngMessageId) Then lngMessageId = CLng(lngMessageId) Else Set adoConn = Nothing Response.Redirect "index.asp" End If strSql = "SELECT tblMessages.*, tblMessages.RecordCreateDate AS MsgCDate, tblMessages.RecordModifyDate AS MsgMDate, tblUsers.*, tblBoards.BoardName, tblBoards.BoardDescShort, " & _ "tblBoards.BoardActiveStatus, tblBoards.BoardScopeStatus " & _ "FROM (tblMessages INNER JOIN tblBoards ON tblMessages.MessageBoardId = tblBoards.BoardId) INNER JOIN tblUsers ON tblMessages.MessageUserId = tblUsers.UserId " & _ "WHERE tblMessages.MessageId = " & lngMessageId & " " If intAdminLoginStatus <> 1 Then strSql = strSql & _ "AND (tblMessages.MessageValidStatus=1 OR tblMessages.MessageUserId=" & lngUserId & ")" End If If Trim(Request.QueryString("archives") & "") = "1" Then bytArchives = 1 Else bytArchives = 0 End If If bytArchives = 1 Then strSql = Replace(strSql, "tblMessages", "tblArchives") intPostStatus = 0 End If Set adoRs = GetRecordset(adoConn, strSql) If adoRs.EOF Then Set adoRs = Nothing Set adoConn = Nothing Response.Redirect "index.asp?action=void" End If Response.Cookies("msgid") = CStr(lngMessageId) Response.Cookies("msgid").Expires = DateAdd("yyyy", 10, Now()) Call IncrementViews(lngMessageId, adoRs.Fields("MessageViews").Value) Call IncrementUserViews(lngUserId) lngBoardId = adoRs.Fields("MessageBoardId").Value lngBoardName = adoRs.Fields("BoardName").Value intBoardScopeStatus = adoRs.Fields("BoardScopeStatus").Value If intBoardScopeStatus = 1 Then blnUserValidated = (intLoginStatus<>0) Else blnUserValidated = True End If If blnUserValidated Then If adoRs.Fields("BoardActiveStatus").Value = 0 And bytArchives = 0 Then Set adoRs = Nothing Set adoConn = Nothing Response.Redirect "index.asp" End If Else Set adoRs = Nothing Set adoConn = Nothing Response.Redirect "index.asp" End If lngHdnMessageThreadId = adoRs.Fields("MessageThreadId").Value lngHdnMessageBoardId = lngBoardId lngHdnMessageId = lngMessageId strHdnMessageHeader = "RE: " & ReplaceQuotes(Replace(Trim(adoRs.Fields("MessageHeader").Value & ""), "RE:", ""), 0) bytHdnMessageShowEmail = adoRs.Fields("UserShowEmailInPosts").Value bytHdnMessageValidStatus = adoRs.Fields("MessageValidStatus").Value bytHdnMessageLevel = adoRs.Fields("MessageLevel").Value + 1 blnTrackedThread = GetUserThreadTrackStatus(lngHdnMessageThreadId) %> <% Function IncrementUserViews(plngUserId) '*** Note: I am using the "UserTotalPosts" field as the UserTotalViews field Dim strSql Dim adoRs Dim lngPostsTotal Dim MLName Dim MLEmail '*** User 16 is the Guest user - to total guest views if plngUserId = 0 then plngUserId = 16 end if strSql = "SELECT tblUsers.* " & _ "FROM tblUsers " & _ "WHERE tblUsers.UserId=" & plngUserId Set adoRs = GetRecordset(adoConn, strSql) If adoRs.EOF Then lngPostsTotal = 1 Else lngPostsTotal = adoRs.Fields("UserTotalPosts").Value + 1 End If Set adoRs = Nothing strSql = "UPDATE tblUsers " & _ "SET tblUsers.UserTotalPosts=" & lngPostsTotal & " " & _ "WHERE tblUsers.UserId=" & plngUserId Call adoConn.Execute(strSql) End Function Function GetUserThreadTrackStatus(lngThreadId) Dim strSql Dim adoRs strSql = "SELECT tblTrackedThreads.* " & _ "FROM tblTrackedThreads " & _ "WHERE UserId=" & lngUserId & " " & _ "AND ThreadId=" & lngThreadId Set adoRs = GetRecordSet(adoConn, strSql) If adoRs.EOF Then strEmailNotification = "" GetUserThreadTrackStatus = False Else If bytAdmEnableEmailNotification = 1 Then If adoRs.Fields("SendEmail").Value = 0 Then strEmailNotification = "   [Add Email Notification]" Else strEmailNotification = "   [Remove Email Notification]" End If Else strEmailNotification = "" End If GetUserThreadTrackStatus = True End If Set adoRs = Nothing End Function Function IncrementViews(plngMessageId, plngViews) Dim strSql strSql = "UPDATE tblMessages " & _ "SET MessageViews=" & plngViews + 1 & " " & _ "WHERE tblMessages.MessageId=" & plngMessageId Call adoConn.Execute(strSql) End Function Function UpdateUserLastReadPost(plngMessageId) Dim strSql strSql = "UPDATE tblUsers " & _ "SET UserLastPostRead=" & plngMessageId & " " & _ "WHERE tblUsers.UserHandle='" & strUserHandle & "'" Call adoConn.Execute(strSql) End Function Function GetThreadDetail(plngThreadId) Dim strSql Dim adoRsThread strSql = "SELECT tblMessages.*, tblUsers.UserHandle " & _ "FROM tblMessages INNER JOIN tblUsers ON tblMessages.MessageUserId = tblUsers.UserId " & _ "WHERE MessageId=" & plngThreadId Set adoRsThread = GetRecordSet(adoConn, strSql) If adoRsThread.EOF Then Response.Write "
 No messages exist for current thread


" Else If lngMessageId = adoRs.Fields("MessageThreadId").Value Then Response.Write "