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 +++++++++++++++++--------------- 3 files changed, 137 insertions(+), 108 deletions(-) (limited to 'html/includes') 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 ''; } + ?> -- cgit