コード例 #1
0
ファイル: test_bots.php プロジェクト: csiki/Croupier
                    if (file_exists('../../data/logs/' . $gameid . '.xml')) {
                        $xml = simplexml_load_file('../../data/logs/' . $gameid . '.xml');
                        foreach ($xml->event as $event) {
                            if ((int) $event->logger == $botid && $event->severity == 1) {
                                // error found
                                $alrighty = false;
                                break;
                            }
                        }
                        if ($alrighty) {
                            SQL("UPDATE bots SET state = 'ok', runError = '0' WHERE id = ?", $botid);
                            $tablesToAdd = SQL("SELECT leaderboardID FROM compiling_bots_leaderboards WHERE botID = ?", $botid);
                            for ($i = 0; $i < count($tablesToAdd); $i++) {
                                $leaderboard = SQL("SELECT * FROM leaderboards WHERE id = ?", $tablesToAdd[$i]["leaderboardID"]);
                                $loaded_leaderboard = new Leaderboard($leaderboard[0]);
                                $loaded_leaderboard->addBot($botid);
                            }
                            SQL("DELETE FROM compiling_bots_leaderboards WHERE botID = ?", $botid);
                        } else {
                            SQL("UPDATE bots SET state = 'runtime', runError = ? WHERE id = ?", $gameid, $botid);
                        }
                    }
                } else {
                    SQL("UPDATE bots SET state='runtime', runError = ? WHERE id = ?", $gameid, $botid);
                }
            }
        } else {
            SQL("UPDATE bots SET state = 'compilation', compError = ? WHERE id = ?", $stderr, $botid);
        }
    }
}
コード例 #2
0
ファイル: participate_bot.php プロジェクト: csiki/Croupier
needLogin();
if (isset($_GET["leaderboardID"]) && isset($_GET["botID"]) && isset($_GET["action"])) {
    //validate
    $lbID = $_GET["leaderboardID"];
    $botID = $_GET["botID"];
    $action = $_GET["action"];
    if (is_numeric($lbID) && is_numeric($botID) && ($action == "1" || $action == "0")) {
        //get bot and add to leaderboard
        $res = SQL("SELECT COUNT(*) FROM bots WHERE id = ? AND accountID = ?", $botID, $_SESSION["accountID"]);
        if ($res == null) {
            echo 0;
            exit;
        }
        $leaderboard = SQL("SELECT * FROM leaderboards WHERE id = ?", $lbID);
        if ($leaderboard == null) {
            echo 0;
            exit;
        }
        $loaded_leaderboard = new Leaderboard($leaderboard[0]);
        if ($action == "1") {
            $loaded_leaderboard->addBot($botID);
        } else {
            $loaded_leaderboard->removeBot($botID);
        }
        echo '1';
    } else {
        die("Invalid request");
    }
} else {
    die("Invalid request");
}