Changed Journal Inquiries so it shows the Bank Deposit/Payment amount instead of...
[fa-stable.git] / admin / db / users_db.inc
index 853de471160d41845cd9890bd611b0a7579904cc..c0bd02b152b315a00f9dfac2b43e3879c7377b9a 100644 (file)
@@ -167,45 +167,53 @@ function check_user_activity($id)
 //-----------------------------------------------------------------------------------------------
 function show_users_online()
 {
-       $timeoutseconds = 120;
-
-       $timestamp=time();
-       $timeout=$timestamp-$timeoutseconds;
-       /*
-       This will try to find out if user is coming behind proxy server. Why is this important?
-       If you have high traffic web site, it might happen that you receive lot of traffic
-       from the same proxy server (like AOL). In that case, the script would count them all as 1 user.
-       This function tryes to get real IP address.
-       Note that getenv() function doesn't work when PHP is running as ISAPI module
-       */
-       if (getenv('HTTP_CLIENT_IP')) {
-               $ip = getenv('HTTP_CLIENT_IP');
-       }
-       elseif (getenv('HTTP_X_FORWARDED_FOR')) {
-               $ip = getenv('HTTP_X_FORWARDED_FOR');
-       }
-       elseif (getenv('HTTP_X_FORWARDED')) {
-               $ip = getenv('HTTP_X_FORWARDED');
-       }
-       elseif (getenv('HTTP_FORWARDED_FOR')) {
-               $ip = getenv('HTTP_FORWARDED_FOR');
-       }
-       elseif (getenv('HTTP_FORWARDED')) {
-               $ip = getenv('HTTP_FORWARDED');
-       }
-       else {
-               $ip = $_SERVER['REMOTE_ADDR'];
-       }
+       global $show_users_online;
        
-       // 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"));
+       if (!isset($show_users_online) || $show_users_online == 0 || !defined('TB_PREF') || !isset($_SESSION['get_text']))
+               return "";
+       $result = db_query("SHOW TABLES LIKE '".TB_PREF."useronline'"); 
+       if (db_num_rows($result) == 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);
+       }
+       else
+               $users = 1;
+       return "$users ".($users == 1 ? _("user online") : _("users online"));
 
 }
 ?>
\ No newline at end of file