From a17984b27e46cc3ca820105d92b41a238cfb6c8c Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Thu, 10 May 2007 23:02:14 +0000 Subject: [PATCH] - Fix base directory issues when called via command-line - Prevent headers from being sent in cli context git-svn-id: http://htmlpurifier.org/svnroot@1042 48356398-32a2-884e-a903-53898d9a118a --- common.php | 2 +- functions.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common.php b/common.php index cb8f055..97baee9 100644 --- a/common.php +++ b/common.php @@ -1,7 +1,7 @@ =")) exit('Requires PHP 5.'); -chdir('../'); // set working directory to parent directory (slightly hacky) +chdir( dirname(__FILE__) . '/../'); // set working directory to parent directory (slightly hacky) require_once 'htmlpurifier/HTMLPurifier.auto.php'; require_once 'functions.php'; diff --git a/functions.php b/functions.php index ad432c7..726ecb1 100644 --- a/functions.php +++ b/functions.php @@ -21,8 +21,10 @@ function set_response_code($code) { if (isset($code_descriptions[$code])) { $text .= ' ' . $code_descriptions[$code]; } - $php->header($_SERVER['SERVER_PROTOCOL'] . ' ' . $text, true, $code); - $php->header('Status: ' . $text); + if (isset($_SERVER['SERVER_PROTOCOL'])) { + $php->header($_SERVER['SERVER_PROTOCOL'] . ' ' . $text, true, $code); + $php->header('Status: ' . $text); + } return $text; } @@ -77,6 +79,7 @@ function is_created_by_us($page) { * Exception handler, prints a pretty HTTP error message * @param $e The uncaught exception * @todo Add debug mode, which results in copious stack-traces too + * @todo Make more friendly to command-line */ function xhtmlcompiler_exception_handler(Exception $e) { if ($e instanceof XHTMLCompiler_Exception) { -- 2.11.4.GIT