Enabled a global flag in config.default.php (config.php), $show_users_online = 0.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 21 Oct 2009 13:49:43 +0000 (13:49 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 21 Oct 2009 13:49:43 +0000 (13:49 +0000)
If this flag is set to 1 FA will show discretely the users online in the footer.

CHANGELOG.txt
admin/db/users_db.inc
config.default.php

index f41a6296dfc34570b60e1b7603ae8b7e644b5b02..80f7c82824ae112a535b3a37aeab41f56dc094e1 100644 (file)
@@ -26,6 +26,10 @@ $ -> Affected files
 $ install.html
   update.html
   /lang/new_language_template/LC_MESSAGES/empty.po
+! Enabled a global flag in config.default.php (config.php), $show_users_online = 0.
+  If this flag is set to 1 FA will show discretely the users online in the footer.
+$ config.default.php
+  /admin/db/users_db.inc
 
 21-Oct-2009 Janusz Dobrowolski
 ! Upgrade scripts modified to be used with 2.1 or 2.2beta
index 3f484639e442843993559a8a2b28e053cf0f7e96..d9e3dae33251e749bcac37a92d7e040c73e755be 100644 (file)
@@ -167,43 +167,52 @@ function check_user_activity($id)
 //-----------------------------------------------------------------------------------------------
 function show_users_online()
 {
-       $timeoutseconds = 120;
-
-       $timestamp=time();
-       $timeout=$timestamp-$timeoutseconds;
-       /*
-       This will find out if user is from behind proxy server. 
-       In that case, the script would count them all as 1 user.
-       This function tryes to get real IP address.
-       */
-       if (isset($_SERVER['HTTP_CLIENT_IP'])) {
-               $ip = $_SERVER['HTTP_CLIENT_IP'];
-       }
-       elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
-               $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
-       }
-       elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
-               $ip = $_SERVER['HTTP_X_FORWARDED'];
-       }
-       elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
-               $ip = $_SERVER['HTTP_FORWARDED_FOR'];
-       }
-       elseif (isset($_SERVER['HTTP_FORWARDED'])) {
-               $ip = $_SERVER['HTTP_FORWARDED'];
-       }
-       else {
-               $ip = $_SERVER['REMOTE_ADDR'];
+       global $show_users_online;
+       
+       if (!isset($show_users_online) || $show_users_online == 0)
+               return "";
+       if (db_num_rows(db_query("SHOW TABLES LIKE '".TB_PREF."useronline'")) == 1)
+       {
+               $timeoutseconds = 120;
+
+               $timestamp=time();
+               $timeout=$timestamp-$timeoutseconds;
+               /*
+               This will find out if user is from behind proxy server. 
+               In that case, the script would count them all as 1 user.
+               This function tryes to get real IP address.
+               */
+               if (isset($_SERVER['HTTP_CLIENT_IP'])) {
+                       $ip = $_SERVER['HTTP_CLIENT_IP'];
+               }
+               elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+                       $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
+               }
+               elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
+                       $ip = $_SERVER['HTTP_X_FORWARDED'];
+               }
+               elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
+                       $ip = $_SERVER['HTTP_FORWARDED_FOR'];
+               }
+               elseif (isset($_SERVER['HTTP_FORWARDED'])) {
+                       $ip = $_SERVER['HTTP_FORWARDED'];
+               }
+               else {
+                       $ip = $_SERVER['REMOTE_ADDR'];
+               }
+
+               // Add user to database
+               db_query("INSERT INTO ".TB_PREF."useronline (timestamp, ip, file) VALUES ('". $timestamp ."','". $ip ."','". $_SERVER['PHP_SELF'] ."')");
+               //Remove users that were not online within $timeoutseconds.
+               db_query("DELETE FROM ".TB_PREF."useronline WHERE timestamp<". $timeout);
+
+               // Select online users
+               $result = db_query("SELECT DISTINCT ip FROM ".TB_PREF."useronline");
+               $users = db_num_rows($result);
        }
-
-       // Add user to database
-       db_query("INSERT INTO ".TB_PREF."useronline (timestamp, ip, file) VALUES ('". $timestamp ."','". $ip ."','". $_SERVER['PHP_SELF'] ."')");
-       //Remove users that were not online within $timeoutseconds.
-       db_query("DELETE FROM ".TB_PREF."useronline WHERE timestamp<". $timeout);
-
-       // Select online users
-       $result = db_query("SELECT DISTINCT ip FROM ".TB_PREF."useronline");
-       $users = db_num_rows($result);
-       return "$users ".($users == 1 ? _("user online") : _(" users online"));
+       else
+               $users = 1;
+       return "$users ".($users == 1 ? _("user online") : _("users online"));
 
 }
 ?>
\ No newline at end of file
index a709a9e314f8131d7814b9185963e11c3320ade0..f5edc7d2749087c76ca36f94f02547438359c9a6 100644 (file)
@@ -77,6 +77,9 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_
        /* use old style convert (income and expense in BS, PL) */
        $use_oldstyle_convert = 0;
 
+       /* show users online discretely in the footer */
+       $show_users_online = 0;
+
        /* Integrated base Wiki Help URL or null if not used */
        //$help_base_url = $path_to_root.'/modules/wiki/index.php?n='._('Help').'.';
        $help_base_url = null;