fix: Update patient_tracker.php (#6595)
[openemr.git] / library / allow_cronjobs.php
blob90c9e612d5eeb4c4a4f14c7cf6c1129d64aa37ae
1 <?php
3 /**
4 * cronjob mapping to allow seamless use of scripts in background.
6 * @package OpenEMR
7 * @link https://www.open-emr.org
8 * @author MD Support <mdsupport@users.sf.net>
9 * @copyright Copyright (c) 2017 MD Support <mdsupport@users.sf.net>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 // Check if running as a cronjob
14 if (php_sapi_name() !== 'cli') {
15 return;
18 /**
19 * Cronjobs are expected to specify arguments as -
20 * php -f full_script_name arg1=value1 arg2=value2
22 * Code below translates $argv to $_REQUEST
24 foreach ($argv as $argk => $argval) {
25 if ($argk == 0) {
26 continue;
28 $pair = explode("=", $argval);
29 $_REQUEST[trim($pair[0])] = (isset($pair[1]) ? trim($pair[1]) : null);
32 // Every job must have at least one argument specifing site
33 if (!isset($_REQUEST['site'])) {
34 exit("site=?");
37 // Simulate $_GET and $_POST for use by scripts
38 $_GET = $_REQUEST;
39 $_POST = $_REQUEST;
41 // Ignore auth checks
42 $ignoreAuth = true;
44 // Since from command line, set $sessionAllowWrite since need to set site_id session and no benefit to set to false
45 $sessionAllowWrite = true;