Skip to content

Commit

Permalink
v6.0.0 Pagination Mod: limitation of showing servers per page
Browse files Browse the repository at this point in the history
Filtering by type or game using ?game= or ?type= parameters
Game icon now is a link to show all server of that game
Now servers shows timestamps of last querying
Admin panel: now you can add ip with port to ip input (LGSL split after ':' automatically)
Updated all styles
Working on PHP 8.0
#25 Added SCUM
  • Loading branch information
tltneon committed Dec 9, 2020
1 parent 818160d commit a2b0b79
Show file tree
Hide file tree
Showing 20 changed files with 385 additions and 168 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/tltneon/lgsl?color=green&style=for-the-badge)](https://github.com/tltneon/lgsl/releases)
![PHP](https://img.shields.io/badge/PHP-5.4--7.4-brightgreen?style=for-the-badge&logo=php)
![PHP](https://img.shields.io/badge/PHP-5.4--8.0-brightgreen?style=for-the-badge&logo=php)
![MySQL](https://img.shields.io/badge/MySQL-5.5.27--8.0.x-brightgreen?style=for-the-badge&logo=mysql)
![MariaDB](https://img.shields.io/badge/MariaDB-5.5--10.5.x-brightgreen?style=for-the-badge&logo=mariadb)

Expand All @@ -8,8 +8,8 @@
[![GitHub forks](https://img.shields.io/github/forks/tltneon/lgsl?style=for-the-badge)](https://github.com/tltneon/lgsl/fork)
[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/tltneon/lgsl?style=for-the-badge)](https://github.com/tltneon/lgsl/archive/master.zip)
[![Packagist](https://img.shields.io/packagist/l/tltneon/lgsl?style=for-the-badge)](https://github.com/tltneon/lgsl/blob/master/LICENSE)
# LGSL v5.10.3 (Live Game Server List) for PHP 7+
Based-off LGSL v5.8 (stand-alone version) from www.greycube.com. This is almost original version of LGSL with [new features](https://github.com/tltneon/lgsl#changelog) and working on PHP 5.4-7.x and MySQL 5.5.27-8.0.x or MariaDB 5.5-10.5.x
# LGSL v6.0.0 (Live Game Server List) for PHP 7+
Based-off LGSL v5.8 (stand-alone version) from www.greycube.com. This is almost original version of LGSL with [new features](https://github.com/tltneon/lgsl#changelog) and working on PHP 5.4-8.x and MySQL 5.5.27-8.0.x or MariaDB 5.5-10.5.x

## [Live Demos](http://lgsl-demo.freesite.vip/) | [Wiki](https://github.com/tltneon/lgsl/wiki) | [How to install]( https://github.com/tltneon/lgsl/wiki/How-to-install-LGSL) | [Supported games](https://github.com/tltneon/lgsl/wiki/Supported-Games) | [Custom styles](https://github.com/tltneon/lgsl/wiki/Styles)

Expand All @@ -21,6 +21,15 @@ Feel free to make [pull request](https://github.com/tltneon/lgsl) with your cust
![lgsl Server List on mobile device](https://i.imgur.com/oui8Nya.png)

## [Changelog](https://github.com/tltneon/lgsl/wiki/Changelog)
#### v6.0.0
- **LGSL now can use pagination!**
- **Filtering by type or game using ?game= or ?type= parameters**
- **Game icon now is a link to show all server of that game**
- **Admin panel: now you can add ip with port to ip input (LGSL split after ':' automatically)**
- **Now servers shows timestamps of last querying**
- **Added Arabic languages**
- *Thanks to [@lamjed001](https://github.com/lamjed001)*
- **Updated all styles**
#### v5.10.3
- **LGSL now has update page**
- **Added Rage:MP protocol**
Expand Down Expand Up @@ -72,4 +81,4 @@ Feel free to make [pull request](https://github.com/tltneon/lgsl) with your cust

##### [:: Older versions](https://github.com/tltneon/lgsl/wiki/Changelog)

Original author of LGSL - Richard Perry (www.greycube.com)
Original author of [LGSL](https://github.com/tltneon/lgsl/releases/tag/v5.8) - Richard Perry (www.greycube.com)
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"license": "GPL-3.0-only",
"keywords":
[
"discord",
"fivem",
"csgo",
"counter-strike",
"team fortress",
Expand All @@ -30,12 +32,13 @@
],
"support": {
"wiki": "https://github.com/tltneon/lgsl/wiki",
"games": "https://github.com/tltneon/lgsl/wiki/Supported-Games",
"source": "https://github.com/tltneon/lgsl",
"issues": "https://github.com/tltneon/lgsl/issues"
},
"require":
{
"php": ">=7.0"
"php": ">=5.4"
},
"autoload":
{
Expand Down
259 changes: 153 additions & 106 deletions install.php

Large diffs are not rendered by default.

Binary file added lgsl_files/icons/scum/scum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lgsl_files/icons/source/left4dead2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lgsl_files/icons/source/svencoop.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 29 additions & 24 deletions lgsl_files/lgsl_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@

//------------------------------------------------------------------------------------------------------------+

if ($_POST && get_magic_quotes_gpc()) { $_POST = lgsl_stripslashes_deep($_POST); }
if ($_POST) { $_POST = lgsl_stripslashes_deep($_POST); }

if (function_exists("mysqli_set_charset"))
{
@mysqli_set_charset("utf8");
@mysqli_set_charset($lgsl_database, "utf8");
}
else
{
Expand Down Expand Up @@ -108,8 +108,12 @@
$cache = mysqli_real_escape_string($lgsl_database, $cache);
$cache_time = mysqli_real_escape_string($lgsl_database, $cache_time);

// THIS WHITESPACE BEING PUT IN THE IP
// THIS PREVENTS PORTS OR WHITESPACE BEING PUT IN THE IP
$ip = trim($ip);
if (strpos($ip, ':') !== false){
$c_port = explode(":", $ip)[1];
$ip = explode(":", $ip)[0];
}

list($c_port, $q_port, $s_port) = lgsl_port_conversion($type, $c_port, $q_port, $s_port);

Expand Down Expand Up @@ -202,21 +206,16 @@
}
.tt{
width: auto;
padding: 7px;
}
}
</style>
';

$output .= "
<form method='post' action=''>
<div>
<br />
<br />
<input type='hidden' name='lgsl_management' value='{$_POST['lgsl_management']}' />
<input type='submit' name='lgsl_return' value='RETURN TO ADMIN' />
<br />
<br />
</div>
<form method='post' action='' style='padding-top: 40px; text-align: center;'>
<input type='hidden' name='lgsl_management' value='{$_POST['lgsl_management']}' />
<input type='submit' name='lgsl_return' value='RETURN TO ADMIN' />
</form>";

return;
Expand All @@ -227,6 +226,12 @@
if (!empty($_POST['lgsl_map_image_paths']))
{
$server_list = lgsl_query_cached_all("s");

$output .= "
<div style='padding: 5px;'>
Haven't got images? <a href='https://github.com/tltneon/lgsl/wiki#how-can-i-add-map-images' target='_blank'>How to: add map icons</a>
</div>
";

foreach ($server_list as $server)
{
Expand All @@ -235,21 +240,21 @@
$image_map = lgsl_image_map($server['b']['status'], $server['b']['type'], $server['s']['game'], $server['s']['map'], FALSE);

$output .= "
<div>
<a href='{$image_map}' target='_blank'> {$image_map} <img src='{$image_map}' width='32' height='32' /> </a>
<div style='padding-bottom: 5px;'>
<div style='display: inline-block;'>
<img src='{$image_map}' width='32' height='32' />
</div>
<div style='display: inline-block;vertical-align: super;'>
<div>Map Name: {$server['s']['map']}</div>
<div>Link: <a href='{$image_map}' target='_blank'>{$image_map}</a></div>
</div>
</div>";
}

$output .= "
<form method='post' action=''>
<div>
<br />
<br />
<input type='hidden' name='lgsl_management' value='{$_POST['lgsl_management']}' />
<input type='submit' name='lgsl_return' value='RETURN TO ADMIN' />
<br />
<br />
</div>
<form method='post' action='' style='padding: 15px;'>
<input type='hidden' name='lgsl_management' value='{$_POST['lgsl_management']}' />
<input type='submit' name='lgsl_return' value='RETURN TO ADMIN' />
</form>";

return;
Expand Down Expand Up @@ -405,7 +410,7 @@

$output .= "
<tr>
<td>NEW <a href='https://github.com/tltneon/lgsl/wiki/Supported-Games' target='_blank' style='position: absolute' title='How to choose query protocol?'>[?]</a></td>
<td>NEW<a href='https://github.com/tltneon/lgsl/wiki/Supported-Games' target='_blank' style='position: absolute;background: #fff;border-radius: 10px;width: 14px;height: 14px;border: 2px solid;margin-top: 7px;' title='How to choose query protocol?'>?</a></td>
<td>
<select name='form_type[{$id}]'>";
//---------------------------------------------------------+
Expand Down
7 changes: 5 additions & 2 deletions lgsl_files/lgsl_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function lgsl_query_cached($type, $ip, $c_port, $q_port, $s_port, $request, $id
$cache['s']['players'] = 0;
$cache['s']['playersmax'] = 0;
$cache['s']['password'] = 0;
$cache['s']['cache_time'] = $cache_time[0];
}

if (!isset($cache['e'])) { $cache['e'] = array(); }
Expand Down Expand Up @@ -247,6 +248,7 @@ function lgsl_query_cached($type, $ip, $c_port, $q_port, $s_port, $request, $id
$live['s']['password'] = $cache['s']['password'];
$live['s']['players'] = 0;
$live['s']['playersmax'] = $cache['s']['playersmax'];
$live['s']['cache_time'] = $cache['s']['cache_time'];
$live['e'] = array();
$live['p'] = array();
}
Expand Down Expand Up @@ -292,14 +294,15 @@ function lgsl_query_group($options = array())
$random = isset($options['random']) ? intval($options['random']) : intval($lgsl_config['random'][$zone]);
$type = empty($options['type']) ? "" : preg_replace("/[^a-z0-9_]/", "_", strtolower($options['type']));
$game = empty($options['game']) ? "" : preg_replace("/[^a-z0-9_]/", "_", strtolower($options['game']));
$mysqli_order = empty($random) ? "`cache_time` ASC" : "rand()";
$page = empty($options['page']) ? "" : "LIMIT {$lgsl_config['pagination_lim']} OFFSET " . strval($lgsl_config['pagination_lim']*((int)$options['page'] - 1));
$mysqli_order = empty($random) ? "id" : "rand()";
$server_limit = empty($random) ? 0 : $random;

$mysqli_where = array("`disabled`=0");
if ($zone != 0) { $mysqli_where[] = "FIND_IN_SET('{$zone}',`zone`)"; }
if ($type != "") { $mysqli_where[] = "`type`='{$type}'"; }

$mysqli_query = "SELECT `id` FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE ".implode(" AND ", $mysqli_where)." ORDER BY {$mysqli_order}";
$mysqli_query = "SELECT `id` FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE ".implode(" AND ", $mysqli_where)." ORDER BY {$mysqli_order} {$page}";
$mysqli_result = mysqli_query($lgsl_database, $mysqli_query) or die(mysqli_error($lgsl_database));
$server_list = array();

Expand Down
11 changes: 7 additions & 4 deletions lgsl_files/lgsl_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,19 @@
$lgsl_config['timeout'] = 0; // 1=gives more time for servers to respond but adds loading delay
$lgsl_config['retry_offline'] = 0; // 1=repeats query when there is no response but adds loading delay
$lgsl_config['cms'] = "sa"; // sets which CMS specific code to use
$lgsl_config['image_mod'] = true; // true = show userbar in server's details
$lgsl_config['image_mod'] = true; // true = show userbar in server's details
$lgsl_config['pagination_mod']= true; // true = using pagination
$lgsl_config['pagination_lim']= 15; // limit per page

include("languages/english.php"); // sets LGSL language
// English language: "languages/english.php" // Richard Perry
// Russian language: "languages/russian.php" // Neon
// French language: "languages/french.php" // own3mall
// German language: "languages/german.php" // ctannurella
// Spanish language: "languages/spanish.php" // own3mall
// Czech language: "languages/czech.php" // Neon
// Bulgarian language: "languages/bulgarian.php" // Neon
// Slovak language: "languages/slovak.php" // KristianP26
// Czech language: "languages/czech.php" // Neon
// Bulgarian language: "languages/bulgarian.php" // Neon
// Slovak language: "languages/slovak.php" // KristianP26
// Arabic language: "languages/arabic.php" // lamjed001

//------------------------------------------------------------------------------------------------------------+
7 changes: 5 additions & 2 deletions lgsl_files/lgsl_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@
<div class='details_info_srow'>
<div class='details_info_ceil'>{$lgsl_config['text']['plr']}:</div><div class='details_info_ceil'>{$server['s']['players']} / {$server['s']['playersmax']}</div></div>
</div>
</div>
<div class='details_info_row'>
Last update: " . Date('d.m.Y H:i:s', $server['s']['cache_time']) . "
</div>
</div>
<div class='details_info_column zone{$server['o']['zone']}' style='background-image: url({$misc['image_map']});'>
<span class='details_location_image' style='background-image: url({$misc['icon_location']});' title='{$misc['text_location']}'></span>
<span class='details_password_image zone{$server['o']['zone']}' style='background-image: url({$misc['image_map_password']});'></span>
<span class='details_password_image zone{$server['o']['zone']}' style='background-image: url({$misc['image_map_password']});' title='Map: {$server['s']['map']}'></span>
<span class='details_game_image' style='background-image: url({$misc['icon_game']});' title='{$misc['text_type_game']}'></span>
</div>
</div>";
Expand Down Expand Up @@ -162,7 +165,7 @@

foreach ($server['e'] as $field => $value)
{
if(preg_match('/(https*:\/\/|www\.)([\w]*\.*)*\w+\/*([\w]*\/*)*/i', $value)){
if(preg_match('/(https*:\/\/www\.|www\.)([\w]*\.*)*\w+\/*([\w]*\/*)*/i', $value)){
$value = "<a href='".$value."' target='_blank'>".$value."</a>";
}
$output .= "
Expand Down
34 changes: 28 additions & 6 deletions lgsl_files/lgsl_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@

require "lgsl_class.php";

$server_list = lgsl_query_group();
$type = (isset($_GET['type']) ? $_GET['type'] : '');
$game = (isset($_GET['game']) ? $_GET['game'] : '');
if($lgsl_config['pagination_mod']){
$page = (isset($_GET['page']) ? (int)$_GET['page'] : 1);
}
$server_list = lgsl_query_group(array("type" => $type, "game" => $game, "page" => $page));
$server_list = lgsl_sort_servers($server_list);

//------------------------------------------------------------------------------------------------------------+
if(count($server_list) == 0)
{
if(count($server_list) == 0) {
$output .= "<div id='back_to_servers_list'><a href='./admin.php'>TO ADMIN PANEL</a></div>";
}

Expand All @@ -36,13 +40,15 @@
{
$misc = lgsl_server_misc($server);
$server = lgsl_server_html($server);
$percent = strval($server['s']['players'] == 0 ? 0 : floor($server['s']['players']/$server['s']['playersmax']*100));
$lastupd = Date('d.m.Y H:i:s', $server['s']['cache_time']);

$output .= "
<tr class='server_{$misc['text_status']}'>
<td class='status_cell'>
<span title='{$lgsl_config['text'][$misc['text_status']]}' class='status_icon_{$misc['text_status']}'></span>
<img alt='{$misc['name_filtered']}' src='{$misc['icon_game']}' title='{$misc['text_type_game']}' class='game_icon' />
<span title='{$lgsl_config['text'][$misc['text_status']]} | Last update: {$lastupd}' class='status_icon_{$misc['text_status']}'></span>
<a href='{$_SERVER['REQUEST_URI']}?&game={$server['s']['game']}'><img alt='{$misc['name_filtered']}' src='{$misc['icon_game']}' title='{$misc['text_type_game']}' class='game_icon' /></a>
</td>
<td title='{$lgsl_config['text']['slk']}' class='connectlink_cell'>
Expand All @@ -67,7 +73,12 @@
</td>
<td class='players_cell'>
<span class='players'>{$server['s']['players']}</span>/<span class='maxplayers'>{$server['s']['playersmax']}</span>
<div class='outer_bar'>
<div class='inner_bar' style='width:{$percent}%;'>
<span class='players_numeric'>{$server['s']['players']}/{$server['s']['playersmax']}</span>
<span class='players_percent{$percent}'>{$percent}%</span>
</div>
</div>
</td>
<td class='details_cell'>";
Expand All @@ -89,6 +100,16 @@

$output .= "
</table>";

if($lgsl_config['pagination_mod']){
$output .= "
<div id='pages'>
" . ($page > 1 ? "<a href='" . str_replace('page='.strval($page), 'page='.strval($page - 1), $_SERVER['REQUEST_URI']) . "'><</a>" : "") . "
<span>Page {$page}</span>
" . (count($server_list) < $lgsl_config['pagination_lim'] ? "" : (isset($_GET['page']) ? "<a href='" . str_replace('page='.strval($page), 'page='.strval($page + 1), $_SERVER['REQUEST_URI']) . "'>></a>" : "<a href='" . $_SERVER['REQUEST_URI'] ."?page=2'>></a>")) . "
</div>
";
}

//------------------------------------------------------------------------------------------------------------+

Expand All @@ -106,5 +127,6 @@

//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
//------ PLEASE MAKE A DONATION OR SIGN THE GUESTBOOK AT GREYCUBE.COM IF YOU REMOVE THIS CREDIT ----------------------------------------------------------------------------------------------------+
//------ WANNA BE HERE? https://github.com/tltneon/lgsl/wiki/Who-uses-LGSL -> LET CREDITS STAY :P --------------------------------------------------------------------------------------------------+
$output .= "<div style='text-align:center; font-family:tahoma; font-size:9px; padding: 33px 0px 11px 0px;'><a href='http://www.greycube.com' style='text-decoration:none'>".lgsl_version()."</a></div>";
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Loading

0 comments on commit a2b0b79

Please sign in to comment.