18 require_once SQ_CORE_PACKAGE_PATH.
'/system/cron/cron_job/cron_job.inc';
45 parent::__construct($assetid);
61 $id = $this->
attr(
'asset');
62 if ($GLOBALS[
'SQ_SYSTEM']->am->assetExists($id)) {
63 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id);
66 return "Refresh Cache \"$name\" [#$asset->id]";
87 $cm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cache_manager');
88 if (!$cm->attr(
'enabled')) {
89 return SQ_CRON_JOB_COMPLETED;
91 $am = $GLOBALS[
'SQ_SYSTEM']->am;
98 $assetid = $this->
attr(
'asset');
99 $cm->clearCache(Array($assetid));
100 $asset = $am->getAsset($assetid);
101 $urls_info = $asset->getURLs();
102 if (empty($urls_info)) {
103 return SQ_CRON_JOB_COMPLETED;
105 foreach ($urls_info as $url_info) {
106 if ($url_info[
'http'] ==
'1') {
107 $urls[] =
'http://'.$url_info[
'url'];
109 if ($url_info[
'https'] ==
'1') {
110 $urls[] =
'https://'.$url_info[
'url'];
116 $public_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'public_user');
117 $GLOBALS[
'SQ_SYSTEM']->setCurrentUser($public_user);
120 foreach ($urls as $url) {
121 $url_info = parse_url($url);
124 $_SERVER[
'HTTP_HOST'] = $url_info[
'host'];
125 $_SERVER[
'PHP_SELF'] = $url_info[
'path'];
126 $_SERVER[
'HTTP'] = ($url_info[
'scheme'] ==
'http') ?
'on' :
'off';
127 $_SERVER[
'HTTPS'] = ($url_info[
'scheme'] ==
'https') ?
'on' :
'off';
134 $GLOBALS[
'SQ_SYSTEM']->restoreCurrentUser();
136 return SQ_CRON_JOB_COMPLETED;
149 $res = parent::run();
150 if ($res & SQ_CRON_JOB_COMPLETED) {
151 if ($GLOBALS[
'SQ_SYSTEM']->am->acquireLock($this->id,
'all')) {
154 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($this->
id,
'all');