123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- class Cronish
- {
-
- public function callTimedEvents()
- {
- $timers = array('minutely' => 60,
- 'hourly' => 3600,
- 'daily' => 86400,
- 'weekly' => 604800);
- foreach($timers as $name=>$interval) {
- $run = false;
- $lastrun = new Config();
- $lastrun->section = 'cron';
- $lastrun->setting = 'last_' . $name;
- $found = $lastrun->find(true);
- if (!$found) {
- $lastrun->value = time();
- if ($lastrun->insert() === false) {
- common_log(LOG_WARNING, "Could not save 'cron' setting '{$name}'");
- continue;
- }
- $run = true;
- } elseif ($lastrun->value < time() - $interval) {
- $orig = clone($lastrun);
- $lastrun->value = time();
- $lastrun->update($orig);
- $run = true;
- }
- if ($run === true) {
-
- Event::handle('Cron' . ucfirst($name));
- }
- }
- }
- }
|