Skip to content
Snippets Groups Projects
Commit 83ecd733 authored by Jared Hancock's avatar Jared Hancock
Browse files

Fix NOTICE errors from cli cron

Fix PHP NOTICE level errors for cron jobs executed from the command line

Fixes #4
parent 7faf3026
No related branches found
No related tags found
No related merge requests found
......@@ -19,8 +19,6 @@ require('api.inc.php');
if (!osTicket::is_cli())
die('cron.php only supports local cron calls - use http -> api/tasks/cron');
@chdir(realpath(dirname(__FILE__)).'/'); //Change dir.
require('api.inc.php');
require_once(INCLUDE_DIR.'api.cron.php');
LocalCronApiController::call();
?>
......@@ -43,6 +43,9 @@ class Bootstrap {
ini_set('date.timezone', 'America/New_York');
}
}
if (!isset($_SERVER['REMOTE_ADDR']))
$_SERVER['REMOTE_ADDR'] = '';
}
function https() {
......
......@@ -367,7 +367,7 @@ class osTicket {
* Secondly, if the directory of main.inc.php is the same as the
* document root, the the ROOT path truly is '/'
*/
if(!$_SERVER['DOCUMENT_ROOT']
if(!isset($_SERVER['DOCUMENT_ROOT'])
|| !strcasecmp($_SERVER['DOCUMENT_ROOT'], $dir))
return '/';
......@@ -411,7 +411,9 @@ class osTicket {
/* returns true if script is being executed via commandline */
function is_cli() {
return (!strcasecmp(substr(php_sapi_name(), 0, 3), 'cli')
|| (!$_SERVER['REQUEST_METHOD'] && !$_SERVER['HTTP_HOST']) //Fallback when php-cgi binary is used via cli
|| (!isset($_SERVER['REQUEST_METHOD']) &&
!isset($_SERVER['HTTP_HOST']))
//Fallback when php-cgi binary is used via cli
);
}
......
......@@ -16,7 +16,9 @@ vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
#Disable direct access.
if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']),basename(__FILE__))) die('kwaheri rafiki!');
if(isset($_SERVER['SCRIPT_NAME'])
&& !strcasecmp(basename($_SERVER['SCRIPT_NAME']),basename(__FILE__)))
die('kwaheri rafiki!');
require('bootstrap.php');
Bootstrap::loadConfig();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment