diff --git a/api.php b/api.php index 130e91f..a5a30c2 100644 --- a/api.php +++ b/api.php @@ -27,8 +27,8 @@ case "server": $players = array(); + if (!isset($_REQUEST['name'])) die('invalid server "name"'); $hostName = urldecode($_REQUEST['name']); - if ($hostName == '') die('error'); $hostName = $db->clean($hostName); $res = $db->select('*','onServers',"WHERE serverName = '$hostName'"); foreach ($res as $row) { @@ -50,6 +50,7 @@ $players = $db->select('id, serverName, playerName, p.playerID, nick, model, country, AllRating', 'onServers s','LEFT JOIN nfkLive_playerStats p ON p.name = s.playerName LEFT JOIN AltStat_Players a ON a.PlayerId = p.playerID WHERE s.playerName <> \'Null\' GROUP BY playerName,serverName ORDER BY id'); +/* $plrs = array(); foreach($players as $plr){ $plrs[$plr['serverName']][] = array( @@ -63,6 +64,7 @@ ); } $players_unique = array(); +*/ $srvs = array(); foreach($servers as $srv){ diff --git a/inc/functions.inc.php b/inc/functions.inc.php index 8af3632..eb7dd22 100644 --- a/inc/functions.inc.php +++ b/inc/functions.inc.php @@ -274,12 +274,14 @@ function GameTypeShortU($gt) { } function stripColor($nick) { - $pure = ""; + $pure = ""; for ($i = 0; $i 0 && ($nick[$i-1] != '^')) - $pure .= $nick[$i]; + if ($nick[$i] == '^') + $i++; + else + $pure .= $nick[$i]; } - return $pure; + return html_entity_decode($pure); } /** @@ -287,14 +289,7 @@ function stripColor($nick) { */ function stripNameColor($nick) { - for ($i = 0; $i<=strlen($nick); $i++ ) - { - if (($nick[$i] != '^') and (!is_numeric($nick[$i+1])) ) - if (($nick[$i-1] != '^') and (!is_numeric($nick[$i])) ) - $pure .= $nick[$i]; - } - //$pure = htmlspecialchars($pure); - return $pure; + return stripColor($nick); } /** @@ -704,10 +699,10 @@ function getUserName($xdata) { } function getIcons($player, $profile = true, $flag = true, $ico = true, $colored = false) { - if ($player['author'] <> "") $player['name'] = $player['author']; + if (isset($player['author']) && $player['author'] <> "") $player['name'] = $player['author']; if ($colored) { - if ($player['nick'] <> "") $plr_name = parseNameColor(clearName($player['nick'])); else $plr_name = clearName($player['name']); + if (isset($player['nick']) && $player['nick'] <> "") $plr_name = parseNameColor(clearName($player['nick'])); else $plr_name = clearName($player['name']); } else $plr_name = clearName($player['name']); if ($profile) { diff --git a/nplanet.php b/nplanet.php index 6334230..aeca640 100644 --- a/nplanet.php +++ b/nplanet.php @@ -41,18 +41,8 @@ 0 && ($nick[$i-1] != '^')) - $pure .= $nick[$i]; - } - - return $pure; -} function cmpServers($a, $b) { @@ -80,7 +70,7 @@ function cmpServers($a, $b) foreach ($servers as $key => $server) { //preg_replace('/\W/', '', $a); - $hostlink = stripNameColor($server['Hostname']); + $hostlink = stripColor($server['Hostname']); $hostlinkx = $hostlink; $hostlink = str_replace("#", "%23", $hostlink); //$link = ((substr($server["Hostname"], 0, 3) == "Rip") or (substr($server["Hostname"], 0, 9) == "[twuo.ru]")) ? (''.$hostlinkx.''):($hostlinkx);