From 906c0652eb9f296f6007a950d0b0bdada3f413df Mon Sep 17 00:00:00 2001 From: Martin Kutschker Date: Tue, 12 Dec 2006 16:37:21 +0000 Subject: [PATCH] Made cli_dispatch.phpsh work when called as "php cli_dispatch.phpsh" and protect from being called on a non CLI git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1870 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 5 +++++ typo3/cli_dispatch.phpsh | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9bafffdb3e8..3bb557851ee3 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ + +2006-12-12 Martin Kutschker + + * Made cli_dispatch.phpsh work when called as "php cli_dispatch.phpsh" and protect from being called on a non CLI + 2006-12-12 Karsten Dambekalns * The EM now stores the list of extensions from TER in the database, see http://bugs.typo3.org/view.php?id=2615 diff --git a/typo3/cli_dispatch.phpsh b/typo3/cli_dispatch.phpsh index d7a5875da41c..4057f4ede298 100755 --- a/typo3/cli_dispatch.phpsh +++ b/typo3/cli_dispatch.phpsh @@ -8,13 +8,16 @@ // The point is to have only ONE script dealing with the environment initialization while the actual processing is all a developer should care for. // ***************************************** +if (PHP_SAPI!='cli') { + die('ERROR: Not called from a command line interface (eg. a shell or scheduler).'.chr(10)); +} + // Defining circumstances for CLI mode: define('TYPO3_cliMode', TRUE); // Defining PATH_thisScript here: Must be the ABSOLUTE path of this script in the right context: // This will work as long as the script is called by it's absolute path! -$temp_PATH_thisScript = isset($_ENV['_']) ? $_ENV['_'] : $_SERVER['_']; -$BACK_PATH = ''; +$temp_PATH_thisScript = isset($_SERVER['argv'][0]) ? $_SERVER['argv'][0] : (isset($_ENV['_']) ? $_ENV['_'] : $_SERVER['_']); // Alternatively, in some environments, we might be able to figure out the absolute path (with no "../" and "./" in) from environment variables... if ($temp_PATH_thisScript{0}!='/') { @@ -26,11 +29,11 @@ if ($temp_PATH_thisScript{0}!='/') { } define('PATH_thisScript',$temp_PATH_thisScript); - // First argument is a key that -define('TYPO3_cliKey', $_SERVER["argv"][0]); + // First argument is a key that points to the script configuration +define('TYPO3_cliKey', $_SERVER['argv'][1]); // Include init file: -require(dirname(PATH_thisScript).'/'.$BACK_PATH.'init.php'); +require(dirname(PATH_thisScript).'/init.php'); if (defined('TYPO3_cliInclude')) { include(TYPO3_cliInclude); @@ -38,4 +41,4 @@ if (defined('TYPO3_cliInclude')) { echo 'ERROR: Nothing to include.'.chr(10); exit; } -?> +?> \ No newline at end of file -- 2.20.1