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:42:06 (GMT)
commitf0a99c4f518b4eb53d7385ba3bd51b40c6241748 (patch)
tree12a60c16cbba5d90cc4b431b155d39d53004533a
parent2dd95ea37d0e4fae85071458258b0affa4a08b70 (diff)
downloadiRony-f0a99c4f518b4eb53d7385ba3bd51b40c6241748.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 c1c3067..4cbbcb2 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
*/