Active Topics Link

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/67176?pagenum=1
05 November 2025, 08:08

Topic


leatherlips
Active Topics Link
01 June 2008, 22:06


Currently, there is a link at the top of the forum that says "Active Topics". I would like to possibly add the number of new topics added since a users last visit. It would look something like this:

Active Topics (5)
The number would represent the additional topics that were new since a users last visit. It would change dependent on the actual number of active topics for that user. If no new topics were added then it would either look like:

Active Topics
or

Active Topics (0)
Does anyone know how to do this?
Of course the formatting of the way the link looks does not have to be limited to what I suggested. It could also look something like this:

5 Active Topics<

 

Replies ...


MaD2ko0l
02 June 2008, 07:41


http://forum.snitz.com/forum/topic.asp?ARCHIVE=true&TOPIC_ID=31252&SearchTerms=Active,Topics

been done many times ;-)<
leatherlips
02 June 2008, 09:19


Thanks.
I'm trying to add it but hava a problem. I am getting an error:

Code:
Type mismatch: 'getNewMemberNumber'

It is around this area in the code:

Code:
if rsForum.eof or rsForum.bof then
'nothing
else
i = 0
do until rsForum.Eof
ForumID = rsForum("FORUM_ID")
if ChkForumAccess(ForumID, getNewMemberNumber()) then
i = i + 1
if i = 1 Then
strSql = strSql & " AND ("
else
strSql = strSql & " OR "
end If
strSQL = strSQL & "F.FORUM_ID=" & ForumID
end if
rsForum.MoveNext
loop
rsForum.close
set rsForum = Nothing
if i > 0 Then
strSql = strSql & ") "
end If
end if
end If
strSql = strSql & "AND (T.T_LAST_POST > '" & lastDate & "'"
This mod is for an older version of Snitz. Can anyone update it for the current version? Here is the code it uses. I figured out that inc_functions.asp now is inc_func_common.asp and inc_top.asp is now inc_header.asp. Perhaps there are other sections in the code itself that need to be renamed to make it work with the current version of Snitz?<
leatherlips
02 June 2008, 09:26


I just realized (blush) that in the statistics at the bottom of the forum, it already tells you how many active topics there are since your last visit. Perhaps that number can be added to the link in the header? How would I do that?<
MaD2ko0l
02 June 2008, 09:51


http://mad2kool.co.uk/forum/faq.asp works fine on my site with no changes.
i put all the code into inc_header, just to test but if you wanted to do it proper then you woudl put the code in in_func_common.asp and then make the change in inc_header.asp to display the link.<
phy1729
02 June 2008, 09:53


In inc_func_common.asp line 1373
[code] Case "members.asp"
strNewTitle = strForumTitle & " - Members"
Case "active.asp" ActiveTopicCount = 0
if not IsNull(Session(strCookieURL & "last_here_date")) then
if not blnHiddenForums then

'## Forum_SQL - Get ActiveTopicCount from DB
strSql = "SELECT COUNT(" & strTablePrefix & "TOPICS.T_LAST_POST) AS NUM_ACTIVE " &_
" FROM " & strTablePrefix & "TOPICS " &_
" WHERE (((" & strTablePrefix & "TOPICS.T_LAST_POST)>'"& Session(strCookieURL & "last_here_date") & "'))" &_
" AND " & strTablePrefix & "TOPICS.T_STATUS <= 1"

set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn

if not rs.EOF then
ActiveTopicCount = rs("NUM_ACTIVE")
else
ActiveTopicCount = 0
end if

rs.close
set rs = nothing
end if
end if
strNewTitle = strForumTitle & " - Active Topics (" & ActiveTopicCount & ")"
Case "faq.asp"
strNewTitle = strForumTitle & " - Frequently Asked Questions"<
MaD2ko0l
02 June 2008, 10:15


phy: that isnt quite what he wanted. but u coudl use that code in inc_header.
find this

Code:
	end if
Response.Write " |" & vbNewline & _
" <a href=""active.asp""" & dWStatus("See what topics have been active since your last visit...") & " tabindex=""-1""><acronym title=""See what topics have been active since your last visit..."">Active Topics</acronym></a>" & vbNewline

and replace it with this

Code:
	end if

ActiveTopicCount = 0
if not IsNull(Session(strCookieURL & "last_here_date")) then
if not blnHiddenForums then

'## Forum_SQL - Get ActiveTopicCount from DB
strSql = "SELECT COUNT(" & strTablePrefix & "TOPICS.T_LAST_POST) AS NUM_ACTIVE " &_
" FROM " & strTablePrefix & "TOPICS " &_
" WHERE (((" & strTablePrefix & "TOPICS.T_LAST_POST)>'"& Session(strCookieURL & "last_here_date") & "'))" &_
" AND " & strTablePrefix & "TOPICS.T_STATUS <= 1"

set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn

if not rs.EOF then
ActiveTopicCount = rs("NUM_ACTIVE")
else
ActiveTopicCount = 0
end if

rs.close
set rs = nothing
end if
end if

Response.Write " |" & vbNewline & _
" <a href=""active.asp""" & dWStatus("See what topics have been active since your last visit...") & " tabindex=""-1""><acronym title=""See what topics have been active since your last visit..."">Active Topics (" & ActiveTopicCount & ")</acronym></a>" & vbNewline

thats another way to do it.
not to sure what the difference is/was between this and the 1 i posted earler.<
phy1729
02 June 2008, 10:16


I thought he meant the title my bad. Oops.<
leatherlips
02 June 2008, 10:47


I used the code you posted MaD2ko0l. The one in the mod you linked to gave me the error I posted above.
Yours is not giving me the error, however, it also displays new topics that I should not have access to such as private forums.
To test this, I made a post in a private forum that my test account does not have access to. Then I logged in with my test account and it shows that there is a new active topic. Of course if they click on the active topics link there are no new ones that it can see. But it still shows it in the active topics link.
Is there a way to take into consideration if the user has access to certain forums or not?<
MaD2ko0l
02 June 2008, 11:51


and that would be why the 1st link i posted would filter out new posts in rivate forums.
have u changed the getNewMemberNumber or the ChkForumAccess functions??? as that may be a problem that you might need to add/change parameter to work properly<
leatherlips
02 June 2008, 12:55


I've not changed those functions as far as I know. However, anything is possible. blush
Here is my inc_func_common.txt file if you could take a look and see if there are any obvious errors.
The line that keeps giving the error is line 136:

Code:
if ChkForumAccess(ForumID, getNewMemberNumber()) then
Thanks.<
MaD2ko0l
02 June 2008, 13:10


this may sound silly, but try putting that function at the bottom of inc_func_common

i say this because when i tryed it, i just put it near the bottom of inc_header for it to work.
so just try that and see what happens<
leatherlips
02 June 2008, 13:15


I put it at the bottom and still get the same error, although now it is on a different line.
Here is the forum I am testing it on:

http://mangionemagic.com/forumfortesting<
MaD2ko0l
02 June 2008, 14:03


well it does seem to work on my site there, but i just realized, this function getNewMemberNumber is the old function to get the memebrs id number, the updated function name is getMemberID maybe you can replace it with that instead.
looks liek it need a bit of an overhaul<
leatherlips
02 June 2008, 14:13


I tried renaming it to getMemberID but no luck.
Any chance you could post the code you have? Then I could compare the two and hopefully see what is going on.<
MaD2ko0l
02 June 2008, 14:14


i have used the exact code from the zip file<
MaD2ko0l
02 June 2008, 15:34


ok here..try this, replace the function with the 1 below

Code:
function getActiveCount()  'Returns the number of Active Topics
ActiveSince = Request.Cookies(strCookieURL & "ActiveSince")
'## Do Cookie stuffs with show last date
if Request.form("cookie") = "2" then
ActiveSince = Request.Form("ShowSinceDateTime")
if strSetCookieToForum = 1 then
Response.Cookies(strCookieURL & "ActiveSince").Path = strCookieURL
end if
Response.Cookies(strCookieURL & "ActiveSince") = ActiveSince
end if
Select Case ActiveSince
Case "LastVisit"
lastDate = ""
Case "LastFifteen"
lastDate = DateToStr(DateAdd("n",-15,strForumTimeAdjust))
Case "LastThirty"
lastDate = DateToStr(DateAdd("n",-30,strForumTimeAdjust))
Case "LastFourtyFive"
lastDate = DateToStr(DateAdd("n",-45,strForumTimeAdjust))
Case "LastHour"
lastDate = DateToStr(DateAdd("h",-1,strForumTimeAdjust))
Case "TwoHour"
lastDate = DateToStr(DateAdd("h",-2,strForumTimeAdjust))
Case "LastDay"
lastDate = DateToStr(DateAdd("d",-1,strForumTimeAdjust))
Case "LastWeek"
lastDate = DateToStr(DateAdd("ww",-1,strForumTimeAdjust))
Case "LastMonth"
lastDate = DateToStr(DateAdd("m",-1,strForumTimeAdjust))
Case Else
lastDate = ""
End Select

if IsEmpty(Session(strCookieURL & "last_here_date")) then
Session(strCookieURL & "last_here_date") = ReadLastHereDate(strDBNTUserName)
end if
if lastDate = "" then
lastDate = Session(strCookieURL & "last_here_date")
end If

if Request.Form("AllRead") = "Y" then
lastDate = ChkString(Request.Form("BuildTime"),"SQLString")

'## The redundant line below is necessary, don't delete it. session(strCookieURL & "last_here_date") = lastDate
Session(strCookieURL & "last_here_date") = lastDate
UpdateLastHereDate lastDate,strDBNTUserName
ActiveSince = ""
end if

if mlev = 3 then
strSql = "SELECT FORUM_ID FROM " & strTablePrefix & "MODERATOR " & _
" WHERE MEMBER_ID = " & MemberID

Set rsMod = Server.CreateObject("ADODB.Recordset")
rsMod.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText

if rsMod.EOF then
recModCount = ""
else
allModData = rsMod.GetRows(adGetRowsRest)
recModCount = UBound(allModData,2)
end if

RsMod.close
set RsMod = nothing

if recModCount <> "" then
for x = 0 to recModCount
if x = 0 then
ModOfForums = allModData(0,x)
else
ModOfForums = ModOfForums & "," & allModData(0,x)
end if
next
else
ModOfForums = ""
end if
else
ModOfForums = ""
end if

'## Forum_SQL - Get all active topics from last visit
strSql = "SELECT COUNT(*) as activeCount " &_
"FROM " & strMemberTablePrefix & "MEMBERS M, " & _
strTablePrefix & "FORUM F, " & _
strTablePrefix & "TOPICS T, " & _
strTablePrefix & "CATEGORY C, " & _
strMemberTablePrefix & "MEMBERS MEMBERS_1 " & _
"WHERE T.T_LAST_POST_AUTHOR = MEMBERS_1.MEMBER_ID " & _
"AND F.F_TYPE = 0 " & _
"AND F.FORUM_ID = T.FORUM_ID " & _
"AND C.CAT_ID = T.CAT_ID " & _
"AND M.MEMBER_ID = T.T_AUTHOR " & _
"AND (T.T_LAST_POST > '" & lastDate & "'"

' DEM --> if not an admin, all unapproved posts should not be viewed. if mlev <> 4 then
strSql = strSql & " AND ((T.T_AUTHOR <> " & MemberID &_
" AND T.T_STATUS < 2)" ' Ignore unapproved/held posts
if mlev = 3 and ModOfForums <> "" then
strSql = strSql & " OR T.FORUM_ID IN (" & ModOfForums & ") "
end if
strSql = strSql & " OR T.T_AUTHOR = " & MemberID & ")"
end if
strSql = strSql & ") "

Set rs = Server.CreateObject("ADODB.Recordset")
if strDBType <> "mysql" then rs.cachesize = 50
rs.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText

if NOT rs.EOF then
getActiveCount = rs("activeCount")
end if

rs.close
set rs = nothing
end function
<
leatherlips
02 June 2008, 16:19


Well, the new code got rid of the error, but it still shows topics in private forums where it shouldn't. Oh well. Thanks for trying! I really appreciate it!<
MaD2ko0l
02 June 2008, 16:54


leatherlips
02 June 2008, 18:39


That seems to have done it! I'll do some more testing to verify. Thanks for sticking with me! Great job! I really appreciate it!<
leatherlips
02 June 2008, 19:32


I just found a problem. sad
I also have the private messages mod installed.
One of my users tried to pm me with a quote and got the following error:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'chkForumAccessNew'
/forum/inc_func_common.asp, line 165

Line 165 is below in red. I've included some of the surrounding code:

if mLev = 4 then
ModerateAllowed = "Y"
elseif mLev = 3 and ModOfForums <> "" then
if (strAuthType = "nt") then
if (chkForumModerator(Forum_ID, Session(strCookieURL & "username")) = "1") then ModerateAllowed = "Y" else ModerateAllowed = "N"
else
if (instr("," & ModOfForums & "," ,"," & Forum_ID & ",") > 0) then ModerateAllowed = "Y" else ModerateAllowed = "N"
end if
else
ModerateAllowed = "N"
end if
if chkForumAccessNew(Forum_PrivateForums,Forum_FPasswordNew,Forum_Subject,Forum_ID,MemberID) = true then if allAllowedForums = "" then
allAllowedForums = Forum_ID
else
allAllowedForums = allAllowedForums & "," & Forum_ID
end if
end if
next
end if
if allAllowedForums = "" then allAllowedForums = 0
end if



Any ideas what is going on?<
Andy Humm
02 June 2008, 19:39


Following on from leatherlips latest error message, I also tried to send a New PM to him and as soon as I clicked on the PM New button/link I received the same error message:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'chkForumAccessNew'
/forum/inc_func_common.asp, line 165

It appears the 'chkForumAccessNew' needs addressing! <
leatherlips
02 June 2008, 19:57


I've tried changing line 165 from this:

if chkForumAccessNew(Forum_PrivateForums,Forum_FPasswordNew,Forum_Subject,Forum_ID,MemberID) = true then

To this:

chkForumAccessNew(fPrivateForums,fFPasswordNew,fForum_Subject,fForum_ID,UserNum) = true then

But it didn't fix it. I changed it to that because that is how it looks now in inc_func_secure.asp. I'm thinking there are other parts of the code that just need to be updated to the current forum code. The topics count code is for an older version of Snitz. Can anyone let me know what other things in the code need to be revised to reflect the newer Snitz code?<
MaD2ko0l
02 June 2008, 21:57


god dam it..why can i never re create these errors tht you guys get?
i will have another look tomorrow. and see what/if i can get the error<
MaD2ko0l
02 June 2008, 22:22


doh, you even said the answer yourself ;-)

inc_func_secure.asp

the reason its messing up on that function is because the page you are trying to view doesnt have inc_func_secure.asp included.
try this

add the folloeing to the very 1st line as in before the <% and then try it.
<!--#INCLUDE FILE="inc_func_secure.asp" -->

the reason i wasnt seeing these errors is i was logged in as the admin :-(<
leatherlips
03 June 2008, 09:18


Originally posted by MaD2ko0l
<!--#INCLUDE FILE="inc_func_secure.asp" -->
That did it! I added it to inc_func_common.asp. That won't cause a problem with the site will it? Or would it be better to add it to the private messages pages?
I didn't see the problem either while logged in as the admin. It seemed to only effect normal users.
Thanks again! cool<
leatherlips
03 June 2008, 09:33


Dang it...
I had a user let me know that he could no longer view the forum. All links took him to the same topic. It only seems to effect normal users because I as the admin never noticed these issues.<
MaD2ko0l
03 June 2008, 10:58


Originally posted by leatherlips
That did it! I added it to inc_func_common.asp. That won't cause a problem with the site will it? Or would it be better to add it to the private messages pages?
I didn't see the problem either while logged in as the admin. It seemed to only effect normal users.

eermm you could add it to the pm pages, but you would need to add it to all pages that didnt have it included.
so you could go through all the pages and add the include to the pages that dont have it,

or

you coudl go through all the asp pages and delete the include and just use it in inc_func_common as inc_func_common is included in everypage the forum uses.


as for the other problem, what do you mean by all the links took him to the same topic?
can you recreate this problem youself?<
leatherlips
03 June 2008, 17:22


Originally posted by MaD2ko0l
as for the other problem, what do you mean by all the links took him to the same topic?
can you recreate this problem youself?
Yes. You can see it on my test forum:

http://mangionemagic.com/forumtest/

Login: demo/demo

If you try to read or post a topic it always goes to my "About This Section" post.<
MaD2ko0l
03 June 2008, 18:07


intreasting...my copy dont do that, howevere after a bit of messing about, as a normal memebr i woudl alwasy get a "you dont have acces to this forum" error and while looking around the code its somthign to do with private forums.
but also what i noticed, it seems as the stats page on default.asp doesnt filter out private forums as well.
i am either missing somthing or this is beyong my knowledge.
will have another look and see what i can come up with

P.S make sure you havent messed up of the code placements as somthign isnt quite right there, its liek it looking at a fixed value when goign to the forum.asp page.
if you remove the active topic cout does the forums work as normal?<
leatherlips
03 June 2008, 21:38


Originally posted by MaD2ko0l
if you remove the active topic cout does the forums work as normal?
Yes. Thanks for sticking with me on this.<
leatherlips
04 June 2008, 08:35


If I'm logged in as the admin it all works great. If I log in as a normal user then the link acts up. What should I be looking for?<
MaD2ko0l
04 June 2008, 09:17


eerrmm...well seen as it works fine as an admin, you will need to look for mlev's that are below 4

and i do belive that it is to do with the privateforums statement.
but i dont know who all you links go to the same forum.
i cannot replicate that problem no matter who i am logged in as on my test site.<
© 2000-2021 Snitz™ Communications