From 9a90e4aae280e607430511c6727d9a714b11f4c5 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 14 Jun 2025 21:12:47 +0200 Subject: [PATCH] Revamped online page --- images/order_asc.gif | Bin 0 -> 56 bytes images/order_desc.gif | Bin 0 -> 56 bytes system/pages/online.php | 26 +++-- system/settings.php | 6 ++ system/templates/online.html.twig | 162 +++++++++++++++++++----------- 5 files changed, 127 insertions(+), 67 deletions(-) create mode 100644 images/order_asc.gif create mode 100644 images/order_desc.gif diff --git a/images/order_asc.gif b/images/order_asc.gif new file mode 100644 index 0000000000000000000000000000000000000000..c9698a5a02f81238b51b1d12bf85840fb7c1fdbe GIT binary patch literal 56 zcmZ?wbhEHbgRG IH3Ne+0CC0*ssI20 literal 0 HcmV?d00001 diff --git a/images/order_desc.gif b/images/order_desc.gif new file mode 100644 index 0000000000000000000000000000000000000000..4a764bd585acf65719cff63448779a4b584fdd09 GIT binary patch literal 56 zcmZ?wbhEHbhasColumn('players', 'promotion')) $promotion = '`promotion`,'; -$order = $_GET['order'] ?? 'name'; -if(!in_array($order, array('country', 'name', 'level', 'vocation'))) - $order = $db->fieldName('name'); -else if($order == 'country') - $order = $db->tableName('accounts') . '.' . $db->fieldName('country'); -else if($order == 'vocation') - $order = $promotion . 'vocation ASC'; +$order = $_GET['order'] ?? 'name_asc'; +if(!in_array($order, ['country_asc', 'country_desc', 'name_asc', 'name_desc', 'level_asc', 'level_desc', 'vocation_asc', 'vocation_desc'])) { + $order = 'name_asc'; +} +else if($order == 'vocation_asc' || $order == 'vocation_desc') { + $order = $promotion . 'vocation_' . (str_contains($order, 'asc') ? 'asc' : 'desc'); +} + +$orderExplode = explode('_', $order); +$orderSql = $orderExplode[0] . ' ' . $orderExplode[1]; $skull_type = 'skull'; if($db->hasColumn('players', 'skull_type')) { @@ -58,11 +61,11 @@ if (setting('core.online_vocations')) { } if($db->hasTable('players_online')) // tfs 1.0 - $playersOnline = $db->query('SELECT `accounts`.`country`, `players`.`name`, `players`.`level`, `players`.`vocation`' . $outfit . ', `' . $skull_time . '` as `skulltime`, `' . $skull_type . '` as `skull` FROM `accounts`, `players`, `players_online` WHERE `players`.`id` = `players_online`.`player_id` AND `accounts`.`id` = `players`.`account_id` ORDER BY ' . $order); + $playersOnline = $db->query('SELECT `accounts`.`country`, `players`.`name`, `players`.`level`, `players`.`vocation`' . $outfit . ', `' . $skull_time . '` as `skulltime`, `' . $skull_type . '` as `skull` FROM `accounts`, `players`, `players_online` WHERE `players`.`id` = `players_online`.`player_id` AND `accounts`.`id` = `players`.`account_id` ORDER BY ' . $orderSql); else - $playersOnline = $db->query('SELECT `accounts`.`country`, `players`.`name`, `players`.`level`, `players`.`vocation`' . $outfit . ', ' . $promotion . ' `' . $skull_time . '` as `skulltime`, `' . $skull_type . '` as `skull` FROM `accounts`, `players` WHERE `players`.`online` > 0 AND `accounts`.`id` = `players`.`account_id` ORDER BY ' . $order); + $playersOnline = $db->query('SELECT `accounts`.`country`, `players`.`name`, `players`.`level`, `players`.`vocation`' . $outfit . ', ' . $promotion . ' `' . $skull_time . '` as `skulltime`, `' . $skull_type . '` as `skull` FROM `accounts`, `players` WHERE `players`.`online` > 0 AND `accounts`.`id` = `players`.`account_id` ORDER BY ' . $orderSql); -$players_data = array(); +$players_data = []; $players = 0; $data = ''; foreach($playersOnline as $player) { @@ -115,7 +118,7 @@ if(count($players_data) > 0) { } if($result) { - $record = 'The maximum on this game world was ' . $result['record'] . ' players' . ($timestamp ? ' on ' . date("M d Y, H:i:s", $result['timestamp']) . '.' : '.'); + $record = $result['record'] . ' player' . ($result['record'] > 1 ? 's' : '') . ($timestamp ? ' (on ' . date("M d Y, H:i:s", $result['timestamp']) . ')' : ''); } } } @@ -124,6 +127,7 @@ $twig->display('online.html.twig', array( 'players' => $players_data, 'record' => $record, 'vocs' => $vocs, + 'order' => $order, )); //search bar diff --git a/system/settings.php b/system/settings.php index 4cfe5c9f..40c8be03 100644 --- a/system/settings.php +++ b/system/settings.php @@ -1264,6 +1264,12 @@ Sent by MyAAC,
'desc' => '', 'default' => false, ], + 'online_datacenter' => [ + 'name' => 'Data Center', + 'type' => 'text', + 'desc' => 'Server Location, will be shown on online page', + 'default' => 'Frankfurt - Germany', + ], [ 'type' => 'section', 'title' => 'Team Page' diff --git a/system/templates/online.html.twig b/system/templates/online.html.twig index 0210d80f..2555873e 100644 --- a/system/templates/online.html.twig +++ b/system/templates/online.html.twig @@ -1,39 +1,7 @@ - - - - -{% if players|length == 0 %} -
Server Status
Currently no one is playing on {{ config.lua.serverName }}.
-{% else %} - - - {% if not status.online %} - Server is offline.
- {% else %} - {% if setting('core.online_afk') %} - {% set players_count = players|length %} - {% set afk = players_count - status.players %} - {% if afk < 0 %} - {% set players_count = players_count + afk|abs %} - {% set afk = 0 %} - {% endif %} - Currently there are {{ status.players }} active and {{ afk }} AFK players.
- Total number of players: {{ players_count }}.
- {% else %} - Currently {{ players|length }} players are online.
- {% endif %} - {% endif %} - {% if setting('core.online_record') %} - {{ record }} - {% endif %} - - - +{# vocation statistics #} +{% if setting('core.online_vocations') %}
- {# vocation statistics #} - {% if setting('core.online_vocations') %} -
- {% if setting('core.online_vocations_images') %} + {% if setting('core.online_vocations_images') %} @@ -69,11 +37,13 @@ {% endfor %}

- {% endif %} {% endif %} +{% endif %} - {# show skulls #} - {% if setting('core.online_skulls') %} +
+ +{# show skulls #} +{% if setting('core.online_skulls') %}
@@ -83,34 +53,114 @@
+{% endif %} + +
+ +{% set title = 'World Information' %} +{% set tableClass = 'Table3' %} +{% set background = config('darkborder') %} +{% set content %} + + + + + + + + + + + {% if setting('core.online_record') %} + + + + {% endif %} -
Status:{% if not status.online %}Offline{% else %}Online{% endif %}
Players Online: + {% if setting('core.online_afk') %} + {% set players_count = players|length %} + {% set afk = players_count - status.players %} + {% if afk < 0 %} + {% set players_count = players_count + afk|abs %} + {% set afk = 0 %} + {% endif %} + Currently there are {{ status.players }} active and {{ afk }} AFK players.
+ Total number of players: {{ players_count }}.
+ {% else %} + {{ players|length }} Players Online. + {% endif %} +
Online Record: + {{ record }} +
- + + + + + + + + +
Location Datacenter:{{ setting('core.online_datacenter') }} (Server date & time: - {{ "now"|date("d/m/Y H:i:s") }})
PvP Type: + {% set worldType = config('lua')['worldType']|lower %} + {% if worldType in ['pvp','2','normal','open','openpvp'] %} + Open PvP + {% elseif worldType in ['no-pvp','nopvp','non-pvp','nonpvp','1','safe','optional','optionalpvp'] %} + Optional PvP + {% elseif worldType in ['pvp-enforced','pvpenforced','pvp-enfo','pvpenfo','pvpe','enforced','enfo','3','war','hardcore','hardcorepvp'] %} + Hardcore PvP + {% endif %} +
+{% endset %} +{% include 'tables.headline.html.twig' %} +
+
+ +{% set title = 'Players Online' %} +{% set tableClass = 'Table2' %} +{% set content %} + + {% if setting('core.account_country') %} - + {% endif %} {% if setting('core.online_outfit') %} - + {% endif %} - - - + + + + {% set i = 0 %} {% for player in players %} {% set i = i + 1 %} - - {% if setting('core.account_country') %} - - {% endif %} - {% if setting('core.online_outfit') %} - - {% endif %} - - - + + + {% if setting('core.account_country') %} + + {% endif %} + + {% if setting('core.online_outfit') %} + + {% endif %} + + + + {% endfor %}
##   + OutfitOutfitNameLevelVocationName   + [sort] + Level   + [sort] + + Vocation   + [sort] + +
{{ player.country_image|raw }}player outfit{{ player.name|raw }}{{ player.skull }}{{ player.level }}{{ player.vocation }}
{{ player.country_image|raw }}player outfit + {{ player.name|raw }}{{ player.skull }} + {{ player.level }}{{ player.vocation }}
-{% endif %} +{% endset %} +{{ include('tables.headline.html.twig') }}