Ejemplo n.º 1
0
 function is_unique()
 {
     $Gamer = new Gamer();
     $Gamer->set_email($this->parent);
     $Gamer->load_by_email();
     return !$Gamer->is_exists();
 }
Ejemplo n.º 2
0
 /**
  * Logout User and Send Url for redirect
  */
 public function logout()
 {
     if (isset($_SESSION['gameID']) && $_SESSION['gameID'] != 0) {
         include_once 'controller/Gamer.php';
         $gamer = new Gamer();
         $gamer->EndGame();
     }
     session_destroy();
     return json_encode(array("uri" => Uri::getAction('Login', 'getMain')));
 }
Ejemplo n.º 3
0
/**
* displayRecentActivity - Displays Recent Activity
*/
function displayRecentActivity($event_id)
{
    global $sql;
    global $time;
    global $pref;
    $events = array();
    $nbr_events = 0;
    if ($event_id != '') {
        $eventid_match = " AND (" . TBL_MATCHS . ".Event = '{$event_id}')";
        $eventid_award = " AND (" . TBL_EVENTS . ".EventID = '{$event_id}')";
    }
    // Add recent games
    $rowsPerPage = $pref['eb_activity_number_of_items'];
    /* Stats/Results */
    $q = "SELECT DISTINCT " . TBL_MATCHS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (" . TBL_MATCHS . ".Status = 'active')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . $eventid_match . " ORDER BY " . TBL_MATCHS . ".TimeReported DESC" . " LIMIT 0, {$rowsPerPage}";
    $result = $sql->db_Query($q);
    $num_rows = mysql_numrows($result);
    if ($num_rows > 0) {
        /* Display table contents */
        for ($i = 0; $i < $num_rows; $i++) {
            $match_id = mysql_result($result, $i, TBL_MATCHS . ".MatchID");
            $match = new Match($match_id);
            $events[$nbr_events][0] = $match->getField('TimeReported');
            $events[$nbr_events][1] = $match->displayMatchInfo(eb_MATCH_NO_EDIT_ICONS);
            $nbr_events++;
        }
    }
    // Add Awards events
    $q = "SELECT " . TBL_AWARDS . ".*, " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*, " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_AWARDS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . ", " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_AWARDS . ".Player = " . TBL_PLAYERS . ".PlayerID)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******".user_id)" . " AND (" . TBL_PLAYERS . ".Event = " . TBL_EVENTS . ".EventID)" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $eventid_award . " ORDER BY " . TBL_AWARDS . ".timestamp DESC" . " LIMIT 0, {$rowsPerPage}";
    $result = $sql->db_Query($q);
    $numAwards = mysql_numrows($result);
    if ($numAwards > 0) {
        /* Display table contents */
        for ($i = 0; $i < $numAwards; $i++) {
            $aID = mysql_result($result, $i, TBL_AWARDS . ".AwardID");
            $aUser = mysql_result($result, $i, TBL_USERS . ".user_id");
            $gamer_id = mysql_result($result, $i, TBL_PLAYERS . ".Gamer");
            $gamer = new Gamer($gamer_id);
            $aUserNickName = $gamer->getField('Name');
            $aEventgame = mysql_result($result, $i, TBL_GAMES . ".Name");
            $aEventgameicon = mysql_result($result, $i, TBL_GAMES . ".Icon");
            $aType = mysql_result($result, $i, TBL_AWARDS . ".Type");
            $aTime = mysql_result($result, $i, TBL_AWARDS . ".timestamp");
            $aTime_local = $aTime + TIMEOFFSET;
            $date = date("d M Y, h:i A", $aTime_local);
            $aEventID = mysql_result($result, $i, TBL_EVENTS . ".EventID");
            $aEventName = mysql_result($result, $i, TBL_EVENTS . ".Name");
            switch ($aType) {
                case 'PlayerTookFirstPlace':
                    $award = EB_AWARD_L2;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/award_star_gold_3.png") . ' alt="' . EB_AWARD_L3 . '" title="' . EB_AWARD_L3 . '"/> ';
                    break;
                case 'PlayerInTopTen':
                    $award = EB_AWARD_L4;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/award_star_bronze_3.png") . ' alt="' . EB_AWARD_L5 . '" title="' . EB_AWARD_L5 . '"/> ';
                    break;
                case 'PlayerStreak5':
                    $award = EB_AWARD_L6;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_bronze_3.png") . ' alt="' . EB_AWARD_L7 . '" title="' . EB_AWARD_L7 . '"/> ';
                    break;
                case 'PlayerStreak10':
                    $award = EB_AWARD_L8;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_silver_3.png") . ' alt="' . EB_AWARD_L9 . '" title="' . EB_AWARD_L9 . '"/> ';
                    break;
                case 'PlayerStreak25':
                    $award = EB_AWARD_L10;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_gold_3.png") . ' alt="' . EB_AWARD_L11 . '" title="' . EB_AWARD_L11 . '"/> ';
                    break;
                case 'PlayerWonTournament':
                    $award = EB_AWARD_L12;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/trophy_gold.png") . ' alt="' . EB_AWARD_L13 . '" title="' . EB_AWARD_L13 . '"/> ';
                    break;
                case 'PlayerRankFirst':
                    $award = EB_AWARD_L14;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_gold_1.png") . ' alt="' . EB_AWARD_L15 . '" title="' . EB_AWARD_L15 . '"/> ';
                    break;
                case 'PlayerRankSecond':
                    $award = EB_AWARD_L16;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_silver_1.png") . ' alt="' . EB_AWARD_L17 . '" title="' . EB_AWARD_L17 . '"/> ';
                    break;
                case 'PlayerRankThird':
                    $award = EB_AWARD_L18;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_bronze_1.png") . ' alt="' . EB_AWARD_L19 . '" title="' . EB_AWARD_L19 . '"/> ';
                    break;
            }
            $award_string = '<tr><td style="vertical-align:top">' . $icon . '</td>';
            $award_string .= '<td><a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $aUserNickName . '</a>';
            $award_string .= ' ' . $award;
            $award_string .= ' ' . EB_MATCH_L12 . ' <img ' . getActivityGameIconResize($aEventgameicon) . ' title="' . $aEventgame . '"/>&nbsp;<a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $aEventID . '">' . $aEventName . '</a>';
            $award_string .= ' <div class="smalltext">';
            if ($time - $aTime < INT_MINUTE) {
                $award_string .= EB_MATCH_L7;
            } else {
                if ($time - $aTime < INT_DAY) {
                    $award_string .= get_formatted_timediff($aTime, $time) . '&nbsp;' . EB_MATCH_L8;
                } else {
                    $award_string .= $date;
                }
            }
            $award_string .= '</div></td></tr>';
            $events[$nbr_events][0] = $aTime;
            $events[$nbr_events][1] = $award_string;
            $nbr_events++;
        }
    }
    $q = "SELECT " . TBL_AWARDS . ".*, " . TBL_TEAMS . ".*, " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_AWARDS . ", " . TBL_TEAMS . ", " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_AWARDS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_TEAMS . ".Event = " . TBL_EVENTS . ".EventID)" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $eventid_award . " ORDER BY " . TBL_AWARDS . ".timestamp DESC" . " LIMIT 0, {$rowsPerPage}";
    $result = $sql->db_Query($q);
    $numAwards = mysql_numrows($result);
    if ($numAwards > 0) {
        /* Display table contents */
        for ($i = 0; $i < $numAwards; $i++) {
            $aID = mysql_result($result, $i, TBL_AWARDS . ".AwardID");
            $aEventgame = mysql_result($result, $i, TBL_GAMES . ".Name");
            $aEventgameicon = mysql_result($result, $i, TBL_GAMES . ".Icon");
            $aType = mysql_result($result, $i, TBL_AWARDS . ".Type");
            $aTime = mysql_result($result, $i, TBL_AWARDS . ".timestamp");
            $aTime_local = $aTime + TIMEOFFSET;
            $date = date("d M Y, h:i A", $aTime_local);
            $aEventID = mysql_result($result, $i, TBL_EVENTS . ".EventID");
            $aEventName = mysql_result($result, $i, TBL_EVENTS . ".Name");
            $aClanTeam = mysql_result($result, $i, TBL_TEAMS . ".TeamID");
            list($tclan, $tclantag, $tclanid) = getClanInfo($aClanTeam);
            switch ($aType) {
                case 'TeamTookFirstPlace':
                    $award = EB_AWARD_L2;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/award_star_gold_3.png") . ' alt="' . EB_AWARD_L3 . '" title="' . EB_AWARD_L3 . '"/> ';
                    break;
                case 'TeamInTopTen':
                    $award = EB_AWARD_L4;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/award_star_bronze_3.png") . ' alt="' . EB_AWARD_L5 . '" title="' . EB_AWARD_L5 . '"/> ';
                    break;
                case 'TeamStreak5':
                    $award = EB_AWARD_L6;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_bronze_3.png") . ' alt="' . EB_AWARD_L7 . '" title="' . EB_AWARD_L7 . '"/> ';
                    break;
                case 'TeamStreak10':
                    $award = EB_AWARD_L8;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_silver_3.png") . ' alt="' . EB_AWARD_L9 . '" title="' . EB_AWARD_L9 . '"/> ';
                    break;
                case 'TeamStreak25':
                    $award = EB_AWARD_L10;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_gold_3.png") . ' alt="' . EB_AWARD_L11 . '" title="' . EB_AWARD_L11 . '"/> ';
                    break;
                case 'TeamWonTournament':
                    $award = EB_AWARD_L12;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/trophy_gold.png") . ' alt="' . EB_AWARD_L13 . '" title="' . EB_AWARD_L13 . '"/> ';
                    break;
                case 'TeamRankFirst':
                    $award = EB_AWARD_L14;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_gold_1.png") . ' alt="' . EB_AWARD_L15 . '" title="' . EB_AWARD_L15 . '"/> ';
                    break;
                case 'TeamRankSecond':
                    $award = EB_AWARD_L16;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_silver_1.png") . ' alt="' . EB_AWARD_L17 . '" title="' . EB_AWARD_L17 . '"/> ';
                    break;
                case 'TeamRankThird':
                    $award = EB_AWARD_L18;
                    $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/medal_bronze_1.png") . ' alt="' . EB_AWARD_L19 . '" title="' . EB_AWARD_L19 . '"/> ';
                    break;
            }
            $award_string = '<tr><td style="vertical-align:top">' . $icon . '</td>';
            $award_string .= '<td><a href="' . e_PLUGIN . 'ebattles/claninfo.php?clanid=' . $tclanid . '">' . $tclan . '</a>';
            $award_string .= ' ' . $award;
            $award_string .= ' ' . EB_MATCH_L12 . ' <img ' . getActivityGameIconResize($aEventgameicon) . ' title="' . $aEventgame . '"/>&nbsp;<a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $aEventID . '">' . $aEventName . '</a>';
            $award_string .= ' <div class="smalltext">';
            if ($time - $aTime < INT_MINUTE) {
                $award_string .= EB_MATCH_L7;
            } else {
                if ($time - $aTime < INT_DAY) {
                    $award_string .= get_formatted_timediff($aTime, $time) . '&nbsp;' . EB_MATCH_L8;
                } else {
                    $award_string .= $date;
                }
            }
            $award_string .= '</div></td></tr>';
            $events[$nbr_events][0] = $aTime;
            $events[$nbr_events][1] = $award_string;
            $nbr_events++;
        }
    }
    $text .= '<table style="margin-left: 0px; margin-right: auto;">';
    multi2dSortAsc($events, 0, SORT_DESC);
    for ($index = 0; $index < min($nbr_events, $rowsPerPage); $index++) {
        $text .= $events[$index][1];
    }
    if ($index == 0) {
        $text .= '<tr><td>' . EB_ACTIVITY_L1 . '</td></tr>';
    }
    $text .= '</table>';
    return $text;
}
Ejemplo n.º 4
0
function updateStats($event_id, $time, $serialize = TRUE)
{
    global $sql;
    global $pref;
    $rater = new rater();
    $file = e_PLUGIN . 'ebattles/cache/sql_cache_event_' . $event_id . '.txt';
    $id = array();
    $uid = array();
    $team = array();
    $name = array();
    $avatar = array();
    $games_played = array();
    $ELO = array();
    $Skill = array();
    $G2 = array();
    $win = array();
    $loss = array();
    $draw = array();
    $windrawloss = array();
    $streaks = array();
    $victory_ratio = array();
    $victory_percent = array();
    $unique_opponents = array();
    $opponentsELO = array();
    $score = array();
    $oppscore = array();
    $scorediff = array();
    $points = array();
    $forfeits = array();
    $forfeits_percent = array();
    $banned = array();
    $rating = array();
    $games_played_score = array();
    $ELO_score = array();
    $Skill_score = array();
    $G2_score = array();
    $win_score = array();
    $loss_score = array();
    $draw_score = array();
    $windrawloss_score = array();
    $victory_ratio_score = array();
    $victory_percent_score = array();
    $unique_opponents_score = array();
    $opponentsELO_score = array();
    $streak_score = array();
    $score_score = array();
    $oppscore_score = array();
    $scorediff_score = array();
    $points_score = array();
    $forfeits_score = array();
    $forfeits_percent_score = array();
    /* Event Info */
    $event = new Event($event_id);
    $type = $event->getField('Type');
    $competition_type = $event->getCompetitionType();
    $hide_ratings_column = $event->getField('hide_ratings_column');
    if ($event->getField('RankingType') == "Classic") {
        $hide_ratings_column = TRUE;
    }
    // Update Players stats
    $q_Players = "SELECT " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_GAMERS . ".User)";
    $result_Players = $sql->db_Query($q_Players);
    $numPlayers = mysql_numrows($result_Players);
    $players_rated = 0;
    for ($player = 0; $player < $numPlayers; $player++) {
        // For each player
        $pid = mysql_result($result_Players, $player, TBL_PLAYERS . ".PlayerID");
        $puid = mysql_result($result_Players, $player, TBL_USERS . ".user_id");
        $gamer_id = mysql_result($result_Players, $player, TBL_PLAYERS . ".Gamer");
        $gamer = new Gamer($gamer_id);
        $pname = $gamer->getField('Name');
        $pavatar = mysql_result($result_Players, $player, TBL_USERS . ".user_image");
        $pteam = mysql_result($result_Players, $player, TBL_PLAYERS . ".Team");
        $pgames_played = mysql_result($result_Players, $player, TBL_PLAYERS . ".GamesPlayed");
        $pELO = mysql_result($result_Players, $player, TBL_PLAYERS . ".ELORanking");
        $pTS_mu = mysql_result($result_Players, $player, TBL_PLAYERS . ".TS_mu");
        $pTS_sigma = mysql_result($result_Players, $player, TBL_PLAYERS . ".TS_sigma");
        $pSkill = $pTS_mu - 3 * $pTS_sigma;
        $pG2_r = mysql_result($result_Players, $player, TBL_PLAYERS . ".G2_r");
        $pG2_RD = mysql_result($result_Players, $player, TBL_PLAYERS . ".G2_RD");
        $pG2 = $pG2_r - 2 * $pG2_RD;
        $pwin = mysql_result($result_Players, $player, TBL_PLAYERS . ".Win");
        $pdraw = mysql_result($result_Players, $player, TBL_PLAYERS . ".Draw");
        $ploss = mysql_result($result_Players, $player, TBL_PLAYERS . ".Loss");
        $pstreak = mysql_result($result_Players, $player, TBL_PLAYERS . ".Streak");
        $pstreak_worst = mysql_result($result_Players, $player, TBL_PLAYERS . ".Streak_Worst");
        $pstreak_best = mysql_result($result_Players, $player, TBL_PLAYERS . ".Streak_Best");
        $pwindrawloss = $pwin . "/" . $pdraw . "/" . $ploss;
        $pwinloss = $pwin . "/" . $ploss;
        $pvictory_ratio = $ploss > 0 ? $pwin / $ploss : $pwin;
        //fm- draw here???
        $pvictory_percent = $pwin + $pdraw + $ploss > 0 ? 100 * $pwin / ($pwin + $pdraw + $ploss) : 0;
        $pscore = mysql_result($result_Players, $player, TBL_PLAYERS . ".Score");
        $poppscore = mysql_result($result_Players, $player, TBL_PLAYERS . ".ScoreAgainst");
        $ppoints = mysql_result($result_Players, $player, TBL_PLAYERS . ".Points");
        $pforfeits = mysql_result($result_Players, $player, TBL_PLAYERS . ".Forfeits");
        $pforfeits_percent = $pgames_played > 0 ? 100 * $pforfeits / $pgames_played : 0;
        $pbanned = mysql_result($result_Players, $player, TBL_PLAYERS . ".Banned");
        $popponentsELO = 0;
        $popponents = 0;
        $prating = 0;
        $prating_votes = 0;
        // Unique Opponents
        // Find all matches played by current player
        $q_Matches = "SELECT " . TBL_MATCHS . ".*, " . TBL_SCORES . ".*, " . TBL_PLAYERS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . " WHERE (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".PlayerID = '{$pid}')";
        $result_Matches = $sql->db_Query($q_Matches);
        $numMatches = mysql_numrows($result_Matches);
        $players = array();
        if ($numMatches > 0) {
            for ($match = 0; $match < $numMatches; $match++) {
                // For each match played by current player
                $mID = mysql_result($result_Matches, $match, TBL_MATCHS . ".MatchID");
                $mplayermatchteam = mysql_result($result_Matches, $match, TBL_SCORES . ".Player_MatchTeam");
                // Find all scores/players(+users) for that match
                $q_Scores = "SELECT " . TBL_MATCHS . ".*, " . TBL_SCORES . ".*, " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$mID}')" . " 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)";
                $result_Scores = $sql->db_Query($q_Scores);
                $numScores = mysql_numrows($result_Scores);
                for ($scoreIndex = 0; $scoreIndex < $numScores; $scoreIndex++) {
                    $osid = mysql_result($result_Scores, $scoreIndex, TBL_SCORES . ".ScoreID");
                    $ouid = mysql_result($result_Scores, $scoreIndex, TBL_USERS . ".user_id");
                    $oplayermatchteam = mysql_result($result_Scores, $scoreIndex, TBL_SCORES . ".Player_MatchTeam");
                    $oELO = mysql_result($result_Scores, $scoreIndex, TBL_PLAYERS . ".ELORanking");
                    if ($oplayermatchteam != $mplayermatchteam) {
                        $players[] = "{$ouid}";
                        $popponentsELO += $oELO;
                        $popponents += 1;
                    }
                    if ($ouid == $puid) {
                        // Get user rating.
                        $rate = $rater->GetRating("ebscores", $osid);
                        $prating += $rate[0] * ($rate[1] + $rate[2] / 10);
                        $prating_votes += $rate[0];
                    }
                }
            }
        }
        $punique_opponents = count(array_unique($players));
        if ($popponents != 0) {
            $popponentsELO /= $popponents;
        }
        if ($prating_votes != 0) {
            $prating /= $prating_votes;
        }
        // For display
        $id[] = $pid;
        $uid[] = $puid;
        $name[] = $pname;
        $avatar[] = $pavatar;
        $team[] = $pteam;
        $games_played[] = $pgames_played;
        $ELO[] = $pELO;
        $Skill[] = max(0, number_format($pSkill, 0));
        $G2[] = number_format($pG2_r, 0) . " +/- " . number_format($pG2_RD, 0);
        $win[] = $pwin;
        $loss[] = $ploss;
        $draw[] = $pdraw;
        $streaks[] = $pstreak . "|" . $pstreak_best . "|" . $pstreak_worst;
        $windrawloss[] = $pwindrawloss;
        $victory_ratio[] = $pwinloss;
        $victory_percent[] = number_format($pvictory_percent, 2) . "%";
        $unique_opponents[] = $punique_opponents;
        $opponentsELO[] = floor($popponentsELO);
        $score[] = $pgames_played > 0 ? number_format($pscore / $pgames_played, 2) : 0;
        $oppscore[] = $pgames_played > 0 ? number_format($poppscore / $pgames_played, 2) : 0;
        $scorediff[] = $pgames_played > 0 ? number_format(($pscore - $poppscore) / $pgames_played, 2) : 0;
        $points[] = $ppoints;
        $forfeits[] = $pforfeits;
        $forfeits_percent[] = number_format($pforfeits_percent, 2) . "%";
        $banned[] = $pbanned;
        $rating[] = displayRating($prating, $prating_votes);
        // Actual score (not for display)
        $games_played_score[] = $pgames_played;
        $ELO_score[] = $pELO;
        $Skill_score[] = $pSkill;
        $G2_score[] = $pG2;
        $win_score[] = $pwin;
        $loss_score[] = $ploss;
        $draw_score[] = $pdraw;
        $windrawloss_score[] = $pwin - $ploss;
        //fm - ???
        $victory_ratio_score[] = $pvictory_ratio;
        $victory_percent_score[] = $pvictory_percent;
        $unique_opponents_score[] = $punique_opponents;
        $opponentsELO_score[] = $popponentsELO;
        $streaks_score[] = $pstreak_best;
        //max(0,$pstreak_best + $pstreak_worst); //fmarc- TBD
        $score_score[] = $pgames_played > 0 ? $pscore / $pgames_played : 0;
        $oppscore_score[] = $pgames_played > 0 ? -$poppscore / $pgames_played : 0;
        $scorediff_score[] = $pgames_played > 0 ? ($pscore - $poppscore) / $pgames_played : 0;
        $points_score[] = $ppoints;
        $forfeits_score[] = -$pforfeits;
        $forfeits_percent_score[] = -$pforfeits_percent;
        if ($pgames_played >= $event->getField('nbr_games_to_rank') && $pbanned == 0) {
            $players_rated++;
        }
    }
    $rating_max = 0;
    $q_Categories = "SELECT " . TBL_STATSCATEGORIES . ".*" . " FROM " . TBL_STATSCATEGORIES . " WHERE (" . TBL_STATSCATEGORIES . ".Event = '{$event_id}')" . " ORDER BY " . TBL_STATSCATEGORIES . ".CategoryMaxValue DESC";
    $result_Categories = $sql->db_Query($q_Categories);
    $numCategories = mysql_numrows($result_Categories);
    $stat_cat_header = array();
    $stat_min = array();
    $stat_max = array();
    $stat_a = array();
    $stat_b = array();
    $stat_score = array();
    $stat_display = array();
    $cat_index = 0;
    $categories = array();
    for ($category = 0; $category < $numCategories; $category++) {
        $cat_name = mysql_result($result_Categories, $category, TBL_STATSCATEGORIES . ".CategoryName");
        $cat_minpoints = mysql_result($result_Categories, $category, TBL_STATSCATEGORIES . ".CategoryMinValue");
        $cat_maxpoints = mysql_result($result_Categories, $category, TBL_STATSCATEGORIES . ".CategoryMaxValue");
        $cat_InfoOnly = mysql_result($result_Categories, $category, TBL_STATSCATEGORIES . ".InfoOnly");
        if ($cat_maxpoints > 0) {
            //dbg- echo "$cat_name<br>";
            $display_cat = 1;
            switch ($cat_name) {
                case "ELO":
                    $cat_header_title = EB_STATS_L1;
                    $cat_header_text = EB_STATS_L2;
                    $min = min($ELO_score);
                    $max = max($ELO_score);
                    $stat_score[$cat_index] = $ELO_score;
                    $stat_display[$cat_index] = $ELO;
                    break;
                case "Skill":
                    $cat_header_title = EB_STATS_L3;
                    $cat_header_text = EB_STATS_L4;
                    $min = min($Skill_score);
                    $max = max($Skill_score);
                    $stat_score[$cat_index] = $Skill_score;
                    $stat_display[$cat_index] = $Skill;
                    break;
                case "Glicko2":
                    $cat_header_title = EB_STATS_L41;
                    $cat_header_text = EB_STATS_L42;
                    $min = min($G2_score);
                    $max = max($G2_score);
                    $stat_score[$cat_index] = $G2_score;
                    $stat_display[$cat_index] = $G2;
                    break;
                case "GamesPlayed":
                    $cat_header_title = EB_STATS_L5;
                    $cat_header_text = EB_STATS_L6;
                    $min = 0;
                    //min($games_played_score);
                    $max = max($games_played);
                    $stat_score[$cat_index] = $games_played_score;
                    $stat_display[$cat_index] = $games_played;
                    break;
                case "VictoryRatio":
                    $cat_header_title = EB_STATS_L7;
                    $cat_header_text = EB_STATS_L8;
                    $min = 0;
                    //min($victory_ratio_score);
                    $max = max($victory_ratio_score);
                    $stat_score[$cat_index] = $victory_ratio_score;
                    $stat_display[$cat_index] = $victory_ratio;
                    break;
                case "VictoryPercent":
                    $cat_header_title = EB_STATS_L9;
                    $cat_header_text = EB_STATS_L10;
                    $min = 0;
                    //min($victory_percent_score);
                    $max = max($victory_percent_score);
                    $stat_score[$cat_index] = $victory_percent_score;
                    $stat_display[$cat_index] = $victory_percent;
                    break;
                case "WinDrawLoss":
                    $cat_header_title = EB_STATS_L11;
                    $cat_header_text = EB_STATS_L12;
                    $min = min($windrawloss_score);
                    $max = max($windrawloss_score);
                    $stat_score[$cat_index] = $windrawloss_score;
                    $stat_display[$cat_index] = $windrawloss;
                    break;
                case "UniqueOpponents":
                    $cat_header_title = EB_STATS_L13;
                    $cat_header_text = EB_STATS_L14;
                    $min = 0;
                    //min($unique_opponents_score);
                    $max = max($unique_opponents_score);
                    $stat_score[$cat_index] = $unique_opponents_score;
                    $stat_display[$cat_index] = $unique_opponents;
                    break;
                case "OpponentsELO":
                    $cat_header_title = EB_STATS_L15;
                    $cat_header_text = EB_STATS_L16;
                    $min = min($opponentsELO_score);
                    $max = max($opponentsELO_score);
                    $stat_score[$cat_index] = $opponentsELO_score;
                    $stat_display[$cat_index] = $opponentsELO;
                    break;
                case "Streaks":
                    $cat_header_title = EB_STATS_L17;
                    $cat_header_text = EB_STATS_L18;
                    $min = min($streaks_score);
                    $max = max($streaks_score);
                    $stat_score[$cat_index] = $streaks_score;
                    $stat_display[$cat_index] = $streaks;
                    break;
                case "Score":
                    $cat_header_title = EB_STATS_L19;
                    $cat_header_text = EB_STATS_L20;
                    $min = min($score_score);
                    $max = max($score_score);
                    $stat_score[$cat_index] = $score_score;
                    $stat_display[$cat_index] = $score;
                    break;
                case "ScoreAgainst":
                    $cat_header_title = EB_STATS_L21;
                    $cat_header_text = EB_STATS_L22;
                    $min = min($oppscore_score);
                    $max = max($oppscore_score);
                    $stat_score[$cat_index] = $oppscore_score;
                    $stat_display[$cat_index] = $oppscore;
                    break;
                case "ScoreDiff":
                    $cat_header_title = EB_STATS_L23;
                    $cat_header_text = EB_STATS_L24;
                    $min = min($scorediff_score);
                    $max = max($scorediff_score);
                    $stat_score[$cat_index] = $scorediff_score;
                    $stat_display[$cat_index] = $scorediff;
                    break;
                case "Points":
                    $cat_header_title = EB_STATS_L25;
                    $cat_header_text = EB_STATS_L26;
                    $min = min($points_score);
                    $max = max($points_score);
                    $stat_score[$cat_index] = $points_score;
                    $stat_display[$cat_index] = $points;
                    break;
                case "Forfeits":
                    $cat_header_title = EB_STATS_L43;
                    $cat_header_text = EB_STATS_L44;
                    $min = min($forfeits_score);
                    $max = max($forfeits_score);
                    $stat_score[$cat_index] = $forfeits_score;
                    $stat_display[$cat_index] = $forfeits;
                    break;
                case "ForfeitsPercent":
                    $cat_header_title = EB_STATS_L45;
                    $cat_header_text = EB_STATS_L46;
                    $min = min($forfeits_percent_score);
                    $max = max($forfeits_percent_score);
                    $stat_score[$cat_index] = $forfeits_percent_score;
                    $stat_display[$cat_index] = $forfeits_percent;
                    break;
                default:
                    $display_cat = 0;
            }
            if ($display_cat == 1) {
                $stat_InfoOnly[$cat_index] = $cat_InfoOnly;
                switch ($event->getField('RankingType')) {
                    case "CombinedStats":
                        if ($cat_InfoOnly == TRUE) {
                            $cat_header = '<b title="' . $cat_header_title . '">' . $cat_header_text . '</b>';
                        } else {
                            $categories[] = $cat_index;
                            $cat_header = '<b title="' . $cat_header_title . ' [' . number_format($cat_maxpoints, 2) . ' ' . EB_STATS_L27 . ']">' . $cat_header_text . '</b>';
                            /*
                            $cat_header = '
                            <b title="'.$cat_header_title.'">'.$cat_header_text.'</b>
                            <br /><div class="smalltext">['.number_format ($cat_maxpoints,2).'&nbsp;'.EB_STATS_L27.']</div>
                            ';
                            */
                            // a = (ymax-ymin)/(xmax-xmin)
                            // b = ymin - a.xmin
                            if ($max == $min) {
                                $a = 0;
                                $b = $cat_maxpoints;
                            } else {
                                $a = ($cat_maxpoints - $cat_minpoints) / ($max - $min);
                                $b = $cat_minpoints - $a * $min;
                            }
                            $stat_min[$cat_index] = $min;
                            $stat_max[$cat_index] = $max;
                            $stat_a[$cat_index] = $a;
                            $stat_b[$cat_index] = $b;
                            $rating_max += $cat_maxpoints;
                        }
                        break;
                    case "Classic":
                        if ($cat_InfoOnly == TRUE) {
                            $cat_header = '<span title="' . $cat_header_title . '">' . $cat_header_text . '</span>';
                        } else {
                            $cat_header = '<b title="' . $cat_header_title . '">' . $cat_header_text . '</b>';
                            $categories[] = $cat_index;
                        }
                        break;
                    default:
                }
                $stat_cat_header[$cat_index] = $cat_header;
                $cat_index++;
            }
        }
    }
    $numDisplayedCategories = $cat_index;
    $ranks = getRanking($stat_score, $categories);
    $stats = array("0" => array('header', '<b>' . EB_STATS_L28 . '</b>', '<b>' . EB_STATS_L29 . '</b>'));
    // user rating not shown
    // $stats[0][] = '<b>'.EB_STATS_L30.'</b>';
    if ($hide_ratings_column == FALSE) {
        $stats[0][] = '<b title="' . EB_STATS_L31 . ' [' . number_format($rating_max, 2) . ' ' . EB_STATS_L27 . ']">' . EB_STATS_L32 . '</b>';
    }
    //$stats[0][] = '<b title="'.EB_STATS_L31.'">'.EB_STATS_L32.'</b><br /><div class="smalltext">['.number_format ($rating_max,2).'&nbsp;'.EB_STATS_L27.']</div>';
    for ($category = 0; $category < $numDisplayedCategories; $category++) {
        $stats[0][] = $stat_cat_header[$category];
    }
    // Challenge column
    $stats[0][] = "<b>" . EB_CHALLENGE_L1 . "<b>";
    switch ($event->getField('RankingType')) {
        case "CombinedStats":
            $OverallScoreThreshold = 0;
            $final_score = array();
            for ($player = 0; $player < $numPlayers; $player++) {
                $OverallScore[$player] = 0;
                if ($games_played[$player] >= $event->getField('nbr_games_to_rank') && $banned[$player] == 0) {
                    for ($category = 0; $category < $numDisplayedCategories; $category++) {
                        if ($stat_InfoOnly[$category] == FALSE) {
                            $final_score[$category][$player] = $stat_a[$category] * $stat_score[$category][$player] + $stat_b[$category];
                            $OverallScore[$player] += $final_score[$category][$player];
                        }
                    }
                } else {
                    for ($category = 0; $category < $numDisplayedCategories; $category++) {
                        $final_score[$category][$player] = 0;
                    }
                }
                $q_update = "UPDATE " . TBL_PLAYERS . " SET OverallScore = '" . floatToSQL($OverallScore[$player]) . "' WHERE (PlayerID = '{$id[$player]}') AND (Event = '{$event_id}')";
                $result_update = $sql->db_Query($q_update);
            }
            break;
        case "Classic":
            $OverallScoreThreshold = $numPlayers;
            for ($player = 0; $player < $numPlayers; $player++) {
                if ($games_played[$player] >= $event->getField('nbr_games_to_rank') && $banned[$player] == 0) {
                    $OverallScore[$player] = array_search($player, $ranks, false) + $numPlayers + 1;
                } else {
                    $OverallScore[$player] = array_search($player, $ranks, false);
                }
                //dbg: echo "<br>Player $player ($name[$player]), os: $OverallScore[$player]";
                $q_update = "UPDATE " . TBL_PLAYERS . " SET OverallScore = '" . floatToSQL($OverallScore[$player]) . "' WHERE (PlayerID = '{$id[$player]}') AND (Event = '{$event_id}')";
                $result_update = $sql->db_Query($q_update);
            }
            break;
        default:
    }
    // Build results table
    //--------------------
    $q_Players = "SELECT *" . " FROM " . TBL_PLAYERS . " WHERE (Event = '{$event_id}')" . " ORDER BY " . TBL_PLAYERS . ".OverallScore DESC, " . TBL_PLAYERS . ".GamesPlayed DESC, " . TBL_PLAYERS . ".ELORanking DESC, " . TBL_PLAYERS . ".Banned ASC";
    $result_Players = $sql->db_Query($q_Players);
    $ranknumber = 1;
    for ($player = 0; $player < $numPlayers; $player++) {
        $pid = mysql_result($result_Players, $player, TBL_PLAYERS . ".PlayerID");
        $puid = mysql_result($result_Players, $player, TBL_PLAYERS . ".User");
        $prank = mysql_result($result_Players, $player, TBL_PLAYERS . ".Rank");
        $prankdelta = mysql_result($result_Players, $player, TBL_PLAYERS . ".RankDelta");
        $pstreak = mysql_result($result_Players, $player, TBL_PLAYERS . ".Streak");
        // Find index of player
        $index = array_search($pid, $id);
        $prank_side_image = "";
        if ($banned[$index] == 1) {
            $rank = '<span title="' . EB_STATS_L33 . '"><img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/user_delete.ico" alt="' . EB_STATS_L34 . '" title="' . EB_STATS_L34 . '"/></span>';
            $prankdelta_string = "";
            $q_update = "UPDATE " . TBL_PLAYERS . " SET Rank = 0 WHERE (PlayerID = '{$pid}') AND (Event = '{$event_id}')";
            $result_update = $sql->db_Query($q_update);
        } elseif ($OverallScore[$index] <= $OverallScoreThreshold) {
            $rank = '<span title="' . EB_STATS_L35 . '">' . EB_STATS_L36 . '</span>';
            $prankdelta_string = "";
            $q_update = "UPDATE " . TBL_PLAYERS . " SET Rank = 0 WHERE (PlayerID = '{$pid}') AND (Event = '{$event_id}')";
            $result_update = $sql->db_Query($q_update);
        } else {
            $rank = $ranknumber;
            $ranknumber++;
            // increases $ranknumber by 1
            $q_update = "UPDATE " . TBL_PLAYERS . " SET Rank = {$rank} WHERE (PlayerID = '{$pid}') AND (Event = '{$event_id}')";
            $result_update = $sql->db_Query($q_update);
            $new_rankdelta = $prank - $rank;
            if ($new_rankdelta != 0) {
                $prankdelta += $new_rankdelta;
                $q_update = "UPDATE " . TBL_PLAYERS . " SET RankDelta = {$prankdelta} WHERE (PlayerID = '{$pid}') AND (Event = '{$event_id}')";
                $result_update = $sql->db_Query($q_update);
            }
            if ($new_rankdelta != 0 && $rank == 1 && $competition_type == 'Ladder') {
                // Award: player took 1st place
                $q_Awards = "INSERT INTO " . TBL_AWARDS . "(Player,Type,timestamp)\r\n\t\t\t\tVALUES ({$pid},'PlayerTookFirstPlace',{$time})";
                $result_Awards = $sql->db_Query($q_Awards);
            }
            if ($new_rankdelta != 0 && ($prank > 10 || $prank == 0) && $rank <= 10 && $competition_type == 'Ladder') {
                // Award: player enters top 10
                $q_Awards = "INSERT INTO " . TBL_AWARDS . "(Player,Type,timestamp)\r\n\t\t\t\tVALUES ({$pid},'PlayerInTopTen',{$time})";
                $result_Awards = $sql->db_Query($q_Awards);
            }
            $q_Awards = "SELECT " . TBL_AWARDS . ".*, " . TBL_PLAYERS . ".*" . " FROM " . TBL_AWARDS . ", " . TBL_PLAYERS . " WHERE (" . TBL_AWARDS . ".Player = " . TBL_PLAYERS . ".PlayerID)" . " AND (" . TBL_PLAYERS . ".PlayerID = '{$pid}')" . " ORDER BY " . TBL_AWARDS . ".timestamp DESC";
            $result_Awards = $sql->db_Query($q_Awards);
            $numAwards = mysql_numrows($result_Awards);
            if ($numAwards > 0) {
                $paward = mysql_result($result_Awards, 0, TBL_AWARDS . ".AwardID");
                $pawardType = mysql_result($result_Awards, 0, TBL_AWARDS . ".Type");
            }
            if ($rank == 1) {
                $prank_side_image = '<img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/awards/award_star_gold_3.png" alt="' . EB_AWARD_L3 . '" title="' . EB_AWARD_L3 . '"/>';
            } else {
                if ($rank <= 10 && ($rank + $prankdelta > min(10, $numPlayers) || $rank + $prankdelta == 0)) {
                    $prank_side_image = '<img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/awards/award_star_bronze_3.png" alt="' . EB_AWARD_L5 . '" title="' . EB_AWARD_L5 . '"/>';
                } else {
                    if ($numAwards > 0 && $pawardType != 'PlayerTookFirstPlace' && $pawardType != 'PlayerInTopTen' && $pstreak >= 5) {
                        switch ($pawardType) {
                            case 'PlayerStreak5':
                                if ($pstreak >= 5) {
                                    $award = EB_AWARD_L6;
                                    $prank_side_image = '<img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/awards/medal_bronze_3.png" alt="' . EB_AWARD_L7 . '" title="' . EB_AWARD_L7 . '"/>';
                                }
                                break;
                            case 'PlayerStreak10':
                                if ($pstreak >= 10) {
                                    $award = EB_AWARD_L8;
                                    $prank_side_image = '<img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/awards/medal_silver_3.png" alt="' . EB_AWARD_L9 . '" title="' . EB_AWARD_L9 . '"/>';
                                }
                                break;
                            case 'PlayerStreak25':
                                if ($pstreak >= 25) {
                                    $award = EB_AWARD_L10;
                                    $prank_side_image = '<img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/awards/medal_gold_3.png" alt="' . EB_AWARD_L11 . '" title="' . EB_AWARD_L11 . '"/>';
                                }
                                break;
                        }
                    } else {
                        if ($prankdelta > 0) {
                            $prank_side_image = '<img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/arrow_up.gif" alt="+' . $prankdelta . '" title="+' . $prankdelta . '"/>';
                        } else {
                            if ($prankdelta < 0 && $rank + $prankdelta != 0) {
                                $prank_side_image = '<img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/arrow_down.gif" alt="' . $prankdelta . '" title="' . $prankdelta . '"/>';
                            } else {
                                if ($rank + $prankdelta == 0) {
                                    $prank_side_image = '<img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/arrow_up.gif" alt="Up" title="' . EB_STATS_L37 . '"/>';
                                }
                            }
                        }
                    }
                }
            }
        }
        list($pclan, $pclantag, $pclanid) = getClanInfo($team[$index]);
        if (strcmp(USERID, $puid) == 0) {
            $stats_row = array("row_highlight");
        } else {
            $stats_row = array("row");
        }
        $stats_row[] = "<b>{$rank}</b> {$prank_side_image}";
        $image = "";
        if ($pref['eb_avatar_enable_playersstandings'] == 1) {
            if ($avatar[$index]) {
                $image = '<img ' . getAvatarResize(avatar($avatar[$index])) . '/>';
            } else {
                if ($pref['eb_avatar_default_image'] != '') {
                    $image = '<img ' . getAvatarResize(getImagePath($pref['eb_avatar_default_image'], 'avatars')) . '/>';
                }
            }
        }
        $stats_row[] = $image . '&nbsp;<a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'"><b>' . $pclantag . $name[$index] . '</b></a>';
        // user rating not shown
        //$stats_row[] = $rating[$index];
        if ($hide_ratings_column == FALSE) {
            $stats_row[] = number_format($OverallScore[$index], 2);
        }
        for ($category = 0; $category < $numDisplayedCategories; $category++) {
            if ($stat_InfoOnly[$category] == TRUE || $event->getField('RankingType') == "Classic") {
                $stats_row[] = $stat_display[$category][$index];
            } else {
                $stats_row[] = $stat_display[$category][$index] . '<br /><div class="smalltext">[' . number_format($final_score[$category][$index], 2) . ']</div>';
            }
        }
        // Add challenge button here
        $challenge_text = ' <a href="javascript:challenge_player_js(\'' . $pid . '\');" title="' . EB_CHALLENGE_L1 . ' ' . $pclantag . $name[$index] . '"><img class="eb_image" src="' . e_PLUGIN . 'ebattles/images/challenge.png" alt="' . EB_CHALLENGE_L1 . ' ' . $pclantag . $name[$index] . '"/></a>';
        $stats_row[] = $challenge_text;
        $stats[] = $stats_row;
    }
    /*
    // debug print array
    print_r($stats);
    print_r($stat_score);
    echo "<br>";
    print_r($ranks);
    */
    if ($serialize) {
        // Serialize results array
        $OUTPUT = serialize($stats);
        $fp = fopen($file, "w");
        // open file with Write permission
        if ($fp == FALSE) {
            // handle error
            $error .= EB_STATS_L38;
            echo $error;
            exit;
        }
        fputs($fp, $OUTPUT);
        fclose($fp);
        /*
        $stats = unserialize(implode('',file($file)));
        foreach ($stats as $id=>$row)
        {
        print $row['category_name']."<br />";
        }
        */
    }
}
Ejemplo n.º 5
0
 function getTeams()
 {
     global $sql;
     $teams = array();
     $checkedin_str = '';
     switch ($this->getMatchPlayersType()) {
         case 'Players':
             $q_Players = "SELECT " . TBL_GAMERS . ".*, " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_GAMERS . ", " . TBL_PLAYERS . ", " . TBL_USERS . " WHERE (" . TBL_PLAYERS . ".Event = '" . $this->getField('EventID') . "')" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_GAMERS . ".User)" . $checkedin_str . " ORDER BY " . TBL_PLAYERS . ".Seed, " . TBL_PLAYERS . ".Joined";
             $result = $sql->db_Query($q_Players);
             $nbrPlayers = mysql_numrows($result);
             for ($player = 0; $player < $nbrPlayers; $player++) {
                 $playerID = mysql_result($result, $player, TBL_PLAYERS . ".PlayerID");
                 $gamerID = mysql_result($result, $player, TBL_GAMERS . ".GamerID");
                 $gamer = new Gamer($gamerID);
                 $pname = $gamer->getField('Name');
                 $pugid = $gamer->getField('UniqueGameID');
                 $pavatar = mysql_result($result, $player, TBL_USERS . ".user_image");
                 $pteam = mysql_result($result, $player, TBL_PLAYERS . ".Team");
                 list($pclan, $pclantag, $pclanid) = getClanInfo($pteam);
                 $pseed = mysql_result($result, $player, TBL_PLAYERS . ".Seed");
                 if ($pseed == 0) {
                     $pseed = $player + 1;
                 }
                 $teams[$pseed - 1]['PlayerID'] = $playerID;
                 $teams[$pseed - 1]['Name'] = $pname;
                 $teams[$pseed - 1]['UniqueGameID'] = $pugid;
                 $teams[$pseed - 1]['Avatar'] = $pavatar;
                 $teams[$pseed - 1]['seed'] = $pseed;
             }
             break;
         case 'Teams':
             $q_Teams = "SELECT " . TBL_CLANS . ".*, " . TBL_TEAMS . ".*, " . TBL_DIVISIONS . ".* " . " FROM " . TBL_CLANS . ", " . TBL_TEAMS . ", " . TBL_DIVISIONS . " WHERE (" . TBL_CLANS . ".ClanID = " . TBL_DIVISIONS . ".Clan)" . " AND (" . TBL_TEAMS . ".Division = " . TBL_DIVISIONS . ".DivisionID)" . " AND (" . TBL_TEAMS . ".Event = '" . $this->getField('EventID') . "')" . $checkedin_str . " ORDER BY " . TBL_TEAMS . ".Seed, " . TBL_TEAMS . ".Joined";
             $result = $sql->db_Query($q_Teams);
             $nbrTeams = mysql_numrows($result);
             for ($team = 0; $team < $nbrTeams; $team++) {
                 $pteam = mysql_result($result, $team, TBL_TEAMS . ".TeamID");
                 $pavatar = '';
                 // TODO: no team avatar for now
                 list($pclan, $pclantag, $pclanid) = getClanInfo($pteam);
                 $pseed = mysql_result($result, $team, TBL_TEAMS . ".Seed");
                 if ($pseed == 0) {
                     $pseed = $team + 1;
                 }
                 $teams[$pseed - 1]['PlayerID'] = $pteam;
                 $teams[$pseed - 1]['Name'] = $pclan;
                 $teams[$pseed - 1]['UniqueGameID'] = '';
                 $teams[$pseed - 1]['Avatar'] = $pavatar;
                 $teams[$pseed - 1]['seed'] = $pseed;
             }
             break;
     }
     //var_dump($teams);
     return $teams;
 }
 public function all()
 {
     $active = isset($_GET['active']) ? $_GET['active'] : 1;
     $gamers = Gamer::all($active);
     REST::returnJson(['status' => 'ok', 'gamers' => $gamers]);
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
function printGamerState(Gamer $gamer)
{
    echo '所持金:' . $gamer->getMoney() . '円' . PHP_EOL;
    echo 'フルーツ:';
    foreach ($gamer->getFruits() as $fruit) {
        echo $fruit . ' ';
    }
    echo PHP_EOL;
    echo PHP_EOL;
}
Ejemplo n.º 9
0
	<div class="spacer">
	';
    $text .= '<form action="' . e_PLUGIN . 'ebattles/matchprocess.php" method="post">';
    $text .= '
	<table>
	<tr>
	<td>
	Player:
	<select class="tbox" name="Player">
	';
    for ($i = 0; $i < $num_rows; $i++) {
        $pid = mysql_result($result, $i, TBL_PLAYERS . ".PlayerID");
        $puid = mysql_result($result, $i, TBL_USERS . ".user_id");
        $prank = mysql_result($result, $i, TBL_PLAYERS . ".Rank");
        $gamer_id = mysql_result($result, $i, TBL_PLAYERS . ".Gamer");
        $gamer = new Gamer($gamer_id);
        $pname = $gamer->getField('Name');
        $pteam = mysql_result($result, $i, TBL_PLAYERS . ".Team");
        list($pclan, $pclantag, $pclanid) = getClanInfo($pteam);
        if ($puid != USERID && ($uteam == 0 || $uteam != $pteam)) {
            if ($prank == 0) {
                $prank_txt = EB_EVENT_L54;
            } else {
                $prank_txt = "#{$prank}";
            }
            $text .= '<option value="' . $pid . '">' . $pclantag . $pname . ' (' . $prank_txt . ')</option>';
        }
    }
    $text .= '
	</select>
	</td>
Ejemplo n.º 10
0
	public function setGamer(Gamer $gamer){
		$gamer->addScore($this);
		$this->gamer = $gamer;
	}
Ejemplo n.º 11
0
                 $text .= '</tr>';
             }
         }
     }
     break;
 case "One Player Tournament":
 case "One Player Ladder":
     // One player event
     //------------
     // Find gamer for that user
     $q = "SELECT " . TBL_GAMERS . ".*" . " FROM " . TBL_GAMERS . " WHERE (" . TBL_GAMERS . ".Game = '" . $event->getField('Game') . "')" . "   AND (" . TBL_GAMERS . ".User = "******")";
     $result = $sql->db_Query($q);
     $num_rows = mysql_numrows($result);
     if ($num_rows != 0) {
         $gamerID = mysql_result($result, 0, TBL_GAMERS . ".GamerID");
         $gamer = new Gamer($gamerID);
         $gamerName = $gamer->getField('Name');
         $gamerUniqueGameID = $gamer->getField('UniqueGameID');
     } else {
         $gamerID = 0;
         $gamerName = '';
         $gamerUniqueGameID = '';
     }
     // Is the user already signed up?
     $q = "SELECT " . TBL_PLAYERS . ".*, " . TBL_GAMERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')" . "   AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . "   AND (" . TBL_GAMERS . ".User = "******")";
     $result = $sql->db_Query($q);
     if (!$result || mysql_numrows($result) < 1) {
         // User is not signed up
         if ($can_signup == 1) {
             $hide_password = $event->getField('password') == "" ? 'hide ignore' : '';
             $text .= '<tr><td style="text-align:right">
Ejemplo n.º 12
0
// tabs-4 "Matches"
$text .= '<div id="tabs-5">';
$rowsPerPage = $pref['eb_default_items_per_page'];
$awards = array();
$nbr_awards = 0;
/* Latest awards */
$q = "SELECT " . TBL_AWARDS . ".*, " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_AWARDS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_AWARDS . ".Player = " . TBL_PLAYERS . ".PlayerID)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******".user_id)" . " AND (" . TBL_PLAYERS . ".Event = '{$event_id}')" . " ORDER BY " . TBL_AWARDS . ".timestamp DESC" . " LIMIT 0, {$rowsPerPage}";
$result = $sql->db_Query($q);
$numAwards = mysql_numrows($result);
if ($numAwards > 0) {
    /* Display table contents */
    for ($i = 0; $i < $numAwards; $i++) {
        $aID = mysql_result($result, $i, TBL_AWARDS . ".AwardID");
        $aUser = mysql_result($result, $i, TBL_USERS . ".user_id");
        $gamer_id = mysql_result($result, $i, TBL_PLAYERS . ".Gamer");
        $gamer = new Gamer($gamer_id);
        $aUserNickName = $gamer->getField('Name');
        $aType = mysql_result($result, $i, TBL_AWARDS . ".Type");
        $aTime = mysql_result($result, $i, TBL_AWARDS . ".timestamp");
        $aTime_local = $aTime + TIMEOFFSET;
        $date = date("d M Y, h:i A", $aTime_local);
        switch ($aType) {
            case 'PlayerTookFirstPlace':
                $award = EB_AWARD_L2;
                $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/award_star_gold_3.png") . ' alt="' . EB_AWARD_L3 . '" title="' . EB_AWARD_L3 . '"/> ';
                break;
            case 'PlayerInTopTen':
                $award = EB_AWARD_L4;
                $icon = '<img ' . getActivityIconResize(e_PLUGIN . "ebattles/images/awards/award_star_bronze_3.png") . ' alt="' . EB_AWARD_L5 . '" title="' . EB_AWARD_L5 . '"/> ';
                break;
            case 'PlayerStreak5':
Ejemplo n.º 13
0
/**
* displayTeamDivisions - Displays ...
*/
function displayTeamDivisions($clan_id, $game_id)
{
    global $sql;
    global $text;
    $q = "SELECT " . TBL_CLANS . ".*, " . TBL_DIVISIONS . ".*, " . TBL_USERS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_CLANS . ", " . TBL_DIVISIONS . ", " . TBL_USERS . ", " . TBL_GAMES . " WHERE (" . TBL_CLANS . ".ClanID = '{$clan_id}')" . " AND (" . TBL_DIVISIONS . ".Clan = " . TBL_CLANS . ".ClanID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_DIVISIONS . ".Captain)" . " AND (" . TBL_GAMES . ".GameID = " . TBL_DIVISIONS . ".Game)";
    $result = $sql->db_Query($q);
    $num_divs = mysql_numrows($result);
    for ($i = 0; $i < $num_divs; $i++) {
        $gid = mysql_result($result, $i, TBL_GAMES . ".GameID");
        $gname = mysql_result($result, $i, TBL_GAMES . ".Name");
        $gicon = mysql_result($result, $i, TBL_GAMES . ".Icon");
        $div_id = mysql_result($result, $i, TBL_DIVISIONS . ".DivisionID");
        $div_captain = mysql_result($result, $i, TBL_USERS . ".user_id");
        $div_captain_name = mysql_result($result, $i, TBL_USERS . ".user_name");
        $clan_password = mysql_result($result, $i, TBL_CLANS . ".password");
        $clan_id = mysql_result($result, $i, TBL_CLANS . ".ClanID");
        if ($gid == $game_id) {
            $text .= '<div class="spacer">';
            $text .= '<p>' . EB_CLAN_L9 . ': <a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $div_captain_name . '</a></p>';
            if (check_class(e_UC_MEMBER)) {
                // Find gamer for that user
                $q_2 = "SELECT " . TBL_GAMERS . ".*" . " FROM " . TBL_GAMERS . " WHERE (" . TBL_GAMERS . ".Game = '" . $gid . "')" . "   AND (" . TBL_GAMERS . ".User = "******")";
                $result_2 = $sql->db_Query($q_2);
                $num_Gamers = mysql_numrows($result_2);
                if ($num_Gamers != 0) {
                    $gamerID = mysql_result($result_2, 0, TBL_GAMERS . ".GamerID");
                    $gamer = new Gamer($gamerID);
                    $gamerName = $gamer->getField('Name');
                    $gamerUniqueGameID = $gamer->getField('UniqueGameID');
                } else {
                    $gamerID = 0;
                    $gamerName = '';
                    $gamerUniqueGameID = '';
                }
                $q_2 = "SELECT " . TBL_MEMBERS . ".*" . " FROM " . TBL_MEMBERS . " WHERE (" . TBL_MEMBERS . ".Division = '{$div_id}')" . " AND (" . TBL_MEMBERS . ".User = "******")";
                $result_2 = $sql->db_Query($q_2);
                if (!$result_2 || mysql_numrows($result_2) < 1) {
                    $hide_password = $clan_password == "" ? 'hide ignore' : '';
                    $text .= '
					<div>
					<input type="hidden" name="division" value="' . $div_id . '"/>
					</div>
					' . ebImageTextButton('joindivision', 'user_add.png', EB_CLAN_L12);
                    $text .= gamerDivisionSignupModalForm($clan_id, $div_id, $gamerID, $gamerName, $gamerUniqueGameID, $hide_password);
                } else {
                    // Check that the member has made no games with this division
                    $q_MemberScores = "SELECT " . TBL_MEMBERS . ".*, " . TBL_TEAMS . ".*, " . TBL_PLAYERS . ".*, " . TBL_SCORES . ".*" . " FROM " . TBL_MEMBERS . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_SCORES . " WHERE (" . TBL_MEMBERS . ".User = "******")" . " AND (" . TBL_MEMBERS . ".Division = '{$div_id}')" . " AND (" . TBL_TEAMS . ".Division = '{$div_id}')" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_SCORES . ".Player = " . TBL_PLAYERS . ".PlayerID)";
                    $result_MemberScores = $sql->db_Query($q_MemberScores);
                    $numMemberScores = mysql_numrows($result_MemberScores);
                    if ($numMemberScores == 0) {
                        $text .= '
						<form action="' . e_PLUGIN . 'ebattles/claninfo.php?clanid=' . $clan_id . '" method="post">
						<div>
						<input type="hidden" name="division" value="' . $div_id . '"/>
						</div>
						' . ebImageTextButton('quitdivision', 'user_delete.ico', EB_CLAN_L13, 'negative jq-button', EB_CLAN_L25) . '
						</form>';
                    }
                }
            }
            $q_2 = "SELECT " . TBL_CLANS . ".*, " . TBL_DIVISIONS . ".*, " . TBL_MEMBERS . ".*, " . TBL_USERS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_CLANS . ", " . TBL_DIVISIONS . ", " . TBL_USERS . ", " . TBL_MEMBERS . ", " . TBL_GAMES . " WHERE (" . TBL_CLANS . ".ClanID = '{$clan_id}')" . " AND (" . TBL_DIVISIONS . ".Clan = " . TBL_CLANS . ".ClanID)" . " AND (" . TBL_DIVISIONS . ".DivisionID = '{$div_id}')" . " AND (" . TBL_MEMBERS . ".Division = " . TBL_DIVISIONS . ".DivisionID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_MEMBERS . ".User)" . " AND (" . TBL_GAMES . ".GameID = " . TBL_DIVISIONS . ".Game)";
            $result_2 = $sql->db_Query($q_2);
            if (!$result_2 || mysql_numrows($result_2) < 1) {
                $text .= '<p>' . EB_CLAN_L14 . '</p>';
            } else {
                $row = mysql_fetch_array($result_2);
                $numMembers = mysql_numrows($result_2);
                $text .= '<p>' . $numMembers . '&nbsp;' . EB_CLAN_L15 . '</p>';
                $text .= '<table class="eb_table" style="width:95%"><tbody>';
                $text .= '<tr>
				<th class="eb_th2">' . EB_CLAN_L16 . '</th>
				<th class="eb_th2">' . EB_CLAN_L17 . '</th>
				<th class="eb_th2">' . EB_CLAN_L18 . '</th>
				</tr>';
                // Captain
                for ($j = 0; $j < $numMembers; $j++) {
                    $mid = mysql_result($result_2, $j, TBL_USERS . ".user_id");
                    $mname = mysql_result($result_2, $j, TBL_USERS . ".user_name");
                    $mjoined = mysql_result($result_2, $j, TBL_MEMBERS . ".timestamp");
                    $mjoined_local = $mjoined + TIMEOFFSET;
                    $date = date("d M Y", $mjoined_local);
                    if ($mid == $div_captain) {
                        $status = EB_CLAN_L9;
                        $text .= '<tr>';
                        $text .= '<td class="eb_td"><b><a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $mname . '</a></b></td>
						<td class="eb_td">' . $status . '</td>
						<td class="eb_td">' . $date . '</td></tr>';
                    }
                }
                // Other members
                for ($j = 0; $j < $numMembers; $j++) {
                    $mid = mysql_result($result_2, $j, TBL_USERS . ".user_id");
                    $mname = mysql_result($result_2, $j, TBL_USERS . ".user_name");
                    $mjoined = mysql_result($result_2, $j, TBL_MEMBERS . ".timestamp");
                    $mjoined_local = $mjoined + TIMEOFFSET;
                    $date = date("d M Y", $mjoined_local);
                    if ($mid != $div_captain) {
                        $status = EB_CLAN_L26;
                        $text .= '<tr>';
                        $text .= '<td class="eb_td"><b><a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $mname . '</a></b></td>
						<td class="eb_td">' . $status . '</td>
						<td class="eb_td">' . $date . '</td></tr>';
                    }
                }
                $text .= '</tbody></table>';
            }
            $text .= '<br /></div>';
        }
    }
}