From a18c35046daee15e7ac5f85db290d54541a03e3c Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 11 Nov 2025 08:17:12 +0100 Subject: Housekeeping lib_rss.php (#8193) * Housekeeping lib_rss.php `lib_rss.php` had become much too large, especially after https://github.com/FreshRSS/FreshRSS/pull/7924 Moved most functions to other places. Mostly no change of code otherwise (see comments). * Extension: composer run-script phpstan-third-party --- lib/Minz/HookType.php | 4 ++-- lib/Minz/Request.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'lib/Minz') diff --git a/lib/Minz/HookType.php b/lib/Minz/HookType.php index 0d96b8832..07db599c3 100644 --- a/lib/Minz/HookType.php +++ b/lib/Minz/HookType.php @@ -26,8 +26,8 @@ enum Minz_HookType: string { case NavMenu = 'nav_menu'; // function() -> string case NavReadingModes = 'nav_reading_modes'; // function($readingModes = array) -> array | null case PostUpdate = 'post_update'; // function(none) -> none - case SimplepieAfterInit = 'simplepie_after_init'; // function(\SimplePie\SimplePie $simplePie, FreshRSS_Feed $feed, bool $result): void - case SimplepieBeforeInit = 'simplepie_before_init'; // function(\SimplePie\SimplePie $simplePie, FreshRSS_Feed $feed): void + case SimplepieAfterInit = 'simplepie_after_init'; // function(FreshRSS_SimplePieCustom $simplePie, FreshRSS_Feed $feed, bool $result): void + case SimplepieBeforeInit = 'simplepie_before_init'; // function(FreshRSS_SimplePieCustom $simplePie, FreshRSS_Feed $feed): void case ViewModes = 'view_modes'; // function($viewModes = array) -> array | null public function signature(): Minz_HookSignature { diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index c938afd7c..973e46f2c 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -254,6 +254,20 @@ class Minz_Request { self::$action_name === $action_name; } + /** + * Use CONN_REMOTE_ADDR (if available, to be robust even when using Apache mod_remoteip) or REMOTE_ADDR environment variable to determine the connection IP. + */ + public static function connectionRemoteAddress(): string { + $remoteIp = is_string($_SERVER['CONN_REMOTE_ADDR'] ?? null) ? $_SERVER['CONN_REMOTE_ADDR'] : ''; + if ($remoteIp == '') { + $remoteIp = is_string($_SERVER['REMOTE_ADDR'] ?? null) ? $_SERVER['REMOTE_ADDR'] : ''; + } + if ($remoteIp == 0) { + $remoteIp = ''; + } + return $remoteIp; + } + /** * Return true if the request is over HTTPS, false otherwise (HTTP) */ -- cgit v1.2.3