diff --git a/system/functions.php b/system/functions.php index 75234685..712cd36e 100644 --- a/system/functions.php +++ b/system/functions.php @@ -1387,39 +1387,48 @@ function getChangelogWhere($v) return 'unknown'; } -function getPlayerNameByAccount($id) + +function getPlayerNameByAccountId($id) { - global $vowels, $ots, $db; - if(is_numeric($id)) - { - $player = new OTS_Player(); - $player->load($id); - if($player->isLoaded()) - return $player->getName(); - else - { - $playerQuery = $db->query('SELECT `id` FROM `players` WHERE `account_id` = ' . $id . ' ORDER BY `lastlogin` DESC LIMIT 1;')->fetch(); + global $db; - $tmp = "*Error*"; - /* - $acco = new OTS_Account(); - $acco->load($id); - if(!$acco->isLoaded()) - return "Unknown name"; + if (!is_numeric($id)) { + return ''; + } - foreach($acco->getPlayersList() as $p) - { - $player= new OTS_Player(); - $player->find($p);*/ - $player->load($playerQuery['id']); - //echo 'id gracza = ' . $p . '
'; - if($player->isLoaded()) - $tmp = $player->getName(); - // break; - //} + $account = new OTS_Account(); + $account->load($id); + if ($account->isLoaded()) { + $query = $db->query('SELECT `name` FROM `players` WHERE `account_id` = ' . $id . ' ORDER BY `lastlogin` DESC LIMIT 1;'); - return $tmp; + if (!$query || !$query->rowCount()) { + return ''; } + + return $query->fetch(PDO::FETCH_ASSOC)['name']; + } + + return ''; +} + +function getPlayerNameByAccount($account) { + if (is_numeric($account)) { + return getPlayerNameByAccountId($account); + } + + return ''; +} + +function getPlayerNameById($id) +{ + if (!is_numeric($id)) { + return ''; + } + + $player = new OTS_Player(); + $player->load($id); + if ($player->isLoaded()) { + return $player->getName(); } return ''; @@ -1427,13 +1436,13 @@ function getPlayerNameByAccount($id) function echo_success($message) { - echo '
' . $message . '
'; + echo '
' . $message . '
'; } function echo_error($message) { global $error; - echo '
' . $message . '
'; + echo '
' . $message . '
'; $error = true; } diff --git a/system/templates/highscores.html.twig b/system/templates/highscores.html.twig index 2e32b7de..ddef7ef2 100644 --- a/system/templates/highscores.html.twig +++ b/system/templates/highscores.html.twig @@ -5,27 +5,27 @@

Ranking for {{ skillName }}{% if vocation is not null %} ({{ vocation }}){% endif %} on {{ config.lua.serverName }}


- - - - + + + +
Filters - - - - - -
Filters + + + + + +