quick minor path updates (#1968)
[openemr.git] / library / allow_cronjobs.php
blob4ae28a9f350181815aea88ee9f1b77634b025331
1 <?php
2 /**
3 * cronjob mapping to allow seamless use of scripts in background.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author MD Support <mdsupport@users.sf.net>
8 * @copyright Copyright (c) 2017 MD Support <mdsupport@users.sf.net>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 // Check if running as a cronjob
13 if (php_sapi_name() !== 'cli') {
14 return;
17 /**
18 * Cronjobs are expected to specify arguments as -
19 * php -f full_script_name arg1=value1 arg2=value2
21 * Code below translates $argv to $_REQUEST
23 foreach ($argv as $argk => $argval) {
24 if ($argk == 0) {
25 continue;
27 $pair = explode("=", $argval);
28 $_REQUEST[trim($pair[0])] = (isset($pair[1]) ? trim($pair[1]) : null);
31 // Every job must have at least one argument specifing site
32 if (!isset($_REQUEST['site'])) {
33 exit("site=?");
36 // Simulate $_GET and $_POST for use by scripts
37 $_GET = $_REQUEST;
38 $_POST = $_REQUEST;
40 // Ignore auth checks
41 $ignoreAuth = true;