예제 #1
0
파일: event.php 프로젝트: testt98/ebattles
    function brackets($scheduleNextMatches = false, $delete_match_id = 0, $style = '')
    {
        global $sql;
        global $time;
        global $pref;
        global $tp;
        global $gold_obj;
        $this->updateFields();
        $type = $this->fields['Type'];
        $competition_type = $this->getCompetitionType();
        $format = $this->fields['Format'];
        $event_id = $this->fields['EventID'];
        $teams = $this->getTeams();
        //var_dump($teams);
        $results = unserialize($this->getFieldHTML('Results'));
        $update_results = false;
        // TODO: check for error (return false)
        $rounds = unserialize($this->getFieldHTML('Rounds'));
        $matchups = $this->getMatchups();
        $nbrRounds = count($matchups);
        $nbrRows = 4 * count($matchups[1]);
        /* */
        $brackets = array();
        $content = array();
        // Initialize grid
        for ($row = 1; $row <= $nbrRows; $row++) {
            for ($column = 1; $column <= $nbrRounds; $column++) {
                $brackets[$row][2 * $column - 1] = '<td class="grid empty"></td>';
                $brackets[$row][2 * $column] = '<td class="grid border-none"></td>';
            }
        }
        $rowspan = 1;
        for ($round = 1; $round <= $nbrRounds; $round++) {
            $nbrMatchups = count($matchups[$round]);
            $rounds[$round]['nbrMatchups'] = 0;
            if ($round < $nbrRounds) {
                for ($matchup = 1; $matchup <= $nbrMatchups; $matchup++) {
                    if (!isset($results[$round][$matchup]['matchs'])) {
                        $results[$round][$matchup]['winner'] = 'not played';
                        $results[$round][$matchup]['bye'] = false;
                    }
                    if (!isset($results[$round][$matchup]['winner'])) {
                        $results[$round][$matchup]['winner'] = 'not played';
                    }
                    if (!isset($results[$round][$matchup]['bye'])) {
                        $results[$round][$matchup]['bye'] = false;
                    }
                    if (!isset($matchups[$round][$matchup]['deleted'])) {
                        $matchups[$round][$matchup]['deleted'] = false;
                    }
                    /* Nbr of matches in the matchup */
                    $nbr_matchs = count($results[$round][$matchup]['matchs']);
                    $matchup_deleted = false;
                    for ($match = 0; $match < 2; $match++) {
                        $matchupString = $matchups[$round][$matchup][$match];
                        $content[$round][$matchup][$match] = $matchupString == '' ? 'E' : $matchupString;
                        if ($matchupString == '') {
                            $row = findRow($round, $matchup, $match, $style);
                            $matchupsRows[$round][$matchup][$match] = $row;
                        } else {
                            if ($matchupString[0] == 'T') {
                                $row = findRow($round, $matchup, $match, $style);
                                $matchupsRows[$round][$matchup][$match] = $row;
                                $team = substr($matchupString, 1);
                                if (empty($teams[$team - 1])) {
                                    $content[$round][$matchup][$match] = 'E';
                                }
                            }
                            if ($matchupString[0] == 'W') {
                                $matchupArray = explode(',', substr($matchupString, 1));
                                $matchupRound = $matchupArray[0];
                                $matchupMatchup = $matchupArray[1];
                                // Get result of matchup
                                $winner = $results[$matchupRound][$matchupMatchup]['winner'];
                                $bye = $results[$matchupRound][$matchupMatchup]['bye'];
                                $deleted = $matchups[$matchupRound][$matchupMatchup]['deleted'];
                                $rowTop = $matchupsRows[$matchupRound][$matchupMatchup][0];
                                $rowBottom = $matchupsRows[$matchupRound][$matchupMatchup][1];
                                $row = ($rowBottom - $rowTop) / 2 + $rowTop;
                                // If result is not a bye, we draw the grid
                                if ($bye != true) {
                                    $brackets[$rowTop][2 * $round - 2] = '<td class="grid border-top"></td>';
                                    $brackets[$rowBottom][2 * $round - 2] = '<td class="grid border-bottom"></td>';
                                    for ($i = $rowTop + 1; $i < $rowBottom; $i++) {
                                        $brackets[$i][2 * $round - 2] = '<td class="grid border-vertical"></td>';
                                    }
                                    for ($i = $rowTop + 2; $i < $rowBottom; $i++) {
                                        $brackets[$i][2 * $round - 3] = '';
                                    }
                                    $brackets[$row][2 * $round - 2] = '<td class="grid border-middle"></td>';
                                }
                                $matchupsRows[$round][$matchup][$match] = $row;
                                if ($winner == 'top') {
                                    $content[$round][$matchup][$match] = $content[$matchupRound][$matchupMatchup][0];
                                } else {
                                    if ($winner == 'bottom') {
                                        $content[$round][$matchup][$match] = $content[$matchupRound][$matchupMatchup][1];
                                    } else {
                                        // Not played
                                        // Detect if match has been previously scheduled and needs to be deleted
                                        if ($nbr_matchs > 0) {
                                            $deleted = true;
                                        }
                                    }
                                }
                                if ($deleted == true) {
                                    $matchup_deleted = true;
                                }
                            }
                            if ($matchupString[0] == 'L' || $matchupString[0] == 'P') {
                                $matchupArray = explode(',', substr($matchupString, 1));
                                $matchupRound = $matchupArray[0];
                                $matchupMatchup = $matchupArray[1];
                                // Get result of matchup
                                $winner = $results[$matchupRound][$matchupMatchup]['winner'];
                                $bye = $results[$matchupRound][$matchupMatchup]['bye'];
                                $deleted = $matchups[$matchupRound][$matchupMatchup]['deleted'];
                                $row = findRow($round, $matchup, $match, $style);
                                $matchupsRows[$round][$matchup][$match] = $row;
                                if ($winner == 'top') {
                                    $loser = $content[$matchupRound][$matchupMatchup][1];
                                    if ($loser[0] == 'T') {
                                        $team = substr($loser, 1);
                                        //echo "M$round,$matchup: L2: $team,".$teams[$team-1]['loss'].'<br>';
                                        if ($teams[$team - 1]['loss'] > 1) {
                                            $content[$round][$matchup][$match] = 'N';
                                        } else {
                                            $content[$round][$matchup][$match] = $loser;
                                        }
                                    } else {
                                        $content[$round][$matchup][$match] = 'E';
                                    }
                                } else {
                                    if ($winner == 'bottom') {
                                        $loser = $content[$matchupRound][$matchupMatchup][0];
                                        if ($loser[0] == 'T') {
                                            $team = substr($loser, 1);
                                            //echo "M$round,$matchup: L2: $team,".$teams[$team-1]['loss'].'<br>';
                                            if ($teams[$team - 1]['loss'] > 1) {
                                                $content[$round][$matchup][$match] = 'N';
                                            } else {
                                                $content[$round][$matchup][$match] = $loser;
                                            }
                                        } else {
                                            $content[$round][$matchup][$match] = 'E';
                                        }
                                    } else {
                                        // Not played
                                        // Detect if match has been previously scheduled and needs to be deleted
                                        if ($nbr_matchs > 0) {
                                            $deleted = true;
                                        }
                                    }
                                }
                                if ($deleted == true) {
                                    $matchup_deleted = true;
                                }
                            }
                        }
                        switch ($content[$round][$matchup][$match]) {
                            case 'E':
                                $results[$round][$matchup]['winner'] = $match == 0 ? 'bottom' : 'top';
                                $results[$round][$matchup]['bye'] = true;
                                break;
                            case 'N':
                                $results[$round][$matchup]['winner'] = $match == 0 ? 'bottom' : 'top';
                                break;
                            case 'F':
                                $results[$round][$matchup]['winner'] = $match == 0 ? 'bottom' : 'top';
                                break;
                        }
                    }
                    // for(match)
                    /* Match deletion*/
                    if ($nbr_matchs > 0) {
                        $match_deleted = false;
                        for ($match = 0; $match < $nbr_matchs; $match++) {
                            if ($results[$round][$matchup]['matchs'][$match]['match_id'] == $delete_match_id || $match_deleted == true || $matchup_deleted == true) {
                                /*
                                var_dump($results[$round][$matchup]);
                                var_dump($delete_match_id);
                                var_dump($match_deleted);
                                var_dump($matchup_deleted);
                                */
                                $update_results = true;
                                $current_match_id = $results[$round][$matchup]['matchs'][$match]['match_id'];
                                echo "match " . $current_match_id . " deleted (M{$round},{$matchup},{$match})<br>";
                                $current_match = new Match($current_match_id);
                                $current_match->deleteMatchScores();
                                $results[$round][$matchup]['winner'] = 'not played';
                                $results[$round][$matchup]['topWins'] = 0;
                                $results[$round][$matchup]['bottomWins'] = 0;
                                $results[$round][$matchup]['winner'] = 'not played';
                                unset($results[$round][$matchup]['matchs'][$match]);
                                $match_deleted = true;
                                if ($this->getField('Status') == 'finished' && $competition_type == 'Tournament') {
                                    // if tournament was finished, we need to remove awards
                                    $this->setFieldDB('Status', 'active');
                                    // Find who got the award for winning the tournament
                                    switch ($type) {
                                        case "One Player Tournament":
                                            $q = "SELECT " . TBL_PLAYERS . ".*, " . TBL_GAMERS . ".*, " . TBL_EVENTS . ".*, " . TBL_AWARDS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_EVENTS . ", " . TBL_AWARDS . " WHERE (" . TBL_PLAYERS . ".PlayerID = " . TBL_AWARDS . ".Player)" . "   AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . "   AND (" . TBL_PLAYERS . ".Event = '{$event_id}')" . "   AND (" . TBL_AWARDS . ".Type = 'PlayerWonTournament')";
                                            $result = $sql->db_Query($q);
                                            $pid = mysql_result($result, 0, TBL_PLAYERS . ".PlayerID");
                                            $uid = mysql_result($result, 0, TBL_GAMERS . ".User");
                                            $aid = mysql_result($result, 0, TBL_AWARDS . ".AwardID");
                                            $q = "DELETE FROM " . TBL_AWARDS . " WHERE (" . TBL_AWARDS . ".AwardID = '{$aid}')";
                                            $result = $sql->db_Query($q);
                                            // gold
                                            if (is_gold_system_active() && $this->getField('GoldWinningEvent') > 0) {
                                                $gold_param['gold_user_id'] = $uid;
                                                $gold_param['gold_who_id'] = 0;
                                                $gold_param['gold_amount'] = $this->getField('GoldWinningEvent');
                                                $gold_param['gold_type'] = EB_L1;
                                                $gold_param['gold_action'] = "debit";
                                                $gold_param['gold_plugin'] = "ebattles";
                                                $gold_param['gold_log'] = EB_GOLD_L8 . ": event=" . $event_id . ", user="******"Clan Tournament":
                                            $q = "SELECT " . TBL_TEAMS . ".*, " . TBL_DIVISIONS . ".*, " . TBL_EVENTS . ".*, " . TBL_AWARDS . ".*" . " FROM " . TBL_TEAMS . ", " . TBL_DIVISIONS . ", " . TBL_EVENTS . ", " . TBL_AWARDS . " WHERE (" . TBL_TEAMS . ".TeamID = " . TBL_AWARDS . ".Team)" . "   AND (" . TBL_TEAMS . ".Division = " . TBL_DIVISIONS . ".DivisionID)" . "   AND (" . TBL_TEAMS . ".Event = '{$event_id}')" . "   AND (" . TBL_AWARDS . ".Type = 'TeamWonTournament')";
                                            $result = $sql->db_Query($q);
                                            $pid = mysql_result($result, 0, TBL_TEAMS . ".TeamID");
                                            $uid = mysql_result($result, 0, TBL_DIVISIONS . ".Captain");
                                            $aid = mysql_result($result, 0, TBL_AWARDS . ".AwardID");
                                            $q = "DELETE FROM " . TBL_AWARDS . " WHERE (" . TBL_AWARDS . ".AwardID = '{$aid}')";
                                            $result = $sql->db_Query($q);
                                            // gold
                                            if (is_gold_system_active() && $this->getField('GoldWinningEvent') > 0) {
                                                $gold_param['gold_user_id'] = $uid;
                                                $gold_param['gold_who_id'] = 0;
                                                $gold_param['gold_amount'] = $this->getField('GoldWinningEvent');
                                                $gold_param['gold_type'] = EB_L1;
                                                $gold_param['gold_action'] = "debit";
                                                $gold_param['gold_plugin'] = "ebattles";
                                                $gold_param['gold_log'] = EB_GOLD_L8 . ": event=" . $event_id . ", user="******"SELECT " . TBL_MATCHS . ".*, " . TBL_SCORES . ".*, " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$current_match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_GAMERS . ".User)" . " ORDER BY " . TBL_SCORES . ".Player_Rank, " . TBL_SCORES . ".Player_MatchTeam";
                                                break;
                                            case 'Teams':
                                                $q = "SELECT " . TBL_MATCHS . ".*, " . TBL_SCORES . ".*, " . TBL_CLANS . ".*, " . TBL_TEAMS . ".*, " . TBL_DIVISIONS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_CLANS . ", " . TBL_TEAMS . ", " . TBL_DIVISIONS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$current_match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_CLANS . ".ClanID = " . TBL_DIVISIONS . ".Clan)" . " AND (" . TBL_TEAMS . ".Division = " . TBL_DIVISIONS . ".DivisionID)" . " ORDER BY " . TBL_SCORES . ".Player_Rank, " . TBL_SCORES . ".Player_MatchTeam";
                                                break;
                                            default:
                                        }
                                        $result = $sql->db_Query($q);
                                        $numScores = mysql_numrows($result);
                                        if ($numScores > 0) {
                                            for ($i = 0; $i < $numScores; $i++) {
                                                switch ($this->getMatchPlayersType()) {
                                                    case 'Players':
                                                        $pid = mysql_result($result, $i, TBL_PLAYERS . ".PlayerID");
                                                        break;
                                                    case 'Teams':
                                                        $pid = mysql_result($result, $i, TBL_TEAMS . ".TeamID");
                                                        break;
                                                    default:
                                                }
                                                $pscoreid = mysql_result($result, $i, TBL_SCORES . ".ScoreID");
                                                $prank = mysql_result($result, $i, TBL_SCORES . ".Player_Rank");
                                                $pscore = mysql_result($result, $i, TBL_SCORES . ".Player_Score");
                                                $pMatchTeam = mysql_result($result, $i, TBL_SCORES . ".Player_MatchTeam");
                                                $teamTop = substr($content[$round][$matchup][0], 1);
                                                $teamBottom = substr($content[$round][$matchup][1], 1);
                                                $results[$round][$matchup]['matchs'][$match]['scores'][$i] = $pscore;
                                                if ($i == 0) {
                                                    $teamTopID = $teams[$teamTop - 1]['PlayerID'];
                                                    $teamBottomID = $teams[$teamBottom - 1]['PlayerID'];
                                                    if ($teamTopID == $pid) {
                                                        $current_match_winner = 'top';
                                                    } else {
                                                        $current_match_winner = 'bottom';
                                                    }
                                                    $results[$round][$matchup]['matchs'][$match]['winner'] = $current_match_winner;
                                                }
                                            }
                                        }
                                    }
                                }
                                // match not played
                                $matchupWinnerID = 0;
                                if ($current_match_winner == 'top') {
                                    $results[$round][$matchup]['topWins'] += 1;
                                    if ($results[$round][$matchup]['topWins'] == ($rounds[$round]['BestOf'] + 1) / 2) {
                                        $results[$round][$matchup]['winner'] = 'top';
                                        $matchupWinnerID = $teamTopID;
                                        //echo "Match $matchs, top won<br>";
                                    }
                                }
                                // winner==top
                                if ($current_match_winner == 'bottom') {
                                    $results[$round][$matchup]['bottomWins'] += 1;
                                    if ($results[$round][$matchup]['bottomWins'] == ($rounds[$round]['BestOf'] + 1) / 2) {
                                        $results[$round][$matchup]['winner'] = 'bottom';
                                        $matchupWinnerID = $teamBottomID;
                                        //echo "Match $matchs, bottom won<br>";
                                    }
                                }
                                // winner==bottom
                                if ($matchupWinnerID != 0) {
                                    if ($round == $nbrRounds - 1 && $competition_type == 'Tournament') {
                                        // player has won the tournament
                                        $this->setFieldDB('Status', 'finished');
                                        // Award: player wins tournament
                                        switch ($type) {
                                            case "One Player Tournament":
                                                $q_Award = "INSERT INTO " . TBL_AWARDS . "(Player,Type,timestamp)\r\n\t\t\t\t\t\t\t\t\t\t\tVALUES ({$matchupWinnerID},'PlayerWonTournament',{$time})";
                                                $result_Award = $sql->db_Query($q_Award);
                                                // gold
                                                if (is_gold_system_active() && $this->getField('GoldWinningEvent') > 0) {
                                                    // find player's user_id
                                                    $q = "SELECT " . TBL_PLAYERS . ".*, " . TBL_GAMERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . " WHERE (" . TBL_PLAYERS . ".PlayerID = '{$matchupWinnerID}')" . "   AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)";
                                                    $result = $sql->db_Query($q);
                                                    $uid = mysql_result($result, 0, TBL_GAMERS . ".User");
                                                    $gold_param['gold_user_id'] = $uid;
                                                    $gold_param['gold_who_id'] = 0;
                                                    $gold_param['gold_amount'] = $this->getField('GoldWinningEvent');
                                                    $gold_param['gold_type'] = EB_L1;
                                                    $gold_param['gold_action'] = "credit";
                                                    $gold_param['gold_plugin'] = "ebattles";
                                                    $gold_param['gold_log'] = EB_GOLD_L8 . ": event=" . $event_id . ", user="******"Clan Tournament":
                                                $q_Award = "INSERT INTO " . TBL_AWARDS . "(Team,Type,timestamp)\r\n\t\t\t\t\t\t\t\t\t\t\tVALUES ({$matchupWinnerID},'TeamWonTournament',{$time})";
                                                $result_Award = $sql->db_Query($q_Award);
                                                // gold
                                                if (is_gold_system_active() && $this->getField('GoldWinningEvent') > 0) {
                                                    // find team captain
                                                    $q = "SELECT " . TBL_TEAMS . ".*, " . TBL_DIVISIONS . ".*" . " FROM " . TBL_TEAMS . ", " . TBL_DIVISIONS . " WHERE (" . TBL_TEAMS . ".TeamID = '{$matchupWinnerID}')" . "   AND (" . TBL_TEAMS . ".Division = " . TBL_DIVISIONS . ".DivisionID)";
                                                    $result = $sql->db_Query($q);
                                                    $uid = mysql_result($result, 0, TBL_DIVISIONS . ".Captain");
                                                    $gold_param['gold_user_id'] = $uid;
                                                    $gold_param['gold_who_id'] = 0;
                                                    $gold_param['gold_amount'] = $this->getField('GoldWinningEvent');
                                                    $gold_param['gold_type'] = EB_L1;
                                                    $gold_param['gold_action'] = "credit";
                                                    $gold_param['gold_plugin'] = "ebattles";
                                                    $gold_param['gold_log'] = EB_GOLD_L8 . ": event=" . $event_id . ", user="******"M$round,$matchup: L1: $team,".$teams[$team-1]['loss'].'<br>';
                            }
                        } else {
                            if ($results[$round][$matchup]['winner'] == 'bottom') {
                                $brackets[$matchupsRows[$round][$matchup][0]][2 * $round - 1] = html_bracket_team_cell($teams, $content[$round][$matchup][0], $topWins, 'loser');
                                $brackets[$matchupsRows[$round][$matchup][1]][2 * $round - 1] = html_bracket_team_cell($teams, $content[$round][$matchup][1], $bottomWins, 'winner');
                                $loser = $content[$round][$matchup][0];
                                if ($loser[0] == 'T') {
                                    $team = substr($loser, 1);
                                    $teams[$team - 1]['loss'] += 1;
                                    //echo "M$round,$matchup: L1: $team,".$teams[$team-1]['loss'].'<br>';
                                }
                            } else {
                                $brackets[$matchupsRows[$round][$matchup][0]][2 * $round - 1] = html_bracket_team_cell($teams, $content[$round][$matchup][0], $topWins);
                                $brackets[$matchupsRows[$round][$matchup][1]][2 * $round - 1] = html_bracket_team_cell($teams, $content[$round][$matchup][1], $bottomWins);
                            }
                        }
                        $matchup_string = '';
                        if ($nbr_matchs > 0) {
                            $tbl = array();
                            for ($match = 0; $match < $nbr_matchs; $match++) {
                                $match_id = $results[$round][$matchup]['matchs'][$match]['match_id'];
                                $match_winner = $results[$round][$matchup]['matchs'][$match]['winner'];
                                $score_0 = $results[$round][$matchup]['matchs'][$match]['scores'][0];
                                $score_1 = $results[$round][$matchup]['matchs'][$match]['scores'][1];
                                $score_0_str = '&nbsp;';
                                $score_1_str = '&nbsp;';
                                if ($this->getField('AllowScore') == TRUE) {
                                    if (isset($score_0)) {
                                        $score_0_str = $score_0;
                                    }
                                    if (isset($score_1)) {
                                        $score_1_str = $score_1;
                                    }
                                }
                                switch ($match_winner) {
                                    case 'top':
                                        $class_str = 'match-winner';
                                        $score_str = $score_0_str;
                                        $match_link_str = '<a href="' . e_PLUGIN . 'ebattles/matchinfo.php?matchid=' . $match_id . '"><div class="' . $class_str . '" title="' . EB_MATCH_L1 . ' ' . ($match + 1) . '">' . $score_str . '</div></a>';
                                        $tbl[$match][0] = '<td>' . $match_link_str . '</td>';
                                        $class_str = 'match-loser';
                                        $score_str = $score_1_str;
                                        $match_link_str = '<a href="' . e_PLUGIN . 'ebattles/matchinfo.php?matchid=' . $match_id . '"><div class="' . $class_str . '" title="' . EB_MATCH_L1 . ' ' . ($match + 1) . '">' . $score_str . '</div></a>';
                                        $tbl[$match][1] = '<td>' . $match_link_str . '</td>';
                                        break;
                                    case 'bottom':
                                        $class_str = 'match-loser';
                                        $score_str = $score_1_str;
                                        $match_link_str = '<a href="' . e_PLUGIN . 'ebattles/matchinfo.php?matchid=' . $match_id . '"><div class="' . $class_str . '" title="' . EB_MATCH_L1 . ' ' . ($match + 1) . '">' . $score_str . '</div></a>';
                                        $tbl[$match][0] = '<td>' . $match_link_str . '</td>';
                                        $class_str = 'match-winner';
                                        $score_str = $score_0_str;
                                        $match_link_str = '<a href="' . e_PLUGIN . 'ebattles/matchinfo.php?matchid=' . $match_id . '"><div class="' . $class_str . '" title="' . EB_MATCH_L1 . ' ' . ($match + 1) . '">' . $score_str . '</div></a>';
                                        $tbl[$match][1] = '<td>' . $match_link_str . '</td>';
                                        break;
                                    default:
                                        $class_str = 'match-not-played';
                                        $matchObj = new Match($match_id);
                                        $permissions = $matchObj->get_permissions(USERID);
                                        $userclass = $permissions['userclass'];
                                        $can_report = $permissions['can_report'];
                                        $can_approve = $permissions['can_approve'];
                                        $can_delete = $permissions['can_delete'];
                                        $can_edit = $permissions['can_edit'];
                                        $match_link_str = '';
                                        $tbl[$match][0] = '';
                                        if ($can_approve == 1) {
                                            $match_link_str = ' <a href="' . e_PLUGIN . 'ebattles/matchinfo.php?matchid=' . $match_id . '"><img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/exclamation.png" alt="' . EB_MATCH_L13 . '" title="' . EB_MATCH_L13 . '"/></a>';
                                            $tbl[$match][0] .= '<td rowspan="2" class="' . $class_str . '"><div class="' . $class_str . '" title="' . EB_MATCH_L1 . ' ' . ($match + 1) . '">' . $match_link_str . '</div></td>';
                                        }
                                        /*
                                        if($can_edit == 1)
                                        {
                                        	if($matchObj->getField('Status') == 'scheduled')
                                        	{
                                        		$match_link_str = ebImageLink('matchschedulededit', EB_MATCHR_L46, '', e_PLUGIN.'ebattles/matchreport.php?eventid='.$event_id.'&amp;matchid='.$match_id.'&amp;actionid=matchschedulededit&amp;userclass='.$userclass, 'page_white_edit.png', '', 'matchreport_link', '', EB_MATCHR_L46.' '.($match+1));
                                        		$tbl[$match][0] .= '<td rowspan="2" class="'.$class_str.'"><div class="'.$class_str.'">'.$match_link_str.'</div></td>';
                                        	}
                                        	else
                                        	{
                                        		$match_link_str = ebImageLink('matchedit', EB_MATCHR_L46, '', e_PLUGIN.'ebattles/matchreport.php?eventid='.$event_id.'&amp;matchid='.$match_id.'&amp;actionid=matchedit&amp;userclass='.$userclass, 'page_white_edit.png', '', 'matchreport_link', '', EB_MATCHR_L46.' '.($match+1));
                                        		$tbl[$match][0] .= '<td rowspan="2" class="'.$class_str.'"><div class="'.$class_str.'">'.$match_link_str.'</div></td>';
                                        	}		
                                        }
                                        */
                                        if ($can_report == 1) {
                                            $match_link_str = ebImageLink('matchscheduledreport', EB_MATCHR_L32, '', e_PLUGIN . 'ebattles/matchreport.php?eventid=' . $event_id . '&amp;matchid=' . $match_id . '&amp;actionid=matchscheduledreport&amp;userclass=' . $userclass, 'report.png', '', 'matchreport_link', '', EB_MATCHR_L32 . ' ' . ($match + 1));
                                            $tbl[$match][0] .= '<td rowspan="2" class="' . $class_str . '"><div class="' . $class_str . '" title="' . EB_MATCH_L1 . ' ' . ($match + 1) . '">' . $match_link_str . '</div></td>';
                                        }
                                        $tbl[$match][1] = '';
                                        break;
                                }
                            }
                            $matchup_string = '<table class="brackets-matchup"><tbody>';
                            $matchup_string .= '<tr>';
                            for ($match = 0; $match < $nbr_matchs; $match++) {
                                $matchup_string .= $tbl[$match][0];
                            }
                            $matchup_string .= '</tr>';
                            $matchup_string .= '<tr>';
                            for ($match = 0; $match < $nbr_matchs; $match++) {
                                $matchup_string .= $tbl[$match][1];
                            }
                            $matchup_string .= '</tr>';
                            $matchup_string .= '</tbody></table>';
                            //echo $tbl_str;
                        }
                        switch ($style) {
                            case 'elimination':
                                $brackets[$matchupsRows[$round][$matchup][0] + 1][2 * $round - 1] = '<td rowspan="' . $rowspan . '" class="match-details" title="' . EB_EVENT_L102 . ' ' . $round . ',' . $matchup . '">
							' . $matchup_string . '
							</td>';
                                break;
                            case 'round-robin':
                                $brackets[$matchupsRows[$round][$matchup][1] + 1][2 * $round - 1] = '<td rowspan="1" class="match-details" title="' . EB_EVENT_L102 . ' ' . $round . ',' . $matchup . '">
							' . $matchup_string . '
							</td>';
                                break;
                        }
                        $rounds[$round]['nbrMatchups']++;
                    }
                    // if(content!='E')
                    if ($scheduleNextMatches == true && $content[$round][$matchup][0][0] == 'T' && $content[$round][$matchup][1][0] == 'T' && $results[$round][$matchup]['winner'] == 'not played') {
                        $update_results = true;
                        $current_match = $results[$round][$matchup]['matchs'][$nbr_matchs - 1];
                        //var_dump($current_match);
                        if (!isset($current_match) || $current_match['winner'] != 'not played') {
                            /*
                            echo 'M'.$round.','.$matchup.':<br>';
                            var_dump($results[$round][$matchup]);
                            var_dump($content[$round][$matchup]);
                            */
                            // Need to schedule the next match
                            // Create Match ------------------------------------------
                            $reported_by = $this->getField('Owner');
                            $time_reported = $time;
                            $comments = '';
                            $time_scheduled = $time_reported;
                            $q = "INSERT INTO " . TBL_MATCHS . "(Event,ReportedBy,TimeReported, Comments, Status, TimeScheduled)\r\n\t\t\t\t\t\t\tVALUES ({$event_id},'{$reported_by}', {$time_reported}, '{$comments}', 'scheduled', {$time_scheduled})";
                            $result = $sql->db_Query($q);
                            $last_id = mysql_insert_id();
                            $match_id = $last_id;
                            // Create Scores ------------------------------------------
                            $teamTop = substr($content[$round][$matchup][0], 1);
                            $teamBottom = substr($content[$round][$matchup][1], 1);
                            switch ($this->getMatchPlayersType()) {
                                case 'Players':
                                    $playerTopID = $teams[$teamTop - 1]['PlayerID'];
                                    $playerBottomID = $teams[$teamBottom - 1]['PlayerID'];
                                    $teamTopID = 0;
                                    $teamBottomID = 0;
                                    break;
                                case 'Teams':
                                    $playerTopID = 0;
                                    $playerBottomID = 0;
                                    $teamTopID = $teams[$teamTop - 1]['PlayerID'];
                                    $teamBottomID = $teams[$teamBottom - 1]['PlayerID'];
                                    break;
                            }
                            $q = "INSERT INTO " . TBL_SCORES . "(MatchID,Player,Team,Player_MatchTeam,Player_Rank)\r\n\t\t\t\t\t\t\tVALUES ({$match_id},{$playerTopID},{$teamTopID},1,1)\r\n\t\t\t\t\t\t\t";
                            $result = $sql->db_Query($q);
                            $q = "INSERT INTO " . TBL_SCORES . "(MatchID,Player,Team,Player_MatchTeam,Player_Rank)\r\n\t\t\t\t\t\t\tVALUES ({$match_id},{$playerBottomID},{$teamBottomID},2,2)\r\n\t\t\t\t\t\t\t";
                            $result = $sql->db_Query($q);
                            $match_array = array();
                            $match_array['winner'] = 'not played';
                            $match_array['match_id'] = $match_id;
                            $results[$round][$matchup]['matchs'][$nbr_matchs] = $match_array;
                            if ($nbr_matchs == 0) {
                                // Send notification to all the players.
                                $fromid = 0;
                                $subject = SITENAME . " " . EB_MATCHR_L52;
                                switch ($this->getMatchPlayersType()) {
                                    case 'Players':
                                        $q_Players = "SELECT DISTINCT " . TBL_USERS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******".user_id)";
                                        $result_Players = $sql->db_Query($q_Players);
                                        $numPlayers = mysql_numrows($result_Players);
                                        break;
                                    case 'Teams':
                                        $q_Players = "SELECT DISTINCT " . TBL_USERS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******".user_id)";
                                        $result_Players = $sql->db_Query($q_Players);
                                        $numPlayers = mysql_numrows($result_Players);
                                        break;
                                    default:
                                }
                                if ($numPlayers > 0) {
                                    for ($j = 0; $j < $numPlayers; $j++) {
                                        $pname = mysql_result($result_Players, $j, TBL_USERS . ".user_name");
                                        $pemail = mysql_result($result_Players, $j, TBL_USERS . ".user_email");
                                        $message = EB_MATCHR_L53 . $pname . EB_MATCHR_L54 . EB_MATCHR_L55 . $this->getField('Name') . EB_MATCHR_L56;
                                        $sendto = mysql_result($result_Players, $j, TBL_USERS . ".user_id");
                                        $sendtoemail = mysql_result($result_Players, $j, TBL_USERS . ".user_email");
                                        if (check_class($pref['eb_pm_notifications_class'])) {
                                            // Send PM
                                            sendNotification($sendto, $subject, $message, $fromid);
                                        }
                                        if (check_class($pref['eb_email_notifications_class'])) {
                                            // Send email
                                            require_once e_HANDLER . "mail.php";
                                            sendemail($sendtoemail, $subject, $message);
                                        }
                                    }
                                }
                            }
                            // if(nbr_matchs==0)
                        }
                        // create match
                    }
                    // schedule next match
                    /*
                    echo 'M'.$round.','.$matchup.':<br>';
                    var_dump($results[$round][$matchup]);
                    var_dump($content[$round][$matchup]);
                    echo '- matchup: top='.$matchups[$round][$matchup][0].', bottom='.$matchups[$round][$matchup][1].'<br>';
                    echo '- content: top='.$content[$round][$matchup][0].', bottom='.$content[$round][$matchup][1].'<br>';
                    echo '- winner='.$results[$round][$matchup]['winner'].', bye='.$results[$round][$matchup]['bye'].'<br>';
                    */
                }
                // for(matchup)
            } else {
                /* Last round, no match */
                for ($matchup = 1; $matchup <= $nbrMatchups; $matchup++) {
                    if (!isset($results[$round][$matchup]['winner'])) {
                        $results[$round][$matchup]['winner'] = '';
                    }
                    if (!isset($results[$round][$matchup]['bye'])) {
                        $results[$round][$matchup]['bye'] = false;
                    }
                    $match = 0;
                    $matchupString = $matchups[$round][$matchup][$match];
                    $content[$round][$matchup][$match] = $matchupString == '' ? 'E' : $matchupString;
                    if ($matchupString[$match] = 'W') {
                        $matchupArray = explode(',', substr($matchupString, 1));
                        $matchupRound = $matchupArray[0];
                        $matchupMatchup = $matchupArray[1];
                        $winner = $results[$matchupRound][$matchupMatchup]['winner'];
                        $bye = $results[$matchupRound][$matchupMatchup]['bye'];
                        $rowTop = $matchupsRows[$matchupRound][$matchupMatchup][0];
                        $rowBottom = $matchupsRows[$matchupRound][$matchupMatchup][1];
                        $row = ($rowBottom - $rowTop) / 2 + $rowTop;
                        if ($bye != true) {
                            $brackets[$rowTop][2 * $round - 2] = '<td class="grid border-top"></td>';
                            $brackets[$rowBottom][2 * $round - 2] = '<td class="grid border-bottom"></td>';
                            for ($i = $rowTop + 1; $i < $rowBottom; $i++) {
                                $brackets[$i][2 * $round - 2] = '<td class="grid border-vertical"></td>';
                            }
                            for ($i = $rowTop + 2; $i < $rowBottom; $i++) {
                                $brackets[$i][2 * $round - 3] = '';
                            }
                            $brackets[$row][2 * $round - 2] = '<td class="grid border-middle"></td>';
                        }
                        $matchupsRows[$round][$matchup][$match] = $rowTop;
                        if ($winner == 'top') {
                            $content[$round][$matchup][$match] = $content[$matchupRound][$matchupMatchup][0];
                        } else {
                            if ($winner == 'bottom') {
                                $content[$round][$matchup][$match] = $content[$matchupRound][$matchupMatchup][1];
                            }
                        }
                        $topWins = $results[$round][$matchup]['topWins'];
                        $bottomWins = $results[$round][$matchup]['bottomWins'];
                        if ($topWins > $bottomWins) {
                            $topWins .= '+';
                            $bottomWins .= '-';
                        }
                        if ($topWins < $bottomWins) {
                            $topWins .= '-';
                            $bottomWins .= '+';
                        }
                        if ($content[$round][$matchup][0][0] != 'E') {
                            $brackets[$row][2 * $round - 1] = html_bracket_team_cell($teams, $content[$round][$matchup][$match], $topWins, 'victor');
                        } else {
                            $brackets[$row][2 * $round - 1] = html_bracket_team_cell($teams, $content[$round][$matchup][$match], $bottomWins);
                        }
                    }
                }
                // for(matchup)
            }
            $rowspan = 2 * $rowspan + 1;
        }
        $bracket_html = '<div id="panel_brackets">';
        $bracket_html .= '<div id="brackets_frame" style="height: 400px;">';
        $bracket_html .= '<div id="brackets">';
        $bracket_html .= '<table class="brackets">';
        $bracket_html .= '<thead><tr>';
        for ($i = 1; $i < $nbrRounds; $i++) {
            if ($rounds[$i]['nbrMatchups'] != 0) {
                $bracket_html .= '<th colspan="2" title="' . EB_EVENTM_L146 . ' ' . $rounds[$i]['BestOf'] . '">';
                $bracket_html .= $rounds[$i]['Title'] . '<br />';
                $bracket_html .= '<div class="smalltext">' . EB_EVENTM_L146 . ' ' . $rounds[$i]['BestOf'] . '</div>';
                $bracket_html .= '</th>';
            } else {
                $bracket_html .= '<th colspan="2"></th>';
            }
        }
        $bracket_html .= '</tr></thead>';
        $bracket_html .= '<tbody>';
        for ($row = 1; $row <= $nbrRows; $row++) {
            $bracket_html .= '<tr>';
            for ($column = 1; $column <= 2 * $nbrRounds; $column++) {
                $bracket_html .= $brackets[$row][$column];
            }
            $bracket_html .= '</tr>';
        }
        $bracket_html .= '</tbody>';
        $bracket_html .= '</table>';
        $bracket_html .= '</div>';
        // brackets
        $bracket_html .= '</div>';
        // brackets_frame
        $bracket_html .= '<div class="clearer"></div>';
        $bracket_html .= '</div>';
        // panel-brackets
        /*
        echo "rounds:<br>";
        var_dump($rounds);
        echo "matchups:<br>";
        var_dump($matchups);
        echo "results:<br>";
        var_dump($results);
        echo "content:<br>";
        var_dump($content);
        echo "teams:<br>";
        var_dump($teams);
        */
        if ($update_results == true) {
            $this->updateResults($results);
            $this->updateFieldDB('Results');
        }
        return array($bracket_html);
    }
예제 #2
0
/**
* displayEvents - Displays the events database table in
* a nicely formatted html table.
*/
function displayPastEvents()
{
    global $sql;
    global $text;
    global $time;
    $pages = new Paginator();
    $array = array('latest' => array(EB_EVENTS_L4, 'EventID'), 'name' => array(EB_EVENTS_L5, TBL_EVENTS . '.Name'), 'game' => array(EB_EVENTS_L6, TBL_GAMES . '.Name'), 'type' => array(EB_EVENTS_L7, TBL_EVENTS . '.Type'), 'start' => array(EB_EVENTS_L8, TBL_EVENTS . '.StartDateTime'));
    if (!isset($_GET['gameid'])) {
        $_GET['gameid'] = "All";
    }
    $gameid = eb_sanitize($_GET['gameid']);
    if (!isset($_GET['matchtype'])) {
        $_GET['matchtype'] = "All";
    }
    $matchtype = eb_sanitize($_GET['matchtype']);
    if (!isset($_GET['orderby'])) {
        $_GET['orderby'] = 'game';
    }
    $orderby = eb_sanitize($_GET['orderby']);
    $sort = "ASC";
    if (isset($_GET["sort"]) && !empty($_GET["sort"])) {
        $sort = $_GET["sort"] == "ASC" ? "DESC" : "ASC";
    }
    $game_string = $gameid == "All" ? "" : "   AND (" . TBL_EVENTS . ".Game = '{$gameid}')";
    $matchtype_string = $matchtype == "All" ? "" : "   AND (" . TBL_GAMES . ".MatchTypes LIKE '%{$matchtype}%')";
    // Drop down list to select Games to display
    $q_Games = "SELECT DISTINCT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES . ", " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $matchtype_string . " ORDER BY Name";
    $result_Games = $sql->db_Query($q_Games);
    $numGames = mysql_numrows($result_Games);
    // Drop down list to select Match type to display
    $q_mt = "SELECT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES . ", " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $game_string;
    $result_mt = $sql->db_Query($q_mt);
    $num_mt = mysql_numrows($result_mt);
    $gmatchtypes = '';
    for ($i = 0; $i < $num_mt; $i++) {
        $gmatchtypes .= ',' . mysql_result($result_mt, $i, TBL_GAMES . ".MatchTypes");
    }
    $text .= '<form id="submitform" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="get">';
    $text .= '<div>';
    $text .= '<table class="table_left">';
    $text .= '<tr>';
    // Games drop down
    $text .= '<td>' . EB_EVENTS_L9 . '<br />';
    $text .= '<select class="tbox" name="gameid" onchange="this.form.submit()">';
    $text .= '<option value="All" ' . ($gameid == "All" ? 'selected="selected"' : '') . '>' . EB_EVENTS_L10 . '</option>';
    for ($i = 0; $i < $numGames; $i++) {
        $gName = mysql_result($result_Games, $i, TBL_GAMES . ".Name");
        $gid = mysql_result($result_Games, $i, TBL_GAMES . ".GameID");
        $text .= '<option value="' . $gid . '" ' . ($gameid == $gid ? 'selected="selected"' : '') . '>' . htmlspecialchars($gName) . '</option>';
    }
    $text .= '</select>';
    $text .= '</td>';
    // Match Types drop down
    $text .= '<td>' . EB_EVENTS_L32 . '<br />';
    $text .= '<select class="tbox" name="matchtype" onchange="this.form.submit()">';
    $text .= '<option value="All" ' . ($matchtype == "All" ? 'selected="selected"' : '') . '>' . EB_EVENTS_L10 . '</option>';
    $gmatchtypes = explode(",", $gmatchtypes);
    $gmatchtypes = array_unique($gmatchtypes);
    sort($gmatchtypes);
    foreach ($gmatchtypes as $gmatchtype) {
        if ($gmatchtype != '') {
            $text .= '<option value="' . $gmatchtype . '" ' . ($gmatchtype == $matchtype ? 'selected="selected"' : '') . '>' . htmlspecialchars($gmatchtype) . '</option>';
        }
    }
    $text .= '</select>';
    $text .= '</td>';
    $text .= '</tr>';
    $text .= '</table>';
    $game_string = $gameid == "All" ? "" : "   AND (" . TBL_EVENTS . ".Game = '{$gameid}')";
    $matchtype_string = $matchtype == "All" ? "" : "   AND (" . TBL_EVENTS . ".MatchType = '{$matchtype}')";
    $q = "SELECT count(*) " . " FROM " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Status = 'finished')" . $game_string . $matchtype_string;
    $result = $sql->db_Query($q);
    $totalItems = mysql_result($result, 0);
    $pages->items_total = $totalItems;
    $pages->mid_range = eb_PAGINATION_MIDRANGE;
    $pages->paginate();
    $orderby_array = $array["{$orderby}"];
    $q = "SELECT " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_EVENTS . ".Status = 'finished')" . "   AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $game_string . $matchtype_string . " ORDER BY {$orderby_array['1']} {$sort}, EventID DESC" . " {$pages->limit}";
    $result = $sql->db_Query($q);
    $numEvents = mysql_numrows($result);
    if (!$result || $numEvents < 0) {
        /* Error occurred, return given name by default */
        $text .= EB_EVENTS_L11 . '</div>';
        $text .= '</form><br/>';
    } else {
        if ($numEvents == 0) {
            $text .= EB_EVENTS_L12 . '</div>';
            $text .= '</form><br/>';
        } else {
            // Paginate & Sorting
            $items = '';
            foreach ($array as $opt => $opt_array) {
                $items .= $opt == $orderby ? '<option selected="selected" value="' . $opt . '">' . $opt_array[0] . '</option>' : '<option value="' . $opt . '">' . $opt_array[0] . '</option>';
            }
            // Paginate
            $text .= '<span class="paginate" style="float:left;">' . $pages->display_pages() . '</span>';
            $text .= '<span style="float:right">';
            // Sort By
            $text .= EB_PGN_L6;
            $text .= '<select class="tbox" name="orderby" onchange="this.form.submit()">';
            $text .= $items;
            $text .= '</select>';
            // Up/Down arrow
            $text .= '<input type="hidden" id="sort" name="sort" value=""/>';
            if ($sort == "ASC") {
                $text .= '<a href="javascript:buttonval(\'ASC\');" title="Ascending"><img src="' . e_PLUGIN . 'ebattles/images/sort_asc.gif" alt="Asc" style="vertical-align:middle; border:0"/></a>';
            } else {
                $text .= '<a href="javascript:buttonval(\'DESC\');" title="Descending"><img src="' . e_PLUGIN . 'ebattles/images/sort_desc.gif" alt="Desc" style="vertical-align:middle; border:0"/></a>';
            }
            $text .= '&nbsp;&nbsp;&nbsp;';
            // Go To Page
            $text .= $pages->display_jump_menu();
            $text .= '&nbsp;&nbsp;&nbsp;';
            // Items per page
            $text .= $pages->display_items_per_page();
            $text .= '</span>';
            $text .= '</div>';
            $text .= '</form><br/><br/>';
            /* Display table contents */
            $text .= '<table class="eb_table" style="width:95%"><tbody>';
            $text .= '<tr>
		<th class="eb_th2">' . EB_EVENTS_L13 . '</th>
		<th colspan="2" class="eb_th2">' . EB_EVENTS_L14 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L15 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L16 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L17 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L18 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L19 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L34 . '</th>
		</tr>';
            for ($i = 0; $i < $numEvents; $i++) {
                $gName = mysql_result($result, $i, TBL_GAMES . ".Name");
                $gIcon = mysql_result($result, $i, TBL_GAMES . ".Icon");
                $event_id = mysql_result($result, $i, TBL_EVENTS . ".EventID");
                $event = new Event($event_id);
                if ($event->getField('StartDateTime') != 0) {
                    $startdatetime_local = $event->getField('StartDateTime') + TIMEOFFSET;
                    $date_start = date("d M Y", $startdatetime_local);
                } else {
                    $date_start = "-";
                }
                if ($event->getField('EndDateTime') != 0) {
                    $enddatetime_local = $event->getField('EndDateTime') + TIMEOFFSET;
                    $date_end = date("d M Y", $enddatetime_local);
                } else {
                    $date_end = "-";
                }
                /* Nbr players */
                $q_2 = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (Event = '{$event_id}')";
                $result_2 = $sql->db_Query($q_2);
                $row = mysql_fetch_array($result_2);
                $nbrplayers = $row['NbrPlayers'];
                /* Nbr Teams */
                $q_2 = "SELECT COUNT(*) as NbrTeams" . " FROM " . TBL_TEAMS . " WHERE (" . TBL_TEAMS . ".Event = '{$event_id}')";
                $result_2 = $sql->db_Query($q_2);
                $row = mysql_fetch_array($result_2);
                $nbrTeams = $row['NbrTeams'];
                /* Nbr matches */
                $q_2 = "SELECT COUNT(DISTINCT " . TBL_MATCHS . ".MatchID) as NbrMatches" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (Event = '{$event_id}')" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)";
                $result_2 = $sql->db_Query($q_2);
                $row = mysql_fetch_array($result_2);
                $nbrmatches = $row['NbrMatches'];
                switch ($event->getField('Type')) {
                    case "One Player Ladder":
                    case "One Player Tournament":
                        $nbrTeamPlayers = $nbrplayers;
                        break;
                    case "Team Ladder":
                        $nbrTeamPlayers = $nbrTeams . '/' . $nbrplayers;
                        break;
                    case "Clan Ladder":
                    case "Clan Tournament":
                        $nbrTeamPlayers = $nbrTeams;
                        break;
                    default:
                }
                $text .= '<tr>
			<td class="eb_td"><a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . $event->getField('Name') . '</a></td>
			<td class="eb_td"><img ' . getGameIconResize($gIcon) . '/></td>
			<td class="eb_td">' . $gName . '</td>
			<td class="eb_td">' . ($event->getField('MatchType') != '' ? $event->getField('MatchType') . ' - ' : '') . $event->eventTypeToString() . '</td>
			<td class="eb_td">' . $date_start . '</td>
			<td class="eb_td">' . $date_end . '</td>
			<td class="eb_td">' . $nbrTeamPlayers . '</td>
			<td class="eb_td">' . $nbrmatches . '</td>
			<td class="eb_td">' . $event->eventStatusToString() . '</td>
			</tr>';
            }
            $text .= '</tbody></table><br />';
            $text .= '<div>';
            $text .= ebImageLink('back_to_events', '', e_PLUGIN . 'ebattles/events.php', '', 'action_back.gif', EB_EVENTP_L3 . ' ' . EB_EVENTP_L4, 'jq-button');
            $text .= '</div>';
        }
    }
}
예제 #3
0
파일: events.php 프로젝트: testt98/ebattles
function displayRecentEvents()
{
    global $pref;
    global $sql;
    global $text;
    global $time;
    $pages = new Paginator();
    // how many rows to show per page
    $rowsPerPage = $pref['eb_default_items_per_page'];
    if (!isset($_GET['gameid'])) {
        $_GET['gameid'] = "All";
    }
    $gameid = eb_sanitize($_GET['gameid']);
    if (!isset($_GET['matchtype'])) {
        $_GET['matchtype'] = "All";
    }
    $matchtype = eb_sanitize($_GET['matchtype']);
    $game_string = $gameid == "All" ? "" : "   AND (" . TBL_EVENTS . ".Game = '{$gameid}')";
    $matchtype_string = $matchtype == "All" ? "" : "   AND (" . TBL_GAMES . ".MatchTypes LIKE '%{$matchtype}%')";
    // Drop down list to select Games to display
    $q_Games = "SELECT DISTINCT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES . ", " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $matchtype_string . " ORDER BY Name";
    $result_Games = $sql->db_Query($q_Games);
    $numGames = mysql_numrows($result_Games);
    if ($numGames > 0) {
        //$text .= '<div>'.$uname.'&nbsp;'.EB_USER_L35.'</div>';
        // Display list of games icons
        $games_links_list = '<div class="spacer">';
        for ($i = 0; $i < $numGames; $i++) {
            $gname = mysql_result($result_Games, $i, TBL_GAMES . ".Name");
            $gicon = mysql_result($result_Games, $i, TBL_GAMES . ".Icon");
            $gid = mysql_result($result_Games, $i, TBL_GAMES . ".GameID");
            if ($gameid == "All") {
                $gname_selected = EB_EVENTS_L10;
            }
            if ($gid == $gameid) {
                $gname_selected = $gname;
            }
            $games_links_list .= '<a href="' . e_PLUGIN . 'ebattles/events.php?gameid=' . $gid . '"><img ' . getGameIconResize($gicon) . ' title="' . $gname . '"/></a>';
            $games_links_list .= '&nbsp;';
        }
        $games_links_list .= '<br /><b>' . $gname_selected . '</b></div><br />';
    }
    $text .= $games_links_list;
    // Drop down list to select Match type to display
    $q_mt = "SELECT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES . ", " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $game_string;
    $result_mt = $sql->db_Query($q_mt);
    $num_mt = mysql_numrows($result_mt);
    $gmatchtypes = '';
    for ($i = 0; $i < $num_mt; $i++) {
        $gmatchtypes .= ',' . mysql_result($result_mt, $i, TBL_GAMES . ".MatchTypes");
    }
    $text .= '<form id="submitformrecent" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="get">';
    $text .= '<div>';
    $text .= '<table class="table_left">';
    $text .= '<tr>';
    // Match Types drop down
    $text .= '<td>' . EB_EVENTS_L32 . '<br />';
    $text .= '<select class="tbox" name="matchtype" onchange="this.form.submit()">';
    $text .= '<option value="All" ' . ($matchtype == "All" ? 'selected="selected"' : '') . '>' . EB_EVENTS_L10 . '</option>';
    $gmatchtypes = explode(",", $gmatchtypes);
    $gmatchtypes = array_unique($gmatchtypes);
    sort($gmatchtypes);
    foreach ($gmatchtypes as $gmatchtype) {
        if ($gmatchtype != '') {
            $text .= '<option value="' . $gmatchtype . '" ' . ($gmatchtype == $matchtype ? 'selected="selected"' : '') . '>' . htmlspecialchars($gmatchtype) . '</option>';
        }
    }
    $text .= '</select>';
    $text .= '</td>';
    $text .= '</tr>';
    $text .= '</table>';
    $game_string = $gameid == "All" ? "" : "   AND (" . TBL_EVENTS . ".Game = '{$gameid}')";
    $matchtype_string = $matchtype == "All" ? "" : "   AND (" . TBL_EVENTS . ".MatchType = '{$matchtype}')";
    $q = "SELECT " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_EVENTS . ".Status = 'finished')" . "   AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $game_string . $matchtype_string . " LIMIT 0, {$rowsPerPage}";
    $result = $sql->db_Query($q);
    $numEvents = mysql_numrows($result);
    if (!$result || $numEvents < 0) {
        /* Error occurred, return given name by default */
        $text .= EB_EVENTS_L11 . '</div>';
        $text .= '</form><br/>';
    } else {
        if ($numEvents == 0) {
            $text .= EB_EVENTS_L12 . '</div>';
            $text .= '</form><br/>';
        } else {
            $text .= '</div>';
            $text .= '</form><br/><br/>';
            /* Display table contents */
            $text .= '<table class="eb_table" style="width:95%"><tbody>';
            $text .= '<tr>
		<th class="eb_th2">' . EB_EVENTS_L13 . '</th>';
            if ($gameid == "All") {
                $text .= '<th colspan="2" class="eb_th2">' . EB_EVENTS_L14 . '</th>';
            }
            $text .= '
		<th class="eb_th2">' . EB_EVENTS_L15 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L16 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L17 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L18 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L19 . '</th>
		<th class="eb_th2">' . EB_EVENTS_L34 . '</th>
		</tr>';
            for ($i = 0; $i < $numEvents; $i++) {
                $gName = mysql_result($result, $i, TBL_GAMES . ".Name");
                $gIcon = mysql_result($result, $i, TBL_GAMES . ".Icon");
                $event_id = mysql_result($result, $i, TBL_EVENTS . ".EventID");
                $event = new Event($event_id);
                if ($event->getField('StartDateTime') != 0) {
                    $startdatetime_local = $event->getField('StartDateTime') + TIMEOFFSET;
                    $date_start = date("d M Y", $startdatetime_local);
                } else {
                    $date_start = "-";
                }
                if ($event->getField('EndDateTime') != 0) {
                    $enddatetime_local = $event->getField('EndDateTime') + TIMEOFFSET;
                    $date_end = date("d M Y", $enddatetime_local);
                } else {
                    $date_end = "-";
                }
                /* Nbr players */
                $q_2 = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (Event = '{$event_id}')";
                $result_2 = $sql->db_Query($q_2);
                $row = mysql_fetch_array($result_2);
                $nbrplayers = $row['NbrPlayers'];
                /* Nbr Teams */
                $q_2 = "SELECT COUNT(*) as NbrTeams" . " FROM " . TBL_TEAMS . " WHERE (" . TBL_TEAMS . ".Event = '{$event_id}')";
                $result_2 = $sql->db_Query($q_2);
                $row = mysql_fetch_array($result_2);
                $nbrTeams = $row['NbrTeams'];
                /* Nbr matches */
                $q_2 = "SELECT COUNT(DISTINCT " . TBL_MATCHS . ".MatchID) as NbrMatches" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (Event = '{$event_id}')" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)";
                $result_2 = $sql->db_Query($q_2);
                $row = mysql_fetch_array($result_2);
                $nbrmatches = $row['NbrMatches'];
                switch ($event->getField('Type')) {
                    case "One Player Ladder":
                    case "One Player Tournament":
                        $nbrTeamPlayers = $nbrplayers;
                        break;
                    case "Team Ladder":
                        $nbrTeamPlayers = $nbrTeams . '/' . $nbrplayers;
                        break;
                    case "Clan Ladder":
                    case "Clan Tournament":
                        $nbrTeamPlayers = $nbrTeams;
                        break;
                    default:
                }
                $text .= '<tr>
			<td class="eb_td"><a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . $event->getField('Name') . '</a></td>';
                if ($gameid == "All") {
                    $text .= '<td class="eb_td"><img ' . getGameIconResize($gIcon) . '/></td>
				<td class="eb_td">' . $gName . '</td>';
                }
                $text .= '
			<td class="eb_td">' . ($event->getField('MatchType') != '' ? $event->getField('MatchType') . ' - ' : '') . $event->eventTypeToString() . '</td>
			<td class="eb_td">' . $date_start . '</td>
			<td class="eb_td">' . $date_end . '</td>
			<td class="eb_td">' . $nbrTeamPlayers . '</td>
			<td class="eb_td">' . $nbrmatches . '</td>
			<td class="eb_td">' . $event->eventStatusToString() . '</td>
			</tr>';
            }
            $text .= '</tbody></table><br />';
            $text .= '<div>';
            $text .= ebImageLink('link_to_eventspast', '', e_PLUGIN . 'ebattles/eventspast.php', '', 'action_back.gif', EB_EVENTS_L21, 'jq-button');
            $text .= '</div>';
        }
    }
}
예제 #4
0
$text .= '<span class="paginate" style="float:left;">' . $pages->display_pages() . '</span>';
$text .= '<span style="float:right">';
// Go To Page
$text .= $pages->display_jump_menu();
$text .= '&nbsp;&nbsp;&nbsp;';
// Items per page
$text .= $pages->display_items_per_page();
$text .= '</span><br /><br />';
/* Stats/Results */
$q = "SELECT DISTINCT " . TBL_MATCHS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (" . TBL_MATCHS . ".Event = '{$event_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " ORDER BY " . TBL_MATCHS . ".TimeReported DESC" . " {$pages->limit}";
$result = $sql->db_Query($q);
$num_rows = mysql_numrows($result);
if ($num_rows > 0) {
    /* Display table contents */
    $text .= '<table class="table_left">';
    for ($i = 0; $i < $num_rows; $i++) {
        $match_id = mysql_result($result, $i, TBL_MATCHS . ".MatchID");
        $match = new Match($match_id);
        $text .= $match->displayMatchInfo(eb_MATCH_NOEVENTINFO);
    }
    $text .= '</table>';
}
$text .= '<br />';
$text .= '<div>';
$text .= ebImageLink('back_to_event', '', e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id, '', 'action_back.gif', EB_MATCHS_L3 . ' ' . EB_MATCHS_L4, 'jq-button');
$text .= '</div>';
$text .= '</div>';
$text .= '</div>';
$ns->tablerender("{$event->getField}('Name') ({$gName} - " . $event->eventTypeToString() . ")", $text);
require_once FOOTERF;
exit;
예제 #5
0
파일: match.php 프로젝트: testt98/ebattles
 function displayMatchInfo($type = 0, $header = '')
 {
     global $time;
     global $sql;
     global $pref;
     $match_id = $this->fields['MatchID'];
     $string = '';
     // Get info about the match
     $q = "SELECT DISTINCT " . TBL_MATCHS . ".*, " . TBL_USERS . ".*, " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_USERS . ", " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_MATCHS . ".MatchID = '" . $match_id . "')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_MATCHS . ".ReportedBy)" . " AND (" . TBL_MATCHS . ".Event = " . TBL_EVENTS . ".EventID)" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)";
     $result = $sql->db_Query($q);
     $numMatchs = mysql_numrows($result);
     if ($numMatchs > 0) {
         $mReportedBy = mysql_result($result, 0, TBL_USERS . ".user_id");
         $mReportedByNickName = mysql_result($result, 0, TBL_USERS . ".user_name");
         $mEventgame = mysql_result($result, 0, TBL_GAMES . ".Name");
         $mEventgameicon = mysql_result($result, 0, TBL_GAMES . ".Icon");
         $mStatus = mysql_result($result, 0, TBL_MATCHS . ".Status");
         $mTime = mysql_result($result, 0, TBL_MATCHS . ".TimeReported");
         $mTime_local = $mTime + TIMEOFFSET;
         $date = date("d M Y, h:i A", $mTime_local);
         $mTimeScheduled = mysql_result($result, 0, TBL_MATCHS . ".TimeScheduled");
         $mTimeScheduled_local = $mTimeScheduled + TIMEOFFSET;
         $dateScheduled = date("d M Y, h:i A", $mTimeScheduled_local);
         $mComments = mysql_result($result, 0, TBL_MATCHS . ".Comments");
         $event_id = mysql_result($result, 0, TBL_EVENTS . ".EventID");
         $event = new Event($event_id);
         // Calculate number of players and teams for the match
         $q = "SELECT DISTINCT " . TBL_SCORES . ".Player_MatchTeam" . " FROM " . TBL_SCORES . " WHERE (" . TBL_SCORES . ".MatchID = '" . $match_id . "')";
         $result = $sql->db_Query($q);
         $nbr_teams = mysql_numrows($result);
         // Check if the match has several ranks
         $q = "SELECT DISTINCT " . TBL_MATCHS . ".*, " . TBL_SCORES . ".Player_Rank" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (" . TBL_MATCHS . ".MatchID = '" . $match_id . "')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)";
         $result = $sql->db_Query($q);
         $numRanks = mysql_numrows($result);
         if ($numRanks > 0) {
             //------------ permissions --------------
             $permissions = $this->get_permissions(USERID);
             $userclass = $permissions['userclass'];
             $can_approve = $permissions['can_approve'];
             $can_report = $permissions['can_report'];
             $can_schedule = $permissions['can_schedule'];
             $can_delete = $permissions['can_delete'];
             $can_edit = $permissions['can_edit'];
             $orderby_str = " ORDER BY " . TBL_SCORES . ".Player_Rank, " . TBL_SCORES . ".Player_MatchTeam";
             if ($nbr_teams == 2) {
                 $orderby_str = " ORDER BY " . TBL_SCORES . ".Player_MatchTeam";
             }
             switch ($event->getMatchPlayersType()) {
                 case 'Players':
                     $q = "SELECT " . TBL_MATCHS . ".*, " . TBL_SCORES . ".*, " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '" . $match_id . "')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_GAMERS . ".User)" . $orderby_str;
                     break;
                 case 'Teams':
                     $q = "SELECT " . TBL_MATCHS . ".*, " . TBL_SCORES . ".*, " . TBL_CLANS . ".*, " . TBL_TEAMS . ".*, " . TBL_DIVISIONS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_CLANS . ", " . TBL_TEAMS . ", " . TBL_DIVISIONS . " WHERE (" . TBL_MATCHS . ".MatchID = '" . $match_id . "')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_CLANS . ".ClanID = " . TBL_DIVISIONS . ".Clan)" . " AND (" . TBL_TEAMS . ".Division = " . TBL_DIVISIONS . ".DivisionID)" . $orderby_str;
                     break;
                 default:
             }
             $result = $sql->db_Query($q);
             $numPlayers = mysql_numrows($result);
             $pname = '';
             $string .= '<tr>';
             if ($header) {
                 $string .= '<td>' . $header . '</td>';
             }
             $scores = '';
             if (($type & eb_MATCH_NOEVENTINFO) == 0) {
                 $string .= '<td style="vertical-align:top">';
                 $string .= '<img ' . getActivityGameIconResize($mEventgameicon) . ' title="' . $mEventgame . '"/>';
                 $string .= '</td>';
             }
             $string .= '<td>';
             $matchteam = 0;
             for ($index = 0; $index < $numPlayers; $index++) {
                 switch ($event->getMatchPlayersType()) {
                     case 'Players':
                         $puid = mysql_result($result, $index, TBL_USERS . ".user_id");
                         $gamer_id = mysql_result($result, $index, TBL_PLAYERS . ".Gamer");
                         $gamer = new Gamer($gamer_id);
                         $pname = $gamer->getField('Name');
                         $pavatar = mysql_result($result, $index, TBL_USERS . ".user_image");
                         $pteam = mysql_result($result, $index, TBL_PLAYERS . ".Team");
                         break;
                     case 'Teams':
                         $pname = mysql_result($result, $index, TBL_CLANS . ".Name");
                         $pavatar = mysql_result($result, $index, TBL_CLANS . ".Image");
                         $pteam = mysql_result($result, $index, TBL_TEAMS . ".TeamID");
                         break;
                     default:
                 }
                 list($pclan, $pclantag, $pclanid) = getClanInfo($pteam);
                 $prank = mysql_result($result, $index, TBL_SCORES . ".Player_Rank");
                 $pmatchteam = mysql_result($result, $index, TBL_SCORES . ".Player_MatchTeam");
                 $pscore = mysql_result($result, $index, TBL_SCORES . ".Player_Score");
                 $pfaction = mysql_result($result, $index, TBL_SCORES . ".Faction");
                 $pfactionIcon = "";
                 //if (($pfaction!=0)&&($type!=0))
                 if ($pfaction != 0) {
                     $q_Factions = "SELECT " . TBL_FACTIONS . ".*" . " FROM " . TBL_FACTIONS . " WHERE (" . TBL_FACTIONS . ".FactionID = '{$pfaction}')";
                     $result_Factions = $sql->db_Query($q_Factions);
                     $numFactions = mysql_numrows($result_Factions);
                     if ($numFactions > 0) {
                         $fIcon = mysql_result($result_Factions, 0, TBL_FACTIONS . ".Icon");
                         $fName = mysql_result($result_Factions, 0, TBL_FACTIONS . ".Name");
                         $pfactionIcon = ' <img ' . getFactionIconResize($fIcon) . ' title="' . $fName . '"/>';
                     }
                 }
                 /* takes too long
                 			$image = '';
                 			if ($pref['eb_avatar_enable_playersstandings'] == 1)
                 			{
                 			switch($event->getMatchPlayersType())
                 			{
                 			case 'Players':
                 			if($pavatar)
                 			{
                 			$image = '<img '.getAvatarResize(avatar($pavatar)).'/>';
                 			} else if ($pref['eb_avatar_default_image'] != ''){
                 			$image = '<img '.getAvatarResize(getImagePath($pref['eb_avatar_default_image'], 'avatars')).'/>';
                 			}
                 			break;
                 			case 'Teams':
                 			if($pavatar)
                 			{
                 			$image = '<img '.getAvatarResize(getImagePath($pavatar, 'team_avatars')).'/>';
                 			} else if ($pref['eb_avatar_default_image'] != ''){
                 			$image = '<img '.getAvatarResize(getImagePath($pref['eb_avatar_default_team_image'], 'team_avatars')).'/>';
                 			}
                 			break;
                 			default:
                 			}
                 			}
                 			*/
                 if ($index > 0) {
                     $scores .= "-" . $pscore;
                     if ($pmatchteam == $matchteam) {
                         $string .= ' &amp; ';
                     } else {
                         if (($type & eb_MATCH_SCHEDULED) != 0) {
                             $str = ' vs. ';
                         } else {
                             if ($prank == $rank) {
                                 $str = ' ' . EB_MATCH_L2 . ' ';
                             } else {
                                 if ($prank > $rank) {
                                     $str = ' ' . EB_MATCH_L3 . ' ';
                                 } else {
                                     $str = ' ' . EB_MATCH_L14 . ' ';
                                 }
                             }
                         }
                         $string .= $str;
                         $matchteam = $pmatchteam;
                         $rank = $prank;
                     }
                 } else {
                     $rank = $prank;
                     $matchteam = $pmatchteam;
                     $scores .= $pscore;
                 }
                 /*
                 echo "rank: $rank, prank: $prank<br>";
                 echo "mt: $matchteam, pmt $pmatchteam<br>";
                 */
                 $string .= $pfactionIcon . ' ';
                 switch ($event->getMatchPlayersType()) {
                     case 'Players':
                         $string .= '<a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $pclantag . $pname . '</a>';
                         break;
                     case 'Teams':
                         $string .= '<a href="' . e_PLUGIN . 'ebattles/claninfo.php?clanid=' . $pclanid . '">' . $pclan . '</a>';
                         break;
                     default:
                 }
             }
             //score here
             if ($event->getField('AllowScore') == TRUE && ($type & eb_MATCH_SCHEDULED) == 0) {
                 $string .= ' (' . $scores . ') ';
             }
             if (($type & eb_MATCH_NOEVENTINFO) == 0) {
                 $string .= ' ' . EB_MATCH_L12 . ' <a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . $event->getField('Name') . '</a>';
             }
             if ($can_approve == 1) {
                 $string .= ' <a href="' . e_PLUGIN . 'ebattles/matchinfo.php?matchid=' . $match_id . '"><img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/exclamation.png" alt="' . EB_MATCH_L13 . '" title="' . EB_MATCH_L13 . '"/></a>';
             } else {
                 if (($type & eb_MATCH_SCHEDULED) == 0 || $can_schedule == 1) {
                     $string .= ' <a href="' . e_PLUGIN . 'ebattles/matchinfo.php?matchid=' . $match_id . '"><img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/magnify.png" alt="' . EB_MATCH_L5 . '" title="' . EB_MATCH_L5 . '"/></a>';
                 }
             }
             if (($type & eb_MATCH_SCHEDULED) == 0) {
                 $string .= ' <div class="smalltext">';
                 $string .= EB_MATCH_L6 . ' <a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $mReportedByNickName . '</a> ';
                 if ($time - $mTime < INT_MINUTE) {
                     $string .= EB_MATCH_L7;
                 } else {
                     if ($time - $mTime < INT_DAY) {
                         $string .= get_formatted_timediff($mTime, $time) . '&nbsp;' . EB_MATCH_L8;
                     } else {
                         $string .= EB_MATCH_L9 . '&nbsp;' . $date . '.';
                     }
                 }
                 $nbr_comments = ebGetCommentTotal("ebmatches", $match_id);
                 $nbr_comments += $mComments == '' ? 0 : 1;
                 $string .= ' <a href="' . e_PLUGIN . 'ebattles/matchinfo.php?matchid=' . $match_id . '" title="' . EB_MATCH_L4 . '&nbsp;' . $match_id . '">' . $nbr_comments . '&nbsp;';
                 $string .= $nbr_comments > 1 ? EB_MATCH_L10 : EB_MATCH_L11;
                 $string .= '</a>';
                 $string .= '</div></td>';
             } else {
                 $string .= ' <div class="smalltext">';
                 $string .= EB_MATCH_L16 . '&nbsp;';
                 $string .= EB_MATCH_L17 . '&nbsp;' . $dateScheduled . '.';
                 $string .= '</div></td>';
             }
             if (($type & eb_MATCH_NO_EDIT_ICONS) == 0) {
                 if ($can_delete == 1) {
                     $delete_text = $competition_type == 'Tournament' ? EB_MATCHD_L29 : EB_MATCHD_L5;
                     $string .= '<td>';
                     $string .= '<form action="' . e_PLUGIN . 'ebattles/matchdelete.php?eventid=' . $event_id . '" method="post">';
                     $string .= '<div>';
                     $string .= '<input type="hidden" name="eventid" value="' . $event_id . '"/>';
                     $string .= '<input type="hidden" name="matchid" value="' . $match_id . '"/>';
                     $string .= '</div>';
                     $string .= ebImageTextButton('deletematch', 'cross.png', '', 'simple', $delete_text, EB_MATCHD_L4);
                     $string .= '</form>';
                     $string .= '</td>';
                 }
                 if ($can_approve == 1) {
                     $string .= '<td>';
                     $string .= '<form id="approvematch_form" action="' . e_PLUGIN . 'ebattles/matchprocess.php" method="post">';
                     $string .= '<div>';
                     $string .= '<input type="hidden" name="eventid" value="' . $event_id . '"/>';
                     $string .= '<input type="hidden" name="matchid" value="' . $match_id . '"/>';
                     $string .= '</div>';
                     $string .= ebImageTextButton('approvematch', 'accept.png', '', 'simple', '', EB_MATCHD_L17);
                     $string .= '</form>';
                     $string .= '</td>';
                 }
                 if ($can_edit == 1) {
                     if ($this->getField('Status') == 'scheduled') {
                         $string .= '<td>';
                         $string .= ebImageLink('matchschedulededit', EB_MATCHR_L46, '', e_PLUGIN . 'ebattles/matchreport.php?eventid=' . $event_id . '&amp;matchid=' . $match_id . '&amp;actionid=matchschedulededit&amp;userclass=' . $userclass, 'page_white_edit.png', '', 'matchreport_link', '', EB_MATCHD_L27);
                         $string .= '</td>';
                     } else {
                         $string .= '<td>';
                         $string .= ebImageLink('matchedit', EB_MATCHR_L46, '', e_PLUGIN . 'ebattles/matchreport.php?eventid=' . $event_id . '&amp;matchid=' . $match_id . '&amp;actionid=matchedit&amp;userclass=' . $userclass, 'page_white_edit.png', '', 'matchreport_link', '', EB_MATCHD_L27);
                         $string .= '</td>';
                     }
                 }
                 if ($can_report == 1) {
                     $string .= '<td>';
                     $string .= '<div>';
                     $string .= ebImageLink('matchscheduledreport', EB_MATCHR_L32, '', e_PLUGIN . 'ebattles/matchreport.php?eventid=' . $event_id . '&amp;matchid=' . $match_id . '&amp;actionid=matchscheduledreport&amp;userclass=' . $userclass, 'report.png', '', 'matchreport_link', '', EB_MATCHD_L30);
                     $string .= '</div>';
                     $string .= '</td>';
                 }
             }
             $string .= '</tr>';
         }
     }
     return $string;
 }
예제 #6
0
        $text .= '<form action="' . e_PLUGIN . 'ebattles/quickreport.php?eventid=' . $event_id . '" method="post"><div>';
        $text .= ebImageTextButton('quicklossreport', 'flag_red.png', EB_EVENT_L56);
        $text .= '</div></form>';
        $text .= '</td>';
    }
    if ($can_report == 1) {
        $text .= '<td>';
        $text .= '<div>';
        $text .= ebImageLink('matchreport', EB_MATCHR_L32, '', e_PLUGIN . 'ebattles/matchreport.php?eventid=' . $event_id . '&amp;actionid=matchreport&amp;userclass=' . $userclass, 'report.png', EB_EVENT_L57, 'matchreport_link jq-button');
        $text .= '</div>';
        $text .= '</td>';
    }
    if ($can_schedule == 1) {
        $text .= '<td>';
        $text .= '<div>';
        $text .= ebImageLink('matchschedule', EB_MATCHR_L32, '', e_PLUGIN . 'ebattles/matchreport.php?eventid=' . $event_id . '&amp;actionid=matchschedule&amp;userclass=' . $userclass, 'add.png', EB_EVENT_L72, 'matchreport_link jq-button');
        $text .= '</div>';
        $text .= '</td>';
    }
    $text .= '</tr>';
    $text .= '</table>';
}
$text .= '<br />';
/* Display Active Matches */
$q = "SELECT COUNT(DISTINCT " . TBL_MATCHS . ".MatchID) as NbrMatches" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (Event = '{$event_id}')" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)";
$result = $sql->db_Query($q);
$row = mysql_fetch_array($result);
$numMatches = $row['NbrMatches'];
$text .= '<p><b>';
$text .= $numMatches . '&nbsp;' . EB_EVENT_L59;
$text .= '</b></p>';