From c5bce8347c521c8c287bd22d3ac705cf606b06b8 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 19 Nov 2007 02:10:09 +0000 Subject: [PATCH] parents-merge 43781 Ensure that Director::isTest/Live/Dev work in cli-script.php calls, #prnt:54 - Weekly Hot Tips didn't get sent. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@45066 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- cli-script.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cli-script.php b/cli-script.php index 10e2a807a..c6afb0ca8 100755 --- a/cli-script.php +++ b/cli-script.php @@ -3,7 +3,6 @@ /** * Main file that handles every page request. */ - $_SERVER['HTTP_HOST'] = $_SERVER['argv'][2]; $_SERVER['SCRIPT_FILENAME'] = __FILE__; chdir(dirname($_SERVER['SCRIPT_FILENAME'])); @@ -20,13 +19,18 @@ if(function_exists('mb_http_output')) { if( preg_match( '/(test\.totallydigital\.co\.nz|dev\.totallydigital\.co\.nz\/test)(.*)/', $_SERVER['SCRIPT_FILENAME'], $nameMatch ) ) { $_SERVER['SCRIPT_NAME'] = $nameMatch[2]; $_SERVER['HTTP_HOST'] = $nameMatch[1]; -} elseif( preg_match( '/dev\.totallydigital\.co\.nz(.*)/', $_SERVER['SCRIPT_FILENAME'], $nameMatch ) ) + $envType = 'test'; +} elseif( preg_match( '/dev\.totallydigital\.co\.nz(.*)/', $_SERVER['SCRIPT_FILENAME'], $nameMatch ) ) { $_SERVER['SCRIPT_NAME'] = $nameMatch[1]; -elseif( preg_match( '/\/sites\/[^\/]+\/www(.*)/', $_SERVER['SCRIPT_FILENAME'], $nameMatch ) ) + $envType = 'dev'; +} elseif( preg_match( '/\/sites\/[^\/]+\/www(.*)/', $_SERVER['SCRIPT_FILENAME'], $nameMatch ) ) { $_SERVER['SCRIPT_NAME'] = $nameMatch[1]; -elseif( preg_match( '/\/sites\/[^\/]+(.*)/', $_SERVER['SCRIPT_FILENAME'], $nameMatch ) ) + $envType = 'live'; +} elseif( preg_match( '/\/sites\/[^\/]+(.*)/', $_SERVER['SCRIPT_FILENAME'], $nameMatch ) ) { $_SERVER['SCRIPT_NAME'] = $nameMatch[1]; -elseif(!isset($_SERVER['SCRIPT_NAME'])) { +} elseif(isset($_SERVER['SCRIPT_NAME'])) { + $envType = 'live'; +} else { echo "Error: could not determine server configuration {$_SERVER['SCRIPT_FILENAME']}\n"; exit(); } @@ -39,7 +43,6 @@ if($_REQUEST && get_magic_quotes_gpc()) { if($_REQUEST['trace']) apd_set_pprof_trace(); - require_once("core/ManifestBuilder.php"); require_once("core/ClassInfo.php"); require_once('core/Object.php'); @@ -65,6 +68,8 @@ require_once(MANIFEST_FILE); if($_GET['debugmanifest']) Debug::show(file_get_contents(MANIFEST_FILE)); +Director::set_environment_type($envType); + // Default director Director::addRules(10, array( 'Security/$Action' => 'Security',