From 949d28a5c18aecf534df8de85cfff0535a7a3fce Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 21 Jan 2008 17:30:31 +1300 Subject: [PATCH] Fix debugging code so this doesn't break a server with open_basedir enabled. Not that I in any way endorse the use of open_basedir... --- inc/always.php | 6 +++--- inc/caldav-PUT-functions.php | 8 +++++--- inc/caldav-REPORT.php | 8 +++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/inc/always.php b/inc/always.php index 54192d7d..db477f2a 100644 --- a/inc/always.php +++ b/inc/always.php @@ -53,13 +53,13 @@ $c->protocol_server_port_script = sprintf( "%s://%s%s%s", (isset($_SERVER['HTTPS init_gettext( 'rscds', '../locale' ); -if ( file_exists("/etc/davical/".$_SERVER['SERVER_NAME']."-conf.php") ) { +if ( @file_exists("/etc/davical/".$_SERVER['SERVER_NAME']."-conf.php") ) { include_once("/etc/davical/".$_SERVER['SERVER_NAME']."-conf.php"); } -else if ( file_exists("/etc/rscds/".$_SERVER['SERVER_NAME']."-conf.php") ) { +else if ( @file_exists("/etc/rscds/".$_SERVER['SERVER_NAME']."-conf.php") ) { include_once("/etc/rscds/".$_SERVER['SERVER_NAME']."-conf.php"); } -else if ( file_exists("../config/config.php") ) { +else if ( @file_exists("../config/config.php") ) { include_once("../config/config.php"); } else { diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php index e58af608..28e856fe 100644 --- a/inc/caldav-PUT-functions.php +++ b/inc/caldav-PUT-functions.php @@ -124,10 +124,12 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) { // According to RFC2445 we should always end with CRLF, but the CalDAV spec says // that normalising XML parses often muck with it and may remove the CR. $icalendar = preg_replace('/\r?\n /', '', $ics_content ); - if ( isset($c->dbg['ALL']) || isset($c->dbg['put']) ) { + if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['put'])) ) { $fh = fopen('/tmp/PUT-2.txt','w'); - fwrite($fh,$icalendar); - fclose($fh); + if ( $fh ) { + fwrite($fh,$icalendar); + fclose($fh); + } } $lines = preg_split('/\r?\n/', $icalendar ); diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php index e3c4c34a..727cbad8 100644 --- a/inc/caldav-REPORT.php +++ b/inc/caldav-REPORT.php @@ -10,10 +10,12 @@ */ dbg_error_log("REPORT", "method handler"); -if ( isset($c->dbg['ALL']) || $c->dbg['report'] ) { +if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || $c->dbg['report']) ) { $fh = fopen('/tmp/REPORT.txt','w'); - fwrite($fh,$request->raw_post); - fclose($fh); + if ( $fh ) { + fwrite($fh,$request->raw_post); + fclose($fh); + } } if ( ! ($request->AllowedTo('read') || $request->AllowedTo('freebusy')) ) {