Most registered users online stat...

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

I was looking around and I'll be damned if I could find where the most users online stat was gathered/stored. I see where it is called in the template, and I see the definition in the languages, but I can't find it anywhere else.

Anyways if I can find it it'd be cool if we were to add/change it so it counted registered users aswell.

Any ideas where that'd be?!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9084
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

That is so strange that you just brought that up. I was just wondering about that today because I was thinking about changing the most users online to only represent the most registered users online at Ozzu, since I am not sure what that number is, and I was curious.

If anything I was thinking about at least filtering out the Google Bot so it would not be counted in the most online user stat, since it highly inflates it.
  • musik
  • Legend
  • Super Moderator
  • User avatar
  • Posts: 6893
  • Loc: up a tree

Post 3+ Months Ago

Ahhhaaaa!!!! This other forum had like 800 people online in one day... noone could figure why but they swore black and blue it was true!!!


GOOGLE BOT!!! :shock:
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

there is no instance of "record" in any of the root files (just /phpbb2/).

It'd be really cool if we could figure that out, it'd make a great mod too! :-P
  • RyTRiX
  • Graduate
  • Graduate
  • User avatar
  • Posts: 239
  • Loc: Michigan

Post 3+ Months Ago

musik wrote:
Ahhhaaaa!!!! This other forum had like 800 people online in one day... noone could figure why but they swore black and blue it was true!!!


GOOGLE BOT!!! :shock:


It can be done pretty easy with any proxy testing program.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

The answer is in the viewonline.php file.

The numbers for online viewers are all determined from analyzing the results of this query:

Code: [ Select ]
//
// Get user list
//
$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
    FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
    WHERE u.user_id = s.session_user_id
        AND s.session_time >= ".( time() - 300 ) . "
    ORDER BY u.username ASC, s.session_ip ASC";
  1. //
  2. // Get user list
  3. //
  4. $sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
  5.     FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
  6.     WHERE u.user_id = s.session_user_id
  7.         AND s.session_time >= ".( time() - 300 ) . "
  8.     ORDER BY u.username ASC, s.session_ip ASC";


That's why you couldn't find one specific table record for who's online and what not.

Basically, online status is determined by an analysis of the session_logged_in status. If the session_logged_in status is "0" for session_user_id "-1" there are no guests on line. All guests are assigned "-1" as a user_id. So if that number is positive that is then added to the registered users number for the total.

Any user_id that is a positive number in the session table is a registered logged in user. The code on this page uses the results from the array to create the variables that are used on the viewonline_body.tpl

By modifying the variables here, you should be able to change the results of what is displayed as total users online.

----------------------------------------------------
Well, after rereading above, I realize that doesn't quite answer the question. The record users online is stored in the phpbb_config table, and it's about 50 rows in, so if you're using phpMyAdmin, you have to go to the second page of the table to find it.

I'll see if I can find the query that updates that table row. There should be a way to do what BWM's talking about, but I think you may have to manually reset that most ever to a lower number, or perhaps if you really want to measure it, maybe even zero (start fresh from the anniversary date, perhaps).

I'll let you know if I find the query.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Here's the code you'll need to change to your liking. It should be moderately easy to change, but as I mentioned before, since our Online online user total will take awhile to exceed the current most ever online, you may want to manually lower that after you've made the change.

It's located near the beginning of the /includes/page_header.php file:

Code: [ Select ]
// Get basic (usernames + totals) online

// situation

//

$logged_visible_online = 0;

$logged_hidden_online = 0;

$guests_online = 0;

$online_userlist = '';



if (defined('SHOW_ONLINE'))

{



    $user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';

    $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip

        FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s

        WHERE u.user_id = s.session_user_id

            AND s.session_time >= ".( time() - 300 ) . "

            $user_forum_sql

        ORDER BY u.username ASC, s.session_ip ASC";

    if( !($result = $db->sql_query($sql)) )

    {

        message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql);

    }



    $userlist_ary = array();

    $userlist_visible = array();



    $prev_user_id = 0;

    $prev_user_ip = '';



    while( $row = $db->sql_fetchrow($result) )

    {

        // User is logged in and therefor not a guest

        if ( $row['session_logged_in'] )

        {

            // Skip multiple sessions for one user

            if ( $row['user_id'] != $prev_user_id )

            {

                $style_color = '';

                if ( $row['user_level'] == ADMIN )

                {

                    $row['username'] = '<b>' . $row['username'] . '</b>';

                    $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';

                }

                else if ( $row['user_level'] == MOD )

                {

                    $row['username'] = '<b>' . $row['username'] . '</b>';

                    $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';

                }



                if ( $row['user_allow_viewonline'] )

                {

                    $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';

                    $logged_visible_online++;

                }

                else

                {

                    $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';

                    $logged_hidden_online++;

                }



                if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )

                {

                    $online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;

                }

            }



            $prev_user_id = $row['user_id'];

        }

        else

        {

            // Skip multiple sessions for one user

            if ( $row['session_ip'] != $prev_session_ip )

            {

                $guests_online++;

            }

        }



        $prev_session_ip = $row['session_ip'];

    }

    $db->sql_freeresult($result);



    if ( empty($online_userlist) )

    {

        $online_userlist = $lang['None'];

    }

    $online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist;



    $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;



    if ( $total_online_users > $board_config['record_online_users'])

    {

        $board_config['record_online_users'] = $total_online_users;

        $board_config['record_online_date'] = time();



        $sql = "UPDATE " . CONFIG_TABLE . "

            SET config_value = '$total_online_users'

            WHERE config_name = 'record_online_users'";

        if ( !$db->sql_query($sql) )

        {

            message_die(GENERAL_ERROR, 'Could not update online user record (nr of users)', '', __LINE__, __FILE__, $sql);

        }



        $sql = "UPDATE " . CONFIG_TABLE . "

            SET config_value = '" . $board_config['record_online_date'] . "'

            WHERE config_name = 'record_online_date'";

        if ( !$db->sql_query($sql) )

        {

            message_die(GENERAL_ERROR, 'Could not update online user record (date)', '', __LINE__, __FILE__, $sql);

        }

    }



    if ( $total_online_users == 0 )

    {

        $l_t_user_s = $lang['Online_users_zero_total'];

    }

    else if ( $total_online_users == 1 )

    {

        $l_t_user_s = $lang['Online_user_total'];

    }

    else

    {

        $l_t_user_s = $lang['Online_users_total'];

    }



    if ( $logged_visible_online == 0 )

    {

        $l_r_user_s = $lang['Reg_users_zero_total'];

    }

    else if ( $logged_visible_online == 1 )

    {

        $l_r_user_s = $lang['Reg_user_total'];

    }

    else

    {

        $l_r_user_s = $lang['Reg_users_total'];

    }



    if ( $logged_hidden_online == 0 )

    {

        $l_h_user_s = $lang['Hidden_users_zero_total'];

    }

    else if ( $logged_hidden_online == 1 )

    {

        $l_h_user_s = $lang['Hidden_user_total'];

    }

    else

    {

        $l_h_user_s = $lang['Hidden_users_total'];

    }



    if ( $guests_online == 0 )

    {

        $l_g_user_s = $lang['Guest_users_zero_total'];

    }

    else if ( $guests_online == 1 )

    {

        $l_g_user_s = $lang['Guest_user_total'];

    }

    else

    {

        $l_g_user_s = $lang['Guest_users_total'];

    }



    $l_online_users = sprintf($l_t_user_s, $total_online_users);

    $l_online_users .= sprintf($l_r_user_s, $logged_visible_online);

    $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);

    $l_online_users .= sprintf($l_g_user_s, $guests_online);

}
  1. // Get basic (usernames + totals) online
  2. // situation
  3. //
  4. $logged_visible_online = 0;
  5. $logged_hidden_online = 0;
  6. $guests_online = 0;
  7. $online_userlist = '';
  8. if (defined('SHOW_ONLINE'))
  9. {
  10.     $user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';
  11.     $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip
  12.         FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
  13.         WHERE u.user_id = s.session_user_id
  14.             AND s.session_time >= ".( time() - 300 ) . "
  15.             $user_forum_sql
  16.         ORDER BY u.username ASC, s.session_ip ASC";
  17.     if( !($result = $db->sql_query($sql)) )
  18.     {
  19.         message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql);
  20.     }
  21.     $userlist_ary = array();
  22.     $userlist_visible = array();
  23.     $prev_user_id = 0;
  24.     $prev_user_ip = '';
  25.     while( $row = $db->sql_fetchrow($result) )
  26.     {
  27.         // User is logged in and therefor not a guest
  28.         if ( $row['session_logged_in'] )
  29.         {
  30.             // Skip multiple sessions for one user
  31.             if ( $row['user_id'] != $prev_user_id )
  32.             {
  33.                 $style_color = '';
  34.                 if ( $row['user_level'] == ADMIN )
  35.                 {
  36.                     $row['username'] = '<b>' . $row['username'] . '</b>';
  37.                     $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
  38.                 }
  39.                 else if ( $row['user_level'] == MOD )
  40.                 {
  41.                     $row['username'] = '<b>' . $row['username'] . '</b>';
  42.                     $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
  43.                 }
  44.                 if ( $row['user_allow_viewonline'] )
  45.                 {
  46.                     $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';
  47.                     $logged_visible_online++;
  48.                 }
  49.                 else
  50.                 {
  51.                     $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';
  52.                     $logged_hidden_online++;
  53.                 }
  54.                 if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
  55.                 {
  56.                     $online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;
  57.                 }
  58.             }
  59.             $prev_user_id = $row['user_id'];
  60.         }
  61.         else
  62.         {
  63.             // Skip multiple sessions for one user
  64.             if ( $row['session_ip'] != $prev_session_ip )
  65.             {
  66.                 $guests_online++;
  67.             }
  68.         }
  69.         $prev_session_ip = $row['session_ip'];
  70.     }
  71.     $db->sql_freeresult($result);
  72.     if ( empty($online_userlist) )
  73.     {
  74.         $online_userlist = $lang['None'];
  75.     }
  76.     $online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist;
  77.     $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;
  78.     if ( $total_online_users > $board_config['record_online_users'])
  79.     {
  80.         $board_config['record_online_users'] = $total_online_users;
  81.         $board_config['record_online_date'] = time();
  82.         $sql = "UPDATE " . CONFIG_TABLE . "
  83.             SET config_value = '$total_online_users'
  84.             WHERE config_name = 'record_online_users'";
  85.         if ( !$db->sql_query($sql) )
  86.         {
  87.             message_die(GENERAL_ERROR, 'Could not update online user record (nr of users)', '', __LINE__, __FILE__, $sql);
  88.         }
  89.         $sql = "UPDATE " . CONFIG_TABLE . "
  90.             SET config_value = '" . $board_config['record_online_date'] . "'
  91.             WHERE config_name = 'record_online_date'";
  92.         if ( !$db->sql_query($sql) )
  93.         {
  94.             message_die(GENERAL_ERROR, 'Could not update online user record (date)', '', __LINE__, __FILE__, $sql);
  95.         }
  96.     }
  97.     if ( $total_online_users == 0 )
  98.     {
  99.         $l_t_user_s = $lang['Online_users_zero_total'];
  100.     }
  101.     else if ( $total_online_users == 1 )
  102.     {
  103.         $l_t_user_s = $lang['Online_user_total'];
  104.     }
  105.     else
  106.     {
  107.         $l_t_user_s = $lang['Online_users_total'];
  108.     }
  109.     if ( $logged_visible_online == 0 )
  110.     {
  111.         $l_r_user_s = $lang['Reg_users_zero_total'];
  112.     }
  113.     else if ( $logged_visible_online == 1 )
  114.     {
  115.         $l_r_user_s = $lang['Reg_user_total'];
  116.     }
  117.     else
  118.     {
  119.         $l_r_user_s = $lang['Reg_users_total'];
  120.     }
  121.     if ( $logged_hidden_online == 0 )
  122.     {
  123.         $l_h_user_s = $lang['Hidden_users_zero_total'];
  124.     }
  125.     else if ( $logged_hidden_online == 1 )
  126.     {
  127.         $l_h_user_s = $lang['Hidden_user_total'];
  128.     }
  129.     else
  130.     {
  131.         $l_h_user_s = $lang['Hidden_users_total'];
  132.     }
  133.     if ( $guests_online == 0 )
  134.     {
  135.         $l_g_user_s = $lang['Guest_users_zero_total'];
  136.     }
  137.     else if ( $guests_online == 1 )
  138.     {
  139.         $l_g_user_s = $lang['Guest_user_total'];
  140.     }
  141.     else
  142.     {
  143.         $l_g_user_s = $lang['Guest_users_total'];
  144.     }
  145.     $l_online_users = sprintf($l_t_user_s, $total_online_users);
  146.     $l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
  147.     $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
  148.     $l_online_users .= sprintf($l_g_user_s, $guests_online);
  149. }



Specifically here is where the record gets updated:
Code: [ Select ]
if ( $total_online_users > $board_config['record_online_users'])

  {

   $board_config['record_online_users'] = $total_online_users;

   $board_config['record_online_date'] = time();



   $sql = "UPDATE " . CONFIG_TABLE . "

     SET config_value = '$total_online_users'

     WHERE config_name = 'record_online_users'";
  1. if ( $total_online_users > $board_config['record_online_users'])
  2.   {
  3.    $board_config['record_online_users'] = $total_online_users;
  4.    $board_config['record_online_date'] = time();
  5.    $sql = "UPDATE " . CONFIG_TABLE . "
  6.      SET config_value = '$total_online_users'
  7.      WHERE config_name = 'record_online_users'";




Looks like this should be all you have to do:

Code: [ Select ]
// This mod changes "most users ever online" to
// "most logged in registered users ever online".
// Installation - Easy
// Installation time - 5 minutes
// Files to modify - 2


//----------------------------------------------------------------------
// Open /includes/page_header.php

Find:
    $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;

Replace with:

    $total_online_users = $logged_visible_online + $logged_hidden_online;


//---------------------------------------------------------------------------
// Open /language/lang_main.php

Find:

$lang['Record_online_users'] = 'Most users ever online was <b>%s</b> on %s'; // first %s = number of users, second %s is the date.

Replace with:

$lang['Record_online_users'] = 'Most logged in registered users ever online was <b>%s</b> on %s'; // first %s = number of users, second %s is the date.

//If you'd like an achievable number to beat, manually reset the record_online_users row in the phpbb_config table to zero or a realistic/achievable number

//save changes to both files
//You're done
  1. // This mod changes "most users ever online" to
  2. // "most logged in registered users ever online".
  3. // Installation - Easy
  4. // Installation time - 5 minutes
  5. // Files to modify - 2
  6. //----------------------------------------------------------------------
  7. // Open /includes/page_header.php
  8. Find:
  9.     $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;
  10. Replace with:
  11.     $total_online_users = $logged_visible_online + $logged_hidden_online;
  12. //---------------------------------------------------------------------------
  13. // Open /language/lang_main.php
  14. Find:
  15. $lang['Record_online_users'] = 'Most users ever online was <b>%s</b> on %s'; // first %s = number of users, second %s is the date.
  16. Replace with:
  17. $lang['Record_online_users'] = 'Most logged in registered users ever online was <b>%s</b> on %s'; // first %s = number of users, second %s is the date.
  18. //If you'd like an achievable number to beat, manually reset the record_online_users row in the phpbb_config table to zero or a realistic/achievable number
  19. //save changes to both files
  20. //You're done



ENJOY! :D

------------------------------------
P.S. This thread should probably get shifted to programming.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 73 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.