コード例 #1
0
ファイル: update.php プロジェクト: eb/phptourney
         dbQuery("INSERT INTO `{$cfg['db_table_prefix']}maps` " . "(`id_match`,`id_map`,`score_p1`,`score_p2`,`comment_p1`,`comment_p2`,`comment_admin`,`num_map`) " . "VALUES({$matches_row['id']},{$id_map}," . "{$score_p1},{$score_p2}," . "'{$comment_p1}','{$comment_p2}'," . "'{$comment_admin}',{$i}) ");
     }
 }
 // Insert next matches
 if ($score_p1 > $score_p2) {
     $id_winner = $matches_row['id_player1'];
     $id_loser = $matches_row['id_player2'];
 } elseif ($score_p1 < $score_p2) {
     $id_winner = $matches_row['id_player2'];
     $id_loser = $matches_row['id_player1'];
 }
 $old_winner_match = getWinnerMatch($matches_row);
 $new_winner_match = insertWinnerMatch($matches_row, $id_winner);
 notifyPlayers($new_winner_match, $old_winner_match);
 $old_loser_match = getLoserMatch($matches_row);
 $new_loser_match = insertLoserMatch($matches_row, $id_loser);
 notifyPlayers($new_loser_match, $old_loser_match);
 // Tourney finished?
 if ($new_winner_match == NULL) {
     dbQuery("UPDATE `{$cfg['db_table_prefix']}seasons` SET `status` = 'finished' " . "WHERE `id` = {$season['id']}");
 }
 // Send match report to irc
 if ($cfg['bot_public_targets'] != "") {
     $irc_channels = explode(";", $cfg['bot_public_targets']);
     foreach ($irc_channels as $irc_channel) {
         if ($cfg['bot_enabled'] and $cfg['bot_host'] != "" and $cfg['bot_port'] != "") {
             $bot_socket = fsockopen($cfg['bot_host'], $cfg['bot_port']);
         } else {
             $bot_socket = NULL;
         }
         if ($bot_socket and ($score_p1 > $score_p2 and $matches_row['score_p1'] <= $matches_row['score_p2'] or $score_p1 < $score_p2 and $matches_row['score_p1'] >= $matches_row['score_p2'] or $matches_row['confirmed'] == "0000-00-00 00:00:00")) {
コード例 #2
0
ファイル: delete.php プロジェクト: eb/phptourney
// Access for admins only
if ($user['usertype_admin']) {
    $id_match = intval($_REQUEST['opt']);
    $matches_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}matches` WHERE `id` = {$id_match}");
    $matches_row = dbFetch($matches_ref);
    if (isLastMatch($matches_row)) {
        dbQuery("UPDATE `{$cfg['db_table_prefix']}matches` SET " . "`submitted` = '0000-00-00 00:00:00', " . "`confirmed` = '0000-00-00 00:00:00' " . "WHERE `id` = {$matches_row['id']}");
        // Delete screenshots
        for ($i = 1; $i <= $matches_row['num_winmaps'] * 2 - 1; $i++) {
            $sshot_dir = "data/screenshots/{$season['id']}/";
            $dst_file = $sshot_dir . "{$season['id']}-{$matches_row['bracket']}-{$matches_row['round']}-{$matches_row['match']}-m{$i}";
            if (file_exists($dst_file . ".jpg")) {
                unlink($dst_file . ".jpg");
            }
            if (file_exists($dst_file . "_thumb.jpg")) {
                unlink($dst_file . "_thumb.jpg");
            }
        }
        // Delete next matches
        $winner_match = insertWinnerMatch($matches_row, 0);
        $loser_match = insertLoserMatch($matches_row, 0);
        $content_tpl->parse("H_MESSAGE_MATCH_REMOVED", "B_MESSAGE_MATCH_REMOVED");
        $content_tpl->parse("H_MESSAGE", "B_MESSAGE");
    } else {
        $content_tpl->parse("H_WARNING_DELETE", "B_WARNING_DELETE");
        $content_tpl->parse("H_WARNING", "B_WARNING");
    }
} else {
    $content_tpl->parse("H_WARNING_NO_ACCESS", "B_WARNING_NO_ACCESS");
    $content_tpl->parse("H_WARNING", "B_WARNING");
}