Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
- <?php
- // RGC Login
- $p = preg_replace(':/{2,}:', '/', $_SERVER['REQUEST_URI']);
- $c = substr_count( $p, '/');
- $__inc_base = ''; for($i=1;$i<$c;$i++) $__inc_base .= '../';
- include_once $__inc_base.'login/login.php';
- //ACCESS CHECKS
- check_access_channeladmin(); //no normal users
- //dotacolors
- /*$dotacolor[0] = '#0000FF';
- $dotacolor[1] = '#66FFFF';
- $dotacolor[2] = '#660099';
- $dotacolor[3] = '#FFFF00';
- $dotacolor[4] = '#FF6600';
- $dotacolor[5] = '#FF66FF';
- $dotacolor[6] = '#999999';
- $dotacolor[7] = '#99CCFF';
- $dotacolor[8] = '#003300';
- $dotacolor[9] = '#330000';*/
- $dotacolor[0] = '#4b72f0';
- $dotacolor[1] = '#5dbfd7';
- $dotacolor[2] = '#7353d9';
- $dotacolor[3] = '#d9d154';
- $dotacolor[4] = '#d8943c';
- $dotacolor[5] = '#cf8bde';
- $dotacolor[6] = '#94a2ab';
- $dotacolor[7] = '#81a1d1';
- $dotacolor[8] = '#49734f';
- //$dotacolor[9] = '#5d4c42';
- $dotacolor[9] = '#663300';
- $___debug = 0;
- if($___debug) takeTime();
- if(!$_GET['gid']) { echo "<center><h2>Invalid GameID</h2></center>"; exit; }
- DisplayStats($_GET['gid']);
- function DisplayStats($gameid)
- {
- global $___debug, $dotacolor;
- $gameid = (int)$gameid;
- // Get GameInfo
- $sql = "SELECT g.gamename, g.channel_id, g.hosted, g.length, g.started, m.name, g.winner FROM game1_info g, client_maps m WHERE g.ID = '$gameid' AND m.ID = g.MapID";
- $inforesult = ValueToArray(mysql_query($sql));
- if($___debug) { echo "<b>[SQL] Select Game Info</b><br>"; takeTime(); }
- if($inforesult['Total'] == 0) return;//die(echo("<b>There exists no game for the <font color='red'>GID $gameid</font></b>"));
- // Get GamePlayers
- $sql = "SELECT a.name, p.player_id, p.status, p.Time, p.LeftReason, p.Kills, p.Deaths, p.Assists FROM game1_players p, client_accounts a WHERE a.ID = p.acc_id AND p.game_id = '$gameid'"; // ORDER BY Time ASC
- $presult = ValueToArray(mysql_query($sql));
- // Get ChannelName
- /*$sql = "SELECT name FROM client_channels WHERE channel_id = '".$inforesult[1]['channel_id']."'";
- $cresult=ValueToArray(mysql_query($sql));
- if($cresult['Total'] == 0) $cresult[1]*/
- $cname = GetSingleResult(mysql_query("SELECT name FROM client_channels WHERE channel_id = '".$inforesult[1]['channel_id']."'"));
- if(!isset($cname)) $cname = "<font color='gray'><i><b>Deleted Room</b></i></font>"; else $cname = BDecode($cname);
- if($___debug) { echo "<b>[SQL] Select Channel Info</b><br>"; takeTime(); }
- //Check for global staff access
- $headadmin = ($_SESSION['access'] == 2); // || $_SESSION['access'] == 13);
- //If not, check for channel the game was hosted on access!
- if(!$headadmin) {
- $sql = "SELECT 1 FROM client_channelaccess WHERE channel_id = ".$inforesult[1]['channel_id']." AND access = 13 AND acc_id = '".$_SESSION['uid']."'";
- $vResult = ValueToArray(mysql_query($sql));
- $headadmin = ($vResult['Total'] != 0);
- }
- //Special for Tiago, cancel games
- //check if he has head admin in this channel
- /*if($headadmin && ($_SESSION['uid']== 37830 || $_SESSION['uid']== 6)) {
- $cancel = true;
- } else */ $cancel = false;
- // NEW GAMENAME
- if($gameid > 2598248) $inforesult[1]['gamename'] = BDecode($inforesult[1]['gamename']);
- if($headadmin) echo "<form action='change.php' method='get'>";
- echo "<b>Game: </b> Warcraft III : The Frozen Throne<br>";
- echo "<b>Map: </b> ".BDecode($inforesult[1]['name'])."<br>";
- //echo "<b>Room: </b> ".BDecode($cresult[1]['name'])."<br>";
- echo "<b>Room: </b> $cname<br>";
- echo "<b>Name: </b> ".$inforesult[1]['gamename']."<br>";
- echo "<b>Time: </b> ".date("d/m/Y - H:i", $inforesult[1]['hosted'])."<br>";
- if($inforesult[1]['length'] != -1) echo "<b>Length: </b> ".TimeToStr($inforesult[1]['length'])."<br>";
- else if($inforesult[1]['started']) echo "<b>Length: </b> ".TimeToStr(time() - $inforesult[1]['started'])." <font color='red'>(ongoing)</font><br>";
- else echo "<b>Status: </b><font color='blue'>(Lobby)</font><br>";
- echo "<br>";
- $winner = $inforesult[1]['winner'];
- echo "<b>Stats</b>";
- echo "<b> (Winner: </b>"; if($inforesult[1]['winner'] == 0) { echo "<i>None</i>"; }
- if($inforesult[1]['winner'] == 1) { echo "<font color='green'>Sentinel</font>"; }
- if($inforesult[1]['winner'] == 2) { echo "<font color='red'>Scourge</font>"; }
- if($inforesult[1]['winner'] == 4) { echo "<i>None - Nulled Sentinel</i>"; }
- if($inforesult[1]['winner'] == 5) { echo "<i>None - Nulled Scourge</i>"; }
- echo "<b>)</b>";
- echo "<hr>";
- //SELECT player_id, name, status, Time, Kills, Deaths, Assissts FROM game1_players p
- if($headadmin) echo "<input type='hidden' name='gid' value='$gameid'>";
- // Sort presult by pid (this should not be needed, but you never know
- for($i=1;$i<=$presult['Total'];$i++) {
- $up[$presult[$i]['player_id']] = $presult[$i];
- } $up['Total'] = $presult['Total'];
- echo "<table border=0><tr>";
- if($headadmin) echo "<td></td>";
- echo "<td><center>Player</td><td><center>K</td><td><center>D</td><td><center>A</td></tr>";
- // Process sorted presult, up=unprocessed players
- for($i=1;$i<=10;$i++) {
- //if($i == 6) echo "<br>";
- if($i == 6) {
- echo "<tr>";
- if($headadmin) echo "<td></td>";
- echo "<td><center><font color='red'>VS</font></center></td><td></td><td></td><td></td>";
- echo "</tr>";
- }
- echo "<tr><td>";
- if(!isset($up[$i])) {
- //echo "<font color='".$dotacolor[$i-1]."'><empty></font><br>";
- echo "<font color='".$dotacolor[$i-1]."'><Player $i></font><br>";
- } else {
- $up[$i]['cleanname'] = CleanString(BDecode($up[$i]['name']));
- if($headadmin) echo "<input type='checkbox' name='$i' value='";
- $font = "<font color='"; if($up[$i]['status'] == 0) {
- if($headadmin) echo "2";
- $font .= "black";
- } else {
- if($headadmin) echo "1";
- $p = $up[$i]['player_id'] - 1;
- if($p >= 5 * ($winner - 1) && $p < 5 * $winner) $font .= "orange";
- else $font .= "red";
- } $font .= "'>";
- if($headadmin) echo "' /></td><td>";
- echo $font."[".TimeToStr($up[$i]['Time'])."]</font> ";
- echo "<a href='search.php?m=0&var=".BDecode($up[$i]['name'])."'><font color='".$dotacolor[$i-1]."'>".$up[$i]['cleanname']."</font></a>";
- //echo " ---".$up[$i]['Kills']." - ".$up[$i]['Deaths']." - ".$up[$i]['Assists']."<br>";
- //echo " ".$up[$i]['Kills']." / ".$up[$i]['Deaths']." / ".$up[$i]['Assists']."<br>";
- $ex = "</td><td><center><font color='".$dotacolor[$i-1]."'>";
- echo $ex.$up[$i]['Kills'].$ex.$up[$i]['Deaths'].$ex.$up[$i]['Assists'];
- }
- echo "</td></tr>";
- }
- echo "</table>";
- if($___debug) { echo "<b>[SQL] Set Players</b><br>"; takeTime(); }
- echo "<br>";
- if($up['Total'] != 0 && $headadmin) echo "<input type='submit' value='Change'></form>";
- if($up['Total'] != 0 && $cancel && $up[1]['winner']) { //No winner, no cancel
- if($up[1]['winner'] < 3) $actionName = "Cancel Game";
- else $actionName = "Rescore Game";
- echo "<form action='cancel.php' action='get'>";
- echo "<input type='hidden' name='gid' value='$gameid'>";
- echo "<input type='submit' value='$actionName'></form>";
- }
- echo "<br>";
- echo DisplayLobbyChat($gameid);
- // Add Fakeplayers (for ongoing games)
- if($up['Total'] == 0) for($i=1;$i<11;$i++) {
- $up[$i]['cleanname'] = "Player ".$i;
- $up[$i]['LeftReason'] = 'game ongoing';
- $up[$i]['Time'] = 0;
- }
- echo "<br><br>";
- echo DisplayGameChat($gameid, $up);
- }
- function DisplayLobbyChat($gameid)
- {
- global $___debug;
- echo "<b>Lobby</b><hr>";
- $sql="SELECT * FROM game1_chat_lobby WHERE game_id = '$gameid'";
- $result=ValueToArray(mysql_query($sql));
- if($___debug) { echo "<b>[SQL] Select Lobby Chat</b><br>"; takeTime(); }
- for($i=0; $i<$result['Total']; $i++)
- {
- echo "[".TimeToStr($result[$i+1]['time'])."] ";
- //OLD LOGS
- if($gameid < 60552) echo $result[$i+1]['nickname'].": ".CleanString($result[$i+1]['message'])."<br>";
- else
- {
- $nick = CleanString(BDecode($result[$i+1]['nickname']));
- $msg = CleanString(BDecode($result[$i+1]['message']));
- if(!$nick) {
- echo "<font color='gray'>".substr($msg, 1)." ";
- if($msg[0] == "1") echo "has joined the game lobby.";
- else if($msg[0] == "2") echo "has left the game lobby.";
- echo "</font>";
- } else echo $nick.": ".$msg; //add to cleanstring maybe? //urldecode(utf8_decode(pack('H*', $result[$i+1]['nickname'])))
- echo '<br>';
- }
- }
- if($___debug) { echo "<b>[Arrange] Lobby Chat</b><br>"; takeTime(); }
- }
- function DisplayGameChat($gameid, $players)
- {
- global $___debug, $dotacolor;
- //$sql="SELECT * FROM game1_chat_ingame WHERE game_id=".$gameid." ORDER BY time ASC";
- $sql="SELECT time, message, player_id, status FROM game1_chat_ingame WHERE game_id = '$gameid' ORDER BY time ASC";
- $result=ValueToArray(mysql_query($sql));
- if($___debug) { echo "<b>[SQL] Select Ingame Chat</b><br>"; takeTime(); }
- echo "<b>Ingame</b><hr>";
- echo "<div style='position: relative; height: 50px; width: 100%;'>";
- //Add leaving as an event
- $eCC = 0;
- for($i=1;$i<=10;$i++) {
- echo "<input type='button' value='".$players[$i]['cleanname']."' class='playerChat' id='".$i."' style='float: left; margin: 5px 5px 0px 0px; width: 150px; height: 30px; color: ".$dotacolor[$i-1]."'>";
- if(isset($players[$i])) {
- $event[$eCC]['time'] = $players[$i]['Time'];
- $event[$eCC]['desc'] = "<font color='".$dotacolor[$i-1]."'>".$players[$i]['cleanname']." ".$players[$i]['LeftReason']."</font>";
- $eCC++;
- }
- }
- </div>
- if($___debug) { echo "<b>[Arrange] Add Leaver Event</b><br>"; takeTime(); }
- // Bubble Sort - for Left Times, SORT ASC
- for($x = 0; $x < count($event); $x++) {
- for($y = 0; $y < count($event); $y++) {
- if($event[$x]['time'] < $event[$y]['time']) {
- $hold = $event[$x];
- $event[$x] = $event[$y];
- $event[$y] = $hold;
- }
- }
- }
- if($___debug) { echo "<b>[Arrange] Bubble Sort</b><br>"; takeTime(); }
- //////// ingame chat div.
- echo "<div style='height: auto; width: 100%; float: left; position: relative;'>"
- $eCC = 0;
- for($i=0; $i<$result['Total']; $i++)
- {
- $pid = $result[$i+1]['player_id']
- if(isset($event[$eCC]) && ($event[$eCC]['time'] <= $result[$i+1]['time']))
- {
- $time = $event[$eCC]['time'];
- $desc = $event[$eCC]['desc'];
- $eCC++;
- $i--;
- }
- else
- {
- $time = $result[$i+1]['time'];
- if($pid > 10) $desc = "<font color='darkred'>[Referee] ";
- else {
- $desc = "<font color='".$dotacolor[$pid-1]."'>".$players[$pid]['cleanname']."</font>";//": ";
- if($result[$i+1]['status'] == 0) $desc .= ": ";
- else if($result[$i+1]['status'] == 1) {
- if($pid >= 1 && $pid <= 5)
- $desc .= "<font color='green'> (Sentinel): ";
- else
- $desc .= "<font color='red'> (Scourge): ";
- }
- else $desc .= " (Private): ";
- }
- if($gameid < 60552) $desc .= CleanString($result[$i+1]['message']);
- else $desc .= CleanString(BDecode($result[$i+1]['message']));
- $desc .= "</font>";
- }
- echo "<div class='player-".$pid."' style='float: left; clear: left;'>[".TimeToStr($time)."]".$desc."</div>";
- }
- // Show remaining events at the end of the chatlog
- while (isset($event[$eCC])) {
- echo "<div style='float: left; clear: left;'> [".TimeToStr($event[$eCC]['time'])."]".$event[$eCC]['desc'];
- $eCC++;
- }
- echo "</div>";
- if($___debug) { echo "<b>[Arrange] Ingame Chat</b><br>"; takeTime(); }
- }
- function CleanString($string) { return htmlspecialchars($string, ENT_QUOTES); }
- function TimeToStr($time)
- {
- $min = floor($time / 60);
- $sec = $time % 60;
- if(strlen($min) == 1) { $min = "0".$min; }
- if(strlen($sec) == 1) { $sec = "0".$sec; }
- return $min.":".$sec;
- }
- //Show how long it took to load the page
- if($___debug) totalTimeTaken();
- ?>
- <script>
- $('.playerChat').click(function(){
- id = $(this).attr('id');
- $('.player-'+id).fadeToggle(100);
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment