summaryrefslogtreecommitdiff
path: root/html/includes
diff options
context:
space:
mode:
authorMatthijs Kuiper <info@matthijskuiper.nl>2018-01-08 16:30:56 +0100
committerMatthijs Kuiper <info@matthijskuiper.nl>2018-01-09 00:44:09 +0100
commitd0102c6fd4b188b0a1c5ffd3bf9a834a64a5c709 (patch)
treeeb8a66085ca7cd2b994497c1d14a6dded7dbf59f /html/includes
parent790d93b495ecc375ea0518a5f43f2944daa9720b (diff)
Match info
Diffstat (limited to 'html/includes')
-rwxr-xr-xhtml/includes/config.php6
-rwxr-xr-xhtml/includes/functions.php138
-rwxr-xr-xhtml/includes/teamstats.php101
3 files changed, 137 insertions, 108 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 @@
<?php
// Database connection details
-$dbname = "";
-$hostname = "";
-$uname = "";
+$dbname = "utstats";
+$hostname = "localhost";
+$uname = "root";
$upass = "";
// The key needed to run the import script
diff --git a/html/includes/functions.php b/html/includes/functions.php
index b8cab68..005a3c1 100755
--- a/html/includes/functions.php
+++ b/html/includes/functions.php
@@ -34,16 +34,16 @@ require_once(dirname(__FILE__) .'/countries.php');
// Addslashes if magic_quotes are off
function my_addslashes($data) {
if (!get_magic_quotes_gpc()) {
- $data = addslashes($data);
+ $data = addslashes($data);
}
return $data;
}
function my_stripslashes($data) {
if (!get_magic_quotes_gpc()) {
- $data = $data;
+ $data = $data;
} else {
- $data = stripslashes($data);
+ $data = stripslashes($data);
}
return $data;
}
@@ -84,14 +84,14 @@ function my_fopen($filename, $mode, &$compression) {
if (substr($filename, -4) == '.bz2') {
if (check_extension('bz2')) {
$compression = 'bz2';
- } else {
+ } else {
return(false);
}
}
if (substr($filename, -3) == '.gz') {
if (check_extension('zlib')) {
$compression = 'zlib';
- } else {
+ } else {
return(false);
}
}
@@ -162,14 +162,12 @@ function get_dp($number) {
function sec2min($number) {
$dp = $number/60;
-
$dp = number_format($dp, 2, '.', '');
return ($dp);
}
function sec2hour($number) {
$dp = $number/3600;
-
$dp = number_format($dp, 2, '.', '');
return ($dp);
}
@@ -250,13 +248,12 @@ function btcaptime($time) {
function GetItemInfo ($itemname, $itemchunks) {
$retval = "N/A";
for ($i = 0; $i < count($itemchunks); $i++) {
- //Found this item
- if (strcasecmp($itemchunks[$i], $itemname) == 0) {
- $retval = $itemchunks[$i+1];
- }
+ //Found this item
+ if (strcasecmp($itemchunks[$i], $itemname) == 0) {
+ $retval = $itemchunks[$i+1];
+ }
}
-
- return $retval;
+ return $retval;
}
function GetMinutes($seconds) {
@@ -271,8 +268,8 @@ function GetMinutes($seconds) {
function FlagImage($country, $mini = true) {
global $a_countries;
- $width = ($mini) ? 15 : 18;
- $height = ($mini) ? 10 : 12;
+ $width = ($mini) ? 20 : 20;
+ $height = ($mini) ? 14 : 14;
if (empty($country)) return('');
if (!file_exists("images/flags/$country.png")) return(''); //18*12
$countryname = (isset($a_countries[$country])) ? $a_countries[$country] : '';
@@ -304,43 +301,39 @@ function RankMovement($diff) {
}
function ordinal($number) {
- // when fed a number, adds the English ordinal suffix. Works for any
- // number, even negatives
-
- if ($number % 100 > 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 = '<img src="images/ranks/'. $rank .'.png" width="'.$width.'" height="'.$height.'" style="border:0;" alt="'. $rank .'" title="'. $ranktext .' in '. $gamename .'">';
+ $width = ($mini) ? 15 : 15;
+ $height = ($mini) ? 12 : 12;
+ $img = '<img class="tooltip" src="images/ranks/'. $rank .'.png" width="17" height="17" style="border:0; margin-bottom: -4px;" alt="'. $rank .'" title="'. $ranktext .' in '. $gamename .'">';
} else {
$img = '';
}
+
$moveimg = '';
if ($rankchange !== NULL) {
$moveimg = ' '. RankMovement($rankchange);
@@ -369,6 +363,7 @@ function RankImageOrText($pid, $name, $rank, $gid, $gamename, $mini = true, $for
return('<span class="rangtext">('.$ranktext.$moveimg.')</span>');
}
}
+
$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 '<table class="box" border="0"><tr><td class="smheading" width="550">';
+ if ($html) echo '<table class="zebra box" border="0"><tr><th class="smheading" width="550">';
echo "Debugging Output:\n";
- if ($html) echo '</td></tr><tr><td width="550" align="left"><pre>';
+ if ($html) echo '</th></tr><tr><td width="550" align="left"><pre>';
echo $message . "\n";
if ($html) echo '</pre></td></tr></table><br><br>';
}
+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 @@
<?php
function teamstats($mid, $title, $extra = NULL, $extratitle = NULL, $order = 'gamescore DESC') {
global $gamename, $gid;
+
$r_info = small_query("SELECT teamgame, t0score, t1score, t2score, t3score FROM uts_match WHERE id = '$mid'");
if (!$r_info) die("Match not found");
+
$teams = ($r_info['teamgame'] == 'True') ? true : false;
$teamscore[-1] = 0;
$teamscore[0] = $r_info['t0score'];
@@ -10,31 +12,29 @@ function teamstats($mid, $title, $extra = NULL, $extratitle = NULL, $order = 'ga
$teamscore[2] = $r_info['t2score'];
$teamscore[3] = $r_info['t3score'];
-
$cols = 10;
if ($teams) $cols++;
if ($extra) $cols++;
-
$oldteam = -1;
-
echo'
- <table class = "box" border="0" cellpadding="0" cellspacing="2" width="600">
- <tbody><tr>
- <td class="heading" colspan="'.$cols.'" align="center">'.htmlentities($title).'</td>
- </tr>';
-
+ <table class="box zebra" border="0" cellpadding="0" cellspacing="0" width="700">
+ <tbody>
+ <tr>
+ <th class="heading" colspan="'.$cols.'" align="center">'.htmlentities($title).'</th>
+ </tr>';
$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'<tr><td class="hlheading" colspan="'.$cols.'" align="center">Team: '.$teamname.'</td></tr>';
+
+ echo'<tr><td class="'.$teamname.'" colspan="'.$cols.'" align="center">Team: '.$teamname.'</td></tr>';
$header = true;
}
+
if ($header) {
$header = false;
echo '
<tr>
- <td class="smheading" align="center">Player</td>
- <td class="smheading" align="center" width="50">Time</td>
- <td class="smheading" align="center" width="50">Score</td>';
- if ($extra) echo' <td class="smheading" align="center" width="50">'.htmlentities($extratitle).'</td>';
+ <th class="smheading" align="center">Player</th>
+ <th class="smheading" align="center" width="50">Time</th>
+ <th class="smheading" align="center" width="50">Score</th>';
+ if ($extra) echo '<th class="smheading" align="center" width="50">'.htmlentities($extratitle).'</th>';
echo'
- <td class="smheading" align="center" width="40" '.OverlibPrintHint('F').'>F</td>
- <td class="smheading" align="center" width="40" '.OverlibPrintHint('K').'>K</td>
- <td class="smheading" align="center" width="40" '.OverlibPrintHint('D').'>D</td>
- <td class="smheading" align="center" width="40" '.OverlibPrintHint('S').'>S</td>';
- if ($teams) echo '<td class="smheading" align="center" width="40" '.OverlibPrintHint('TK').'>TK</td>';
+ <th class="smheading tooltip" align="center" width="40" title="Frags: A player\'s frag count is equal to their kills minus suicides. In team games team kills (not team suicides) are also subtracted from the player\'s kills.">F</th>
+ <th class="smheading tooltip" align="center" width="40" title="Kills: Number of times a player kills another player.">K</th>
+ <th class="smheading tooltip" align="center" width="40" title="Deaths: Number of times a player gets killed by another player.">D</th>
+ <th class="smheading tooltip" align="center" width="40" title="Suicides: Number of times a player dies due to action of their own cause. Suicides can be environment induced (drowning, getting crushed, falling) or weapon related (fatal splash damage from their own weapon).">S</th>';
+ if ($teams) echo '<th class="smheading tooltip" align="center" width="40" title="Team Kills: Number of times a player in a team based game kills someone on their own team.">TK</th>';
echo '
- <td class="smheading" align="center" width="55" '.OverlibPrintHint('EFF').'>Eff.</td>
- <td class="smheading" align="center" width="55" '.OverlibPrintHint('ACC').'>Acc.</td>
- <td class="smheading" align="center" width="50" '.OverlibPrintHint('TTL').'>Avg TTL</td>
+ <th class="smheading tooltip" align="center" width="55" title="Efficiency: A ratio that denotes the player\'s kill skill by comparing it with his overall performance. A perfect efficiency is equal to 1 (100%), anything less than 0.5 (50%) is below average. Formula: Kills / (Kills + Deaths + Suicides [+Team Kills])">Eff.</th>
+ <th class="smheading tooltip" align="center" width="55" title="Accuracy: Overall accuracy when using all weapons. Most accurate in insta but also very accurate in normal weapons.">Acc.</th>
+ <th class="smheading tooltip" align="center" width="50" title="Average Time to Live: The length of time a player is in a game in seconds divided by how many times he/she dies, thus giving an average time of how long he/she will live.">Avg TTL</th>
</tr>';
}
@@ -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 '<tr>';
+ echo '<tr class="clickableRow" href="./?p=matchp&amp;mid='.$mid.'&amp;pid='.$r_players['pid'].'">';
+
if ($r_players['banned'] != 'Y') {
- echo '<td nowrap class="darkhuman" align="left"><a class="darkhuman" href="./?p=matchp&amp;mid='.$mid.'&amp;pid='.$r_players['pid'].'">'.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).'</a></td>';
+ echo '<td nowrap align="left"><a href="./?p=matchp&amp;mid='.$mid.'&amp;pid='.$r_players['pid'].'">'.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).'</a></td>';
} else {
- echo '<td nowrap class="darkhuman" align="left"><span style="text-decoration: line-through;">'.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).'</span></td>';
+ echo '<td nowrap align="left"><span style="text-decoration: line-through;">'.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).'</span></td>';
}
- echo '<td class="'.$class.'" align="center">'.GetMinutes($r_players['gametime']/TIMERATIO).'</td>';
+
+ echo '<td class="'.$class.'" align="center">'.GetMinutes($r_players['gametime'] / TIMERATIO).'</td>';
echo '<td class="'.$class.'" align="center">'.$r_players['gamescore'].'</td>';
if ($extra) echo '<td class="'.$class.'" align="center">'.$r_players[$extra].'</td>';
@@ -121,14 +124,15 @@ function teamstats($mid, $title, $extra = NULL, $extratitle = NULL, $order = 'ga
if ($teams) echo '<td class="'.$class.'" align="center">'.$r_players['teamkills'].'</td>';
- echo '<td class="'.$class.'" align="center">'.$eff.'</td>';
- echo '<td class="'.$class.'" align="center">'.$acc.'</td>';
- echo '<td class="'.$class.'" align="center">'.$ttl.'</td>';
+ echo '<td align="center">'.$eff.'</td>';
+ echo '<td align="center">'.$acc.'</td>';
+ echo '<td align="center">'.$ttl.'</td>';
echo '</tr>';
}
+
teamstats_team_totals($totals, $num, $teams, $extra, $teamscore[$oldteam]);
- echo '</tbody></table><br>';
+ echo '</tbody></table><br>';
}
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 '<tr>';
- echo '<td nowrap class="dark" align="center">Totals</td>';
- echo '<td class="darkgrey" align="center"></td>';
+ echo '<td nowrap class="totals" align="center">Totals</td>';
+ echo '<td class="totals" align="center"></td>';
+
if ($teams) {
- echo '<td class="darkgrey" align="center"><strong>'.$teamscore.'</strong> ('.$totals[gamescore].')</td>';
+ echo '<td class="totals" align="center"><strong>'.$teamscore.'</strong> ('.$totals[gamescore].')</td>';
} else {
- echo '<td class="darkgrey" align="center">'.$totals[gamescore].'</td>';
+ echo '<td class="totals" align="center">'.$totals[gamescore].'</td>';
}
- if ($extra) echo '<td class="darkgrey" align="center">'.$totals[$extra].'</td>';
+ if ($extra) echo '<td class="totals" align="center">'.$totals[$extra].'</td>';
- echo '<td class="darkgrey" align="center">'.$totals[frags].'</td>';
- echo '<td class="darkgrey" align="center">'.$totals[kills].'</td>';
- echo '<td class="darkgrey" align="center">'.$totals[deaths].'</td>';
- echo '<td class="darkgrey" align="center">'.$totals[suicides].'</td>';
+ echo '<td class="totals" align="center">'.$totals[frags].'</td>';
+ echo '<td class="totals" align="center">'.$totals[kills].'</td>';
+ echo '<td class="totals" align="center">'.$totals[deaths].'</td>';
+ echo '<td class="totals" align="center">'.$totals[suicides].'</td>';
- if ($teams) echo '<td class="darkgrey" align="center">'.$totals[teamkills].'</td>';
+ if ($teams) echo '<td class="totals" align="center">'.$totals[teamkills].'</td>';
- echo '<td class="darkgrey" align="center">'.$eff.'</td>';
- echo '<td class="darkgrey" align="center">'.$acc.'</td>';
- echo '<td class="darkgrey" align="center">'.$ttl.'</td>';
+ echo '<td class="totals" align="center">'.$eff.'</td>';
+ echo '<td class="totals" align="center">'.$acc.'</td>';
+ echo '<td class="totals" align="center">'.$ttl.'</td>';
echo '</tr>';
}
+
?>