Revamped online page

This commit is contained in:
slawkens 2025-06-14 21:12:47 +02:00
parent ba4ed6a04b
commit 9a90e4aae2
5 changed files with 127 additions and 67 deletions

BIN
images/order_asc.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 B

BIN
images/order_desc.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 B

View File

@ -22,13 +22,16 @@ $promotion = '';
if($db->hasColumn('players', 'promotion')) if($db->hasColumn('players', 'promotion'))
$promotion = '`promotion`,'; $promotion = '`promotion`,';
$order = $_GET['order'] ?? 'name'; $order = $_GET['order'] ?? 'name_asc';
if(!in_array($order, array('country', 'name', 'level', 'vocation'))) if(!in_array($order, ['country_asc', 'country_desc', 'name_asc', 'name_desc', 'level_asc', 'level_desc', 'vocation_asc', 'vocation_desc'])) {
$order = $db->fieldName('name'); $order = 'name_asc';
else if($order == 'country') }
$order = $db->tableName('accounts') . '.' . $db->fieldName('country'); else if($order == 'vocation_asc' || $order == 'vocation_desc') {
else if($order == 'vocation') $order = $promotion . 'vocation_' . (str_contains($order, 'asc') ? 'asc' : 'desc');
$order = $promotion . 'vocation ASC'; }
$orderExplode = explode('_', $order);
$orderSql = $orderExplode[0] . ' ' . $orderExplode[1];
$skull_type = 'skull'; $skull_type = 'skull';
if($db->hasColumn('players', 'skull_type')) { if($db->hasColumn('players', 'skull_type')) {
@ -58,11 +61,11 @@ if (setting('core.online_vocations')) {
} }
if($db->hasTable('players_online')) // tfs 1.0 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 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; $players = 0;
$data = ''; $data = '';
foreach($playersOnline as $player) { foreach($playersOnline as $player) {
@ -115,7 +118,7 @@ if(count($players_data) > 0) {
} }
if($result) { 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, 'players' => $players_data,
'record' => $record, 'record' => $record,
'vocs' => $vocs, 'vocs' => $vocs,
'order' => $order,
)); ));
//search bar //search bar

View File

@ -1264,6 +1264,12 @@ Sent by MyAAC,<br/>
'desc' => '', 'desc' => '',
'default' => false, 'default' => false,
], ],
'online_datacenter' => [
'name' => 'Data Center',
'type' => 'text',
'desc' => 'Server Location, will be shown on online page',
'default' => 'Frankfurt - Germany',
],
[ [
'type' => 'section', 'type' => 'section',
'title' => 'Team Page' 'title' => 'Team Page'

View File

@ -1,35 +1,3 @@
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tr bgcolor="{{ config.vdarkborder }}">
<td class="white"><b>Server Status</b></td>
</tr>
{% if players|length == 0 %}
<tr bgcolor="{{ config.darkborder }}"><td>Currently no one is playing on {{ config.lua.serverName }}.</td></tr></table>
{% else %}
<tr bgcolor="{{ config.darkborder }}">
<td>
{% if not status.online %}
Server is offline.<br/>
{% 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 <b>{{ status.players }}</b> active and <b>{{ afk }}</b> AFK players.<br/>
Total number of players: <b>{{ players_count }}</b>.<br/>
{% else %}
Currently {{ players|length }} players are online.<br/>
{% endif %}
{% endif %}
{% if setting('core.online_record') %}
{{ record }}
{% endif %}
</td>
</tr>
</table>
<br/>
{# vocation statistics #} {# vocation statistics #}
{% if setting('core.online_vocations') %} {% if setting('core.online_vocations') %}
<br/> <br/>
@ -72,6 +40,8 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<br/>
{# show skulls #} {# show skulls #}
{% if setting('core.online_skulls') %} {% if setting('core.online_skulls') %}
<table width="100%" cellspacing="1"> <table width="100%" cellspacing="1">
@ -85,32 +55,112 @@
</table> </table>
{% endif %} {% endif %}
<table border="0" cellspacing="1" cellpadding="4" width="100%"> <br/>
<tr bgcolor="{{ config.vdarkborder }}">
{% set title = 'World Information' %}
{% set tableClass = 'Table3' %}
{% set background = config('darkborder') %}
{% set content %}
<table width="100%">
<tr>
<td class="LabelV150"><b>Status:</b></td>
<td>{% if not status.online %}Offline{% else %}Online{% endif %}</td>
</tr>
<tr>
<td class="LabelV150"><b>Players Online:</b></td>
<td>
{% 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 <b>{{ status.players }}</b> active and <b>{{ afk }}</b> AFK players.<br/>
Total number of players: <b>{{ players_count }}</b>.<br/>
{% else %}
{{ players|length }} Players Online.
{% endif %}
</td>
</tr>
{% if setting('core.online_record') %}
<tr>
<td class="LabelV150"><b>Online Record:</b></td>
<td>
{{ record }}
</td>
</tr>
{% endif %}
<tr>
<td class="LabelV150"><b>Location Datacenter:</b></td>
<td>{{ setting('core.online_datacenter') }} <small>(Server date & time: - {{ "now"|date("d/m/Y H:i:s") }})</small></td>
</tr>
<tr>
<td class="LabelV150"><b>PvP Type:</b></td>
<td>
{% 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 %}
</td>
</tr>
</table>
{% endset %}
{% include 'tables.headline.html.twig' %}
<br/>
<br/>
{% set title = 'Players Online' %}
{% set tableClass = 'Table2' %}
{% set content %}
<table width="100%">
<tr class="LabelH" style="position: relative; z-index: 20;">
{% if setting('core.account_country') %} {% if setting('core.account_country') %}
<td width="11px"><a href="{{ getLink('online?order=country') }}" class="white">#</A></td> <td width="11px"><a href="{{ getLink('online')}}?order=country_{{ order == 'country_asc' ? 'desc' : 'asc' }}">#&#160;&#160;</a>
</td>
{% endif %} {% endif %}
{% if setting('core.online_outfit') %} {% if setting('core.online_outfit') %}
<td class="white"><b>Outfit</b></td> <td><b>Outfit</b></td>
{% endif %} {% endif %}
<td width="60%"><a href="{{ getLink('online?order=name') }}" class="white">Name</A></td> <td style="text-align:left; width:50%">Name&#160;&#160;
<td width="20%"><a href="{{ getLink('online?order=level') }}" class="white">Level</A></td> <small style="font-weight:normal">[<a href="{{ getLink('online')}}?order=name_{{ order == 'name_asc' ? 'desc' : 'asc' }}">sort</a>]</small>
<td width="20%"><a href="{{ getLink('online?order=vocation') }}" class="white">Vocation</td> <img class="sortarrow" src="images/{{ order == 'name_asc' ? 'order_desc' : (order == 'name_desc' ? 'order_asc' : 'news/blank') }}.gif"/></td>
<td style="text-align:left;width:30%">Level&#160;&#160;
<small style="font-weight:normal">[<a href="{{ getLink('online')}}?order=level_{{ order == 'level_asc' ? 'desc' : 'asc' }}">sort</a>]</small>
<img class="sortarrow" src="images/{{ order == 'level_asc' ? 'order_desc' : (order == 'level_desc' ? 'order_asc' : 'news/blank') }}.gif"/>
</td>
<td style="text-align:left;width:50%">Vocation&#160;&#160;
<small style="font-weight:normal">[<a href="{{ getLink('online')}}?order=vocation_{{ order == 'vocation_asc' ? 'desc' : 'asc' }}">sort</a>]</small>
<img class="sortarrow" src="images/{{ order == 'vocation_asc' ? 'order_desc' : (order == 'vocation_desc' ? 'order_asc' : 'news/blank') }}.gif"/>
</td>
</tr> </tr>
{% set i = 0 %} {% set i = 0 %}
{% for player in players %} {% for player in players %}
{% set i = i + 1 %} {% set i = i + 1 %}
<tr bgcolor="{{ getStyle(i) }}">
<tr style="background: {{ getStyle(i) }}; text-align: right; height: 40px;">
{% if setting('core.account_country') %} {% if setting('core.account_country') %}
<td>{{ player.country_image|raw }}</td> <td>{{ player.country_image|raw }}</td>
{% endif %} {% endif %}
{% if setting('core.online_outfit') %} {% if setting('core.online_outfit') %}
<td width="5%"><img style="position:absolute;margin-top:{% if player.player.looktype in setting('core.outfit_images_wrong_looktypes') %}-20px;margin-left:-0px;{% else %}-45px;margin-left:-25px;{% endif %}" src="{{ player.outfit }}" alt="player outfit"/></td> <td width="5%"><img style="position:absolute;margin-top:-48px;margin-left:-70px;" src="{{ player.outfit }}" alt="player outfit"/></td>
{% endif %} {% endif %}
<td>{{ player.name|raw }}{{ player.skull }}</td>
<td>{{ player.level }}</td> <td style="width:70%; text-align:left">
<td>{{ player.vocation }}</td> {{ player.name|raw }}{{ player.skull }}
</td>
<td style="width:10%">{{ player.level }}</td>
<td style="width:20%">{{ player.vocation }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endif %} {% endset %}
{{ include('tables.headline.html.twig') }}