Skip to content

Commit 2dc84ee

Browse files
committed
Fixed error & sorting #228
1 parent 99f84f7 commit 2dc84ee

5 files changed

Lines changed: 42 additions & 36 deletions

File tree

admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require "src/lgsl_config.php";
2+
require_once "src/lgsl_config.php";
33

44
if (empty($lgsl_config['admin']['user']) || empty($lgsl_config['admin']['pass'])) {
55
exit($lgsl_config['text']['aum']);

src/lgsl_admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
if (!defined("LGSL_ADMIN")) { header('HTTP/1.0 404 Not Found'); exit(); }
1313

14-
require "lgsl_class.php";
15-
require "lgsl_language.php";
14+
require_once "lgsl_class.php";
15+
require_once "lgsl_language.php";
1616
$lang = new Lang($_COOKIE['lgsl_lang'] ?? Lang::EN);
1717

1818
if (!function_exists("fsockopen") && !$lgsl_config['feed']['method']) {

src/lgsl_class.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,10 @@ function &unserializeData(array &$data): array {
460460
$server['e'] = $cache['e'];
461461
$server['p'] = $cache['p'];
462462
if (isset($cache['h'])) $server['h'] = $cache['h'];
463-
if (isset($cache['o']['location'])) $server['o']['location'] = $cache['o']['location'];
464-
if (isset($cache['o']['conn_tries'])) $server['o']['conn_tries'] = $cache['o']['conn_tries'];
463+
foreach (['location', 'conn_tries', 'colored_name'] as $i) {
464+
if (isset($cache['o'][$i]))
465+
$server['o'][$i] = $cache['o'][$i];
466+
}
465467
$server['s']['cache_time'] = new Timestamp($data['cache_time']);
466468
}
467469
return $server;
@@ -678,7 +680,8 @@ function __construct($options = []) {
678680
$this->_other = [
679681
"zone" => null,
680682
"comment" => '',
681-
'conn_tries' => 0
683+
'conn_tries' => 0,
684+
'colored_name' => null
682685
];
683686
}
684687

@@ -700,11 +703,11 @@ public function queryLive($request = 'seph') {
700703
$protocol = new Protocol($this, $request);
701704
$protocol->query();
702705

703-
global $lgsl_config;
704-
if ($lgsl_config['history'] && LGSL::requestHas($request, "h") && !$this->isPending()) {
706+
$config = new Config();
707+
if ($config['history'] && LGSL::requestHas($request, "h") && !$this->isPending()) {
705708
$last = end($this->_history);
706709
if (!$last || time() - $last['t'] >= 60 * 15) { // RECORD IF 15 MINS IS PASSED
707-
$history_limit = $lgsl_config['history_hours'] * 3600;
710+
$history_limit = $config['history_hours'] * 3600;
708711
foreach ($this->_history as $key => $value) {
709712
if (time() - $this->_history[$key]['t'] > $history_limit) { // NOT OLDER THAN $lgsl_config['history_hours'] HOURS
710713
unset($this->_history[$key]);
@@ -721,7 +724,7 @@ public function queryLive($request = 'seph') {
721724
}
722725
}
723726

724-
if ($lgsl_config['locations'] && empty($this->_other['location'])) {
727+
if ($config['locations'] && empty($this->_other['location'])) {
725728
$this->_other['location'] = $this->queryLocation();
726729
}
727730
}
@@ -821,15 +824,15 @@ public function getName($htmlSafe = false) {
821824
if ($this->isPending()) {
822825
return LGSL::NONE;
823826
}
824-
$name = Helper::lgslHtmlColor($this->_server['name'], true);
825827
if ($htmlSafe) {
826-
$name = preg_replace('/([\x{0001F000}-\x{0001FAFF}])/mu', '', $name);
828+
$name = preg_replace('/([\x{0001F000}-\x{0001FAFF}])/mu', '', $this->_server['name']);
827829
return htmlspecialchars($name, ENT_QUOTES);
828830
}
829-
return $name;
831+
return $this->_server['name'];
830832
}
831833
public function getColoredName() {
832-
return Helper::lgslHtmlColor($this->_server['name']);
834+
if (isset($this->_other['colored_name'])) return Helper::lgslHtmlColor($this->_other['colored_name']);
835+
return $this->_server['name'];
833836
}
834837
public function setName($name) {
835838
$this->_server['name'] = $name;
@@ -1199,8 +1202,8 @@ function toString() {
11991202

12001203
$lgsl_file_path = LGSL::filePath();
12011204

1202-
require "{$lgsl_file_path}lgsl_config.php";
1203-
require "{$lgsl_file_path}lgsl_protocol.php";
1205+
require_once "{$lgsl_file_path}lgsl_config.php";
1206+
require_once "{$lgsl_file_path}lgsl_protocol.php";
12041207

12051208
$auth = md5(($_SERVER['REMOTE_ADDR'] ?? "").md5($lgsl_config['admin']['user'].md5($lgsl_config['admin']['pass'])));
12061209
$cookie = $_COOKIE['lgsl_admin_auth'] ?? "";

src/lgsl_list.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
require "lgsl_language.php";
1616
$lang = new Lang($_COOKIE['lgsl_lang'] ?? Lang::EN);
1717
global $output;
18+
$config = new Config();
1819

1920
$type = $_GET['type'] ?? '';
2021
$game = $_GET['game'] ?? '';
2122
$mode = $_GET['mode'] ?? '';
22-
$sort = $_GET['sort'] ?? '';
23+
$sort = $_GET['sort'] ?? $config['sort']['servers'];
2324
$order= (isset($_GET['order']) ? $_GET['order'] == "ASC" ? "DESC" : 'ASC' : "ASC");
2425

25-
$page = ($lgsl_config['pagination_mod'] && isset($_GET['page']) ? (int)$_GET['page'] : 1);
26+
$page = ($config['pagination_mod'] && isset($_GET['page']) ? (int)$_GET['page'] : 1);
2627

2728
$uri = $_SERVER['REQUEST_URI'];
2829

29-
if ($lgsl_config['preloader']) {
30+
if ($config['preloader']) {
3031
$uri = $_SERVER['HTTP_REFERER'];
3132
}
3233

@@ -47,11 +48,11 @@
4748
<table id='server_list_table'>
4849
<tr id='server_list_table_top'>
4950
<th class='status_cell'>{$lgsl_config['text']['sts']}:</th>
50-
<th class='connectlink_cell'><a href='{$ipsort}'>{$lgsl_config['text']['adr']}:</a></th>
51-
<th class='servername_cell'><a href='{$namesort}'>{$lgsl_config['text']['tns']}:</a></th>
52-
<th class='map_cell'><a href='{$mapsort}'>{$lgsl_config['text']['map']}:</a></th>
53-
<th class='players_cell'><a href='{$playersort}'>{$lgsl_config['text']['plr']}:</a></th>
54-
<th class='details_cell'>{$lgsl_config['text']['dtl']}:</th>
51+
<th class='connectlink_cell'><a href='{$ipsort}'>{$config['text']['adr']}:</a></th>
52+
<th class='servername_cell'><a href='{$namesort}'>{$config['text']['tns']}:</a></th>
53+
<th class='map_cell'><a href='{$mapsort}'>{$config['text']['map']}:</a></th>
54+
<th class='players_cell'><a href='{$playersort}'>{$config['text']['plr']}:</a></th>
55+
<th class='details_cell'>{$config['text']['dtl']}:</th>
5556
</tr>";
5657

5758
foreach ($server_list as $server) {
@@ -62,13 +63,13 @@
6263
<tr class='server_{$server->getStatus()}'>
6364
6465
<td class='status_cell'>
65-
<span title='{$lgsl_config['text'][$server->getStatus()]} | {$lgsl_config['text']['lst']}: {$lastupd}' class='status_icon_{$server->getStatus()}'></span>
66+
<span title='{$config['text'][$server->getStatus()]} | {$config['text']['lst']}: {$lastupd}' class='status_icon_{$server->getStatus()}'></span>
6667
<a href='{$gamelink}'>
6768
<img alt='{$server->getName()}' src='{$server->addUrlPath($server->getGameIcon())}' title='{$server->getGameFormatted()}' class='game_icon' />
6869
</a>
6970
</td>
7071
71-
<td title='{$lgsl_config['text']['slk']}' class='connectlink_cell'>
72+
<td title='{$config['text']['slk']}' class='connectlink_cell'>
7273
<a href='{$server->getConnectionLink()}'>
7374
{$server->getAddress()}
7475
</a>
@@ -117,12 +118,12 @@
117118
$output .= "
118119
</table>";
119120

120-
if ($lgsl_config['pagination_mod'] && ((int)($servers / $lgsl_config['pagination_lim']) > 0 || $page > 1)) {
121+
if ($config['pagination_mod'] && ((int)($servers / $config['pagination_lim']) > 0 || $page > 1)) {
121122
$output .= "
122123
<div id='pages'>
123124
" . ($page > 1 ? "<a href='" . LGSL::buildLink($uri, ["page" => $page - 1]) . "'> < </a>" : "") . "
124-
<span>{$lgsl_config['text']['pag']} {$page}</span>
125-
" . ($servers < $lgsl_config['pagination_lim'] ?
125+
<span>{$config['text']['pag']} {$page}</span>
126+
" . ($servers < $config['pagination_lim'] ?
126127
"" :
127128
(isset($_GET['page']) ?
128129
"<a href='" . LGSL::buildLink($uri, ["page" => $page + 1]) . "'> > </a>" :
@@ -136,9 +137,9 @@
136137

137138
$output .= "
138139
<div id='totals'>
139-
<div> {$lgsl_config['text']['tns']}: {$total['servers']} </div>
140-
<div> {$lgsl_config['text']['tnp']}: {$total['players']} </div>
141-
<div> {$lgsl_config['text']['tmp']}: {$total['playersmax']} </div>
140+
<div> {$config['text']['tns']}: {$total['servers']} </div>
141+
<div> {$config['text']['tnp']}: {$total['players']} </div>
142+
<div> {$config['text']['tmp']}: {$total['playersmax']} </div>
142143
</div>";
143144
}
144145

@@ -147,5 +148,5 @@
147148
//------ WANNA BE HERE? https://github.com/tltneon/lgsl/wiki/Who-uses-LGSL -> LET CREDITS STAY :P --------------------------------------------------------------------------------------------------+
148149
$output .= "<div style='text-align:center; font-family:tahoma; font-size:9px; padding: 33px 0px 11px 0px;'><a href='https://github.com/tltneon/lgsl' style='text-decoration:none'>".lgsl_version()."</a></div>";
149150
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
150-
if ($lgsl_config['preloader'])
151+
if ($config['preloader'])
151152
echo $output;

src/lgsl_protocol.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,9 @@ public function process() {
614614
}
615615
}
616616

617-
$this->_data['s']['name'] = $this->_data['e']['hostname'] ?? $this->_data['e']['sv_hostname'] ?? LGSL::NONE;
618-
if (isset($this->_data['e']['sv_hostname'])) { $this->_data['e']['sv_hostname'] = strtolower(Helper::lgslHtmlColor($this->_data['e']['sv_hostname'], "1", true)); }
617+
$this->_data['s']['name'] = Helper::lgslHtmlColor($this->_data['e']['hostname'] ?? $this->_data['e']['sv_hostname'] ?? LGSL::NONE, "1", true);
618+
$this->_data['o']['colored_name'] = $this->_data['e']['hostname'] ?? $this->_data['e']['sv_hostname'] ?? LGSL::NONE;
619+
if (isset($this->_data['e']['sv_hostname'])) { $this->_data['e']['sv_hostname'] = $this->_data['s']['name']; }
619620
if (isset($this->_data['e']['protocol']) && $type === PROTOCOL::CALLOFDUTYIW) {
620621
$games = ['1' => 'IW6', '2' => 'H1', '6' => 'IW3', '7' => 'T7', '20604' => 'IW5', '151' => 'IW4', '101' => 'T4'];
621622
$this->_data['s']['game'] = $games[$this->_data['e']['protocol']] ?? "Unknown {$this->_data['e']['protocol']}";
@@ -2414,7 +2415,8 @@ class Query35 extends QueryJson { // FiveM / RedM
24142415
public function process() {
24152416
$buffer = $this->fetch("http://{$this->_server->getIp()}:{$this->_server->getQueryPort()}/dynamic.json");
24162417
if (!$buffer) return $this::NO_RESPOND;
2417-
$this->_data['s']['name'] = Helper::lgslParseColor($buffer['hostname'], 'fivem', false);
2418+
$this->_data['s']['name'] = Helper::lgslParseColor($buffer['hostname'], 'fivem');
2419+
$this->_data['o']['colored_name'] = Helper::lgslParseColor($buffer['hostname'], 'fivem', false);
24182420
$this->_data['s']['players'] = $buffer['clients'];
24192421
$this->_data['s']['playersmax'] = $buffer['sv_maxclients'];
24202422
$this->_data['s']['map'] = $buffer['mapname'];

0 commit comments

Comments
 (0)