Skip to content

Commit

Permalink
Sorting function for servers #228
Browse files Browse the repository at this point in the history
  • Loading branch information
tltneon committed Feb 27, 2025
1 parent a875379 commit bf37db8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ function check($name, $bool, $hint = '') {
$output .= check('CURL', LGSL::isEnabled("curl"), 'optional: for some games');
$output .= check('BZ2', function_exists("bzdecompress"), 'optional: for some games');
$output .= check('GD', LGSL::isEnabled("gd"), 'optional: for charts & userbars');
$output .= check('SQLite', extension_loaded('sqlite3'), 'optional: alt db');
}

$output .= "
Expand Down Expand Up @@ -480,6 +481,7 @@ function check($name, $bool, $hint = '') {
<l k='sorts'></l>:
<select type='text' name='sort_servers_by' onChange='changeValue(event)' />
<option value='id'>ID</option>
<option value='ip'>IP</option>
<option value='type'>Type</option>
<option value='zone'>Zone</option>
<option value='players'>Players</option>
Expand Down
4 changes: 2 additions & 2 deletions src/lgsl_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public function loadServer(Server &$server): void {
}

static function getServersGroup($options = []) {
global $lgsl_config;
$lgsl_config = new Config();
$db = LGSL::db();

$ip = isset($options['ip']) ? $options['ip'] : (int) $lgsl_config['pagination_lim'];
Expand All @@ -385,7 +385,7 @@ static function getServersGroup($options = []) {
$page = empty($options['page']) ? "" : "LIMIT {$limit} OFFSET " . strval($limit*((int)$options['page'] - 1));
$status = empty($options['status']) ? "" : 1;
$order = empty($options['order']) ? "" : $options['order'];
$sort = empty($options['sort']) ? "" : (in_array($options['sort'], ['ip', 'name', 'map', 'players']) ? $options['sort'] : "");
$sort = empty($options['sort']) ? $lgsl_config['sort']['servers'] : (in_array($options['sort'], ['ip', 'name', 'map', 'players']) ? $options['sort'] : "");
$server_limit = empty($options['limit']) ? "" : $lgsl_config['pagination_lim'];
$server_limit = empty($random) ? $server_limit : $random;

Expand Down

0 comments on commit bf37db8

Please sign in to comment.