summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-01-07 11:42:06 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2015-01-07 11:45:58 (GMT)
commit1f6fb15ddbf93e9dd77a437b7415994ff0463169 (patch)
tree831b0c3ad2a449aa2ef780dbddca6b3900d0d798
parent2a123ba4561bafc8a91ab3eff1e666287a3be5fa (diff)
downloadiRony-1f6fb15ddbf93e9dd77a437b7415994ff0463169.tar.gz
Fix HTTP raw logging in non-apache environments (#4128). Patch by Daniel Hoffend
-rw-r--r--lib/Kolab/Utils/DAVLogger.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/Kolab/Utils/DAVLogger.php b/lib/Kolab/Utils/DAVLogger.php
index 0e12671..ee4bd80 100644
--- a/lib/Kolab/Utils/DAVLogger.php
+++ b/lib/Kolab/Utils/DAVLogger.php
@@ -100,7 +100,7 @@ class DAVLogger extends DAV\ServerPlugin
// catch all headers
$http_headers = array();
- foreach (apache_request_headers() as $hdr => $value) {
+ foreach ($this->get_request_headers() as $hdr => $value) {
if (strtolower($hdr) == 'authorization') {
$method = preg_match('/^((basic|digest)\s+)/i', $value, $m) ? $m[1] : '';
$value = $method . str_repeat('*', strlen($value) - strlen($method));
@@ -118,6 +118,32 @@ class DAVLogger extends DAV\ServerPlugin
}
}
+ /*
+ * Wrapper function in case apache_request_headers() is not available
+ *
+ * @return array
+ */
+ public function get_request_headers()
+ {
+ if (function_exists('apache_request_headers')) {
+ return apache_request_headers();
+ }
+
+ $return = array();
+ foreach ($_SERVER as $key => $value) {
+ if (preg_match('/^HTTP_(.*)/',$key,$regs)) {
+ // restore original letter case
+ $key = str_replace('_',' ',$regs[1]);
+ $key = ucwords(strtolower($key));
+ $key = str_replace(' ','-',$key);
+
+ // build return array
+ $return[$key] = $value;
+ }
+ }
+ return $return;
+ }
+
/**
* Handler for 'exception' events
*/