27 if (isset($_SERVER[
'argv'][1])) {
28 define(
'SQ_SYSTEM_ROOT', $_SERVER[
'argv'][1]);
30 define(
'SQ_SYSTEM_ROOT', dirname(dirname(dirname(__FILE__))));
34 define(
'SQ_IN_CRON', 1);
36 require_once SQ_SYSTEM_ROOT.
'/core/include/init.inc';
37 ini_set(
'memory_limit', SQ_CONF_CRON_MEMORY_LIMIT.
'M');
39 $root_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
40 if (is_null($root_user)) {
41 trigger_localised_error(
'CRON0023', E_USER_ERROR);
44 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
45 trigger_localised_error(
'CRON0022', E_USER_ERROR);
48 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
49 if (is_null($cron_mgr)) {
50 trigger_localised_error(
'CRON0021', E_USER_ERROR);
53 if (!empty($_SERVER[
'argv'][1]) && $_SERVER[
'argv'][1] ==
'RESET_RUNNING') {
54 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($cron_mgr->id,
'attributes', 0, TRUE)) {
55 trigger_localised_error(
'CRON0016', E_USER_ERROR, $cron_mgr->name);
57 if (!$cron_mgr->setAttrValue(
'running', FALSE)) {
58 trigger_localised_error(
'CRON0010', E_USER_ERROR);
60 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($cron_mgr->id,
'attributes');
83 function make_proper_path($path=
'')
89 $path_components = explode(
'/',$path);
91 if (empty($path_components[0])) {
93 unset($path_components[0]);
98 foreach ($path_components as $component) {
101 if (!empty($stack)) array_pop($stack);
110 array_push($stack, $component);
114 $new_path = implode(
'/', $stack);
116 return $root.$new_path;