Print Page | Close Window

"Time Spent Online" modification request

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums Modifications
Forum Description: Mod's and Add-on's for Web Wiz Forums.
URL: https://forums.webwiz.net/forum_posts.asp?TID=20178
Printed Date: 28 March 2026 at 5:52am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: "Time Spent Online" modification request
Posted By: WebG
Subject: "Time Spent Online" modification request
Date Posted: 05 June 2006 at 6:54pm
 
Has anybody already written a TIME SPENT ONLINE mod that would show/store the amount of time each user has spent online in the forum yet?   I searched and didn't see one, and I know other forums have this option so I know it's possible.
 
Doing a quick glance through v8.02, it looks like we just need to modify FUNCTIONS_COMMON in the following manner:
 
 - In the ADD NEW USER TO ARRAY section, we add a new array element to track the user's incoming time stamp (already there -- array item #3)
 
 - In the REMOVE UNACTIVE USERS section, when we loop through to delete that user from the array, we calculate TIMESPENT = DATEDIFF("seconds", Array Item #3, Now) and add that to the TIMESPENT value (a new field) in the user's record in the database.
 
 - Finally, in FORUM_POSTS where we display the user's stuff (or in the PROFILE popup page, wherever else), we just display the number of seconds that the user has been active online -- run through a new convert function that can equate the number of seconds to a years/months/days/hours/minutes/seconds calculation that can be used on any page that needs it.
 
It doesn't seem too complicated, and the data appears readily available.   Think this will work?  Missing anything?   Thoughts?



Replies:
Posted By: WebG
Date Posted: 07 June 2006 at 3:59am
Well, this one is turning into a doozy, and it's a little odd.  So I turn to you for advice.
 
In FUNCTIONS_COMMON, I added the following to the REMOVE ACTIVE USERS section:
 
  'Check the IP address and last active time less than 20 minutes
  If CDate(saryActiveUsers(4, intArrayPass)) < DateAdd("n", -20, Now()) OR intActiveUsersDblArrayPos = intArrayPass Then
 
'Update database
strSQL = "UPDATE " & strDbTable & "Author " & strRowLock & " " & _
"SET " & strDbTable & "Author.TimeSpentOnline = " & DateDiff("s", saryActiveUsers(4, intArrayPass), Now()) + CInt(saryActiveUsers(10, intArrayPass)) & " " & _
"WHERE " & strDbTable & "Author.Author_ID=" & saryActiveUsers(1, intArrayPass) & ";"
'Write the updated no. of seconds to the database
adoCon.Execute(strSQL)
 
..... switch the selected item to the end of the array, then truncate the array by one element....
 
end if
 
 
(I had already set saryActiveUsers(10, intArrayPass) to be a new field from tblAuthor called intTimeSpentOnline.    That's the doozy of a change, with a few instances of the saryActiveUsers array that needed to be tweaked, but we'll talk about that later after I get this working)
 
So after a little fussing around, I'm getting values stored in the database.  But the numbers are all in the 1200+ range, indicating that these folks have been signed on for 20-30 minutes (1200/60 secs), when I barely even saw them logged in as active users.   They do have "last logged in" times that fall into the right range... if they really were 'active users' for that long.
 
What I'm looking for is that once someone clicks "logoff" OR otherwise becomes inactive, that would remove them from the active users list and update the time correctly.   Is it the IF statement in that REMOVE ACTIVE USERS area that's making this only trigger after 20+ minutes have passed?  If so, then where should I put that update code?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net