Add a message to avoid using wrong script file

This commit is contained in:
Laurent Destailleur 2019-03-11 18:02:03 +01:00
parent f356d534cd
commit 585e604ac4
2 changed files with 10 additions and 1 deletions

View File

@ -34,6 +34,13 @@ if (! defined('NOLOGIN')) define('NOLOGIN', '1');
$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) define("DOLENTITY", $entity);
// Error if CLI mode
if (php_sapi_name() == "cli")
{
echo "Error: This page can't be used as a CLI script. For the CLI version of script, launch cron_run_job.php available into scripts/cron/ directory.\n";
exit(-1);
}
// librarie core
// Dolibarr environment
require '../../main.inc.php';
@ -46,6 +53,8 @@ global $langs, $conf;
// Language Management
$langs->loadLangs(array("admin", "cron"));
/*
* View
*/

View File

@ -35,7 +35,7 @@ $sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
// Test if batch mode
// Error if Web mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit(-1);