Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media


Welcome, Guest. Please login or register.
Did you miss your activation email?

July 09, 2020, 06:49:04 PM

Login with username, password and session length
  • Total Members: 3786
  • Latest: Deaks
  • Total Posts: 190418
  • Total Topics: 20856
  • Online Today: 79
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 0
Guests: 63
Total: 63

Author Topic: Updating Most Online  (Read 2576 times)

0 Members and 1 Guest are viewing this topic.


  • Guest
Updating Most Online
« on: December 14, 2007, 12:23:10 AM »
I have a site
which should not look much like a forum (forum was easiest to implement and it helps me to get users to update softwares in my site rather than I would do all updates by myself (as I do in another site: www.tapworld.net (luckily there is two other updaters as well)).

This site has TinyPortal in use and it shows posts from one board (Software) in front page. From there users usually go to Boards using "Software list" icon from the top of site or using links from "Links" box (right side of the front page).

Users of this forum are usually never supposed to open forum or board index ( http://www.beyonwizsoftware.net/index.php?action=forum ).

TinyPortal's Stats box shows most online stats. Here is code from TPortalBlocks.template.php:
Code: [Select]
            echo '
                  <hr /><img src="'.$settings['images_url'].'/icons/info.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=stats"><b>'.$txt['tp-stats'].'</b></a>
                 <br />'.$bullet.$txt[489].': '.$modSettings['totalMessages']. '
  <br />'.$bullet. $txt[490].': '.$modSettings['totalTopics']. '
  <br />'.$bullet.$txt['tp-mostonline-today'].': '.$modSettings['mostOnlineToday'].'
  <br />'.$bullet.$txt['tp-mostonline'].': '.$modSettings['mostOnline'].'<br />

I tried to find out when and where most online is updated and it seems to happen in BoardIndex.php:
Code: [Select]
// Track most online statistics?
if (!empty($modSettings['trackStats']))
// Determine the most users online - both all time and per day.
$total_users = $context['num_guests'] + $context['num_users_online'];

// More members on now than ever were?  Update it!
if (!isset($modSettings['mostOnline']) || $total_users >= $modSettings['mostOnline'])
updateSettings(array('mostOnline' => $total_users, 'mostDate' => time()));

$date = strftime('%Y-%m-%d', forum_time(false));

// One or more stats are not up-to-date?
if (!isset($modSettings['mostOnlineUpdated']) || $modSettings['mostOnlineUpdated'] != $date)
$request = db_query("
FROM {$db_prefix}log_activity
WHERE date = '$date'
LIMIT 1", __FILE__, __LINE__);

// The log_activity hasn't got an entry for today?
if (mysql_num_rows($request) == 0)
INSERT IGNORE INTO {$db_prefix}log_activity
(date, mostOn)
VALUES ('$date', $total_users)", __FILE__, __LINE__);
// There's an entry in log_activity on today...
list ($modSettings['mostOnlineToday']) = mysql_fetch_row($request);

if ($total_users > $modSettings['mostOnlineToday'])
trackStats(array('mostOn' => $total_users));

$total_users = max($total_users, $modSettings['mostOnlineToday']);

updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => $total_users));
// Highest number of users online today?
elseif ($total_users > $modSettings['mostOnlineToday'])
trackStats(array('mostOn' => $total_users));
updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => $total_users));

It also seems to be so that this code is run only when http://www.beyonwizsoftware.net/index.php?action=forum is opened. This code is not run when TinyPortal fronpage is shown. And in my site this board index is rarely used, it means most online stats won't update often.

Could anyone help me to add code that updates most online stats from BoardIndex.php to TinyPortal (TPortal.php I suppose) or to somewhere else where it would be run regulary.