Commit 3dfa3443 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1373 Modify custom header so it matches the apache modphp version.

Released under the Affero GNU General Public License (AGPL) version 3.
parent e4f164c3
...@@ -254,11 +254,20 @@ class Request { ...@@ -254,11 +254,20 @@ class Request {
} }
} }
if (defined('USE_CUSTOM_REMOTE_IP_HEADER') && USE_CUSTOM_REMOTE_IP_HEADER !== false && isset(self::$headers[strtolower(USE_CUSTOM_REMOTE_IP_HEADER)])) { if (defined('USE_CUSTOM_REMOTE_IP_HEADER') && USE_CUSTOM_REMOTE_IP_HEADER !== false) {
$remoteIP = self::filterIP(self::$headers[strtolower(USE_CUSTOM_REMOTE_IP_HEADER)]); // make custom header compatible with Apache modphp (see ZP-1332)
if ($remoteIP) { $header = $apacheHeader = strtolower(USE_CUSTOM_REMOTE_IP_HEADER);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Using custom header '%s' to determine remote IP: %s - connect is coming from IP: %s", USE_CUSTOM_REMOTE_IP_HEADER, $remoteIP, self::$remoteAddr)); if (substr($apacheHeader, 0, 5) === 'http_') {
self::$remoteAddr = $remoteIP; $apacheHeader = substr($apacheHeader, 5);
}
$apacheHeader = str_replace("_", "-", $apacheHeader);
if (isset(self::$headers[$header]) || isset(self::$headers[$apacheHeader])) {
$remoteIP = isset(self::$headers[$header]) ? self::$headers[$header] : self::$headers[$apacheHeader];
$remoteIP = self::filterIP($remoteIP);
if ($remoteIP) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Using custom header '%s' to determine remote IP: %s - connect is coming from IP: %s", USE_CUSTOM_REMOTE_IP_HEADER, $remoteIP, self::$remoteAddr));
self::$remoteAddr = $remoteIP;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment