From b82b5f6a533f8c7023abdcdd95bd5ace5e815d9c Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Fri, 2 Sep 2016 17:40:59 -0400 Subject: [PATCH] fix getting original ip --- controller/Request.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/controller/Request.class.php b/controller/Request.class.php index 3560e0c8..d86f89c1 100644 --- a/controller/Request.class.php +++ b/controller/Request.class.php @@ -36,9 +36,10 @@ class Request public static function getOriginalIp(): string { - return isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? - $_SERVER['HTTP_X_FORWARDED_FOR'] : - (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''); + return isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : + (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? + trim(explode(',',$_SERVER['HTTP_X_FORWARDED_FOR'])[0]) : + (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '')); } public static function getUserAgent(): string