17 require_once SQ_CORE_PACKAGE_PATH.
'/system/cron/cron_job/cron_job.inc';
18 require_once SQ_FUDGE_PATH.
'/db_extras/db_extras.inc';
44 parent::__construct($assetid);
62 require_once SQ_CORE_PACKAGE_PATH.
'/system/system_asset_fns.inc';
63 if (!system_asset_fns_create_pre_check($this)) {
66 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
67 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
69 if ($linkid = parent::create($link)) {
70 if (!system_asset_fns_create_cleanup($this)) {
76 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
78 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
81 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
98 return $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->
type(),
'name');
129 trigger_localised_error(
'CRON0024', E_USER_WARNING, $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->type(),
'name'));
165 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
167 $collections = $fm->getCollections();
171 foreach ($collections as $collection_id => $collection) {
172 $log_path = $fm->getCollectionDataPath($collection_id,
'log');
174 $log_files = glob($log_path.
'/*.log');
175 if (!empty($log_files)) {
176 foreach ($log_files as $log_file) {
177 $log_name = basename($log_file);
180 if ($log_name ==
'click.log')
continue;
183 $archive_name = $log_name.
'.'.date(
'Ymd');
184 $archive_path = $log_path.
'/'.$archive_name;
186 while (file_exists($archive_path)) {
187 $archive_path = $log_path.
'/'.$archive_name.
'.'.((string) $alternative);
190 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
191 move_file($log_file, $archive_path);
195 $rotated[$collection_id] = $archive_path;
198 $period = $fm->attr(
'keep_log_period');
199 if (!empty($period)) {
200 $expiry_date = strtotime(
'-'.((
int) $period).
' months');
201 $archive_logs = glob($log_path.
'/'.$log_name.
'.*');
202 foreach ($archive_logs as $archive_log) {
203 $found_archive_log_name = basename($archive_log);
204 preg_match(
'/log\.([0-9]+)/i', $found_archive_log_name, $match);
205 $log_date = array_get_index($match, 1, 0);
206 if (!empty($log_date)) {
207 $log_date_expiry = strtotime($log_date);
208 if ($log_date_expiry < $expiry_date) {
210 unlink($archive_log);
213 if (isset($rotated[$collection_id]) && $rotated[$collection_id] == $found_archive_log_name) {
214 unset($rotated[$collection_id]);
224 if (!empty($rotated)) {
226 $log_reports = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'funnelback_search_log_report', FALSE, TRUE);
229 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
231 foreach ($log_reports as $reportid => $info) {
232 $report = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($reportid);
234 'assetid' => $reportid,
238 $status = $hh->freestyleHIPO(
'hipo_job_generate_report', $vars);
242 return SQ_CRON_JOB_COMPLETED;
259 $res = parent::run();
260 if ($res & SQ_CRON_JOB_REMOVE) {
261 $res = $res - SQ_CRON_JOB_REMOVE;