From 3a3b22e44f4881844c05f3edfc16595b46c75379 Mon Sep 17 00:00:00 2001 From: xiaomlove <353856593@qq.com> Date: Tue, 23 Jan 2024 01:34:06 +0800 Subject: [PATCH 1/2] getip() real by default --- include/globalfunctions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 7a4c9e9e..7abf6fda 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -49,7 +49,7 @@ function validip($ip) else return false; } -function getip() { +function getip($true = true) { if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; @@ -67,7 +67,9 @@ function getip() { $ip = getenv('REMOTE_ADDR') ?? ''; } } - + if ($true) { + return strstr($ip, ",", true); + } return $ip; } From a25c3d65742a4c4c568548637e32c865c2fa8e7c Mon Sep 17 00:00:00 2001 From: xiaomlove <353856593@qq.com> Date: Tue, 23 Jan 2024 01:36:58 +0800 Subject: [PATCH 2/2] getip() param name use real --- include/globalfunctions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 7abf6fda..5366eb1c 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -49,7 +49,7 @@ function validip($ip) else return false; } -function getip($true = true) { +function getip($real = true) { if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; @@ -67,7 +67,7 @@ function getip($true = true) { $ip = getenv('REMOTE_ADDR') ?? ''; } } - if ($true) { + if ($real) { return strstr($ip, ",", true); } return $ip;