Exemplo n.º 1
0
 static function get_definitions()
 {
     $v = "";
     $events = ORM::factory("schedule")->order_by("next_run_datetime", "asc")->find_all();
     if ($events->count()) {
         $v = new View("scheduler_definitions.html");
         $v->schedule_definitions = array();
         foreach ($events as $schedule) {
             $entry[] = $schedule->id;
             $entry[] = $schedule->name;
             $run_date = strftime("%A, %b %e, %Y %H:%M ", $schedule->next_run_datetime);
             $intervals = scheduler::intervals();
             $interval = $intervals[$schedule->interval];
             if (!empty($schedule->task_id)) {
                 $status = t("Running");
             } else {
                 if ($schedule->next_run_datetime < time()) {
                     $status = t("Overdue");
                 } else {
                     $status = t("Scheduled");
                 }
             }
             $v->schedule_definitions[] = (object) array("id" => $schedule->id, "name" => $schedule->name, "run_date" => $run_date, "interval" => $interval, "status" => $status);
         }
     }
     return $v;
 }
Exemplo n.º 2
0
 private function _handle_request($method, $id = null)
 {
     $schedule = ORM::factory("schedule", $id);
     $form = scheduler::get_form($method, $schedule);
     $valid = $form->validate();
     if ($valid) {
         $schedule->name = $form->schedule_group->schedule_name->value;
         $schedule->interval = $form->schedule_group->interval->value;
         $schedule->next_run_datetime = $this->_start_date($form->schedule_group->run_date->dow->selected, $form->schedule_group->run_date->time->value);
         $schedule->task_callback = $form->schedule_group->callback->value;
         $schedule->save();
         if ($method == "define") {
             message::success(t("Added scheduled task: %name", array("name" => $schedule->name)));
         } else {
             message::success(t("Updated scheduled task: %name", array("name" => $schedule->name)));
         }
         print json_encode(array("result" => "success", "reload" => 1));
     } else {
         print json_encode(array("result" => "error", "form" => (string) $form));
     }
 }
Exemplo n.º 3
0
<?php

require_once "./team.php";
require_once "./scheduler.php";
// teams for the tournament
$colours = ["red", "green", "yellow", "blue", "orange", "pink", "black", "white"];
$S = new scheduler(51, $colours);
//$S = new scheduler(5, ["red", "blue"]);
// schedule 6 rounds of the game
$S->schedule_fixtures(1);
// play all 6 rounds of the game
$S->play_rounds(6);
foreach ($S->teams as $t) {
    echo "team " . $t->colour . " has " . $t->number_of_players . " players\n";
}
echo "--------------------\n";
$fixtures = $S->get_fixtures();
$cnt = 1;
foreach ($fixtures as $f) {
    echo "Fixture {$cnt}:\n";
    echo "\t-----\n";
    echo "\tPairs (" . sizeof($f['pairs']) . "):\n";
    $i = 1;
    foreach ($f['pairs'] as $p) {
        $status1 = $p[0]->results[$cnt - 1] ? "Winner" : "Loser";
        $status2 = $p[1]->results[$cnt - 1] ? "Winner" : "Loser";
        echo "\t" . $p[0]->name . " (" . $p[0]->team . ", {$status1}) \t\t vs\t\t";
        echo $p[1]->name . " (" . $p[1]->team . ", {$status2}) \n";
    }
    echo "\t-----\n";
    echo "\tUnpaired players:\n";
Exemplo n.º 4
0
 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
 |                                                                         |
 +-------------------------------------------------------------------------+
*/
include "../../include/session.php";
include "include/tables.php";
include "include/fields.php";
include "include/scheduler.php";
$thetable = new scheduler($db, "tbld:83de284b-ef79-3567-145c-30ca38b40796");
$therecord = $thetable->processAddEditPage();
if (isset($therecord["phpbmsStatus"])) {
    $statusmessage = $therecord["phpbmsStatus"];
}
$pageTitle = "Scheduler";
$currentpath = getcwd();
$phpbms->cssIncludes[] = "pages/scheduler.css";
$phpbms->jsIncludes[] = "modules/base/javascript/scheduler.js";
//Form Elements
//==============================================================
$theform = new phpbmsForm();
$theform->id = $theform->name;
$theinput = new inputCheckbox("inactive", $therecord["inactive"]);
$theform->addField($theinput);
$theinput = new inputField("name", $therecord["name"], NULL, true, NULL, 32, 64);
<?php

include "../php/handler.php";
include "../php/scheduler.php";
include "../php/result.php";
$bts_scheduler = new scheduler();
$bts_handler = new handler();
$bts_handler->connect();
$bts_handler->delete_old();
$fehlerDummy = '';
$fehlerRandom = '';
$fehlerRR = '';
$fehlerScheduler = '';
$fehler = false;
if (isset($_POST['senden'])) {
    if ($_POST['senden'] == 'Speichern') {
        if (isset($_POST['name']) && !is_array($_POST['name']) && $_POST['name'] == '') {
            $fehlerDummy .= '<a>Bitte geben Sie einen Namen ein.</a><br />';
            $fehler = true;
        }
        if (!(isset($_POST['cpulaufzeit']) && !is_array($_POST['cpulaufzeit']) && $_POST['cpulaufzeit'] != '' && $_POST['cpulaufzeit'] + 0 > 0 && $_POST['cpulaufzeit'] + 0 < 501)) {
            $fehlerDummy .= '<a>Bitte geben Sie eine CPU Laufzeit von 0 bis max.500 ein. </a><br />';
            $fehler = true;
        }
        if (!(isset($_POST['ankunftszeit']) && !is_array($_POST['ankunftszeit']) && $_POST['ankunftszeit'] != '' && $_POST['ankunftszeit'] + 0 > 0 && $_POST['ankunftszeit'] + 0 < 101)) {
            $fehlerDummy .= '<a>Bitte geben Sie eine Ankunfzeit von 1 bis max.100 ein. </a><br />';
            $fehler = true;
        }
        if (!(isset($_POST['prioritaet']) && !is_array($_POST['prioritaet']) && $_POST['prioritaet'] != '' && $_POST['prioritaet'] + 0 > 0 && $_POST['prioritaet'] + 0 < 101)) {
            $fehlerDummy .= '<a>Bitte geben Sie eine Priorität von 0 bis max.100 ein. </a><br />';
            $fehler = true;
Exemplo n.º 6
0
include $game_path . 'include/functions.php';
include $game_path . 'include/libs/maps.php';
define('TICK_LOG_FILE', $game_path . 'logs/daily.log');
define('IN_SCHEDULER', true);
// we are in the scheduler...
error_reporting(E_ERROR);
if (!empty($_SERVER['SERVER_SOFTWARE'])) {
    echo 'The scheduler can only be called by CLI!';
    exit;
}
// #######################################################################################
// #######################################################################################
// Init
$starttime = microtime() + time();
// create logging facility
$sdl = new scheduler();
// create sql-object for db-connection
$db = new sql($config['server'] . ":" . $config['port'], $config['game_database'], $config['user'], $config['password']);
$game = new game();
$sdl->log('<br><br><br><b>-------------------------------------------------------------</b><br>' . '<b>Starting Daily script at ' . date('d.m.y H:i:s', time()) . '</b>');
// #######################################################################################
// #######################################################################################
// Reset New Registration Count
$sdl->start_job('Reset New Registration Count');
if (!$db->query('UPDATE config SET new_register = 0')) {
    $sdl->log('<b>Error:</b> cannot reset new registration count!');
}
$sdl->finish_job('Reset New Registration Count');
// #######################################################################################
// #######################################################################################
// Check sitting abuse and lock'em
Exemplo n.º 7
0
 static function admin_maintenance_content($maintenance_content)
 {
     $maintenance_content[] = scheduler::get_definitions();
 }
Exemplo n.º 8
0
// we are in the scheduler...
// include commons classes and functions
include 'commons.php';
// ########################################################################################
// ########################################################################################
// Init
$starttime = microtime() + time();
include $game_path . 'include/global.php';
include $game_path . 'include/functions.php';
include $game_path . 'include/text_races.php';
include $game_path . 'include/race_data.php';
include $game_path . 'include/ship_data.php';
include $game_path . 'include/libs/moves.php';
include $game_path . 'include/libs/world.php';
// Needed by NPC BOT
$sdl = new scheduler();
$db = new sql($config['server'] . ":" . $config['port'], $config['game_database'], $config['user'], $config['password']);
// create sql-object for db-connection
$game = new game();
$sdl->log('<br><br><br><b>-------------------------------------------------------------</b><br>' . '<b>Starting Scheduler at ' . date('d.m.y H:i:s', time()) . '</b>');
if (($cfg_data = $db->queryrow('SELECT * FROM config')) === false) {
    $sdl->log('- Fatal: Could not query tick data! ABORTED');
    exit;
}
$ACTUAL_TICK = $cfg_data['tick_id'];
$NEXT_TICK = $cfg_data['tick_time'] - time();
$LAST_TICK_TIME = $cfg_data['tick_time'] - TICK_DURATION * 60;
$STARDATE = $cfg_data['stardate'];
$FUTURE_SHIP = $cfg_data['future_ship'];
if ($cfg_data['tick_stopped']) {
    $sdl->log('Finished Scheduler in ' . round(microtime() + time() - $starttime, 4) . ' secs<br>Tick has been stopped (Unlock in table "config")');
Exemplo n.º 9
0
include 'NPC_BOT.php';
include 'ferengi.php';
include 'borg.php';
include 'settlers.php';
// include commons classes and functions
include 'commons.php';
error_reporting(E_ERROR);
if (!empty($_SERVER['SERVER_SOFTWARE'])) {
    echo 'The scheduler can only be called by CLI!';
    exit;
}
// ########################################################################################
// ########################################################################################
// Init
$starttime = microtime() + time();
$sdl = new scheduler();
$sdl->log('<br><b>-------------------------------------------------------------</b><br>' . '<b>Starting Install BOTs at ' . date('d.m.y H:i:s', time()) . '</b>', INSTALL_LOG_FILE_NPC);
// create sql-object for db-connection
$db = new sql($config['server'] . ":" . $config['port'], $config['game_database'], $config['user'], $config['password']);
$game = new game();
// Install Quark BOT
$quark = new Ferengi($db, $sdl);
$quark->Install();
// Install SevenOfNine BOT
$borg = new Borg($db, $sdl);
$borg->Install();
// Install Settlers BOT
$settlers = new Settlers($db, $sdl);
$settlers->Install();
// ########################################################################################
// ########################################################################################
Exemplo n.º 10
0
define('TICK_LOG_FILE', $game_path . 'logs/fixall/tick_' . date('d-m-Y', time()) . '.log');
define('IN_SCHEDULER', true);
// we are in the scheduler...
// include commons classes and functions
include 'commons.php';
// ########################################################################################
// ########################################################################################
// Init
$starttime = microtime() + time();
include $game_path . 'include/global.php';
include $game_path . 'include/functions.php';
include $game_path . 'include/text_races.php';
include $game_path . 'include/race_data.php';
include $game_path . 'include/ship_data.php';
include $game_path . 'include/libs/moves.php';
$sdl = new scheduler();
$db = new sql($config['server'] . ":" . $config['port'], $config['game_database'], $config['user'], $config['password']);
// create sql-object for db-connection
$sdl->log('<br><br><br><b>-------------------------------------------------------------</b><br>' . '<b>Starting FixAll-Script at ' . date('d.m.y H:i:s', time()) . '</b>');
if (($cfg_data = $db->queryrow('SELECT * FROM config')) === false) {
    $sdl->log('- Fatal: Could not query tick data! ABORTED');
    exit;
}
$ACTUAL_TICK = $cfg_data['tick_id'];
$NEXT_TICK = $cfg_data['tick_time'] - time();
$LAST_TICK_TIME = $cfg_data['tick_time'] - 5 * 60;
$STARDATE = $cfg_data['stardate'];
if ($cfg_data['tick_stopped']) {
    $sdl->log('Finished FixAll-Script in ' . round(microtime() + time() - $starttime, 4) . ' secs<br>Tick has been stopped (Unlock in table "config")');
    exit;
}
Exemplo n.º 11
0
if (isset($_POST['rounds'])) {
    $M = (int) $_POST['rounds'];
}
$id = 0;
$teams = [];
$team_colours = [];
while (isset($_POST["team{$id}"])) {
    $name = $_POST["team{$id}"];
    $colour = $_POST["colour{$id}"];
    $teams[] = $name;
    $team_colours["{$name}"] = $colour;
    $id++;
}
require_once "scheduler.php";
if (sizeof($teams) == sizeof($team_colours) && sizeof($teams) > 0 && $N > 0) {
    $S = new scheduler($N, $teams);
    $S->schedule_fixtures($M);
    $S->play_rounds($M);
    $data = $S->get_fixtures();
    echo "<table id='teams_assigned'>";
    echo "<th>Teams assigned</th>";
    foreach ($S->teams as $t) {
        echo "<tr style='background-color: " . $team_colours[$t->colour] . "'>";
        echo "<td>" . $t->colour . "</td>";
        echo "<td>" . $t->number_of_players . " players</td>";
        echo "<td>List of players: ";
        foreach ($t->players as $pl) {
            echo $pl->name . '  ';
        }
        echo "</td>";
        echo "</tr>";
Exemplo n.º 12
0
define('IN_SCHEDULER', true);
// wir sind im scheduler...
// include commons classes and functions
include 'commons.php';
// ########################################################################################
// ########################################################################################
// Init
$starttime = microtime() + time();
//include($game_path . '/include/sql.php');
include $game_path . 'include/global.php';
include $game_path . 'include/functions.php';
include $game_path . 'include/text_races.php';
include $game_path . 'include/race_data.php';
include $game_path . 'include/ship_data.php';
include $game_path . 'include/libs/moves.php';
$sdl = new scheduler();
$db = new sql($config['server'] . ":" . $config['port'], $config['game_database'], $config['user'], $config['password']);
// create sql-object for db-connection
$game = new game();
$sdl->log('<br><br><br><b>-------------------------------------------------------------</b><br>' . '<b>Starting Scheduler at ' . date('d.m.y H:i:s', time()) . '</b>');
if (($cfg_data = $db->queryrow('SELECT * FROM config')) === false) {
    $sdl->log('- Fatal: Could not query tick data! ABORTED');
    exit;
}
$ACTUAL_TICK = $cfg_data['tick_id'];
$NEXT_TICK = $cfg_data['tick_time'] - time();
$LAST_TICK_TIME = $cfg_data['tick_time'] - TICK_DURATION * 60;
$STARDATE = $cfg_data['stardate'];
if ($cfg_data['tick_stopped']) {
    $sdl->log('Finished Scheduler in ' . round(microtime() + time() - $starttime, 4) . ' secs<br>Tick has been stopped (Unlock in table "config")');
    exit;
Exemplo n.º 13
0
// we are in the scheduler...
// include commons classes and functions
include 'commons.php';
// include BOT class
include 'NPC_BOT.php';
// #######################################################################################
// #######################################################################################
// Init
$starttime = microtime() + time();
include $game_path . 'include/global.php';
include $game_path . 'include/functions.php';
include $game_path . 'include/text_races.php';
include $game_path . 'include/race_data.php';
include $game_path . 'include/ship_data.php';
include $game_path . 'include/libs/moves.php';
$sdl = new scheduler();
$db = new sql($config['server'] . ":" . $config['port'], $config['game_database'], $config['user'], $config['password']);
// create sql-object for db-connection
$game = new game();
$sdl->log('<br><br><br><b>-------------------------------------------------------------</b><br>' . '<b>Starting SixHours-Script at ' . date('d.m.y H:i:s', time()) . '</b>');
if (($cfg_data = $db->queryrow('SELECT * FROM config')) === false) {
    $sdl->log('- Fatal: Could not query tick data! ABORTED');
    exit;
}
$ACTUAL_TICK = $cfg_data['tick_id'];
$NEXT_TICK = $cfg_data['tick_time'] - time();
$LAST_TICK_TIME = $cfg_data['tick_time'] - 5 * 60;
$STARDATE = $cfg_data['stardate'];
if ($cfg_data['tick_stopped']) {
    $sdl->log('Finished SixHours-Script in ' . round(microtime() + time() - $starttime, 4) . ' secs<br>Tick has been stopped (Unlock in table "config")');
    exit;
Exemplo n.º 14
0
<?php

defined('SYSPATH') or die('No direct script access.');
define('BACKUP_PLUGIN_FOLDER', DOCROOT . 'backups' . DIRECTORY_SEPARATOR);
if (!is_dir(BACKUP_PLUGIN_FOLDER)) {
    mkdir(BACKUP_PLUGIN_FOLDER, 0775);
}
Observer::observe('scheduler_callbacks', function () {
    scheduler::add(function ($from, $to) {
        $color = 'green';
        $data = array();
        $handle = opendir(BACKUP_PLUGIN_FOLDER);
        while (false !== ($file = readdir($handle))) {
            if (!preg_match("/(sql|zip)/", $file, $m)) {
                continue;
            }
            $created = filectime(BACKUP_PLUGIN_FOLDER . $file);
            if ($from <= $created and $to >= $created) {
                $data[] = array('title' => 'Backup::(' . $file . ')', 'start' => $created, 'url' => URL::site(Route::get('backend')->uri(array('controller' => 'backup', 'action' => 'view', 'id' => $file))), 'color' => $color, 'allDay' => FALSE);
            }
        }
        closedir($handle);
        return $data;
    });
});
Route::set('backup', ADMIN_DIR_NAME . '/backup(/<action>(/<file>))', array('action' => '(view|delete|restore)', 'file' => '.*'))->defaults(array('controller' => 'backup'));