<?php
 class vB_Library_Cron extends vB_Library { public function runById($cronid) { $nextitem = vB::getDbAssertor()->getRow('cron', ['cronid' => $cronid]); $this->runCronInternal($nextitem); } public function runByVarname($varname) { $nextitem = vB::getDbAssertor()->getRow('cron', ['varname' => $varname]); $this->runCronInternal($nextitem); } public function runCron() { require_once(DIR . '/includes/functions_cron.php'); $nextitem = vB::getDbAssertor()->getRow('vBForum:fetchCronByDate', [ 'date' => vB::getRequest()->getTimeNow() ]); if ($nextitem) { if ($nextrun = build_cron_item($nextitem['cronid'], $nextitem)) { $this->tryIncludeCronFile($nextitem); } } else { build_cron_next_run(); } } private function runCronInternal($nextitem) { if ($nextitem) { ignore_user_abort(true); vB_Utility_Functions::setPhpTimeout(0); require_once(DIR . '/includes/functions_cron.php'); $this->tryIncludeCronFile($nextitem); } else { throw new vB_Exception_Api('invalid_action_specified_gerror'); } } private function tryIncludeCronFile($nextitem) { if (empty($nextitem['filename'])) { return; } $cronfile = DIR . '/' . $nextitem['filename']; if (file_exists($cronfile)) { try { include($cronfile); } catch (Throwable $e) { log_cron_exception($e, $nextitem, true); throw $e; } } else { $nextitem['loglevel'] = 1; log_cron_phrase('cron_failed_file_missing', $nextitem); } } } 