1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Improved check for CLI mode. Parsed $argv to $_GET in CLI mode.

This commit is contained in:
Cameron 2021-01-05 12:25:28 -08:00
parent 661fd6fb2c
commit 53866fd6b9

View File

@ -800,6 +800,11 @@ class e107
*/
public static function isCli()
{
if(PHP_SAPI === 'cli')
{
return true;
}
return self::getE107('cli');
}
@ -4785,10 +4790,19 @@ class e107
$_SERVER['PHP_SELF'] = $requestUrl;
}*/
if(!empty($_SERVER['_']) && empty($_SERVER['SCRIPT_FILENAME']) && self::isCli())
if(self::isCli())
{
if(!empty($_SERVER['argv']) && empty($_GET))
{
parse_str($_SERVER['argv'][1], $_GET); // convert argv to $_GET for script testing via CLI.
}
if(!empty($_SERVER['_']) && empty($_SERVER['SCRIPT_FILENAME']))
{
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['_'];
}
}
$eSelf = !empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME'];
$_self = $this->HTTP_SCHEME.'://'.$_SERVER['HTTP_HOST'].$eSelf;