/** * displayEvents - Displays the events database table in * a nicely formatted html table. */ function displayPastEvents() { global $sql; global $text; global $time; $pages = new Paginator(); $array = array('latest' => array(EB_EVENTS_L4, 'EventID'), 'name' => array(EB_EVENTS_L5, TBL_EVENTS . '.Name'), 'game' => array(EB_EVENTS_L6, TBL_GAMES . '.Name'), 'type' => array(EB_EVENTS_L7, TBL_EVENTS . '.Type'), 'start' => array(EB_EVENTS_L8, TBL_EVENTS . '.StartDateTime')); if (!isset($_GET['gameid'])) { $_GET['gameid'] = "All"; } $gameid = eb_sanitize($_GET['gameid']); if (!isset($_GET['matchtype'])) { $_GET['matchtype'] = "All"; } $matchtype = eb_sanitize($_GET['matchtype']); if (!isset($_GET['orderby'])) { $_GET['orderby'] = 'game'; } $orderby = eb_sanitize($_GET['orderby']); $sort = "ASC"; if (isset($_GET["sort"]) && !empty($_GET["sort"])) { $sort = $_GET["sort"] == "ASC" ? "DESC" : "ASC"; } $game_string = $gameid == "All" ? "" : " AND (" . TBL_EVENTS . ".Game = '{$gameid}')"; $matchtype_string = $matchtype == "All" ? "" : " AND (" . TBL_GAMES . ".MatchTypes LIKE '%{$matchtype}%')"; // Drop down list to select Games to display $q_Games = "SELECT DISTINCT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES . ", " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $matchtype_string . " ORDER BY Name"; $result_Games = $sql->db_Query($q_Games); $numGames = mysql_numrows($result_Games); // Drop down list to select Match type to display $q_mt = "SELECT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES . ", " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $game_string; $result_mt = $sql->db_Query($q_mt); $num_mt = mysql_numrows($result_mt); $gmatchtypes = ''; for ($i = 0; $i < $num_mt; $i++) { $gmatchtypes .= ',' . mysql_result($result_mt, $i, TBL_GAMES . ".MatchTypes"); } $text .= '<form id="submitform" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="get">'; $text .= '<div>'; $text .= '<table class="table_left">'; $text .= '<tr>'; // Games drop down $text .= '<td>' . EB_EVENTS_L9 . '<br />'; $text .= '<select class="tbox" name="gameid" onchange="this.form.submit()">'; $text .= '<option value="All" ' . ($gameid == "All" ? 'selected="selected"' : '') . '>' . EB_EVENTS_L10 . '</option>'; for ($i = 0; $i < $numGames; $i++) { $gName = mysql_result($result_Games, $i, TBL_GAMES . ".Name"); $gid = mysql_result($result_Games, $i, TBL_GAMES . ".GameID"); $text .= '<option value="' . $gid . '" ' . ($gameid == $gid ? 'selected="selected"' : '') . '>' . htmlspecialchars($gName) . '</option>'; } $text .= '</select>'; $text .= '</td>'; // Match Types drop down $text .= '<td>' . EB_EVENTS_L32 . '<br />'; $text .= '<select class="tbox" name="matchtype" onchange="this.form.submit()">'; $text .= '<option value="All" ' . ($matchtype == "All" ? 'selected="selected"' : '') . '>' . EB_EVENTS_L10 . '</option>'; $gmatchtypes = explode(",", $gmatchtypes); $gmatchtypes = array_unique($gmatchtypes); sort($gmatchtypes); foreach ($gmatchtypes as $gmatchtype) { if ($gmatchtype != '') { $text .= '<option value="' . $gmatchtype . '" ' . ($gmatchtype == $matchtype ? 'selected="selected"' : '') . '>' . htmlspecialchars($gmatchtype) . '</option>'; } } $text .= '</select>'; $text .= '</td>'; $text .= '</tr>'; $text .= '</table>'; $game_string = $gameid == "All" ? "" : " AND (" . TBL_EVENTS . ".Game = '{$gameid}')"; $matchtype_string = $matchtype == "All" ? "" : " AND (" . TBL_EVENTS . ".MatchType = '{$matchtype}')"; $q = "SELECT count(*) " . " FROM " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Status = 'finished')" . $game_string . $matchtype_string; $result = $sql->db_Query($q); $totalItems = mysql_result($result, 0); $pages->items_total = $totalItems; $pages->mid_range = eb_PAGINATION_MIDRANGE; $pages->paginate(); $orderby_array = $array["{$orderby}"]; $q = "SELECT " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_EVENTS . ".Status = 'finished')" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $game_string . $matchtype_string . " ORDER BY {$orderby_array['1']} {$sort}, EventID DESC" . " {$pages->limit}"; $result = $sql->db_Query($q); $numEvents = mysql_numrows($result); if (!$result || $numEvents < 0) { /* Error occurred, return given name by default */ $text .= EB_EVENTS_L11 . '</div>'; $text .= '</form><br/>'; } else { if ($numEvents == 0) { $text .= EB_EVENTS_L12 . '</div>'; $text .= '</form><br/>'; } else { // Paginate & Sorting $items = ''; foreach ($array as $opt => $opt_array) { $items .= $opt == $orderby ? '<option selected="selected" value="' . $opt . '">' . $opt_array[0] . '</option>' : '<option value="' . $opt . '">' . $opt_array[0] . '</option>'; } // Paginate $text .= '<span class="paginate" style="float:left;">' . $pages->display_pages() . '</span>'; $text .= '<span style="float:right">'; // Sort By $text .= EB_PGN_L6; $text .= '<select class="tbox" name="orderby" onchange="this.form.submit()">'; $text .= $items; $text .= '</select>'; // Up/Down arrow $text .= '<input type="hidden" id="sort" name="sort" value=""/>'; if ($sort == "ASC") { $text .= '<a href="javascript:buttonval(\'ASC\');" title="Ascending"><img src="' . e_PLUGIN . 'ebattles/images/sort_asc.gif" alt="Asc" style="vertical-align:middle; border:0"/></a>'; } else { $text .= '<a href="javascript:buttonval(\'DESC\');" title="Descending"><img src="' . e_PLUGIN . 'ebattles/images/sort_desc.gif" alt="Desc" style="vertical-align:middle; border:0"/></a>'; } $text .= ' '; // Go To Page $text .= $pages->display_jump_menu(); $text .= ' '; // Items per page $text .= $pages->display_items_per_page(); $text .= '</span>'; $text .= '</div>'; $text .= '</form><br/><br/>'; /* Display table contents */ $text .= '<table class="eb_table" style="width:95%"><tbody>'; $text .= '<tr> <th class="eb_th2">' . EB_EVENTS_L13 . '</th> <th colspan="2" class="eb_th2">' . EB_EVENTS_L14 . '</th> <th class="eb_th2">' . EB_EVENTS_L15 . '</th> <th class="eb_th2">' . EB_EVENTS_L16 . '</th> <th class="eb_th2">' . EB_EVENTS_L17 . '</th> <th class="eb_th2">' . EB_EVENTS_L18 . '</th> <th class="eb_th2">' . EB_EVENTS_L19 . '</th> <th class="eb_th2">' . EB_EVENTS_L34 . '</th> </tr>'; for ($i = 0; $i < $numEvents; $i++) { $gName = mysql_result($result, $i, TBL_GAMES . ".Name"); $gIcon = mysql_result($result, $i, TBL_GAMES . ".Icon"); $event_id = mysql_result($result, $i, TBL_EVENTS . ".EventID"); $event = new Event($event_id); if ($event->getField('StartDateTime') != 0) { $startdatetime_local = $event->getField('StartDateTime') + TIMEOFFSET; $date_start = date("d M Y", $startdatetime_local); } else { $date_start = "-"; } if ($event->getField('EndDateTime') != 0) { $enddatetime_local = $event->getField('EndDateTime') + TIMEOFFSET; $date_end = date("d M Y", $enddatetime_local); } else { $date_end = "-"; } /* Nbr players */ $q_2 = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (Event = '{$event_id}')"; $result_2 = $sql->db_Query($q_2); $row = mysql_fetch_array($result_2); $nbrplayers = $row['NbrPlayers']; /* Nbr Teams */ $q_2 = "SELECT COUNT(*) as NbrTeams" . " FROM " . TBL_TEAMS . " WHERE (" . TBL_TEAMS . ".Event = '{$event_id}')"; $result_2 = $sql->db_Query($q_2); $row = mysql_fetch_array($result_2); $nbrTeams = $row['NbrTeams']; /* Nbr matches */ $q_2 = "SELECT COUNT(DISTINCT " . TBL_MATCHS . ".MatchID) as NbrMatches" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (Event = '{$event_id}')" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)"; $result_2 = $sql->db_Query($q_2); $row = mysql_fetch_array($result_2); $nbrmatches = $row['NbrMatches']; switch ($event->getField('Type')) { case "One Player Ladder": case "One Player Tournament": $nbrTeamPlayers = $nbrplayers; break; case "Team Ladder": $nbrTeamPlayers = $nbrTeams . '/' . $nbrplayers; break; case "Clan Ladder": case "Clan Tournament": $nbrTeamPlayers = $nbrTeams; break; default: } $text .= '<tr> <td class="eb_td"><a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . $event->getField('Name') . '</a></td> <td class="eb_td"><img ' . getGameIconResize($gIcon) . '/></td> <td class="eb_td">' . $gName . '</td> <td class="eb_td">' . ($event->getField('MatchType') != '' ? $event->getField('MatchType') . ' - ' : '') . $event->eventTypeToString() . '</td> <td class="eb_td">' . $date_start . '</td> <td class="eb_td">' . $date_end . '</td> <td class="eb_td">' . $nbrTeamPlayers . '</td> <td class="eb_td">' . $nbrmatches . '</td> <td class="eb_td">' . $event->eventStatusToString() . '</td> </tr>'; } $text .= '</tbody></table><br />'; $text .= '<div>'; $text .= ebImageLink('back_to_events', '', e_PLUGIN . 'ebattles/events.php', '', 'action_back.gif', EB_EVENTP_L3 . ' ' . EB_EVENTP_L4, 'jq-button'); $text .= '</div>'; } } }
<?php /** * embedded brackets * */ require_once "../../class2.php"; require_once e_PLUGIN . "ebattles/include/main.php"; require_once e_PLUGIN . "ebattles/include/event.php"; /******************************************************************* ********************************************************************/ $text = ''; $text .= '<html>'; $text .= '<head>'; $text .= '<link rel="stylesheet" type="text/css" href="./css/brackets.css" />'; $text .= '</head>'; $text .= '<body>'; $event_id = intval($_GET['eventid']); if (!$event_id) { header("Location: ./events.php"); exit; } $event = new Event($event_id); list($bracket_html) = $event->brackets(false, 0, 'elimination'); $text .= $bracket_html; $ns->tablerender($event->getField('Name') . " ({$egame} - " . $event->eventTypeToString() . ")", $text); ?>
function user_form($action, $players_id, $players_name, $event_id, $match_id, $allowDraw, $allowForfeit, $allowScore, $userclass, $date_scheduled, $user_player) { global $sql; global $text; global $tp; global $time; /* Event Info */ $event = new Event($event_id); if (e_WYSIWYG) { $insertjs = "rows='5'"; } else { require_once e_HANDLER . "ren_help.php"; $insertjs = "rows='5' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'"; } /* //dbg form echo "<br>_POST: "; var_dump($_POST); echo "<br>_GET: "; var_dump($_GET); */ $match_str = ''; $matchreport_str = EB_MATCHR_L31; if ($action == 'matchedit') { $matchreport_str = EB_MATCHR_L46; $text .= '<div>'; $text .= EB_MATCHR_L45 . " {$match_id}<br />"; $text .= '<img src="' . e_PLUGIN . 'ebattles/images/exclamation.png"/>'; $text .= EB_MATCHR_L47; $text .= '</div><br />'; } if ($action == 'matchschedulededit') { $matchreport_str = EB_MATCHR_L46; $text .= '<div>'; $text .= EB_MATCHR_L45 . " {$match_id}<br />"; $text .= '</div><br />'; } if ($action == 'matchschedule') { $matchreport_str = EB_MATCHR_L48; } if ($match_id) { $match_str = '&matchid=' . $match_id; } if ($action) { $action_str = '&actionid=' . $action; } // Assign values to POST if not set // fm: check might not be correct here // should check if $action=='matchedit') only? if (!isset($_POST['time_reported']) || $action == 'matchscheduledreport') { $_POST['time_reported'] = $time; } $time_reported = $_POST['time_reported']; if (!isset($_POST['reported_by'])) { $_POST['reported_by'] = USERID; } $reported_by = $_POST['reported_by']; if (isset($_POST['match_comment'])) { $comment = $tp->toDB($_POST['match_comment']); } else { $comment = ''; } for ($matchMap = 0; $matchMap < min($numMaps, $event->getField('MaxMapsPerMatch')); $matchMap++) { if (!isset($_POST['map' . $matchMap])) { $_POST['map' . $matchMap] = 0; } } // if vars are not set, set them as empty. if (!isset($_POST['nbr_players'])) { $_POST['nbr_players'] = 2; } if (!isset($_POST['nbr_teams'])) { $_POST['nbr_teams'] = 2; } // This form should only be used for 2 teams matches (1v1, 2v2, ...) // now to output the form HTML. $max_nbr_players = count($players_id) - 1; $nbr_players = $_POST['nbr_players']; $nbr_teams = $_POST['nbr_teams']; $nbr_players_per_team = $_POST['nbr_players'] / $_POST['nbr_teams']; $i = 1; // player index for ($t = 1; $t <= $nbr_teams; $t++) { if (!isset($_POST['rank' . $t])) { $_POST['rank' . $t] = 'Team #' . $t; } for ($p = 1; $p <= $nbr_players_per_team; $p++) { if (!isset($_POST['team' . $i])) { $_POST['team' . $i] = 'Team #' . $t; } if (!isset($_POST['score' . $i])) { $_POST['score' . $i] = 0; } if (!isset($_POST['faction' . $i])) { $_POST['faction' . $i] = 0; } $i++; } } $result = 1; if ($_POST['rank1'] == 'Team #2' && $_POST['rank2'] == 'Team #1') { $result = 2; } if ($_POST['draw2'] == 1) { $result = 3; } if ($_POST['rank1'] == 'Team #2' && $_POST['rank2'] == 'Team #1' && $_POST['forfeit2'] == 1) { $result = 4; } if ($_POST['rank1'] == 'Team #1' && $_POST['rank2'] == 'Team #2' && $_POST['forfeit2'] == 1) { $result = 5; } if (!isset($_POST['result'])) { $_POST['result'] = $result; } //var_dump($result); ///////////////// /// MAIN FORM /// ///////////////// $text .= '<form id="matchreportform" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?eventid=' . $event_id . $match_str . $action_str . '" method="post">'; $text .= '<div>'; // TABLE - Match result if ($nbr_players > 2) { $array_result = array(1 => array(EB_MATCHR_L60, true), 2 => array(EB_MATCHR_L61, true), 3 => array(EB_MATCHR_L62, $allowDraw == TRUE ? true : false), 4 => array(EB_MATCHR_L63, $allowForfeit == TRUE ? true : false), 5 => array(EB_MATCHR_L64, $allowForfeit == TRUE ? true : false)); } else { $array_result = array(1 => array(EB_MATCHR_L65, true), 2 => array(EB_MATCHR_L66, true), 3 => array(EB_MATCHR_L67, $allowDraw == TRUE ? true : false), 4 => array(EB_MATCHR_L68, $allowForfeit == TRUE ? true : false), 5 => array(EB_MATCHR_L69, $allowForfeit == TRUE ? true : false)); } if ($action != 'matchschedule' && $action != 'matchschedulededit') { $text .= '<table id="matchresult_selectresult" class="table_left"><tbody>'; $text .= '<tr>'; $text .= '<td>' . EB_MATCHR_L59 . '</td>'; $text .= '<td>'; $text .= '<select class="tbox" name="result">'; foreach ($array_result as $opt => $opt_array) { if ($opt_array[1] == true) { $selected_str = $_POST['result'] == $opt ? 'selected="selected"' : ''; $text .= '<option value="' . $opt . '" ' . $selected_str . '>' . $opt_array[0] . '</option>'; } } $text .= '</select>'; $text .= '</td>'; $text .= '</tr>'; $text .= '</tbody></table>'; } // TABLE - Players/Teams Selection //---------------------------------- // List of all Factions $q_Factions = "SELECT " . TBL_FACTIONS . ".*" . " FROM " . TBL_FACTIONS . " WHERE (" . TBL_FACTIONS . ".Game = '" . $event->getField('Game') . "')"; $result_Factions = $sql->db_Query($q_Factions); $numFactions = mysql_numrows($result_Factions); $disable_input = $action == 'matchscheduledreport' ? 1 : 0; if ($action != 'matchschedulededit') { // TABLE - Teams //$text .= EB_MATCHR_L20; $text .= '<table id="matchresult_teams" style="text-align:center" class="table_left">'; $text .= '<thead>'; $text .= '<tr>'; $text .= '<th class="eb_th1"></th>'; // Team # $text .= '<th class="eb_th1"></th>'; // Player # $text .= '<th class="eb_th1"></th>'; // Name if ($action != 'matchschedule' && $action != 'matchschedulededit' && $allowScore == TRUE) { $text .= '<th class="eb_th1">' . EB_MATCHR_L26 . '</th>'; } // Score if ($action != 'matchschedule' && $action != 'matchschedulededit' && $numFactions > 0) { $text .= '<th class="eb_th1">' . EB_MATCHR_L41 . '</th>'; } // Faction $text .= '</tr>'; $text .= '</thead>'; $text .= '<tbody>'; $p = 1; // player index for ($t = 1; $t <= $nbr_teams; $t++) { if ($nbr_players > 2) { $p = 1; } // reset player number $text .= '<tr>'; $text .= '<td>'; $text .= $nbr_players > 2 ? EB_MATCHR_L10 . $t : ''; $text .= '</td>'; $text .= '</tr>'; for ($i = 1; $i <= $nbr_players; $i++) { if ($_POST['team' . $i] == 'Team #' . $t) { $text .= '<tr>'; $text .= '<td>'; $text .= '<input type="hidden" name="team' . $i . '" value="Team #' . $t . '"/>'; $text .= '</td>'; $text .= '<td>' . EB_MATCHR_L23 . $p . ': </td>'; $match_winner = 0; if ($event->getField('match_report_userclass') == eb_UC_MATCH_WINNER && $userclass == eb_UC_EVENT_PLAYER && $i == 1 && $user_player != 0) { $match_winner = 1; $_POST['player' . $i] = $user_player; } if ($disable_input == 1 || $match_winner == 1) { for ($j = 1; $j <= $max_nbr_players + 1; $j++) { if (strtolower($_POST['player' . $i]) == strtolower($players_id[$j - 1])) { $text .= '<td><input type="hidden" name="player' . $i . '" value="' . $players_id[$j - 1] . '"/>'; $text .= $players_name[$j - 1] . '</td>'; } } } else { $text .= '<td><select class="tbox" name="player' . $i . '">'; for ($j = 1; $j <= $max_nbr_players + 1; $j++) { $text .= '<option value="' . $players_id[$j - 1] . '"'; if (strtolower($_POST['player' . $i]) == strtolower($players_id[$j - 1])) { $text .= ' selected="selected"'; } $text .= '>' . $players_name[$j - 1] . '</option>'; } $text .= '</select></td>'; } if ($action != 'matchschedule' && $action != 'matchschedulededit') { if ($allowScore == TRUE) { $text .= '<td>'; $text .= '<input class="tbox" type="text" size="3" name="score' . $i . '" value="' . $_POST['score' . $i] . '"/>'; $text .= '</td>'; } if ($numFactions > 0) { $text .= '<td><select class="tbox" name="faction' . $i . '">'; $text .= '<option value="0"'; $text .= '>' . EB_MATCHR_L43 . '</option>'; for ($faction = 1; $faction <= $numFactions; $faction++) { $fID = mysql_result($result_Factions, $faction - 1, TBL_FACTIONS . ".FactionID"); $fIcon = mysql_result($result_Factions, $faction - 1, TBL_FACTIONS . ".Icon"); $fName = mysql_result($result_Factions, $faction - 1, TBL_FACTIONS . ".Name"); $text .= '<option value="' . $fID . '"'; if (strtolower($_POST['faction' . $i]) == $fID) { $text .= ' selected="selected"'; } $text .= '>' . $fName . '</option>'; } $text .= '</select></td>'; } } $p++; $text .= '</tr>'; } } } $text .= '</tbody>'; $text .= '</table>'; $text .= '<br />'; // Map Selection //---------------------------------- // List of all Maps $q_Maps = "SELECT " . TBL_MAPS . ".*" . " FROM " . TBL_MAPS . " WHERE (" . TBL_MAPS . ".Game = '" . $event->getField('Game') . "')"; $result_Maps = $sql->db_Query($q_Maps); $numMaps = mysql_numrows($result_Maps); if ($numMaps > 0) { $text .= EB_MATCHR_L42; $text .= '<table id="matchresult_selectMap" class="table_left"><tbody>'; for ($matchMap = 0; $matchMap < min($numMaps, $event->getField('MaxMapsPerMatch')); $matchMap++) { $text .= '<tr>'; $text .= '<td><select class="tbox" name="map' . $matchMap . '">'; $text .= '<option value="0"'; $text .= '>' . EB_MATCHR_L43 . '</option>'; for ($map = 0; $map < $numMaps; $map++) { $mID = mysql_result($result_Maps, $map, TBL_MAPS . ".MapID"); $mImage = mysql_result($result_Maps, $map, TBL_MAPS . ".Image"); $mName = mysql_result($result_Maps, $map, TBL_MAPS . ".Name"); $mDescrition = mysql_result($result_Maps, $map, TBL_MAPS . ".Description"); $text .= '<option value="' . $mID . '"'; if (strtolower($_POST['map' . $matchMap]) == $mID) { $text .= ' selected="selected"'; } $text .= '>' . $mName . '</option>'; } $text .= '</select></td>'; $text .= '</tr>'; } $text .= '</tbody></table>'; $text .= '<br />'; } } if ($action != 'matchschedule' && $action != 'matchschedulededit') { // Comments //---------------------------------- $text .= '<br />'; $text .= '<div style="display:table; margin-left:auto; margin-right:auto;">'; $text .= EB_MATCHR_L30 . '<br />'; $text .= '<textarea class="tbox" id="match_comment" name="match_comment" style="width:400px" cols="70" ' . $insertjs . '>' . $comment . '</textarea>'; if (!e_WYSIWYG) { $text .= '<br />' . display_help("helpb", "comment"); } $text .= '</div>'; $text .= '<br />'; } if ($action == 'matchschedule' || $action == 'matchschedulededit') { //<!-- Date Selection --> $text .= EB_MATCHR_L49; $text .= ' <table> <tr> <td> <table> <tr> <td> <div><input class="tbox timepicker" type="text" name="date_scheduled" id="f_date" value="' . $date_scheduled . '" readonly="readonly" /></div> </td> <td> <div><input class="eb_button" type="button" value="' . EB_MATCHR_L51 . '" onclick="clearDate(this.form);"/></div> </td> </tr> </table> </td> </tr> </table> '; } $text .= '<div style="display:table; margin-left:auto; margin-right:auto;">'; $text .= '<input type="hidden" name="nbr_players" value="' . $nbr_players . '"/>'; $text .= '<input type="hidden" name="nbr_teams" value="' . $nbr_teams . '"/>'; $text .= '<input type="hidden" name="userclass" value="' . $userclass . '"/>'; $text .= '<input type="hidden" name="reported_by" value="' . $reported_by . '"/>'; $text .= '<input type="hidden" name="time_reported" value="' . $time_reported . '"/>'; $text .= '<input class="eb_button" type="submit" value="' . $matchreport_str . '" name="submit_match"/>'; $text .= '<span id="ajaxSpinnerContainer"> <img src="' . e_PLUGIN . 'ebattles/images/ajax-loader.gif" title="working..." alt="working..."/> ' . EB_EVENTM_L157 . ' </span>'; $text .= '</div>'; $text .= '</div>'; $text .= '</form>'; }
function displayRecentEvents() { global $pref; global $sql; global $text; global $time; $pages = new Paginator(); // how many rows to show per page $rowsPerPage = $pref['eb_default_items_per_page']; if (!isset($_GET['gameid'])) { $_GET['gameid'] = "All"; } $gameid = eb_sanitize($_GET['gameid']); if (!isset($_GET['matchtype'])) { $_GET['matchtype'] = "All"; } $matchtype = eb_sanitize($_GET['matchtype']); $game_string = $gameid == "All" ? "" : " AND (" . TBL_EVENTS . ".Game = '{$gameid}')"; $matchtype_string = $matchtype == "All" ? "" : " AND (" . TBL_GAMES . ".MatchTypes LIKE '%{$matchtype}%')"; // Drop down list to select Games to display $q_Games = "SELECT DISTINCT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES . ", " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $matchtype_string . " ORDER BY Name"; $result_Games = $sql->db_Query($q_Games); $numGames = mysql_numrows($result_Games); if ($numGames > 0) { //$text .= '<div>'.$uname.' '.EB_USER_L35.'</div>'; // Display list of games icons $games_links_list = '<div class="spacer">'; for ($i = 0; $i < $numGames; $i++) { $gname = mysql_result($result_Games, $i, TBL_GAMES . ".Name"); $gicon = mysql_result($result_Games, $i, TBL_GAMES . ".Icon"); $gid = mysql_result($result_Games, $i, TBL_GAMES . ".GameID"); if ($gameid == "All") { $gname_selected = EB_EVENTS_L10; } if ($gid == $gameid) { $gname_selected = $gname; } $games_links_list .= '<a href="' . e_PLUGIN . 'ebattles/events.php?gameid=' . $gid . '"><img ' . getGameIconResize($gicon) . ' title="' . $gname . '"/></a>'; $games_links_list .= ' '; } $games_links_list .= '<br /><b>' . $gname_selected . '</b></div><br />'; } $text .= $games_links_list; // Drop down list to select Match type to display $q_mt = "SELECT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES . ", " . TBL_EVENTS . " WHERE (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $game_string; $result_mt = $sql->db_Query($q_mt); $num_mt = mysql_numrows($result_mt); $gmatchtypes = ''; for ($i = 0; $i < $num_mt; $i++) { $gmatchtypes .= ',' . mysql_result($result_mt, $i, TBL_GAMES . ".MatchTypes"); } $text .= '<form id="submitformrecent" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="get">'; $text .= '<div>'; $text .= '<table class="table_left">'; $text .= '<tr>'; // Match Types drop down $text .= '<td>' . EB_EVENTS_L32 . '<br />'; $text .= '<select class="tbox" name="matchtype" onchange="this.form.submit()">'; $text .= '<option value="All" ' . ($matchtype == "All" ? 'selected="selected"' : '') . '>' . EB_EVENTS_L10 . '</option>'; $gmatchtypes = explode(",", $gmatchtypes); $gmatchtypes = array_unique($gmatchtypes); sort($gmatchtypes); foreach ($gmatchtypes as $gmatchtype) { if ($gmatchtype != '') { $text .= '<option value="' . $gmatchtype . '" ' . ($gmatchtype == $matchtype ? 'selected="selected"' : '') . '>' . htmlspecialchars($gmatchtype) . '</option>'; } } $text .= '</select>'; $text .= '</td>'; $text .= '</tr>'; $text .= '</table>'; $game_string = $gameid == "All" ? "" : " AND (" . TBL_EVENTS . ".Game = '{$gameid}')"; $matchtype_string = $matchtype == "All" ? "" : " AND (" . TBL_EVENTS . ".MatchType = '{$matchtype}')"; $q = "SELECT " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_EVENTS . ".Status = 'finished')" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . $game_string . $matchtype_string . " LIMIT 0, {$rowsPerPage}"; $result = $sql->db_Query($q); $numEvents = mysql_numrows($result); if (!$result || $numEvents < 0) { /* Error occurred, return given name by default */ $text .= EB_EVENTS_L11 . '</div>'; $text .= '</form><br/>'; } else { if ($numEvents == 0) { $text .= EB_EVENTS_L12 . '</div>'; $text .= '</form><br/>'; } else { $text .= '</div>'; $text .= '</form><br/><br/>'; /* Display table contents */ $text .= '<table class="eb_table" style="width:95%"><tbody>'; $text .= '<tr> <th class="eb_th2">' . EB_EVENTS_L13 . '</th>'; if ($gameid == "All") { $text .= '<th colspan="2" class="eb_th2">' . EB_EVENTS_L14 . '</th>'; } $text .= ' <th class="eb_th2">' . EB_EVENTS_L15 . '</th> <th class="eb_th2">' . EB_EVENTS_L16 . '</th> <th class="eb_th2">' . EB_EVENTS_L17 . '</th> <th class="eb_th2">' . EB_EVENTS_L18 . '</th> <th class="eb_th2">' . EB_EVENTS_L19 . '</th> <th class="eb_th2">' . EB_EVENTS_L34 . '</th> </tr>'; for ($i = 0; $i < $numEvents; $i++) { $gName = mysql_result($result, $i, TBL_GAMES . ".Name"); $gIcon = mysql_result($result, $i, TBL_GAMES . ".Icon"); $event_id = mysql_result($result, $i, TBL_EVENTS . ".EventID"); $event = new Event($event_id); if ($event->getField('StartDateTime') != 0) { $startdatetime_local = $event->getField('StartDateTime') + TIMEOFFSET; $date_start = date("d M Y", $startdatetime_local); } else { $date_start = "-"; } if ($event->getField('EndDateTime') != 0) { $enddatetime_local = $event->getField('EndDateTime') + TIMEOFFSET; $date_end = date("d M Y", $enddatetime_local); } else { $date_end = "-"; } /* Nbr players */ $q_2 = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (Event = '{$event_id}')"; $result_2 = $sql->db_Query($q_2); $row = mysql_fetch_array($result_2); $nbrplayers = $row['NbrPlayers']; /* Nbr Teams */ $q_2 = "SELECT COUNT(*) as NbrTeams" . " FROM " . TBL_TEAMS . " WHERE (" . TBL_TEAMS . ".Event = '{$event_id}')"; $result_2 = $sql->db_Query($q_2); $row = mysql_fetch_array($result_2); $nbrTeams = $row['NbrTeams']; /* Nbr matches */ $q_2 = "SELECT COUNT(DISTINCT " . TBL_MATCHS . ".MatchID) as NbrMatches" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (Event = '{$event_id}')" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)"; $result_2 = $sql->db_Query($q_2); $row = mysql_fetch_array($result_2); $nbrmatches = $row['NbrMatches']; switch ($event->getField('Type')) { case "One Player Ladder": case "One Player Tournament": $nbrTeamPlayers = $nbrplayers; break; case "Team Ladder": $nbrTeamPlayers = $nbrTeams . '/' . $nbrplayers; break; case "Clan Ladder": case "Clan Tournament": $nbrTeamPlayers = $nbrTeams; break; default: } $text .= '<tr> <td class="eb_td"><a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . $event->getField('Name') . '</a></td>'; if ($gameid == "All") { $text .= '<td class="eb_td"><img ' . getGameIconResize($gIcon) . '/></td> <td class="eb_td">' . $gName . '</td>'; } $text .= ' <td class="eb_td">' . ($event->getField('MatchType') != '' ? $event->getField('MatchType') . ' - ' : '') . $event->eventTypeToString() . '</td> <td class="eb_td">' . $date_start . '</td> <td class="eb_td">' . $date_end . '</td> <td class="eb_td">' . $nbrTeamPlayers . '</td> <td class="eb_td">' . $nbrmatches . '</td> <td class="eb_td">' . $event->eventStatusToString() . '</td> </tr>'; } $text .= '</tbody></table><br />'; $text .= '<div>'; $text .= ebImageLink('link_to_eventspast', '', e_PLUGIN . 'ebattles/eventspast.php', '', 'action_back.gif', EB_EVENTS_L21, 'jq-button'); $text .= '</div>'; } } }
$a = new MPQFile($tmpname, true, $debug); $init = $a->getState(); if ($init == false) { $text .= "Error parsing uploaded file, make sure it is a valid MPQ archive!<br />\n"; } else { if ($a->getFileType() == "SC2replay") { $b = $a->parseReplay(); $parseDurationString .= sprintf("Parsed replay in %d ms.<br />\n", (microtime_float() - $start) * 1000); $players = $b->getPlayers(); $recorder = $b->getRecorder(); $error_str = ''; if ($event_id) { $event = new Event($event_id); $match = new Match(); // Check if replay->TeamSize == event->MatchType if ($b->getTeamSize() != $event->getField('MatchType')) { $error_str .= '<li>' . EB_SUBMITREPLAY_L3 . '</li>'; } // Check if winner is known if (!$b->isWinnerKnown()) { $error_str .= '<li>' . EB_SUBMITREPLAY_L4 . '</li>'; } // Check if the replay has already been submitted. $q2 = "SELECT " . TBL_MATCHS . ".*" . " FROM " . TBL_MATCHS . " WHERE (" . TBL_MATCHS . ".TimePlayed = '" . $b->getCtime() . "')"; $result2 = $sql->db_Query($q2); $num_rows = mysql_numrows($result2); if ($num_rows != 0) { $error_str .= '<li>' . EB_SUBMITREPLAY_L7 . '</li>'; } $match->setField('Event', $event_id); $match->setField('ReportedBy', USERID);
$pid = $_POST['player']; // Player can quit an event if he has not played yet // TODO - can quit if event not started. $q = "SELECT DISTINCT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_SCORES . " WHERE (" . TBL_PLAYERS . ".PlayerID = '{$pid}')" . " AND (" . TBL_SCORES . ".Player = " . TBL_PLAYERS . ".PlayerID)"; $result = $sql->db_Query($q); $nbrscores = mysql_numrows($result); if ($nbrscores == 0) { deletePlayer($pid); $event->setFieldDB('IsChanged', 1); } header("Location: eventinfo.php?eventid={$event_id}"); } if (isset($_POST['checkinevent'])) { $pid = $_POST['player']; checkinPlayer($pid); if ($event->getField('FixturesEnable') == TRUE && $event->getField('Status') == 'active') { $event->brackets(true); } $event->setFieldDB('IsChanged', 1); header("Location: eventinfo.php?eventid={$event_id}"); } if (isset($_POST['teamcheckinevent'])) { $team_id = $_POST['team']; checkinTeam($team_id); if ($event->getField('FixturesEnable') == TRUE && $event->getField('Status') == 'active') { $event->brackets(true); } $event->setFieldDB('IsChanged', 1); header("Location: eventinfo.php?eventid={$event_id}"); } if (isset($_POST['joinevent'])) {
function challengeDecline() { global $sql; global $tp; global $time; global $pref; // 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"); $cReportedByEmail = mysql_result($result, 0, TBL_USERS . ".user_email"); $event_id = mysql_result($result, 0, TBL_EVENTS . ".EventID"); $event = new Event($event_id); $subject = SITENAME . " " . EB_CHALLENGE_L29; $message = EB_CHALLENGE_L30 . $cReportedByNickName . EB_CHALLENGE_L31 . USERNAME . EB_CHALLENGE_L32 . $event->getField('Name') . EB_CHALLENGE_L33; $fromid = 0; $sendto = $cReportedBy; $sendtoemail = $cReportedByEmail; if (check_class($pref['eb_pm_notifications_class'])) { // Send PM sendNotification($sendto, $subject, $message, $fromid); } if (check_class($pref['eb_email_notifications_class'])) { // Send email require_once e_HANDLER . "mail.php"; sendemail($sendtoemail, $subject, $message); } } $this->deleteChallenge(); }
<script type="text/javascript" src="' . e_PLUGIN . 'ebattles/js/slider.js"></script> '; $event_id = intval($_GET['eventid']); if (!$event_id) { header("Location: ./events.php"); exit; } $q = "SELECT " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_EVENTS . ", " . TBL_GAMES . ", " . TBL_USERS . " WHERE (" . TBL_EVENTS . ".EventID = '{$event_id}')" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_EVENTS . ".Owner)"; $result = $sql->db_Query($q); $event = new Event($event_id); $egame = mysql_result($result, 0, TBL_GAMES . ".Name"); $egameid = mysql_result($result, 0, TBL_GAMES . ".GameID"); $egameicon = mysql_result($result, 0, TBL_GAMES . ".Icon"); $eowner = mysql_result($result, 0, TBL_USERS . ".user_id"); $eownername = mysql_result($result, 0, TBL_USERS . ".user_name"); $eventIsChanged = $event->getField('IsChanged'); $eventStatus = $event->getField('Status'); $rounds = unserialize($event->getFieldHTML('Rounds')); $eMaxNumberPlayers = $event->getField('MaxNumberPlayers'); $type = $event->getField('Type'); $competition_type = $event->getCompetitionType(); /* Nbr players */ $q = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')"; $result = $sql->db_Query($q); $row = mysql_fetch_array($result); $nbr_players = $row['NbrPlayers']; $q = "SELECT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')" . " AND (" . TBL_PLAYERS . ".CheckedIn = '1')" . " AND (" . TBL_PLAYERS . ".Seed <= '{$eMaxNumberPlayers}')"; $result = $sql->db_Query($q); $nbr_players_checked_in = mysql_numrows($result); /* Nbr Teams */ $q = "SELECT COUNT(*) as NbrTeams" . " FROM " . TBL_TEAMS . " WHERE (Event = '{$event_id}')";
function addMember($user, $notify) { global $sql; global $time; $div_id = $this->fields['DivisionID']; $game_id = $this->fields['Game']; $q = "SELECT " . TBL_USERS . ".*" . " FROM " . TBL_USERS . " WHERE (" . TBL_USERS . ".user_id = '{$user}')"; $result = $sql->db_Query($q); $Name = mysql_result($result, 0, TBL_USERS . ".user_name"); $UniqueGameID = ""; $gamerID = updateGamer($user, $game_id, $Name, $UniqueGameID); $q = " INSERT INTO " . TBL_MEMBERS . "(Division,User,timestamp)\r\n\t\tVALUES ({$div_id},{$user},{$time})"; $sql->db_Query($q); // User will automatically be signed up to all current events this division participates in $q_2 = "SELECT " . TBL_TEAMS . ".*, " . TBL_EVENTS . ".*" . " FROM " . TBL_TEAMS . ", " . TBL_EVENTS . " WHERE (" . TBL_TEAMS . ".Division = '{$div_id}')" . " AND (" . TBL_TEAMS . ".Event = " . TBL_EVENTS . ".EventID)" . " AND (" . TBL_EVENTS . ".Status != 'finished')"; $result_2 = $sql->db_Query($q_2); $num_rows_2 = mysql_numrows($result_2); if ($num_rows_2 > 0) { for ($j = 0; $j < $num_rows_2; $j++) { $event_id = mysql_result($result_2, $j, TBL_EVENTS . ".EventID"); $event = new Event($event_id); $team_id = mysql_result($result_2, $j, TBL_TEAMS . ".TeamID"); $team_banned = mysql_result($result_2, $j, TBL_TEAMS . ".Banned"); // Verify there is no other player for that user/event/team $q = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (Event = '{$event_id}')" . " AND (Team = '{$team_id}')" . " AND (User = "******")"; $result = $sql->db_Query($q); $row = mysql_fetch_array($result); $nbrplayers = $row['NbrPlayers']; if ($nbrplayers == 0) { $q = " INSERT INTO " . TBL_PLAYERS . "(Event,Gamer,Team,ELORanking,TS_mu,TS_sigma,G2_r,G2_RD,G2_sigma,Joined,Banned)\r\n\t\t\t\t\tVALUES ({$event_id}, {$gamerID}, {$team_id}, " . $event->getField('ELO_default') . ", " . $event->getField('TS_default_mu') . ", " . $event->getField('TS_default_sigma') . "," . $event->fields['G2_default_r'] . "," . $event->fields['G2_default_RD'] . "," . $event->fields['G2_default_sigma'] . ",{$time}, {$team_banned})"; $sql->db_Query($q); $event->setFieldDB('IsChanged', 1); } } } if ($notify) { list($cname, $ctag, $cid) = $this->getClanInfo(); $sendto = $user; $subject = SITENAME . " " . $cname; $message = EB_CLANM_L39 . $username . EB_CLANM_L40 . $cname . EB_CLANM_L41 . EB_CLANM_L43; sendNotification($sendto, $subject, $message, $fromid = 0); // Send email $message = EB_CLANM_L39 . $username . EB_CLANM_L39 . $cname . EB_CLANM_L42 . SITEURLBASE . e_PLUGIN_ABS . "ebattles/claninfo.php?clanid=" . $cid . EB_CLANM_L43; require_once e_HANDLER . "mail.php"; sendemail($useremail, $subject, $message); } }
$prank_txt = EB_EVENT_L54; } else { $prank_txt = "#{$prank}"; } $text .= '<option value="' . $pid . '">' . $pclantag . $pname . ' (' . $prank_txt . ')</option>'; } } $text .= ' </select> </td> </tr> <tr> <td> '; $reported_by = USERID; $text .= '<div>'; $text .= '<input type="hidden" name="EventID" value="' . $event_id . '"/>'; $text .= '<input type="hidden" name="reported_by" value="' . $reported_by . '"/>'; $text .= ' </div> ' . ebImageTextButton('qrsubmitloss', 'flag_red.png', EB_MATCHQL_L6) . ' </td> </tr> </table> </form> </div> '; } $ns->tablerender($event->getField('Name') . " ({$egame} - " . $event->eventTypeToString() . ") - " . EB_MATCHQL_L1, $text); require_once FOOTERF; exit;
require_once e_PLUGIN . "ebattles/include/clan.php"; /******************************************************************* ********************************************************************/ // Specify if we use WYSIWYG for text areas global $e_wysiwyg; $e_wysiwyg = "match_comment"; // set $e_wysiwyg before including HEADERF $event_id = intval($_GET['eventid']); $match_id = intval($_GET['matchid']); $action = eb_sanitize($_GET['actionid']); if (!$event_id) { header("Location: ./events.php"); exit; } $event = new Event($event_id); $type = $event->getField('Type'); $competition_type = $event->getCompetitionType(); $matchtype = $event->getField('MatchType'); //------------ event permissions -------------- $event_permissions = $event->get_permissions(USERID); $userclass = $event_permissions['userclass']; $can_report = $event_permissions['can_report']; $can_schedule = $event_permissions['can_schedule']; switch ($event->getMatchPlayersType()) { case 'Players': $q = "SELECT " . TBL_PLAYERS . ".*, " . TBL_USERS . ".*, " . TBL_GAMERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')" . " AND (" . TBL_PLAYERS . ".Banned != 1)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_GAMERS . ".User)" . " ORDER BY " . TBL_GAMERS . ".UniqueGameID"; $result = $sql->db_Query($q); $num_rows = mysql_numrows($result); if (!$result) { die('Invalid query: ' . mysql_error()); }
function SubmitTeamChallenge($event_id, $challengerpuid, $challengedtid) { global $sql; global $text; global $tp; global $time; global $pref; $event = new Event($event_id); // Challenger Info // Attention here, we use user_id, so there has to be 1 user for 1 player $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_USERS . ".user_id = '{$challengerpuid}')"; $result = $sql->db_Query($q); $challengerpid = mysql_result($result, 0, TBL_PLAYERS . ".PlayerID"); $challengertid = mysql_result($result, 0, TBL_PLAYERS . ".Team"); list($challengertclan, $challengertclantag, $challengertclanid) = getClanInfo($challengertid); // Challenged Info // Nothing needed here // ... $challenge_times = ''; for ($date = 1; $date <= $event->getField('MaxDatesPerChallenge'); $date++) { $challenge_date = $_POST['date' . $date]; $challenge_time_local = strtotime($challenge_date); $challenge_time_local = $challenge_time_local - TIMEOFFSET; // Convert to GMT time if ($date > 1) { $challenge_times .= ','; } $challenge_times .= $challenge_time_local; } // comments //---------------------------------- $comments = $tp->toDB($_POST['challenge_comments']); $time_reported = $time; // Create Challenge ------------------------------------------ $q = "INSERT INTO " . TBL_CHALLENGES . "(Event,ChallengerTeam,ChallengedTeam,ReportedBy,TimeReported,Comments,Status,MatchDates)\r\n\tVALUES (\r\n\t'{$event_id}',\r\n\t'{$challengertid}',\r\n\t'{$challengedtid}',\r\n\t'{$challengerpuid}',\r\n\t'{$time_reported}',\r\n\t'{$comments}',\r\n\t'requested',\r\n\t'{$challenge_times}'\r\n\t)"; $result = $sql->db_Query($q); // Send PM $fromid = 0; $subject = SITENAME . " " . EB_CHALLENGE_L23; // All members of the challenged division will receive the PM $q = "SELECT " . TBL_TEAMS . ".*, " . TBL_MEMBERS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_TEAMS . ", " . TBL_USERS . ", " . TBL_MEMBERS . " WHERE (" . TBL_TEAMS . ".TeamID = '{$challengedtid}')" . " AND (" . TBL_MEMBERS . ".Division = " . TBL_TEAMS . ".Division)" . " AND (" . TBL_USERS . ".user_id = " . TBL_MEMBERS . ".User)"; $result = $sql->db_Query($q); $num_rows = mysql_numrows($result); if ($num_rows > 0) { for ($j = 0; $j < $num_rows; $j++) { $challengedpname = mysql_result($result, $j, TBL_USERS . ".user_name"); $challengedpemail = mysql_result($result, $j, TBL_USERS . ".user_email"); $message = EB_CHALLENGE_L24 . $challengedpname . EB_CHALLENGE_L25 . $challengertclan . EB_CHALLENGE_L26 . $event->getField('Name') . EB_CHALLENGE_L27; if (check_class($pref['eb_pm_notifications_class'])) { $sendto = mysql_result($result, $j, TBL_USERS . ".user_id"); sendNotification($sendto, $subject, $message, $fromid); } if (check_class($pref['eb_email_notifications_class'])) { // Send email require_once e_HANDLER . "mail.php"; sendemail($challengedpemail, $subject, $message); } } } }
$prating = 0; $prating_votes = 0; for ($scoreIndex = 0; $scoreIndex < $numScores; $scoreIndex++) { $sid = mysql_result($result_Scores, $scoreIndex, TBL_SCORES . ".ScoreID"); // Get user rating. $rate = $rater->GetRating("ebscores", $sid); $prating += $rate[0] * ($rate[1] + $rate[2] / 10); $prating_votes += $rate[0]; } if ($prating_votes != 0) { $prating /= $prating_votes; } $rating = displayRating($prating, $prating_votes); $text .= '<tr>'; $text .= '<td class="eb_td">'; $text .= '<a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . $event->getField('Name') . '</a>'; $text .= '</td>'; //$text .= '<td class="eb_td">'; //$text .= '<img '.getGameIconResize($gIcon).'/> '.$gName; //$text .= '</td>'; $text .= '<td class="eb_td">'; $text .= $pRank; $text .= '</td>'; $text .= '<td class="eb_td">'; $text .= $pWinLoss; $text .= '</td>'; $text .= '<td class="eb_td">'; $text .= $rating; $text .= '</td>'; $text .= '<td class="eb_td">'; $text .= $event->eventStatusToString();
/* Nbr players */ $q = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (" . TBL_PLAYERS . ".Event = '" . $event_id . "')"; $result = $sql->db_Query($q); $row = mysql_fetch_array($result); $nbrplayers = $row['NbrPlayers']; /* Nbr Teams */ $q = "SELECT COUNT(*) as NbrTeams" . " FROM " . TBL_TEAMS . " WHERE (Event = '" . $event_id . "')"; $result = $sql->db_Query($q); $row = mysql_fetch_array($result); $nbrteams = $row['NbrTeams']; $update_matchupsfile = 0; $can_manage = 0; if (check_class($pref['eb_mod_class'])) { $can_manage = 1; } if (USERID == $event->getField('Owner')) { $can_manage = 1; } if ($action == 'create' && check_class($pref['eb_events_create_class'])) { $can_manage = 1; } if ($can_manage == 0) { header("Location: ./eventinfo.php?eventid={$event_id}"); exit; } $event->setFieldDB('IsChanged', 1); if (isset($_POST['eventpublish'])) { /* Event Status */ $event->setFieldDB('Status', 'signup'); //echo "-- eventpublish --<br />"; header("Location: eventmanage.php?eventid={$event_id}");
$event = new Event($event_id); //------------ permissions -------------- $permissions = $event->get_permissions(USERID); $userclass = $permissions['userclass']; $can_approve = $permissions['can_approve']; $can_report = $permissions['can_report']; $can_schedule = $permissions['can_schedule']; $can_report_quickloss = $permissions['can_report_quickloss']; $can_submit_replay = $permissions['can_submit_replay']; $can_challenge = $permissions['can_challenge']; $egame = mysql_result($result, 0, TBL_GAMES . ".Name"); $egameid = mysql_result($result, 0, TBL_GAMES . ".GameID"); $egameicon = mysql_result($result, 0, TBL_GAMES . ".Icon"); $eowner = mysql_result($result, 0, TBL_USERS . ".user_id"); $eownername = mysql_result($result, 0, TBL_USERS . ".user_name"); $eventIsChanged = $event->getField('IsChanged'); $eventStatus = $event->getField('Status'); $rounds = unserialize($event->getFieldHTML('Rounds')); $eMaxNumberPlayers = $event->getField('MaxNumberPlayers'); $type = $event->getField('Type'); $competition_type = $event->getCompetitionType(); /* Nbr players */ $q = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')"; $result = $sql->db_Query($q); $row = mysql_fetch_array($result); $nbr_players = $row['NbrPlayers']; $q = "SELECT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')" . " AND (" . TBL_PLAYERS . ".CheckedIn = '1')" . " AND (" . TBL_PLAYERS . ".Seed <= '{$eMaxNumberPlayers}')"; $result = $sql->db_Query($q); $nbr_players_checked_in = mysql_numrows($result); /* Nbr Teams */ $q = "SELECT COUNT(*) as NbrTeams" . " FROM " . TBL_TEAMS . " WHERE (Event = '{$event_id}')";
function user_form($action, $players_id, $players_name, $event_id, $match_id, $allowDraw, $allowForfeit, $allowScore, $userclass, $date_scheduled, $user_player) { global $sql; global $text; global $tp; global $time; /* Event Info */ $event = new Event($event_id); if (e_WYSIWYG) { $insertjs = "rows='5'"; } else { require_once e_HANDLER . "ren_help.php"; $insertjs = "rows='5' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'"; } /* //dbg form echo "<br>_POST: "; var_dump($_POST); echo "<br>_GET: "; var_dump($_GET); */ $match_str = ''; $matchreport_str = EB_MATCHR_L31; if ($action == 'matchedit') { $matchreport_str = EB_MATCHR_L46; $text .= '<div>'; $text .= EB_MATCHR_L45 . " {$match_id}<br />"; $text .= '<img src="' . e_PLUGIN . 'ebattles/images/exclamation.png"/>'; $text .= EB_MATCHR_L47; $text .= '</div><br />'; } if ($action == 'matchschedulededit') { $matchreport_str = EB_MATCHR_L46; $text .= '<div>'; $text .= EB_MATCHR_L45 . " {$match_id}<br />"; $text .= '</div><br />'; } if ($action == 'matchschedule') { $matchreport_str = EB_MATCHR_L48; } if ($match_id) { $match_str = '&matchid=' . $match_id; } if ($action) { $action_str = '&actionid=' . $action; } // Assign values to POST if not set // fm: check might not be correct here // should check if $action=='matchedit') only? if (!isset($_POST['time_reported']) || $action == 'matchscheduledreport') { $_POST['time_reported'] = $time; } $time_reported = $_POST['time_reported']; if (!isset($_POST['reported_by'])) { $_POST['reported_by'] = USERID; } $reported_by = $_POST['reported_by']; if (isset($_POST['match_comment'])) { $comment = $tp->toDB($_POST['match_comment']); } else { $comment = ''; } for ($matchMap = 0; $matchMap < min($numMaps, $event->getField('MaxMapsPerMatch')); $matchMap++) { if (!isset($_POST['map' . $matchMap])) { $_POST['map' . $matchMap] = 0; } } // if vars are not set, set them as empty. if (!isset($_POST['nbr_players'])) { $_POST['nbr_players'] = 2; } if (!isset($_POST['nbr_teams'])) { $_POST['nbr_teams'] = 2; } // now to output the form HTML. $max_nbr_players = count($players_id) - 1; $nbr_players = $_POST['nbr_players']; $nbr_teams = $_POST['nbr_teams']; if (isset($_POST['addPlayer'])) { $nbr_players++; } if (isset($_POST['removePlayer'])) { $nbr_players--; } if ($nbr_players > $max_nbr_players) { $nbr_players = $max_nbr_players; } if ($nbr_players < 2) { $nbr_players = 2; } $_POST['nbr_players'] = $nbr_players; for ($i = 1; $i <= $nbr_players; $i++) { if (!isset($_POST['player' . $i])) { $_POST['player' . $i] = $players_id[0]; } //debug - echo "Player #".$i.": ".$_POST['player'.$i]."<br />"; } if (isset($_POST['addTeam'])) { $nbr_teams++; } if (isset($_POST['removeTeam'])) { $nbr_teams--; } if ($nbr_teams > $max_nbr_players) { $nbr_teams = $max_nbr_players; } if ($nbr_teams < 2) { $nbr_teams = 2; } $_POST['nbr_teams'] = $nbr_teams; for ($i = 1; $i <= $nbr_players; $i++) { if (!isset($_POST['team' . $i])) { $_POST['team' . $i] = 'Team #' . $i; } if (!isset($_POST['score' . $i])) { $_POST['score' . $i] = 0; } if (!isset($_POST['faction' . $i])) { $_POST['faction' . $i] = 0; } } for ($i = 1; $i <= $nbr_teams; $i++) { if (!isset($_POST['rank' . $i])) { $_POST['rank' . $i] = 'Team #' . $i; } } //[dbg]$text .= "nbr_players = $nbr_players, nbr_teams = $nbr_teams<br>"; ///////////////// /// MAIN FORM /// ///////////////// $text .= '<form id="matchreportform" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?eventid=' . $event_id . $match_str . $action_str . '" method="post">'; $text .= '<div>'; // TABLE - Player/Teams Add/Remove //---------------------------------- if ($action != 'matchscheduledreport' && $action != 'matchschedulededit') { $text .= EB_MATCHR_L15; $text .= '<table id="matchresult_nbrPlayersTeams"><tbody>'; // Nbr of Players $text .= '<tr><td>' . $nbr_players . ' ' . EB_MATCHR_L21 . '</td>'; $text .= '<td><input type="hidden" name="nbr_players" value="' . $_POST['nbr_players'] . '"/>'; // Add Player if ($nbr_players < $max_nbr_players) { $text .= '<input class="eb_button" type="submit" value="' . EB_MATCHR_L16 . '" name="addPlayer"/></td>'; } else { $text .= '<input class="button_disabled" type="submit" value="' . EB_MATCHR_L16 . '" name="addPlayer" disabled="disabled"/></td>'; } // Remove Player if ($nbr_players > 2) { $text .= '<td><input class="eb_button" type="submit" value="' . EB_MATCHR_L17 . '" name="removePlayer"/></td>'; } else { $text .= '<td><input class="button_disabled" type="submit" value="' . EB_MATCHR_L17 . '" name="removePlayer" disabled="disabled"/></td>'; } $text .= '</tr>'; // Nbr of Teams $text .= '<tr><td>' . $nbr_teams . ' ' . EB_MATCHR_L22 . '</td>'; $text .= '<td><input type="hidden" name="nbr_teams" value="' . $_POST['nbr_teams'] . '"/>'; // Add Team if ($nbr_teams < $nbr_players) { $text .= '<input class="eb_button" type="submit" value="' . EB_MATCHR_L18 . '" name="addTeam"/></td>'; } else { $text .= '<input class="button_disabled" type="submit" value="' . EB_MATCHR_L18 . '" name="addTeam" disabled="disabled"/></td>'; } // Remove Team if ($nbr_teams > 2) { $text .= '<td><input class="eb_button" type="submit" value="' . EB_MATCHR_L19 . '" name="removeTeam"/></td>'; } else { $text .= '<td><input class="button_disabled" type="submit" value="' . EB_MATCHR_L19 . '" name="removeTeam" disabled="disabled"/></td>'; } $text .= '</tr>'; $text .= '</tbody></table>'; //$text .= '<p><input class="inspector" type="button" value="Inspect" onclick="junkdrawer.inspectListOrder(\'matchresultlist\')"/></p>'; $text .= '<br />'; } // TABLE - Players/Teams Selection //---------------------------------- // List of all Factions $q_Factions = "SELECT " . TBL_FACTIONS . ".*" . " FROM " . TBL_FACTIONS . " WHERE (" . TBL_FACTIONS . ".Game = '" . $event->getField('Game') . "')"; $result_Factions = $sql->db_Query($q_Factions); $numFactions = mysql_numrows($result_Factions); $disable_input = $action == 'matchscheduledreport' ? 1 : 0; if ($action != 'matchscheduledreport') { $text .= EB_MATCHR_L20; } $text .= '<table id="matchresult_selectPlayersTeams"><tbody>'; $text .= '<tr><td></td><td>' . EB_MATCHR_L38 . '</td>'; $text .= '<td>' . EB_MATCHR_L25 . '</td>'; if ($action != 'matchschedule' && $action != 'matchschedulededit' && $allowScore == TRUE) { $text .= '<td>' . EB_MATCHR_L26 . '</td>'; } if ($action != 'matchschedule' && $action != 'matchschedulededit' && $numFactions > 0) { $text .= '<td>' . EB_MATCHR_L41 . '</td>'; } $text .= '</tr>'; for ($i = 1; $i <= $nbr_players; $i++) { $text .= '<tr><td>' . EB_MATCHR_L23 . $i . ': </td>'; $match_winner = 0; if ($event->getField('match_report_userclass') == eb_UC_MATCH_WINNER && $i == 1 && $user_player != 0) { $match_winner = 1; $_POST['player' . $i] = $user_player; } if ($disable_input == 1 || $match_winner == 1) { for ($j = 1; $j <= $max_nbr_players + 1; $j++) { if (strtolower($_POST['player' . $i]) == strtolower($players_id[$j - 1])) { $text .= '<td><input type="hidden" name="player' . $i . '" value="' . $players_id[$j - 1] . '"/>'; $text .= $players_name[$j - 1] . '</td>'; } } } else { $text .= '<td><select class="tbox" name="player' . $i . '">'; for ($j = 1; $j <= $max_nbr_players + 1; $j++) { $text .= '<option value="' . $players_id[$j - 1] . '"'; if (strtolower($_POST['player' . $i]) == strtolower($players_id[$j - 1])) { $text .= ' selected="selected"'; } $text .= '>' . $players_name[$j - 1] . '</option>'; } $text .= '</select></td>'; } if ($disable_input == 1) { for ($j = 1; $j <= $nbr_teams; $j++) { if (strtolower($_POST['team' . $i]) == 'team #' . $j) { $text .= '<td><input type="hidden" name="team' . $j . '" value="Team #' . $j . '"/>'; $text .= EB_MATCHR_L29 . $j . '</td>'; } } } else { $text .= '<td><select class="tbox" name="team' . $i . '">'; for ($j = 1; $j <= $nbr_teams; $j++) { $text .= '<option value="Team #' . $j . '"'; if (strtolower($_POST['team' . $i]) == 'team #' . $j) { $text .= ' selected="selected"'; } $text .= '>' . EB_MATCHR_L29 . $j . '</option>'; } $text .= '</select></td>'; } if ($action != 'matchschedule' && $action != 'matchschedulededit') { if ($allowScore == TRUE) { $text .= '<td>'; $text .= '<input class="tbox" type="text" size="3" name="score' . $i . '" value="' . $_POST['score' . $i] . '"/>'; $text .= '</td>'; } if ($numFactions > 0) { $text .= '<td><select class="tbox" name="faction' . $i . '">'; $text .= '<option value="0"'; $text .= '>' . EB_MATCHR_L43 . '</option>'; for ($faction = 1; $faction <= $numFactions; $faction++) { $fID = mysql_result($result_Factions, $faction - 1, TBL_FACTIONS . ".FactionID"); $fIcon = mysql_result($result_Factions, $faction - 1, TBL_FACTIONS . ".Icon"); $fName = mysql_result($result_Factions, $faction - 1, TBL_FACTIONS . ".Name"); $text .= '<option value="' . $fID . '"'; if (strtolower($_POST['faction' . $i]) == $fID) { $text .= ' selected="selected"'; } $text .= '>' . $fName . '</option>'; } $text .= '</select></td>'; } } $text .= '</tr>'; } $text .= '</tbody></table>'; $text .= '<br />'; if ($action != 'matchschedule' && $action != 'matchschedulededit') { // TABLE - Teams Rank Selection //---------------------------------- $text .= EB_MATCHR_L24; $text .= '<table id="matchresult_rankTeams"><tbody>'; $text .= '<tr><td></td><td>' . EB_MATCHR_L25 . '</td>'; if ($allowDraw == TRUE) { $text .= '<td>' . EB_MATCHR_L27 . '</td>'; } if ($allowForfeit == TRUE) { $text .= '<td>' . EB_MATCHR_L57 . '</td>'; } $text .= '</tr>'; for ($i = 1; $i <= $nbr_teams; $i++) { $text .= '<tr>'; $text .= '<td>'; $text .= EB_MATCHR_L28 . $i . ':'; $text .= '</td>'; $text .= '<td><select class="tbox" name="rank' . $i . '" id="rank' . $i . '" onchange = "SwitchSelected(' . $i . ')">'; for ($j = 1; $j <= $nbr_teams; $j++) { $text .= '<option value="Team #' . $j . '"'; if (strtolower($_POST['rank' . $i]) == 'team #' . $j) { $text .= ' selected="selected"'; } $text .= '>' . EB_MATCHR_L29 . $j . '</option>'; } $text .= '</select></td>'; if ($allowDraw == TRUE) { $text .= '<td>'; if ($i > 1) { $text .= '<input class="tbox" type="checkbox" name="draw' . $i . '" value="1"'; if (strtolower($_POST['draw' . $i]) != "") { $text .= ' checked="checked"'; } $text .= '/>'; } $text .= '</td>'; } if ($allowForfeit == TRUE) { $text .= '<td>'; if ($i > 1) { $text .= '<input class="tbox" type="checkbox" name="forfeit' . $i . '" value="1"'; if (strtolower($_POST['forfeit' . $i]) != "") { $text .= ' checked="checked"'; } $text .= '/>'; } $text .= '</td>'; } $text .= '</tr>'; } $text .= '</tbody></table>'; } // Map Selection //---------------------------------- // List of all Maps $q_Maps = "SELECT " . TBL_MAPS . ".*" . " FROM " . TBL_MAPS . " WHERE (" . TBL_MAPS . ".Game = '" . $event->getField('Game') . "')"; $result_Maps = $sql->db_Query($q_Maps); $numMaps = mysql_numrows($result_Maps); if ($numMaps > 0) { $text .= EB_MATCHR_L42; $text .= '<table id="matchresult_selectMap" class="table_left"><tbody>'; for ($matchMap = 0; $matchMap < min($numMaps, $event->getField('MaxMapsPerMatch')); $matchMap++) { $text .= '<tr>'; $text .= '<td><select class="tbox" name="map' . $matchMap . '">'; $text .= '<option value="0"'; $text .= '>' . EB_MATCHR_L43 . '</option>'; for ($map = 0; $map < $numMaps; $map++) { $mID = mysql_result($result_Maps, $map, TBL_MAPS . ".MapID"); $mImage = mysql_result($result_Maps, $map, TBL_MAPS . ".Image"); $mName = mysql_result($result_Maps, $map, TBL_MAPS . ".Name"); $mDescrition = mysql_result($result_Maps, $map, TBL_MAPS . ".Description"); $text .= '<option value="' . $mID . '"'; if (strtolower($_POST['map' . $matchMap]) == $mID) { $text .= ' selected="selected"'; } $text .= '>' . $mName . '</option>'; } $text .= '</select></td>'; $text .= '</tr>'; } $text .= '</tbody></table>'; $text .= '<br />'; } if ($action != 'matchschedule' && $action != 'matchschedulededit') { // Comments //---------------------------------- $text .= '<br />'; $text .= '<div style="display:table; margin-left:auto; margin-right:auto;">'; $text .= EB_MATCHR_L30 . '<br />'; $text .= '<textarea class="tbox" id="match_comment" name="match_comment" style="width:400px" cols="70" ' . $insertjs . '>' . $comment . '</textarea>'; if (!e_WYSIWYG) { $text .= '<br />' . display_help("helpb", "comment"); } $text .= '</div>'; $text .= '<br />'; } if ($action == 'matchschedule' || $action == 'matchschedulededit') { //<!-- Date Selection --> $text .= EB_MATCHR_L49; $text .= ' <table> <tr> <td> <table> <tr> <td> <div><input class="tbox timepicker" type="text" name="date_scheduled" id="f_date" value="' . $date_scheduled . '" readonly="readonly" /></div> </td> <td> <div><input class="eb_button" type="button" value="' . EB_MATCHR_L51 . '" onclick="clearDate(this.form);"/></div> </td> </tr> </table> </td> </tr> </table> '; } $text .= '<div style="display:table; margin-left:auto; margin-right:auto;">'; $text .= '<input type="hidden" name="nbr_players" value="' . $nbr_players . '"/>'; $text .= '<input type="hidden" name="nbr_teams" value="' . $nbr_teams . '"/>'; $text .= '<input type="hidden" name="userclass" value="' . $userclass . '"/>'; $text .= '<input type="hidden" name="reported_by" value="' . $reported_by . '"/>'; $text .= '<input type="hidden" name="time_reported" value="' . $time_reported . '"/>'; $text .= '<input class="eb_button" type="submit" value="' . $matchreport_str . '" name="submit_match"/>'; $text .= '<span id="ajaxSpinnerContainer"> <img src="' . e_PLUGIN . 'ebattles/images/ajax-loader.gif" title="working..." alt="working..."/> ' . EB_EVENTM_L157 . ' </span>'; $text .= '</div>'; $text .= '</div>'; $text .= '</form>'; }
function get_permissions($user_id) { global $sql; global $pref; $userclass = 0; $can_edit = 0; $can_approve = 0; $can_report = 0; $can_schedule = 0; $can_delete = 0; $can_submit_media = 0; $can_delete_media = 0; $match_id = $this->fields['MatchID']; $event_id = $this->fields['Event']; $event = new Event($event_id); $type = $event->getField('Type'); $competition_type = $event->getCompetitionType(); $mStatus = $this->fields['Status']; $reported_by = $this->fields['ReportedBy']; // Is the user a moderator? $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); switch ($event->getMatchPlayersType()) { case 'Players': $reporter_matchteam = 0; $q_Reporter = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = '******')"; $result_Reporter = $sql->db_Query($q_Reporter); $numRows = mysql_numrows($result_Reporter); if ($numRows > 0) { $reporter_matchteam = mysql_result($result_Reporter, 0, TBL_SCORES . ".Player_MatchTeam"); } // Is the user an opponent of the reporter? $q_Opps = "SELECT DISTINCT " . TBL_SCORES . ".*" . " 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_SCORES . ".Player_MatchTeam != '{$reporter_matchteam}')" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result_Opps = $sql->db_Query($q_Opps); $numOpps = mysql_numrows($result_Opps); break; case 'Teams': $reporter_matchteam = 0; $q_Reporter = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = '******')"; $result_Reporter = $sql->db_Query($q_Reporter); $numRows = mysql_numrows($result_Reporter); if ($numRows > 0) { $reporter_matchteam = mysql_result($result_Reporter, 0, TBL_SCORES . ".Player_MatchTeam"); } // Is the user an opponent of the reporter? $q_Opps = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_SCORES . ".Player_MatchTeam != '{$reporter_matchteam}')" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result_Opps = $sql->db_Query($q_Opps); $numOpps = mysql_numrows($result_Opps); //dbg: echo "numOpps: $numOpps, mt: $reporter_matchteam<br />"; break; default: } // Is the user a player in the match & not banned? switch ($event->getMatchPlayersType()) { case 'Players': $q_UserPlayers = "SELECT DISTINCT " . TBL_SCORES . ".*" . " 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 . ".Banned != 1)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result_UserPlayers = $sql->db_Query($q_UserPlayers); $numUserPlayers = mysql_numrows($result_UserPlayers); //dbg: echo "numUserPlayers: $numUserPlayers<br>"; break; case 'Teams': $q_UserPlayers = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '" . $match_id . "')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_TEAMS . ".Banned != 1)" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_PLAYERS . ".Banned != 1)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result_UserPlayers = $sql->db_Query($q_UserPlayers); $numUserPlayers = mysql_numrows($result_UserPlayers); //dbg: echo "numUserPlayers: $numUserPlayers<br>"; break; default: } if ($user_id == $reported_by && $mStatus == 'pending') { $can_edit = 1; } if (check_class($pref['eb_mod_class'])) { $can_delete = 1; } if ($user_id == $event->getField('Owner')) { $userclass |= eb_UC_EVENT_OWNER; $can_delete = 1; $can_approve = 1; $can_report = 1; $can_schedule = 1; $can_edit = 1; $can_submit_media = 1; $can_delete_media = 1; } if ($numMods > 0) { $userclass |= eb_UC_EB_MODERATOR; $can_delete = 1; $can_approve = 1; $can_report = 1; $can_schedule = 1; $can_edit = 1; $can_submit_media = 1; $can_delete_media = 1; } if (check_class($pref['eb_mod_class'])) { $userclass |= eb_UC_EB_MODERATOR; $can_approve = 1; $can_report = 1; $can_schedule = 1; $can_edit = 1; $can_submit_media = 1; $can_delete_media = 1; } if ($numOpps > 0) { $userclass |= eb_UC_EVENT_PLAYER; $can_approve = 1; } if ($numUserPlayers > 0) { $can_report = 1; } if ($numPlayed > 0 && check_class($pref['eb_media_submit_class'])) { $can_submit_media = 1; } if ($userclass < $event->getField('MatchesApproval')) { $can_approve = 0; } if ($event->getField('MatchesApproval') == eb_UC_NONE) { $can_approve = 0; } if ($mStatus != 'pending') { $can_approve = 0; } if ($mStatus != 'scheduled') { $can_report = 0; } if ($can_edit == 1) { if ($competition_type == 'Tournament' && $mStatus != 'scheduled') { $can_edit = 0; } } //echo "m($match_id).perm.can_report=$can_report<br>"; $permissions = array(); $permissions['userclass'] = $userclass; $permissions['can_edit'] = $can_edit; $permissions['can_approve'] = $can_approve; $permissions['can_report'] = $can_report; $permissions['can_schedule'] = $can_schedule; $permissions['can_delete'] = $can_delete; $permissions['can_submit_media'] = $can_submit_media; $permissions['can_delete_media'] = $can_delete_media; //echo "match $match_id permissions:<br>"; //var_dump($permissions); return $permissions; }
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).' '.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).' '.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 . ' <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 />"; } */ } }
} if (isset($_POST['challenge_accept'])) { // Verify form $error_str = ''; if (!empty($error_str)) { // show form again $text .= $challenge->challengeConfirmForm(); // errors have occured, halt execution and show form again. $text .= '<div class="eb_errors">' . EB_MATCHR_L14; $text .= '<ul>' . $error_str . '</ul></div>'; } else { $challenge->challengeAccept(); $text .= EB_CHALLENGE_L22; $text .= '<br />'; $text .= '<br />' . EB_CHALLENGE_L13 . ' [<a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . EB_CHALLENGE_L14 . '</a>]<br />'; } } if (isset($_POST['challenge_decline'])) { $challenge->challengeDecline(); $text .= EB_EVENT_L69; $text .= '<br />'; $text .= '<br />' . EB_CHALLENGE_L13 . ' [<a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . EB_CHALLENGE_L14 . '</a>]<br />'; } $ns->tablerender($event->getField('Name') . " (" . $event->eventTypeToString() . ") - " . EB_CHALLENGE_L1, $text); require_once FOOTERF; exit; ?>
require_once e_PLUGIN . "ebattles/include/main.php"; require_once e_PLUGIN . "ebattles/include/match.php"; require_once e_PLUGIN . "ebattles/include/event.php"; /******************************************************************* ********************************************************************/ require_once HEADERF; global $sql; $text = ''; /* Event Name */ $event_id = intval($_GET['eventid']); if (!$event_id) { header("Location: ./events.php"); exit; } if (!isset($_POST['deletematch'])) { $text .= '<br />' . EB_MATCHDEL_L2 . '<br />'; } else { $event = new Event($event_id); $match_id = $_POST['matchid']; $match = new Match($match_id); $match->delete(); if ($event->getField('FixturesEnable') == TRUE) { $event->brackets(true); } $text .= '<br />' . EB_MATCHDEL_L3 . '<br />'; header("Location: eventinfo.php?eventid={$event_id}"); } $text .= '<br />' . EB_MATCHDEL_L4 . ' [<a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '">' . EB_MATCHDEL_L5 . '</a>]<br />'; $ns->tablerender(EB_MATCHDEL_L1, $text); require_once FOOTERF; exit;
$text .= '</ul>'; $text .= '<div id="tabs-1">'; // Did the user play in that match $q = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result = $sql->db_Query($q); $nbr_players = mysql_numrows($result); if ($nbr_players > 0) { $uteam = mysql_result($result, 0, TBL_SCORES . ".Player_MatchTeam"); } // Get event information $q = "SELECT " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*, " . TBL_MATCHS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_EVENTS . ", " . TBL_GAMES . ", " . TBL_MATCHS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_EVENTS . ".EventID = " . TBL_MATCHS . ".Event)" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_MATCHS . ".ReportedBy)"; $result = $sql->db_Query($q); $event_id = mysql_result($result, 0, TBL_EVENTS . ".EventID"); $event = new Event($event_id); $match = new Match($match_id); $type = $event->getField('Type'); $competition_type = $event->getCompetitionType(); $gName = mysql_result($result, 0, TBL_GAMES . ".Name"); $mStatus = mysql_result($result, 0, TBL_MATCHS . ".Status"); $reported_by = mysql_result($result, 0, TBL_MATCHS . ".ReportedBy"); $reported_by_name = mysql_result($result, 0, TBL_USERS . ".user_name"); $matchMaps = explode(",", mysql_result($result, 0, TBL_MATCHS . ".Maps")); $mTimeScheduled = mysql_result($result, 0, TBL_MATCHS . ".TimeScheduled"); $mTimeScheduled_local = $mTimeScheduled + TIMEOFFSET; $dateScheduled = date("d M Y, h:i A", $mTimeScheduled_local); $categoriesToShow = array(); $q_Categories = "SELECT " . TBL_STATSCATEGORIES . ".*" . " FROM " . TBL_STATSCATEGORIES . " WHERE (" . TBL_STATSCATEGORIES . ".Event = '{$event_id}')"; $result_Categories = $sql->db_Query($q_Categories); $numCategories = mysql_numrows($result_Categories); for ($category = 0; $category < $numCategories; $category++) { $cat_name = mysql_result($result_Categories, $category, TBL_STATSCATEGORIES . ".CategoryName");