Esempio n. 1
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;
 }
Esempio n. 2
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;
}
Esempio n. 3
0
 function displayChallengeInfo($type = 0)
 {
     global $time;
     global $sql;
     global $pref;
     $string = '';
     // Get info about the challenge
     $q = "SELECT DISTINCT " . TBL_CHALLENGES . ".*, " . TBL_USERS . ".*, " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_CHALLENGES . ", " . TBL_USERS . ", " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_CHALLENGES . ".ChallengeID = '" . $this->fields['ChallengeID'] . "')" . " AND (" . TBL_USERS . ".user_id = " . TBL_CHALLENGES . ".ReportedBy)" . " AND (" . TBL_CHALLENGES . ".Event = " . TBL_EVENTS . ".EventID)" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)";
     $result = $sql->db_Query($q);
     $numChallenges = mysql_numrows($result);
     if ($numChallenges > 0) {
         $cReportedBy = mysql_result($result, 0, TBL_USERS . ".user_id");
         $cReportedByNickName = mysql_result($result, 0, TBL_USERS . ".user_name");
         $cEventgame = mysql_result($result, 0, TBL_GAMES . ".Name");
         $cEventgameicon = mysql_result($result, 0, TBL_GAMES . ".Icon");
         $cStatus = mysql_result($result, 0, TBL_CHALLENGES . ".Status");
         $cTime = mysql_result($result, 0, TBL_CHALLENGES . ".TimeReported");
         $cTime_local = $cTime + TIMEOFFSET;
         $date = date("d M Y, h:i A", $cTime_local);
         $event_id = mysql_result($result, 0, TBL_EVENTS . ".EventID");
         $event = new Event($event_id);
         $cChallengerpID = mysql_result($result, 0, TBL_CHALLENGES . ".ChallengerPlayer");
         $cChallengedpID = mysql_result($result, 0, TBL_CHALLENGES . ".ChallengedPlayer");
         $cChallengertID = mysql_result($result, 0, TBL_CHALLENGES . ".ChallengerTeam");
         $cChallengedtID = mysql_result($result, 0, TBL_CHALLENGES . ".ChallengedTeam");
         $string .= '<tr>';
         // Game icon
         if (($type & eb_MATCH_NOEVENTINFO) == 0) {
             $string .= '<td style="vertical-align:top"><a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event->getField('EventID') . '" title="' . $cEventgame . '">';
             $string .= '<img ' . getActivityGameIconResize($cEventgameicon) . '/>';
             $string .= '</a></td>';
         }
         $string .= '<td>';
         // User info
         $q = "SELECT " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*, " . TBL_TEAMS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . ", " . TBL_TEAMS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')" . "   AND (" . TBL_TEAMS . ".TeamID = " . TBL_PLAYERS . ".Team)" . "   AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . "   AND (" . TBL_GAMERS . ".User = '******')";
         $result = $sql->db_Query($q);
         $uteam = mysql_result($result, 0, TBL_PLAYERS . ".Team");
         switch ($event->getMatchPlayersType()) {
             case 'Players':
                 // Challenger Info
                 $q = "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)" . "   AND (" . TBL_PLAYERS . ".PlayerID = '{$cChallengerpID}')";
                 $result = $sql->db_Query($q);
                 $challengerpid = mysql_result($result, 0, TBL_PLAYERS . ".PlayerID");
                 $challengerpuid = mysql_result($result, 0, TBL_USERS . ".user_id");
                 $challengerpname = mysql_result($result, 0, TBL_USERS . ".user_name");
                 $challengerpavatar = mysql_result($result, $index, TBL_USERS . ".user_image");
                 $challengerpteam = mysql_result($result, $index, TBL_PLAYERS . ".Team");
                 list($challengerpclan, $challengerpclantag, $challengerpclanid) = getClanInfo($challengerpteam);
                 $isUserChallenger = USERID == $challengerpuid ? TRUE : FALSE;
                 $string .= '<a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $challengerpclantag . $challengerpname . '</a>';
                 $string .= ' vs. ';
                 // Challenged Info
                 $q = "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)" . "   AND (" . TBL_PLAYERS . ".PlayerID = '{$cChallengedpID}')";
                 $result = $sql->db_Query($q);
                 $challengedpid = mysql_result($result, 0, TBL_PLAYERS . ".PlayerID");
                 $challengedpuid = mysql_result($result, 0, TBL_USERS . ".user_id");
                 $challengedpname = mysql_result($result, 0, TBL_USERS . ".user_name");
                 $challengedpavatar = mysql_result($result, $index, TBL_USERS . ".user_image");
                 $challengedpteam = mysql_result($result, $index, TBL_PLAYERS . ".Team");
                 list($challengedpclan, $challengedpclantag, $challengedpclanid) = getClanInfo($challengedpteam);
                 $isUserChallenged = USERID == $challengedpuid ? TRUE : FALSE;
                 $string .= '<a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $challengedpclantag . $challengedpname . '</a>';
                 break;
             case 'Teams':
                 // Challenger Info
                 $q = "SELECT " . TBL_TEAMS . ".*" . "   AND (" . TBL_TEAMS . ".TeamID = '{$cChallengertID}')";
                 $result = $sql->db_Query($q);
                 $challengertrank = mysql_result($result, 0, TBL_TEAMS . ".Rank");
                 list($challengertclan, $challengertclantag, $challengertclanid) = getClanInfo($cChallengertID);
                 $isUserChallenger = $uteam == $cChallengertID ? TRUE : FALSE;
                 $string .= '<a href="' . e_PLUGIN . 'ebattles/claninfo.php?clanid=' . $challengertclanid . '">' . $challengertclan . '</a>';
                 $string .= ' vs. ';
                 // Challenged Info
                 $q = "SELECT " . TBL_TEAMS . ".*" . "   AND (" . TBL_TEAMS . ".TeamID = '{$cChallengedtID}')";
                 $result = $sql->db_Query($q);
                 $challengedtrank = mysql_result($result, 0, TBL_TEAMS . ".Rank");
                 list($challengedtclan, $challengedtclantag, $challengedtclanid) = getClanInfo($cChallengedtID);
                 $isUserChallenged = $uteam == $cChallengedtID ? TRUE : FALSE;
                 $string .= '<a href="' . e_PLUGIN . 'ebattles/claninfo.php?clanid=' . $challengedtclanid . '">' . $challengedtclan . '</a>';
                 break;
             default:
         }
         // Event
         if (($type & eb_MATCH_NOEVENTINFO) == 0) {
             $string .= ' ' . EB_MATCH_L12 . ' <a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . $event->getField('Name') . '</a>';
         }
         // Submitted by
         $string .= ' <div class="smalltext">';
         $string .= EB_MATCH_L15 . ' <a href="' . e_PLUGIN . 'ebattles/userinfo.php?user='******'">' . $cReportedByNickName . '</a> ';
         if ($time - $cTime < INT_MINUTE) {
             $string .= EB_MATCH_L7;
         } else {
             if ($time - $cTime < INT_DAY) {
                 $string .= get_formatted_timediff($cTime, $time) . '&nbsp;' . EB_MATCH_L8;
             } else {
                 $string .= EB_MATCH_L9 . '&nbsp;' . $date . '.';
             }
         }
         $string .= '</div></td>';
         // Action form
         // Is the user a moderator?
         $can_delete = 0;
         $q_Mods = "SELECT " . TBL_EVENTMODS . ".*" . " FROM " . TBL_EVENTMODS . " WHERE (" . TBL_EVENTMODS . ".Event = '{$event_id}')" . "   AND (" . TBL_EVENTMODS . ".User = "******")";
         $result_Mods = $sql->db_Query($q_Mods);
         $numMods = mysql_numrows($result_Mods);
         if (check_class($pref['eb_mod_class'])) {
             $can_delete = 1;
         }
         if (USERID == $eowner) {
             $userclass |= eb_UC_EVENT_OWNER;
             $can_delete = 1;
         }
         if ($numMods > 0) {
             $userclass |= eb_UC_EB_MODERATOR;
             $can_delete = 1;
         }
         // If the user is challenger, show the "Withdraw" button
         /*
         if ($isUserChallenger == TRUE)
         {
         $can_delete = 1;
         }
         */
         if ($can_delete == 1) {
             $string .= '<td>';
             $string .= '<form action="' . e_PLUGIN . 'ebattles/challengeconfirm.php?eventid=' . $event_id . '&amp;challengeid=' . $this->fields['ChallengeID'] . '" method="post">';
             $string .= '<div>';
             $string .= ebImageTextButton('challenge_withdraw', 'delete.png', '', 'simple', EB_CHALLENGE_L16, EB_CHALLENGE_L15);
             $string .= '</div>';
             $string .= '</form>';
             $string .= '</td>';
         }
         // If the user is challenged, show the "Confirm"  button
         if ($isUserChallenged == TRUE) {
             $string .= '<td>';
             $string .= '<form action="' . e_PLUGIN . 'ebattles/challengeconfirm.php?eventid=' . $event_id . '&amp;challengeid=' . $this->fields['ChallengeID'] . '" method="post">';
             $string .= '<div>';
             $string .= ebImageTextButton('challenge_confirm', 'page_white_edit.png', '', 'simple', '', EB_CHALLENGE_L17);
             $string .= '</div>';
             $string .= '</form>';
             $string .= '</td>';
         }
         // If the user is admin/moderator, show the "Edit" button
         // fm: TBD ???
         $string .= '</tr>';
     }
     return $string;
 }