Famicom World

Famicom World => Updates and Suggestions => Topic started by: MaxXimus on May 21, 2008, 10:53:55 am

Title: How does the "Most Time Online" feature calculate time?
Post by: MaxXimus on May 21, 2008, 10:53:55 am
Does it update every so often? I usually leave my browser windows open idleing on webpages, but my time online never seems to grow. I was just wondering how time is calculated, and the circumstances in which time is added to your count.
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: UglyJoe on May 21, 2008, 11:12:37 am
Interesting question.  I'll poke around SMF's source code later and try to figure that out (since Google isn't helping much...).
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: 133MHz on May 21, 2008, 11:14:31 am
Apparently you have to be doing something on the forum for it to register time, not just leaving the window open doing nothing, maybe checking cookies every X seconds or something. Makes sense, otherwise I'd just leave my browser window open 24/7 and rack up online time ;D.
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: nurd on May 21, 2008, 01:33:33 pm
Where is this?
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: 133MHz on May 21, 2008, 01:57:46 pm
At the forum main page, go down where it says Forum Stats and click on [More Stats].
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: JC on May 21, 2008, 03:41:16 pm
133 is right. You've got to be active. Once you become inactive, I think you get an extra 10-15 minutes (that's how long you'll show at the bottom of the mainpage as active. After 10-15 minutes, you disappear from the bottom of the mainpage -- no more time given until you become active again.
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: UglyJoe on May 21, 2008, 04:02:45 pm
To answer your question:


  // Mark your session as being logged.
  $_SESSION['log_time'] = time();

  // Well, they are online now.
  if (empty($_SESSION['timeOnlineUpdated']))
    $_SESSION['timeOnlineUpdated'] = time();

  // Set their login time, if not already done within the last minute.
  if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60)
  {
    // Don't count longer than 15 minutes.
    if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
      $_SESSION['timeOnlineUpdated'] = time();

    $user_settings['totalTimeLoggedIn'] += time() - $_SESSION['timeOnlineUpdated'];
    updateMemberData($ID_MEMBER, array('lastLogin' => time(), 'memberIP' => '\'' . $user_info['ip'] . '\'', 'memberIP2' => '\'' . $_SERVER['BAN_CHECK_IP'] .

    if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
      cache_put_data('user_settings-' . $ID_MEMBER, $user_settings, 60);

    $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
    $_SESSION['timeOnlineUpdated'] = time();
  }


It's basically this:

-You access the forum (and are already logged in)
---Your total time does not go up
-You then access a thread 5 minutes later
---Your total time goes up by 5 minutes
-You then access a thread 30 seconds later
---You total time does not go up (less than 60 seconds from the last time update)
-You then access a thread 45 seconds later
---Your total time goes up by 75 seconds (30 + 45 = 75 seconds, which is more than 60 seconds, which means your time goes up).
-You then access a thread 16 minutes later
---Your total time does not go up (the limit is 15 minutes between actions, at this point, you've started a new "session").
-You then access a thread 7 minutes later
---Your total time goes up by 7 minutes.

Does that clear things up?
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: JC on May 21, 2008, 04:19:43 pm
More complex than is necessary, maybe. ::)  SMF. :P
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: Paul-FC on May 22, 2008, 09:47:43 am
apparently i am 4th place in "Most Time Online" :D
Title: Re: How does the "Most Time Online" feature calculate time?
Post by: MaxXimus on May 22, 2008, 10:16:06 am
That is why I brought it up. You signed up after me, and you have been online almost twice as much. I just can't see how that is possible, especially since I log in about 10 to 15 times a day. :S