From d0102c6fd4b188b0a1c5ffd3bf9a834a64a5c709 Mon Sep 17 00:00:00 2001 From: Matthijs Kuiper Date: Mon, 8 Jan 2018 16:30:56 +0100 Subject: Match info --- html/includes/config.php | 6 +- html/includes/functions.php | 138 +++++++++++++++++++-------------- html/includes/teamstats.php | 101 ++++++++++++------------ html/pages/match_info.php | 48 +++++++----- html/pages/match_info_charts.php | 65 ++++++++-------- html/pages/match_info_server.php | 162 +++++++++++++-------------------------- 6 files changed, 249 insertions(+), 271 deletions(-) diff --git a/html/includes/config.php b/html/includes/config.php index 77d42fa..55b9ffe 100755 --- a/html/includes/config.php +++ b/html/includes/config.php @@ -1,9 +1,9 @@ 10 && $number %100 < 14): + // when fed a number, adds the English ordinal suffix. Works for any number, even negatives + if ($number % 100 > 10 && $number %100 < 14) { + $suffix = "th"; + } else { + switch($number % 10) { + case 0: $suffix = "th"; - else: - switch($number % 10) { - - case 0: - $suffix = "th"; - break; - - case 1: - $suffix = "st"; - break; + break; - case 2: - $suffix = "nd"; - break; + case 1: + $suffix = "st"; + break; - case 3: - $suffix = "rd"; - break; + case 2: + $suffix = "nd"; + break; - default: - $suffix = "th"; - break; - } + case 3: + $suffix = "rd"; + break; - endif; + default: + $suffix = "th"; + break; + } + } - return $suffix; + return $suffix; } function RankImageOrText($pid, $name, $rank, $gid, $gamename, $mini = true, $format = NULL, $rankchange = NULL) { - $points = 0; + if (empty($rank)) { $r_rank = small_query("SELECT rank FROM uts_rank WHERE pid = '$pid' AND gid= '$gid';"); if (!$r_rank) return(''); @@ -351,12 +344,13 @@ function RankImageOrText($pid, $name, $rank, $gid, $gamename, $mini = true, $for $ranktext = $rank.ordinal($rank); if (file_exists("images/ranks/$rank.png")) { - $width = ($mini) ? 14 : 16; - $height = ($mini) ? 10 : 13; - $img = ''. $rank .''; + $width = ($mini) ? 15 : 15; + $height = ($mini) ? 12 : 12; + $img = ''. $rank .''; } else { $img = ''; } + $moveimg = ''; if ($rankchange !== NULL) { $moveimg = ' '. RankMovement($rankchange); @@ -369,6 +363,7 @@ function RankImageOrText($pid, $name, $rank, $gid, $gamename, $mini = true, $for return('('.$ranktext.$moveimg.')'); } } + $imageortext = ($img) ? $img : $ranktext; $search = array('%RT%', '%RN%', '%RP%', '%RI%', '%GN%', '%PN%', '%IT%'); $replace = array($ranktext, $rank, $points, $img, $gamename, $name, $imageortext); @@ -418,8 +413,10 @@ function debug_output($desc, $data) { for ($i = 0; $i < $len; $i++) { echo substr($data, $i, 1) .' '; } + echo "\n"; echo str_repeat(' ', (strlen($desc) + 2)); + for ($i = 0; $i < $len; $i++) { echo ord(substr($data, $i, 1)) .' '; } @@ -433,7 +430,6 @@ function check_extension($name) { return(@dl($prefix . $name . PHP_SHLIB_SUFFIX)); } - function compress_file($method, $in, $out, $stripx00) { if ((!file_exists($out) and !is_writeable(dirname($out))) or (file_exists($out) and !is_writable($out))) return(false); $blocksize = 8192; @@ -469,16 +465,18 @@ function compress_file($method, $in, $out, $stripx00) { } @fclose($fp_in); + switch($method) { case 'bz2': @bzclose($fp_out); break; case 'zlib': @gzclose($fp_out); break; - case 'none': @fclose($fp_out); break; + case 'none': @fclose($fp_out); break; } + return(true); } function backup_logfile($method, $filename, $backupfilename, $stripx00) { - switch($method) { + switch ($method) { case 'compress': if (!check_extension('bz2') or !compress_file('bz2', $filename, $backupfilename, $stripx00)) { return(backup_logfile('gzip', $filename, $backupfilename, $stripx00)); @@ -528,11 +526,10 @@ function purge_backups($dir, $maxage) { unlink($cna); $deleted++; } - } closedir($dh); - return($deleted); + return $deleted; } function file_size_info($filesize) { @@ -551,12 +548,12 @@ function GetCurrentWatchlist() { foreach($watchlist as $key => $value) { $watchlist[$key] = addslashes($value); } - return($watchlist); + return $watchlist; } function PlayerOnWatchlist($pid) { $watchlist = GetCurrentWatchlist(); - return(in_array($pid, $watchlist)); + return in_array($pid, $watchlist); } function ToggleWatchStatus($pid) { @@ -570,21 +567,48 @@ function ToggleWatchStatus($pid) { $watchlist[] = $pid; $status = 1; } - setcookie('uts_watchlist', implode(',',$watchlist), time()+60*60*24*30*365*5); - return($status); + + setcookie('uts_watchlist', implode(',', $watchlist), time() + 60*60*24*30*365*5); + return $status; } function DeBugMessage($message) { global $debug, $html; - if(!$debug) { + + if (!$debug) { return; } - if ($html) echo ' - - '; - +
'; + if ($html) echo '
'; echo "Debugging Output:\n"; - if ($html) echo '
';
+	if ($html) echo '
';
 	echo $message . "\n";
 	if ($html) echo '


'; } +function getMapImageName($mapname) { + for ($i=0; $i<3; $i++) { + // try substracting modname from map + if ($i == 1) { + if(($x_pos = strpos($mapname, '-')) !== false) { + $mapname = substr($mapname, $x_pos + 1); + } + } + + // try also substracting league names from map + if ($i==2) { + $mapVersions = array('CB1','CB2','CB3','CB4','CB5','CB6','CB7','CB','LE13','LE14','LE15','LE16','LE17','LE18','LE19','LE','-DE13','-DE14','-DE15','-DE16','-DE17','-DE18','-DE19','v2','v3','v4','v5','-MLIG','-GU','-SDOM','-][ugn','-ugn','ALT2lightedit','-LE102','-','LE100','LE101','LE102','LE103','LE104','LE105','-v17','test3C','Fixed','XL','DM','MLTDM'); + $mapname = str_replace($mapVersions, "", $mapname); + } + + $mappic = strtolower("images/maps/" . $mapname . "_large.jpg"); + + if(file_exists(dirname(dirname(__FILE__)) . "/" . $mappic)) { + return $mappic; + } + } + + return "images/maps/blank_large.jpg"; +} + ?> diff --git a/html/includes/teamstats.php b/html/includes/teamstats.php index fd06ead..b2116b9 100755 --- a/html/includes/teamstats.php +++ b/html/includes/teamstats.php @@ -1,8 +1,10 @@ -
'.htmlentities($title).'
+ + + + '; $sql_players = "SELECT pi.name, pi.banned, p.pid, p.team, p.country, p.gametime, p.gamescore, p.frags, p.deaths, p.suicides, p.teamkills, p.eff, p.accuracy, p.ttl, p.rank".(($extra) ? ', p.'.$extra.' AS '.$extra : '')." - FROM uts_player AS p, uts_pinfo AS pi WHERE p.pid = pi.id AND matchid = $mid - ORDER BY".(($teams) ? ' team ASC,' : '')." $order"; + FROM uts_player AS p, uts_pinfo AS pi WHERE p.pid = pi.id AND matchid = $mid + ORDER BY".(($teams) ? ' team ASC,' : '')." $order"; $q_players = mysql_query($sql_players) or die(mysql_error()); $header = true; teamstats_init_totals($totals, $num); + while ($r_players = zero_out(mysql_fetch_array($q_players))) { $r_players['dom_cp'] = $r_players['gamescore'] - $r_players['frags']; - $r_players['team'] = intval($r_players['team']); + if ($teams and $oldteam != $r_players['team']) { if ($r_players['team'] != 0) teamstats_team_totals($totals, $num, $teams, $extra, $teamscore[$oldteam]); $oldteam = $r_players['team']; @@ -46,27 +46,29 @@ function teamstats($mid, $title, $extra = NULL, $extratitle = NULL, $order = 'ga case 2: $teamname = 'Green'; break; case 3: $teamname = 'Gold'; break; } - echo''; + + echo''; $header = true; } + if ($header) { $header = false; echo ' - - - '; - if ($extra) echo' '; + + + '; + if ($extra) echo ''; echo' - - - - '; - if ($teams) echo ''; + + + + '; + if ($teams) echo ''; echo ' - - - + + + '; } @@ -87,7 +89,7 @@ function teamstats($mid, $title, $extra = NULL, $extratitle = NULL, $order = 'ga $totals['acc'] += $r_players['accuracy']; $totals['ttl'] += $r_players['ttl']; $num++; - + if ($r_players['banned'] == 'Y') { $eff = '-'; $acc = '-'; @@ -101,15 +103,16 @@ function teamstats($mid, $title, $extra = NULL, $extratitle = NULL, $order = 'ga $r_players['teamkills'] = '-'; } - $class = ($num % 2) ? 'grey' : 'grey2'; - echo ''; + echo ''; + if ($r_players['banned'] != 'Y') { - echo ''; + echo ''; } else { - echo ''; + echo ''; } - echo ''; + + echo ''; echo ''; if ($extra) echo ''; @@ -121,14 +124,15 @@ function teamstats($mid, $title, $extra = NULL, $extratitle = NULL, $order = 'ga if ($teams) echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; echo ''; } + teamstats_team_totals($totals, $num, $teams, $extra, $teamscore[$oldteam]); - echo '
'.htmlentities($title).'
Team: '.$teamname.'
Team: '.$teamname.'
PlayerTimeScore'.htmlentities($extratitle).'PlayerTimeScore'.htmlentities($extratitle).'FKDSTKFKDSTKEff.Acc.Avg TTLEff.Acc.Avg TTL
'.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).''.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).''.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).''.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).''.GetMinutes($r_players['gametime']/TIMERATIO).''.GetMinutes($r_players['gametime'] / TIMERATIO).''.$r_players['gamescore'].''.$r_players[$extra].''.$r_players['teamkills'].''.$eff.''.$acc.''.$ttl.''.$eff.''.$acc.''.$ttl.'

'; + echo '
'; } function teamstats_init_totals(&$totals, &$num, $extra = null) { @@ -151,27 +155,28 @@ function teamstats_team_totals(&$totals, $num, $teams, $extra, $teamscore) { $acc = get_dp($totals['acc'] / $num); $ttl = GetMinutes($totals['ttl'] / $num); - echo ''; - echo 'Totals'; - echo ''; + echo 'Totals'; + echo ''; + if ($teams) { - echo ''.$teamscore.' ('.$totals[gamescore].')'; + echo ''.$teamscore.' ('.$totals[gamescore].')'; } else { - echo ''.$totals[gamescore].''; + echo ''.$totals[gamescore].''; } - if ($extra) echo ''.$totals[$extra].''; + if ($extra) echo ''.$totals[$extra].''; - echo ''.$totals[frags].''; - echo ''.$totals[kills].''; - echo ''.$totals[deaths].''; - echo ''.$totals[suicides].''; + echo ''.$totals[frags].''; + echo ''.$totals[kills].''; + echo ''.$totals[deaths].''; + echo ''.$totals[suicides].''; - if ($teams) echo ''.$totals[teamkills].''; + if ($teams) echo ''.$totals[teamkills].''; - echo ''.$eff.''; - echo ''.$acc.''; - echo ''.$ttl.''; + echo ''.$eff.''; + echo ''.$acc.''; + echo ''.$ttl.''; echo ''; } + ?> diff --git a/html/pages/match_info.php b/html/pages/match_info.php index 31edc2d..8d77186 100755 --- a/html/pages/match_info.php +++ b/html/pages/match_info.php @@ -3,39 +3,46 @@ $r_info = small_query("SELECT teamgame, t0, t1, t2, t3, t0score, t1score, t2scor if (!$r_info) die("Match not found"); $teamgame = ($r_info['teamgame'] == 'True') ? true : false; -echo ' - - - - -
Unreal Tournament Match
-
'; include("pages/match_info_server.php"); -include("pages/match_info_charts.php"); $GLOBALS['gid'] = $gid; $_GLOBALS['gid'] = $gid; $GLOBALS['gamename'] = $gamename; $_GLOBALS['gamename'] = $gamename; -include('includes/teamstats.php'); +include("includes/teamstats.php"); +include("pages/match_info_charts.php"); +echo "

WOOOt

"; + switch($real_gamename) { + case "Assault": case "Assault (insta)": include("pages/match_info_ass.php"); break; - + case "Capture the Flag": case "Capture the Flag (insta)": + case "5v5 iCTF": + case "1v1 iCTF": + case "2v2 iCTF": + case "3v3 iCTF": + case "5v5 teleCTF": + case "5v5 saCTF": + case "5v5 nwCTF": + case "3v3 nwCTF": include("pages/match_info_ctf.php"); teamstats($mid, 'Match Summary'); - break; - + break; + case "Domination": case "Domination (insta)": + case "4v4 iDOM": + case "4v4 sDOM": + case "4v4 nwDOM": teamstats($mid, 'Match Summary', 'dom_cp', 'Dom Pts'); break; - + case "JailBreak": case "JailBreak (insta)": teamstats($mid, 'Match Summary', 'ass_obj', 'Team Releases'); @@ -44,11 +51,13 @@ switch($real_gamename) { case "Bunny Track": include("pages/match_info_bt.php"); break; - + case "Tournament DeathMatch": case "Tournament Team Game": case "Tournament DeathMatch (insta)": case "Tournament Team Game (insta)": + case "FFA iDM": + case "2v2v2v2 iTDM": teamstats($mid, 'Match Summary'); break; @@ -66,21 +75,20 @@ switch($real_gamename) { default: if ($teamgame) { teamstats($mid, 'Match Summary'); - } else { + } else { teamstats($mid, 'Player Summary'); } } - -if ($real_gamename == "Assault" or $real_gamename== "Assault (insta)") { +if ($real_gamename == "Assault" or $real_gamename == "Assault (insta)") { include("pages/match_info_other2.php"); } else if ($real_gamename != "Bunny Track") { include("pages/match_info_other.php"); } -if ($real_gamename == "Capture the Flag" or $real_gamename== "Capture the Flag (insta)") { - include("pages/match_report.php"); +if ($real_gamename == "Capture the Flag" or $real_gamename == "Capture the Flag (insta)") { + include("pages/match_report.php"); } -?> \ No newline at end of file +?> diff --git a/html/pages/match_info_charts.php b/html/pages/match_info_charts.php index a6170e7..ed62fe5 100644 --- a/html/pages/match_info_charts.php +++ b/html/pages/match_info_charts.php @@ -11,15 +11,15 @@ $chartOutput = ""; $prevRenderedChart = ""; // get all charts for this match -$charts = mysql_query("SELECT d.* , t.charttype, t.category, t.type, t.color, t.layout,t.columns -FROM uts_chartdata d -JOIN uts_charttypes t ON d.chartid = t.id -WHERE d.mid = $mid -ORDER BY d.id ASC") or die(mysql_error()); +$charts = mysql_query("SELECT d.* , t.charttype, t.category, t.type, t.color, t.layout,t.columns + FROM uts_chartdata d + JOIN uts_charttypes t ON d.chartid = t.id + WHERE d.mid = $mid + ORDER BY d.id ASC") or die(mysql_error()); $chartCount = mysql_num_rows($charts); -if($chartCount >0) { +if ($chartCount >0) { $i = 0; // cycle over charts @@ -36,50 +36,47 @@ if($chartCount >0) { $data = unserialize(gzdecode($chart['data'])); $labels = unserialize(gzdecode($chart['labels'])); $categories = unserialize(gzdecode($chart['categories'])); - + // append previous chart - this is done to ensure proper outlining (can only know in +1 round) $chartOutput .= $prevRenderedChart; - + // print a new section if we're now in a different category - if($category != $prevCategory) { - - if(strlen($prevCategory)>0) + if ($category != $prevCategory) { + + if(strlen($prevCategory) > 0) $chartOutput .= renderFootBlock(); - + $chartOutput .= renderHeaderBlock($category); $prevCategory = $category; - + } else { - if($i>1 && $i%2 == 0) - $chartOutput .= ""; + if ($i>1 && $i%2 == 0) + $chartOutput .= ""; else - $chartOutput .= ""; - } - + $chartOutput .= ""; + } + $prevRenderedChart = renderChart($mid."-".$i,$layout,$color,$title,$data,$labels,$categories,$renderer_width*$columns,$renderer_heigth,$charttype); $i++; } - + // finishing up $chartOutput .= $prevRenderedChart; $chartOutput .= renderFootBlock(); - echo " - - "; - + echo ' + '; + echo $chartOutput; } - - -?> \ No newline at end of file +?> diff --git a/html/pages/match_info_server.php b/html/pages/match_info_server.php index b3c6f40..b2d9a57 100755 --- a/html/pages/match_info_server.php +++ b/html/pages/match_info_server.php @@ -1,71 +1,4 @@ - - Totals for This Match - - - Team Score - Player Score - Frags - Kills - Deaths - Suicides - '; - -// Get Summary Info -$teamscore = small_query("SELECT SUM(t0score + t1score + t2score + t3score) AS result FROM uts_match WHERE id = $mid"); -$playerscore = small_query("SELECT SUM(gamescore) AS result FROM uts_player WHERE matchid = $mid"); -$fragcount = small_query("SELECT SUM(frags) AS result FROM uts_match WHERE id = $mid"); -$killcount = small_query("SELECT SUM(kills) AS result FROM uts_match WHERE id = $mid"); -$deathcount = small_query("SELECT SUM(deaths) AS result FROM uts_match WHERE id = $mid"); -$suicidecount = small_query("SELECT SUM(suicides) AS result FROM uts_match WHERE id = $mid"); - -echo' - - '.$teamscore[result].' - '.$playerscore[result].' - '.$fragcount[result].' - '.$killcount[result].' - '.$deathcount[result].' - '.$suicidecount[result].' - '; - -// Teamgame? Then show score -if ($teamgame) { - echo ' - - '; - echo ' - Score:'; - if ($r_info[t0]) { - echo ' - '.$r_info[t0score]; - } - if ($r_info[t1]) { - echo ' - - '.$r_info[t1score]; - } - if ($r_info[t2]) { - echo ' - - '.$r_info[t2score]; - } - if ($r_info[t3]) { - echo ' - - '.$r_info[t3score]; - } - echo ' - - '; -} - -echo ' - -
- - - - '; $matchinfo = small_query("SELECT m.time, m.servername, g.name AS gamename, m.gamename AS real_gamename, m.gid, m.mapname, m.mapfile, m.serverinfo, m.gameinfo, m.mutators, m.serverip FROM uts_match AS m, uts_games AS g WHERE m.gid = g.id AND m.id = $mid"); $matchdate = mdate($matchinfo[time]); @@ -74,56 +7,67 @@ $real_gamename = $matchinfo[real_gamename]; $gid = $matchinfo[gid]; $mapname = un_ut($matchinfo[mapfile]); -$mappic = strtolower("images/maps/".$mapname.".jpg"); - -if (file_exists($mappic)) { -} else { - $mappic = ("images/maps/blank.jpg"); -} - +$mappic = getMapImageName($mapname); $myurl = urlencode($mapname); -$mapnameToPrint = $matchinfo['mapname']; -if($mapnameToPrint == "Untitled") - $mapnameToPrint = $mapname; +$mapnameToPrint = $matchinfo[mapname]; +if ($mapnameToPrint == "Untitled") { + $mapnameToPrint = $mapname; +} - echo' - - - - - - - - - - - - - - - - - +echo' +
Unreal Tournament Match Stats
Match Date'.$matchdate.'Server'.$matchinfo[servername].'
Match Type'.$gamename.'Map Name'.$mapnameToPrint.'
Server Info'.$matchinfo[serverinfo].''.$mapname.'
+ - - + + +
Game Info'.$matchinfo[gameinfo].'
Match Stats
+ +
+ + + +'; + +if ($r_info[t0score] > 0 || $r_info[t1score] > 0) { + echo ' - - - -
Mutators'.$matchinfo[mutators].'
-
'; + '.$r_info[t0score].' + '.$r_info[t1score].' + '; + if ($r_info[t2score] > 0 || $r_info[t3score] > 0) { + echo' + + '.$r_info[t2score].' + '.$r_info[t3score].' + '; + } +} -// Get Summary Info -$teamscore = small_query("SELECT SUM(t0score + t1score + t2score + t3score) AS result FROM uts_match WHERE id = $mid"); -$playerscore = small_query("SELECT SUM(gamescore) AS result FROM uts_player WHERE matchid = $mid"); -$fragcount = small_query("SELECT SUM(frags) AS result FROM uts_match WHERE id = $mid"); -$killcount = small_query("SELECT SUM(kills) AS result FROM uts_match WHERE id = $mid"); -$deathcount = small_query("SELECT SUM(deaths) AS result FROM uts_match WHERE id = $mid"); -$suicidecount = small_query("SELECT SUM(suicides) AS result FROM uts_match WHERE id = $mid"); +echo ' + + Match Date + '.$matchdate.' + Server + '.$matchinfo[servername].' + + + Mutators + '.$matchinfo[mutators].' + Map Name + '.$mapnameToPrint.' + + + Server Info + '.$matchinfo[serverinfo].' + Game Info + '.$matchinfo[gameinfo].' + + + +
'; ?> -- cgit