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/functions.php | 138 ++++++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 57 deletions(-) (limited to 'html/includes/functions.php') 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 = ''. $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"; +} + ?> -- cgit