fixing CLI check for servers using cgi-fcgi (PHP_SAPI is in those cases same for web and cli mode)
parent
9c79bc90ec
commit
9866ab0c22
|
@ -25,13 +25,13 @@
|
||||||
* @link http://www.phpservermonitor.org/
|
* @link http://www.phpservermonitor.org/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
if(php_sapi_name() != 'cli') {
|
|
||||||
die('This script can only be run from the command line.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// include main configuration and functionality
|
// include main configuration and functionality
|
||||||
require_once dirname(__FILE__) . '/../src/bootstrap.php';
|
require_once dirname(__FILE__) . '/../src/bootstrap.php';
|
||||||
|
|
||||||
|
if(!psm_is_cli()) {
|
||||||
|
die('This script can only be run from the command line.');
|
||||||
|
}
|
||||||
|
|
||||||
// prevent cron from running twice at the same time
|
// prevent cron from running twice at the same time
|
||||||
// however if the cron has been running for X mins, we'll assume it died and run anyway
|
// however if the cron has been running for X mins, we'll assume it died and run anyway
|
||||||
// if you want to change PSM_CRON_TIMEOUT, have a look in src/includes/psmconfig.inc.php.
|
// if you want to change PSM_CRON_TIMEOUT, have a look in src/includes/psmconfig.inc.php.
|
||||||
|
|
|
@ -432,6 +432,17 @@ function psm_POST($key, $alt = null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we are in CLI mode
|
||||||
|
*
|
||||||
|
* Note, php_sapi cannot be used because cgi-fcgi returns both for web and cli
|
||||||
|
* source: https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_is_cli/7
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function psm_is_cli() {
|
||||||
|
return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)));
|
||||||
|
}
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
#
|
#
|
||||||
# Debug functions
|
# Debug functions
|
||||||
|
|
Loading…
Reference in New Issue