From 585e604ac4c446278fca9e406b27bfd2f7e0be21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2019 18:02:03 +0100 Subject: [PATCH] Add a message to avoid using wrong script file --- htdocs/public/cron/cron_run_jobs.php | 9 +++++++++ scripts/cron/cron_run_jobs.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index 936da02dbb8..de928a95c50 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -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 */ diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 034315fdc10..b115f4bbea9 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -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);