Beispiel #1
0
<?php

include_once "php/include.php";
needLogin();
function getBotStateText($state, $botID)
{
    global $tr;
    switch ($state) {
        case 'ok':
            return $tr["STATE_OK"];
        case 'processing':
            return $tr["STATE_PROCESSING"];
        case 'compilation':
            return "<a href=\"show_compileError.php?botID=" . $botID . "\">" . $tr["STATE_COMPILATION"] . "</a>";
        case 'runtime':
            return $tr["STATE_RUNTIME"];
    }
}
if (isset($_GET["botID"]) && is_numeric($_GET["botID"])) {
    $botID = $_GET["botID"];
    $bot = SQL("SELECT state FROM bots WHERE id = ? AND accountID = ?", $botID, $_SESSION["accountID"]);
    if ($bot == null) {
        echo 'null';
    } else {
        echo json_encode([$bot[0]["state"] != "processing", getBotStateText($bot[0]["state"], $botID)]);
    }
} else {
    echo 'null';
}
Beispiel #2
0
</th>
            </tr>
            </thead>
            <tbody>
            <?php 
$leaderboards = array();
$res = SQL("SELECT * FROM leaderboards");
foreach ($res as $lb) {
    $leaderboards[] = new Leaderboard($lb);
}
$bots = SQL("SELECT id, name, lastChangeTime, code_lang, state, compError, runError\n                        FROM bots WHERE accountID = ?", $_SESSION["accountID"]);
if ($bots == null) {
    $bots = array();
}
foreach ($bots as $bot) {
    $stateColumn = getBotStateText($bot["state"], $bot["id"]);
    echo '<tr data-botID="' . $bot["id"] . '" data-compiling="' . ($bot["state"] == "processing" ? "true" : "false") . '">';
    echo '<td class="botName">' . $bot["name"] . '</td>';
    echo '<td>' . $bot["lastChangeTime"] . '</td>';
    echo '<td>' . $bot["code_lang"] . '</td>';
    echo '<td class="botState">' . $stateColumn . '</td>';
    $botLeaderboards = array();
    foreach ($leaderboards as $leaderboard) {
        if ($leaderboard->isBotParticipating($bot["id"]) && $leaderboard->isActivated()) {
            $botLeaderboards[] = $leaderboard->getFirendlyName();
        }
    }
    echo '<td>' . (count($botLeaderboards) > 0 ? implode(", ", $botLeaderboards) : " - ") . '</td>';
    echo '<td style="cursor:pointer" onclick="document.location = \'played_games.php?id=' . $bot["id"] . '\';">' . '<div class="icon playedGamesIcon" title="' . $tr["PLAYED_GAMES"] . '"></div></td>';
    echo '<td style="cursor:pointer" onclick="document.location = \'edit_bot.php?id=' . $bot["id"] . '\';">
                    <div class="icon editIcon" title="' . $tr["EDIT_BOT"] . '"></div></td>';