Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - "Time Spent Online" modification request
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

"Time Spent Online" modification request

 Post Reply Post Reply
Author
WebG View Drop Down
Groupie
Groupie


Joined: 19 November 2004
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebG Quote  Post ReplyReply Direct Link To This Post Topic: "Time Spent Online" modification request
    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?
Back to Top
WebG View Drop Down
Groupie
Groupie


Joined: 19 November 2004
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebG Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.