26 error_reporting(E_ALL);
27 if (php_sapi_name() !=
'cli') trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
29 if (count($_SERVER[
'argv']) != 3) {
31 echo
"\tphp ".basename($_SERVER[
'argv'][0]).
" <SYSTEM_ROOT> <cron job assetid>\n\n";
35 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
36 if (empty($SYSTEM_ROOT)) {
37 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
41 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
42 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
45 $ASSETID = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'';
47 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
48 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
50 $root_user = &$GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
51 if (is_null($root_user)) {
52 echo
"Unable to get Root User\n";
56 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
57 echo
"Unable to set Root User as current user\n";
61 $cron_job = &$GLOBALS[
'SQ_SYSTEM']->am->getAsset($ASSETID);
62 if (is_null($cron_job)) {
63 echo
"Asset ID passed (#'.$ASSETID.') does not point to a valid asset\n";
66 if (!is_a($cron_job,
'cron_job')) {
67 echo
"Asset ID passed (#'.$ASSETID.') does not point to a Cron Job asset";
71 $result = $cron_job->run();
73 pre_echo(
"Result: ".implode(
', ',get_bit_names(
'SQ_CRON_JOB_', $result,
true)));