Example #1
0
 public static function checkAll()
 {
     $job = new cronjob();
     while ($job->found()) {
         $runs = floor((time() - $job->lastrun) / $job->interval);
         if ($runs > 0) {
             $lastrun = $job->lastrun;
             //Update quickly to prevent cron reruns
             $job->lastrun += $runs * $job->interval;
             $job->update();
             require self::$crondir . $job->name . '.php';
             for ($i = 1; $i <= $runs && $i <= self::$maxRuns; $i++) {
                 call_user_func($job->name, $lastrun + $i * $job->interval);
             }
         }
     }
 }
global $dbCronjobNewsLog;
global $dbNewsProcess;
global $dbCronjobErrorLog;
if (!is_object($dbCronjobData)) {
    $dbCronjobData = new dbCronjobData();
}
if (!is_object($dbCronjobNewsLog)) {
    $dbCronjobNewsLog = new dbCronjobNewsletterLog();
}
if (!is_object($dbNewsProcess)) {
    $dbNewsProcess = new dbKITnewsletterProcess();
}
if (!is_object($dbCronjobErrorLog)) {
    $dbCronjobErrorLog = new dbCronjobErrorLog();
}
$cronjob = new cronjob();
$cronjob->action();
class cronjob
{
    const request_key = 'key';
    private $error;
    private $start_script;
    public function __construct()
    {
        $this->start_script = time(true);
    }
    // __construct()
    private function setError($error)
    {
        global $dbCronjobErrorLog;
        $this->error = $error;
	</thead>
	<tbody>';
foreach ($cj->result as $job) {
    if ($next = $job->getNextExecutionTime()) {
        $next = date('d.m.Y H:i:s', $next);
    }
    echo "\n\t<tr>\n\t\t<td>" . htmlspecialchars($job->cronjob_id) . "</td>\n\t\t<td>" . htmlspecialchars($job->server_kurzbz) . "</td>\n\t\t<td>" . htmlspecialchars($job->titel) . "</td>\n\t\t<td>" . ($job->aktiv ? 'Ja' : 'Nein') . "</td>\n\t\t<td>" . $datum_obj->formatDatum($job->last_execute, 'd.m.Y H:i:s') . "</td>\n\t\t<td>" . $next . " (<a href=\"" . $_SERVER['PHP_SELF'] . "?cronjob_id={$job->cronjob_id}&type=execute\">jetzt starten</a>)</td>\n\t\t<td><a href=\"" . $_SERVER['PHP_SELF'] . "?cronjob_id={$job->cronjob_id}&type=edit\">details</a></td>\n\t\t<td><a href=\"" . $_SERVER['PHP_SELF'] . "?cronjob_id={$job->cronjob_id}&type=delete\">entfernen</a></td>\n\t</tr>";
}
echo '</tbody></table>';
// Neu anlegen eines Jobs
if (isset($_GET['type']) && ($_GET['type'] == 'edit' || $_GET['type'] == 'new')) {
    if (!$rechte->isBerechtigt('basis/cronjob', null, 'suid')) {
        die('Sie haben keine Berechtigung zum Bearbeiten der Daten');
    }
    //Formular zum Editieren und neu Anlegen der Daten anzeigen
    $cj = new cronjob();
    echo '<br><hr><br>';
    if ($_GET['type'] == 'edit') {
        if (!isset($_GET['cronjob_id'])) {
            die('Fehlerhafte Parameteruebergabe');
        }
        if (!$cj->load($_GET['cronjob_id'])) {
            die('Fehler beim Laden des Eintrages');
        }
        $cj->new = false;
        echo '<h3>Details zu Cronjob ' . $cj->cronjob_id . '</h3>';
    } else {
        echo '<h3>Neuer Cronjob</h3>';
        $cj->new = true;
    }
    echo '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '?type=save">';
Example #4
0
 * Authors: Christian Paminger 		< *****@*****.** >
 *          Andreas Oesterreicher 	< *****@*****.** >
 *          Rudolf Hangl 			< *****@*****.** >
 *          Gerald Simane-Sequens 	< *****@*****.** >
 */
/**
 * Cronjob.php
 * 
 * Dieses Script muss in der Crontab eingetragen werden. Von hier aus werden dann
 * die entsprechenden anderen Scripte aufgerufen.
 */
require_once dirname(__FILE__) . '/../../config/vilesci.config.inc.php';
require_once dirname(__FILE__) . '/../../include/cronjob.class.php';
require_once dirname(__FILE__) . '/../../include/datum.class.php';
$datum = new datum();
$cj = new cronjob();
if (!$cj->getAll(SERVER_NAME, 'reihenfolge', true)) {
    die('Fehler beim Laden der Cronjobs');
}
foreach ($cj->result as $cronjob) {
    $timestamp = $cronjob->getNextExecutionTime();
    if ($timestamp && time() >= $timestamp) {
        //Starten des Jobs
        if ($cronjob->execute()) {
            echo date('d.m.Y H:i:s') . ' ' . $cronjob->titel . '(' . $cronjob->cronjob_id . ') executed<br>' . "\n";
        } else {
            echo date('d.m.Y H:i:s') . ' ' . $cronjob->titel . '(' . $cronjob->cronjob_id . ') <b>failed</b><br>' . "\n";
        }
    }
}
?>