diff options
Diffstat (limited to 'lib/Minz')
| -rw-r--r-- | lib/Minz/HookType.php | 4 | ||||
| -rw-r--r-- | lib/Minz/Request.php | 14 |
2 files changed, 16 insertions, 2 deletions
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 @@ -255,6 +255,20 @@ class Minz_Request { } /** + * 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) */ public static function isHttps(): bool { |
