1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- defined('GNUSOCIAL') || die();
- 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 = hrtime(true);
- if ($lastrun->insert() === false) {
- common_log(LOG_WARNING, "Could not save 'cron' setting '{$name}'");
- continue;
- }
- $run = true;
- } elseif ($lastrun->value < hrtime(true) - $interval * 1000000000) {
- $orig = clone($lastrun);
- $lastrun->value = hrtime(true);
- $lastrun->update($orig);
- $run = true;
- }
- if ($run === true) {
-
- Event::handle('Cron' . ucfirst($name));
- }
- }
- }
- }
|