예제 #1
0
 static function reCalculateCronjobs($cronjobID = NULL)
 {
     require_once 'includes/libs/tdcron/class.tdcron.php';
     require_once 'includes/libs/tdcron/class.tdcron.entry.php';
     $cronjobsList = array();
     $SQL = "";
     $where = "";
     if (!empty($cronjobID)) {
         $where = " WHERE cronjobID = " . $cronjobID;
     }
     $cronjobsRaw = $GLOBALS['DATABASE']->query("SELECT cronjobID, min, hours, dom, month, dow FROM " . CRONJOBS . $where . ";");
     while ($cronjobRow = $GLOBALS['DATABASE']->fetchArray($cronjobsRaw)) {
         $cronTabString = implode(' ', array($cronjobRow['min'], $cronjobRow['hours'], $cronjobRow['dom'], $cronjobRow['month'], $cronjobRow['dow']));
         $nextTime = tdCron::getNextOccurrence($cronTabString, TIMESTAMP);
         $SQL .= "UPDATE " . CRONJOBS . " SET nextTime = " . $nextTime . " WHERE cronjobID = " . $cronjobRow['cronjobID'] . ";";
     }
     $GLOBALS['DATABASE']->multi_query($SQL);
 }
예제 #2
0
 static function reCalculateCronjobs($cronjobID = NULL)
 {
     require_once 'includes/libs/tdcron/class.tdcron.php';
     require_once 'includes/libs/tdcron/class.tdcron.entry.php';
     $db = Database::get();
     if (!empty($cronjobID)) {
         $sql = 'SELECT cronjobID, min, hours, dom, month, dow FROM %%CRONJOBS%% WHERE cronjobID = :cronjobId;';
         $cronjobResult = $db->select($sql, array(':cronjobId' => $cronjobID));
     } else {
         $sql = 'SELECT cronjobID, min, hours, dom, month, dow FROM %%CRONJOBS%%;';
         $cronjobResult = $db->select($sql);
     }
     $sql = 'UPDATE %%CRONJOBS%% SET nextTime = :nextTime WHERE cronjobID = :cronjobId;';
     foreach ($cronjobResult as $cronjobRow) {
         $cronTabString = implode(' ', array($cronjobRow['min'], $cronjobRow['hours'], $cronjobRow['dom'], $cronjobRow['month'], $cronjobRow['dow']));
         $nextTime = tdCron::getNextOccurrence($cronTabString, TIMESTAMP + 60);
         $db->update($sql, array(':nextTime' => $nextTime, ':cronjobId' => $cronjobRow['cronjobID']));
     }
 }