diff --git a/controller/Session.class.php b/controller/Session.class.php index 5387dd2e..492f33b8 100644 --- a/controller/Session.class.php +++ b/controller/Session.class.php @@ -34,9 +34,9 @@ class Session static::setNamespace(static::NAMESPACE_DEFAULT, $oldSession); } - Response::addPostRenderCallback(function(){ + Response::addPostRenderCallback(function () { $site_visitor_id = key_exists(static::USER_ID, $_SESSION) ? $_SESSION[static::USER_ID] : ''; - $response = LBRY::logWebVisitor(static::SITE_ID, $site_visitor_id, $_SERVER['REMOTE_ADDR']); + $response = LBRY::logWebVisitor(static::SITE_ID, $site_visitor_id, static::getOriginalIp()); if (!is_null($response) && key_exists('data', $response) && key_exists('visitor_id', $response['data'])) { @@ -111,4 +111,9 @@ class Session { static::unsetNamespace(static::NAMESPACE_FLASH_REMOVE); } + + public static function getOriginalIp() + { + return $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? null; + } }