Skip to content

Commit

Permalink
Refactoring & Zone bar changed
Browse files Browse the repository at this point in the history
  • Loading branch information
tltneon committed Aug 21, 2024
1 parent 08aef92 commit 1d4444e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 44 deletions.
11 changes: 5 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

require ("src/lgsl_config.php");
require ("src/lgsl_language.php");
$_COOKIE['lgsl_lang'] = $_COOKIE['lgsl_lang'] ?? tltneon\LGSL\Lang::EN;
$lang = new tltneon\LGSL\Lang($_COOKIE['lgsl_lang']);
$lang = new tltneon\LGSL\Lang($_COOKIE['lgsl_lang'] ?? tltneon\LGSL\Lang::EN);
if (empty($lgsl_config['installed'])) header("Location: install.php");
global $output, $title;

function load_page($file) {
function loadPage($file) {
global $lgsl_config;
if ($lgsl_config['preloader']) {
$loader = @file_get_contents('src/other/loader.html');
Expand Down Expand Up @@ -55,9 +54,9 @@ function alertContents() {
$s = $_GET['s'] ?? null;
$ip = $_GET['ip'] ?? null;
$port = $_GET['port'] ?? null;
if ($s === "add") { $output = load_page("add"); $title .= " | {$lang->get("aas")}";}
elseif ((int) $s > 0 || $ip && $port) { $output = load_page("details"); }
else { $output = load_page("list"); }
if ($s === "add") { $output = loadPage("add"); $title .= " | {$lang->get("aas")}";}
elseif ((int) $s > 0 || $ip && $port) { $output = loadPage("details"); }
else { $output = loadPage("list"); }
//------------------------------------------------------------------------------------------------------------+
?>
<!DOCTYPE html>
Expand Down
5 changes: 3 additions & 2 deletions src/lgsl_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@
}
}

$iframeLink = "src/lgsl_zone.php?{$g}&bg=transparent&text=white&link=yellow";
$output .= "
<iframe src='src/lgsl_zone.php?{$g}' alt='{$server->getName()}' style='border: 0; display: block; background: white;width: 200px;height: calc(275px + {$framespace}px);margin: auto;'></iframe><br />
<textarea onClick='this.select();'><iframe src='{$p}src/lgsl_zone.php?{$g}'></iframe></textarea>
<iframe src='{$iframeLink}' alt='{$server->getName()}' style='border: 1px dotted gray; display: block; width: 200px; height: calc(275px + {$framespace}px); margin: auto;'></iframe><br />
<textarea onClick='this.select();'><iframe src='{$p}{$iframeLink}'></iframe></textarea>
</div>
</details>
<div class='spacer'></div>
Expand Down
18 changes: 6 additions & 12 deletions src/lgsl_protocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,9 @@ public function process() {
}
}

if (!empty($this->_data['e']['hostname'])) { $this->_data['s']['name'] = $this->_data['e']['hostname']; }
if (!empty($this->_data['e']['sv_hostname'])) { $this->_data['s']['name'] = Helper::lgslParseColor($this->_data['e']['sv_hostname'], "1"); }
if (isset($this->_data['e']['protocol']) && $type !== PROTOCOL::UNVANQUISHED) {
if ($type === PROTOCOL::CALLOFDUTYIW) {
$games = ['1' => 'IW6', '2' => 'H1', '6' => 'IW3', '7' => 'T7', '20604' => 'IW5', '151' => 'IW4', '101' => 'T4'];
}
$this->_data['s']['name'] = $this->_data['e']['hostname'] ?? $this->_data['e']['sv_hostname'] ?? LGSL::NONE;
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']}";
}
if (isset($this->_data['e']['gamename'])) { $this->_data['s']['game'] = $this->_data['e']['gamename']; }
Expand All @@ -620,13 +617,10 @@ public function process() {
}
$this->_data['s']['mode'] = $games[$this->_data['e']['g_gametype']] ?? $this->_data['e']['g_gametype'];
}
if (isset($this->_data['e']['mapname'])) { $this->_data['s']['map'] = $this->_data['e']['mapname']; }
$this->_data['s']['map'] = $this->_data['e']['mapname'] ?? LGSL::NONE;
$this->_data['s']['players'] = empty($part['2']) ? 0 : count($part) - 2;
if (isset($this->_data['e']['maxclients'])) { $this->_data['s']['playersmax'] = $this->_data['e']['maxclients']; } // QUAKE 2
if (isset($this->_data['e']['sv_maxclients'])) { $this->_data['s']['playersmax'] = $this->_data['e']['sv_maxclients']; }
if (isset($this->_data['e']['pswrd'])) { $this->_data['s']['password'] = $this->_data['e']['pswrd']; } // CALL OF DUTY
if (isset($this->_data['e']['needpass'])) { $this->_data['s']['password'] = $this->_data['e']['needpass']; } // QUAKE 2
if (isset($this->_data['e']['g_needpass'])) { $this->_data['s']['password'] = (int) $this->_data['e']['g_needpass']; }
$this->_data['s']['playersmax'] = $this->_data['e']['maxclients'] ?? $this->_data['e']['sv_maxclients'] ?? 0;
$this->_data['s']['password'] = $this->_data['e']['pswrd'] ?? $this->_data['e']['needpass'] ?? (int) $this->_data['e']['g_needpass'] ?? 0;

array_shift($part); // REMOVE HEADER
array_shift($part); // REMOVE SETTING
Expand Down
51 changes: 27 additions & 24 deletions src/lgsl_zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@
$port = (int) ($_GET['port'] ?? 0);
if (!isset($lgsl_zone_number) && !$ip && !$port) { exit("LGSL PROBLEM: $lgsl_zone_number NOT SET"); }
$background = $_GET['bg'] ?? '#FFF';
$font = $_GET['font'] ?? '#000';
$text = $_GET['text'] ?? '#000';
$link = $_GET['link'] ?? '#0000ED';

require "lgsl_class.php";
require "lgsl_language.php";
$lang = new Lang($_COOKIE['lgsl_lang'] ?? Lang::EN);

$zone_width = "{$lgsl_config['zone']['width']}px";
$zone_grid = $lgsl_config['grid'][$lgsl_zone_number] ?? 1;
$zone_count = 0;
$output = '';

$request = empty($lgsl_config['players'][$lgsl_zone_number]) ? "s" : "sp";
$request = empty($lgsl_config['players'][$lgsl_zone_number]) ? "s" : "sp";
if ($lgsl_zone_number) {
$server_list = Database::getServersGroup(["request"=>$request, "zone"=>$lgsl_zone_number]);
} else {
Expand All @@ -42,10 +44,11 @@
<style>
html {
background-color: $background;
color: $font
color: $text
}
a {
color: $link;
text-decoration:none;
}
.sidebarserver * {
scrollbar-width: thin;
Expand All @@ -69,7 +72,7 @@
border: none;
}
.marquee{
.marquee {
width:100%;
white-space:nowrap;
overflow:hidden;
Expand Down Expand Up @@ -103,39 +106,39 @@

$marquee = strlen($server->getName()) > 25 ? "class='on'" : "";
$output .= "
<td style='vertical-align:top; text-align:center'>
<td style='vertical-align:top;'>
<table style='width:{$zone_width}; margin:auto; text-align:center' cellpadding='0' cellspacing='2'>
<table style='width:{$zone_width}; margin:auto; text-align:center;' cellpadding='0' cellspacing='2'>
<tr>
<td title='{$lgsl_config['text']['slk']}' style='padding:0px; text-align:center'>
<div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; white-space:nowrap; overflow:hidden; text-align:center'>
<a href='{$server->getConnectionLink()}' style='text-decoration:none'>
<td title='{$lang->get('slk')}' style='padding:0px;'>
<div style='width:{$zone_width}; white-space:nowrap; overflow:hidden;'>
<a href='{$server->getConnectionLink()}'>
{$server->getAddress()}
</a>
</div>
</td>
</tr>
<tr>
<td title='{$server->getName()}' style='padding:0px; text-align:center'>
<div class='marquee' style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; white-space:nowrap; overflow:hidden; text-align:center'>
<td title='{$server->getName()}' style='padding:0px;'>
<div class='marquee' style='width:{$zone_width}; white-space:nowrap; overflow:hidden;'>
<span {$marquee}>{$server->getName()}</span>
</div>
</td>
</tr>
<tr>
<td style='padding:0px; text-align:center'>
<div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; padding:0px; position:relative'>
<td style='padding:0px;'>
<div style='width:{$zone_width}; padding:0px; position:relative'>
<a href='".LGSL::link($server->getIp(), $server->getConnectionPort())."' target='_blank'>
<img alt='' src='{$server->getMapImage()}' title='{$lgsl_config['text']['vsd']}' style='vertical-align:middle; width: 100%; border-radius: 4px;' />
<img alt='' src='{$server->mapPasswordImage()}' title='{$lgsl_config['text']['vsd']}' style='position:absolute; z-index:2; bottom:2px; right:2px;' />
<img alt='' src='{$server->addUrlPath($server->getGameIcon())}' title='{$server->getGameFormatted()}' style='position:absolute; z-index:2; top:2px; left:2px; width: 24px; border-radius: 4px;' />
<img alt='' src='{$server->getMapImage()}' title='{$lang->get('vsd')}' style='vertical-align:middle; width: 100%; border-radius: 4px;'>
<img alt='' src='{$server->mapPasswordImage()}' title='{$lang->get('vsd')}' style='position:absolute; z-index:2; bottom:2px; right:2px;'>
<img alt='' src='{$server->addUrlPath($server->getGameIcon())}' title='{$server->getGameFormatted()}' style='position:absolute; z-index:2; top:2px; left:2px; width: 24px; border-radius: 4px;'>
";
if ($lgsl_config['locations'])
$output .= "
<img alt='' class='details_location_image flag f{$server->getLocation()}' title='{$server->getLocationFormatted()}' style='position:absolute; z-index:2; top:2px; right:2px;' />
<img alt='' class='details_location_image flag f{$server->getLocation()}' title='{$server->getLocationFormatted()}' style='position:absolute; z-index:2; top:2px; right:2px;'>
";
$output .= "
</a>
Expand All @@ -144,8 +147,8 @@
</tr>
<tr>
<td title='{$server->getMap()}' style='padding:0px; text-align:center'>
<div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; white-space:nowrap; overflow:hidden; text-align:center'>
<td title='{$lang->get('map')}: {$server->getMap()}' style='padding:0px;'>
<div style='width:{$zone_width}; white-space:nowrap; overflow:hidden;'>
{$server->getMap()}
</div>
</td>
Expand All @@ -158,22 +161,22 @@
$output .= "
<tr>
<td style='border-radius: 4px;'>
<span style='padding:1px; float:left'> {$lgsl_config['text']['zpl']} </span>
<span style='padding:1px; float:left'> {$lang->get('zpl')} </span>
<span style='padding:1px; float:right'> {$server->getPlayersCountFormatted()} </span>";
$players = $server->getPlayersArray();
if (count($players) > 0) {
$output .= "<div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; height:{$zone_height}; border-top: 1px solid #8080807a; overflow: overlay; text-align:left'>";
$output .= "<div style='width:{$zone_width}; height:{$zone_height}; border-top: 1px solid #8080807a; overflow: overlay; text-align:left'>";

foreach ($players as $player) {
$output .= "
<div style='left:0px; right:0px; top:0px; bottom:0px; padding:1px; white-space:nowrap; overflow:hidden; text-align:left' title='{$player['name']}'> {$player['name']} </div>";
<div style='padding:1px; white-space:nowrap; overflow:hidden; text-align:left' title='{$player['name']}'> {$player['name']} </div>";
}

$output .= "</div";
} else {
$inner_width = $server->getPlayersPercent();
$output .="
<br />
<br>
<div style='margin-top: 5px; border: 1px solid #555555; background-color: #222222; height: 4px;'>
<div style='width: $inner_width%; background-color: #ff8400; height: 4px;'></div>
</div>";
Expand All @@ -185,7 +188,7 @@
$output .= "
<tr>
<td style='padding:0px; border:1px solid; border-radius: 4px;'>
<span style='padding:1px; float:left'> {$lgsl_config['text']['zpl']} </span>
<span style='padding:1px; float:left'> {$lang->get('zpl')} </span>
<span style='padding:1px; float:right'> {$server->getPlayersCount()} </span>
</td>
</tr>";
Expand Down

0 comments on commit 1d4444e

Please sign in to comment.