diff --git a/htdocs/caldav.php b/htdocs/caldav.php index 3dc4fdb5..6c77304a 100644 --- a/htdocs/caldav.php +++ b/htdocs/caldav.php @@ -24,8 +24,34 @@ elseif ( isset($_SERVER['PATH_INFO']) && preg_match( '{^/\.well-known/(.+)$}', $ exit(0); } require_once('./always.php'); -// dbg_error_log( 'caldav', ' User agent: %s', ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Unfortunately Mulberry does not send a "User-agent" header with its requests :-(')) ); -// dbg_log_array( 'headers', '_SERVER', $_SERVER, true ); + +function logRequestHeaders() { + global $c; + + /** Log the request headers */ + $lines = apache_request_headers(); + dbg_error_log( "LOG ", "***************** Request Header ****************" ); + dbg_error_log( "LOG ", "%s %s", $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'] ); + foreach( $lines AS $k => $v ) { + if ( $k != 'Authorization' || (isset($c->dbg['password']) && $c->dbg['password'] ) ) + dbg_error_log( "LOG headers", "-->%s: %s", $k, $v ); + else + dbg_error_log( "LOG headers", "-->%s: %s", $k, 'Delicious tasty password eaten by debugging monster!' ); + } + dbg_error_log( "LOG ", "******************** Request ********************" ); + + // Log the request in all it's gory detail. + $lines = preg_split( '#[\r\n]+#', file_get_contents( 'php://input')); + foreach( $lines AS $v ) { + dbg_error_log( "LOG request", "-->%s", $v ); + } + unset($lines); +} + +if ( (isset($c->dbg['ALL']) && $c->dbg['ALL']) || (isset($c->dbg['request']) && $c->dbg['request']) ) + logRequestHeaders(); + + require_once('HTTPAuthSession.php'); $session = new HTTPAuthSession(); diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index e45db661..b7b8f38d 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -111,25 +111,6 @@ class CalDAVRequest $this->raw_post = file_get_contents( 'php://input'); - if ( (isset($c->dbg['ALL']) && $c->dbg['ALL']) || (isset($c->dbg['request']) && $c->dbg['request']) ) { - /** Log the request headers */ - $lines = apache_request_headers(); - dbg_error_log( "LOG ", "***************** Request Header ****************" ); - dbg_error_log( "LOG ", "%s %s", $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'] ); - foreach( $lines AS $k => $v ) { - if ( $k == 'Authorization' ) - dbg_error_log( "LOG headers", "-->%s: %s", $k, 'Delicious tasty password eaten by debugging monster!' ); - else - dbg_error_log( "LOG headers", "-->%s: %s", $k, $v ); - } - dbg_error_log( "LOG ", "******************** Request ********************" ); - // Log the request in all it's gory detail. - $lines = preg_split( '#[\r\n]+#', $this->raw_post); - foreach( $lines AS $v ) { - dbg_error_log( "LOG request", "-->%s", $v ); - } - } - if ( isset($debugging) && isset($_GET['method']) ) { $_SERVER['REQUEST_METHOD'] = $_GET['method']; }