diff --git a/admin.php b/admin.php index 30f4a91..724e165 100644 --- a/admin.php +++ b/admin.php @@ -1,5 +1,5 @@ _other = [ "zone" => null, "comment" => '', - 'conn_tries' => 0 + 'conn_tries' => 0, + 'colored_name' => null ]; } @@ -700,11 +703,11 @@ public function queryLive($request = 'seph') { $protocol = new Protocol($this, $request); $protocol->query(); - global $lgsl_config; - if ($lgsl_config['history'] && LGSL::requestHas($request, "h") && !$this->isPending()) { + $config = new Config(); + if ($config['history'] && LGSL::requestHas($request, "h") && !$this->isPending()) { $last = end($this->_history); if (!$last || time() - $last['t'] >= 60 * 15) { // RECORD IF 15 MINS IS PASSED - $history_limit = $lgsl_config['history_hours'] * 3600; + $history_limit = $config['history_hours'] * 3600; foreach ($this->_history as $key => $value) { if (time() - $this->_history[$key]['t'] > $history_limit) { // NOT OLDER THAN $lgsl_config['history_hours'] HOURS unset($this->_history[$key]); @@ -721,7 +724,7 @@ public function queryLive($request = 'seph') { } } - if ($lgsl_config['locations'] && empty($this->_other['location'])) { + if ($config['locations'] && empty($this->_other['location'])) { $this->_other['location'] = $this->queryLocation(); } } @@ -821,15 +824,15 @@ public function getName($htmlSafe = false) { if ($this->isPending()) { return LGSL::NONE; } - $name = Helper::lgslHtmlColor($this->_server['name'], true); if ($htmlSafe) { - $name = preg_replace('/([\x{0001F000}-\x{0001FAFF}])/mu', '', $name); + $name = preg_replace('/([\x{0001F000}-\x{0001FAFF}])/mu', '', $this->_server['name']); return htmlspecialchars($name, ENT_QUOTES); } - return $name; + return $this->_server['name']; } public function getColoredName() { - return Helper::lgslHtmlColor($this->_server['name']); + if (isset($this->_other['colored_name'])) return Helper::lgslHtmlColor($this->_other['colored_name']); + return $this->_server['name']; } public function setName($name) { $this->_server['name'] = $name; @@ -1199,8 +1202,8 @@ function toString() { $lgsl_file_path = LGSL::filePath(); - require "{$lgsl_file_path}lgsl_config.php"; - require "{$lgsl_file_path}lgsl_protocol.php"; + require_once "{$lgsl_file_path}lgsl_config.php"; + require_once "{$lgsl_file_path}lgsl_protocol.php"; $auth = md5(($_SERVER['REMOTE_ADDR'] ?? "").md5($lgsl_config['admin']['user'].md5($lgsl_config['admin']['pass']))); $cookie = $_COOKIE['lgsl_admin_auth'] ?? ""; diff --git a/src/lgsl_list.php b/src/lgsl_list.php index e5325dc..ddd776c 100644 --- a/src/lgsl_list.php +++ b/src/lgsl_list.php @@ -15,18 +15,19 @@ require "lgsl_language.php"; $lang = new Lang($_COOKIE['lgsl_lang'] ?? Lang::EN); global $output; + $config = new Config(); $type = $_GET['type'] ?? ''; $game = $_GET['game'] ?? ''; $mode = $_GET['mode'] ?? ''; - $sort = $_GET['sort'] ?? ''; + $sort = $_GET['sort'] ?? $config['sort']['servers']; $order= (isset($_GET['order']) ? $_GET['order'] == "ASC" ? "DESC" : 'ASC' : "ASC"); - $page = ($lgsl_config['pagination_mod'] && isset($_GET['page']) ? (int)$_GET['page'] : 1); + $page = ($config['pagination_mod'] && isset($_GET['page']) ? (int)$_GET['page'] : 1); $uri = $_SERVER['REQUEST_URI']; - if ($lgsl_config['preloader']) { + if ($config['preloader']) { $uri = $_SERVER['HTTP_REFERER']; } @@ -47,11 +48,11 @@ - - - - - + + + + + "; foreach ($server_list as $server) { @@ -62,13 +63,13 @@ -
{$lgsl_config['text']['sts']}:{$lgsl_config['text']['adr']}:{$lgsl_config['text']['tns']}:{$lgsl_config['text']['map']}:{$lgsl_config['text']['plr']}:{$lgsl_config['text']['dtl']}:{$config['text']['adr']}:{$config['text']['tns']}:{$config['text']['map']}:{$config['text']['plr']}:{$config['text']['dtl']}:
- getStatus()]} | {$lgsl_config['text']['lst']}: {$lastupd}' class='status_icon_{$server->getStatus()}'> + getStatus()]} | {$config['text']['lst']}: {$lastupd}' class='status_icon_{$server->getStatus()}'> {$server->getName()}
"; - if ($lgsl_config['pagination_mod'] && ((int)($servers / $lgsl_config['pagination_lim']) > 0 || $page > 1)) { + if ($config['pagination_mod'] && ((int)($servers / $config['pagination_lim']) > 0 || $page > 1)) { $output .= "
" . ($page > 1 ? " < " : "") . " - {$lgsl_config['text']['pag']} {$page} - " . ($servers < $lgsl_config['pagination_lim'] ? + {$config['text']['pag']} {$page} + " . ($servers < $config['pagination_lim'] ? "" : (isset($_GET['page']) ? " > " : @@ -136,9 +137,9 @@ $output .= "
-
{$lgsl_config['text']['tns']}: {$total['servers']}
-
{$lgsl_config['text']['tnp']}: {$total['players']}
-
{$lgsl_config['text']['tmp']}: {$total['playersmax']}
+
{$config['text']['tns']}: {$total['servers']}
+
{$config['text']['tnp']}: {$total['players']}
+
{$config['text']['tmp']}: {$total['playersmax']}
"; } @@ -147,5 +148,5 @@ //------ WANNA BE HERE? https://github.com/tltneon/lgsl/wiki/Who-uses-LGSL -> LET CREDITS STAY :P --------------------------------------------------------------------------------------------------+ $output .= "
".lgsl_version()."
"; //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -if ($lgsl_config['preloader']) +if ($config['preloader']) echo $output; \ No newline at end of file diff --git a/src/lgsl_protocol.php b/src/lgsl_protocol.php index d4cc2d1..fd537d6 100644 --- a/src/lgsl_protocol.php +++ b/src/lgsl_protocol.php @@ -614,8 +614,9 @@ public function process() { } } - $this->_data['s']['name'] = $this->_data['e']['hostname'] ?? $this->_data['e']['sv_hostname'] ?? LGSL::NONE; - if (isset($this->_data['e']['sv_hostname'])) { $this->_data['e']['sv_hostname'] = strtolower(Helper::lgslHtmlColor($this->_data['e']['sv_hostname'], "1", true)); } + $this->_data['s']['name'] = Helper::lgslHtmlColor($this->_data['e']['hostname'] ?? $this->_data['e']['sv_hostname'] ?? LGSL::NONE, "1", true); + $this->_data['o']['colored_name'] = $this->_data['e']['hostname'] ?? $this->_data['e']['sv_hostname'] ?? LGSL::NONE; + if (isset($this->_data['e']['sv_hostname'])) { $this->_data['e']['sv_hostname'] = $this->_data['s']['name']; } if (isset($this->_data['e']['protocol']) && $type === PROTOCOL::CALLOFDUTYIW) { $games = ['1' => 'IW6', '2' => 'H1', '6' => 'IW3', '7' => 'T7', '20604' => 'IW5', '151' => 'IW4', '101' => 'T4']; $this->_data['s']['game'] = $games[$this->_data['e']['protocol']] ?? "Unknown {$this->_data['e']['protocol']}"; @@ -2414,7 +2415,8 @@ class Query35 extends QueryJson { // FiveM / RedM public function process() { $buffer = $this->fetch("http://{$this->_server->getIp()}:{$this->_server->getQueryPort()}/dynamic.json"); if (!$buffer) return $this::NO_RESPOND; - $this->_data['s']['name'] = Helper::lgslParseColor($buffer['hostname'], 'fivem', false); + $this->_data['s']['name'] = Helper::lgslParseColor($buffer['hostname'], 'fivem'); + $this->_data['o']['colored_name'] = Helper::lgslParseColor($buffer['hostname'], 'fivem', false); $this->_data['s']['players'] = $buffer['clients']; $this->_data['s']['playersmax'] = $buffer['sv_maxclients']; $this->_data['s']['map'] = $buffer['mapname'];