From 6236f2bd5dad4ced5038eadb83eac9692cf1f7b5 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 12 Nov 2007 13:36:03 +0000 Subject: More stable ULTRAHOME setting, auto_prepend_local support --- it_auto_prepend.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/it_auto_prepend.php b/it_auto_prepend.php index 3f69096..b2a3cec 100644 --- a/it_auto_prepend.php +++ b/it_auto_prepend.php @@ -32,12 +32,12 @@ function it_initialize() { if ($_SERVER['REMOTE_ADDR']) # Web? { - $GLOBALS['ULTRAHOME'] = dirname($_SERVER['SCRIPT_FILENAME']); + $GLOBALS['ULTRAHOME'] = dirname($_SERVER['DOCUMENT_ROOT']); umask(0002); # Work around bugs.php.net/bug.php?id=28401 $_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']); } else # Shell - $GLOBALS['ULTRAHOME'] = dirname(preg_match('|^/|', $argv[0]) ? $argv[0] : getcwd() . '/' . $argv[0]); + $GLOBALS['ULTRAHOME'] = dirname(dirname(preg_match('|^/|', $argv[0]) ? $argv[0] : getcwd() . '/' . $argv[0])); $needsconvert = !@eval("return is_array(42=>69,);"); # Check if PHP is patched to support our syntax, see http://cschneid.com/php/ @@ -48,6 +48,9 @@ function it_initialize() { ini_set('include_path', "$it_path:$include_path"); require_once("$it_path/auto_prepend.php"); + + if (file_exists("$it_path/auto_prepend_local.php")) + require_once("$it_path/auto_prepend_local.php"); } else { @@ -57,10 +60,10 @@ function it_initialize() @set_error_handler("it_errorhandler", E_USER_ERROR | E_RECOVERABLE_ERROR | E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE); ini_set('include_path', IT_CONVERT_DIR . ":$it_path:$include_path"); - $user_includes = explode(":", $include_path); + $user_includes = explode(":", $include_path); - # XXX Note: Comment this out if you want system wide include path converted and auto_prepend.php considered - $user_includes = array_diff($user_includes, array_diff(explode(":", get_cfg_var('include_path')), array("."))); + # XXX Note: Comment this out if you want system wide include path converted and auto_prepend.php considered + $user_includes = array_diff($user_includes, array_diff(explode(":", get_cfg_var('include_path')), array("."))); foreach (array_reverse($user_includes) as $include) { @@ -76,6 +79,9 @@ function it_initialize() $autoprepend = it_convert($autoprepend); require_once($autoprepend); + + if (file_exists("$include/auto_prepend_local.php")) + require_once("$include/auto_prepend_local.php"); } } -- cgit v1.2.3