From: Joe Hunt Date: Tue, 13 Oct 2009 22:16:05 +0000 (+0000) Subject: Rerun with better algorithm. X-Git-Tag: v2.4.2~19^2~1124 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=a8c6e7e820741388aca1e6c42aed7f899b38c188;p=fa-stable.git Rerun with better algorithm. --- diff --git a/admin/db/users_db.inc b/admin/db/users_db.inc index 853de471..3f484639 100644 --- a/admin/db/users_db.inc +++ b/admin/db/users_db.inc @@ -172,31 +172,29 @@ function show_users_online() $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 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. - Note that getenv() function doesn't work when PHP is running as ISAPI module */ - if (getenv('HTTP_CLIENT_IP')) { - $ip = getenv('HTTP_CLIENT_IP'); + if (isset($_SERVER['HTTP_CLIENT_IP'])) { + $ip = $_SERVER['HTTP_CLIENT_IP']; } - elseif (getenv('HTTP_X_FORWARDED_FOR')) { - $ip = getenv('HTTP_X_FORWARDED_FOR'); + elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } - elseif (getenv('HTTP_X_FORWARDED')) { - $ip = getenv('HTTP_X_FORWARDED'); + elseif (isset($_SERVER['HTTP_X_FORWARDED'])) { + $ip = $_SERVER['HTTP_X_FORWARDED']; } - elseif (getenv('HTTP_FORWARDED_FOR')) { - $ip = getenv('HTTP_FORWARDED_FOR'); + elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) { + $ip = $_SERVER['HTTP_FORWARDED_FOR']; } - elseif (getenv('HTTP_FORWARDED')) { - $ip = getenv('HTTP_FORWARDED'); + 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.