Skip to content

Commit

Permalink
attempt to fix paths,
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmi08 committed Jan 6, 2024
1 parent c7537a2 commit 57780ed
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 111 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ I am not a player, so this is unknown territory for me.

- unlimited zones and unlimites menu areas

## 6.2.1 version

### Limitation

You can't use e107 inside original files because file userbar.php (generating userbar), so SEF-URL is not possible for detail page. For now.

- fixed detail and userbar for SEF-URL versiona
- rewritten admin part for easier settings
- updated core lgsl 6.2.1
- still PHP 7.4
114 changes: 29 additions & 85 deletions admin_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
exit;
}

define("LGSL_ADMIN", "1");
require "lgsl_files/lgsl_class.php";

e107::lan('lgsl', true);

class lgsl_adminArea extends e_admin_dispatcher
Expand Down Expand Up @@ -409,10 +412,6 @@ public function renderHelp()
public function customPage()
{


define("LGSL_ADMIN", "1");


$output = "<div class='lgsl table-responsive'>";
require "lgsl_files/lgsl_admin.php";
$output .= "</div>";
Expand All @@ -425,94 +424,25 @@ public function linksPage()

$output = "<div class='lgsl table-responsive'>";
$output .= 'SITEURL: <pre>' . SITEURL . '</pre>';
$link = e107::url('lgsl', 'index');
$link = e107::url('lgsl', 'index', array(), ['mode'=>'full']);
$output .= 'SEF URL (you can change alias/name in URL configuration): <pre>' . $link . '</pre>';
$link = e_PLUGIN . "lgsl/index.php";
$output .= 'LEGACY URLs : <pre>' . $link . '</pre>';
$link = e_PLUGIN_ABS . "lgsl/index.php";
$output .= 'LEGACY URLs : <pre>' . $link . '</pre>';
$link = e107::url('lgsl', 'detail', array('query_path' => '?s=1'));
$output .= 'SEF URL DETAIL s=1: <pre>' . $link . '</pre>';
/* $link = e107::url('lgsl', 'detail', array('query_path' => '?s=1'));
$output .= 'SEF URL DETAIL s=1: <pre>' . $link . '</pre>';*/
$link = e_PLUGIN . "lgsl/index.php?s=1";
$output .= 'LEGACY URLs : <pre>' . $link . '</pre>';

//result of lgsl_url_path()
$link = $this->lgsl_url_path();
$output .= 'LGSL URL PATH (simulated) : <pre>' . $link . '</pre>';
$link = lgsl_url_path();
$output .= 'LGSL URL PATH (path to core lgsl files): <pre>' . $link . '</pre>';
$output .= "</div>";

e107::getRender()->tablerender('', $output);
$output = "";
}

//simulation, check lgsl_class.php
public function lgsl_url_path()
{
// CHECK IF PATH HAS BEEN SET IN CONFIG

$lgsl_config = e107::pref('lgsl');

if ($lgsl_config['url_path'])
{
return $lgsl_config['url_path'];
}

// USE FULL DOMAIN PATH TO AVOID ALIAS PROBLEMS

$host_path = (!isset($SERVER['HTTPS']) || strtolower($SERVER['HTTPS']) != "on") ? "http://" : "https://";
$host_path .= $SERVER['HTTP_HOST'];

// GET FULL PATHS ( EXTRA CODE FOR WINDOWS AND IIS - NO DOCUMENT_ROOT - BACKSLASHES - DOUBLESLASHES - ETC )

if ($SERVER['DOCUMENT_ROOT'])
{
$base_path = $this->lgsl_realpath($SERVER['DOCUMENT_ROOT']);
$base_path = str_replace("\\", "/", $base_path);
$base_path = str_replace("//", "/", $base_path);
}
else
{
$file_path = $SERVER['SCRIPT_NAME'];
$file_path = str_replace("\\", "/", $file_path);
$file_path = str_replace("//", "/", $file_path);

$base_path = $SERVER['PATH_TRANSLATED'];
$base_path = str_replace("\\", "/", $base_path);
$base_path = str_replace("//", "/", $base_path);
$base_path = substr($base_path, 0, -strlen($file_path));
}

$lgsl_path = dirname($this->lgsl_realpath(__FILE__));
$lgsl_path = str_replace("\\", "/", $lgsl_path);

// REMOVE ANY TRAILING SLASHES

if (substr($base_path, -1) == "/")
{
$base_path = substr($base_path, 0, -1);
}
if (substr($lgsl_path, -1) == "/")
{
$lgsl_path = substr($lgsl_path, 0, -1);
}

// USE THE DIFFERENCE BETWEEN PATHS

if (substr($lgsl_path, 0, strlen($base_path)) == $base_path)
{
$url_path = substr($lgsl_path, strlen($base_path));

return $host_path . $url_path . "/";
}

return "/#LGSL_PATH_PROBLEM#{$base_path}#{$lgsl_path}#/";
}

public function lgsl_realpath($path)
{
// WRAPPER SO IT CAN BE DISABLED
global $lgsl_config;
return $lgsl_config['no_realpath'] ? $path : realpath($path);
}

}


Expand Down Expand Up @@ -798,22 +728,36 @@ class lgsl_zone_hosting_ui extends lgsl_ui
protected $prefs = array(

'direct_index' => array(
'title' => 'Direct index ', 'tab' => 8, 'type' => 'boolean',
'writeParms' => array('default' => 1), 'data' => 'integer', 'help' => '1/ON =link to index.php instead of the folder '
'title' => 'Direct index',
'type' => 'boolean',
'writeParms' => array('default' => 0),
'data' => 'integer',
'help' => '1/ON =link to index.php instead of the folder '
),

'no_realpath' => array(
'title' => 'No realpath', 'tab' => 8, 'type' => 'boolean',
'writeParms' => array('default' => 0), 'data' => 'integer', 'help' => '1/ON = do not use the realpath function '
'title' => 'No realpath',
'type' => 'boolean',
'writeParms' => array('default' => 0),
'data' => 'integer',
'help' => '1/ON = do not use the realpath function '
),

'url_path' => array(
'title' => 'No realpath', 'tab' => 8, 'type' => 'text',
'title' => 'No realpath', 'type' => 'text',
'writeParms' => array('default' => '', 'size' => 'block-level'), 'data' => 'string', 'help' => ' full url to /lgsl_files/ for when auto detection fails '
),
);

function init()
{
$mes = "If you use SEF-URL version, set direct index off and!";

}
}



class lgsl_form_ui extends e_admin_form_ui
{
public function zone_grid($curVal, $mode)
Expand Down
9 changes: 8 additions & 1 deletion e_url.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ class lgsl_url // plugin-folder + '_url'
function config()
{
$config = array();


$config['userbar'] = array(
'alias' => 'LGSL',
'regex' => '^{alias}/userbar.php\?(.*)$',
'sef' => '{alias}/userbar.php{query_path}',
'redirect' => '{e_PLUGIN}lgsl/userbar.php?$1',
);

$config['detail'] = array(
'alias' => 'LGSL',
'regex' => '^{alias}/\?(.*)$',
Expand Down
17 changes: 9 additions & 8 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

require("lgsl_files/lgsl_config.php");


if ($lgsl_prefs['style'])
{
e107::css('lgsl', 'lgsl_files/styles/' . $lgsl_prefs['style']);
Expand All @@ -40,12 +39,7 @@
}


//in lgsl_config you can use e107 stuff because usebar.php
$lgsl_prefs['zone_grid'] = e107::unserialize($lgsl_prefs['zone_grid']);
$lgsl_prefs['zone_players'] = e107::unserialize($lgsl_prefs['zone_players']);
$lgsl_prefs['zone_random'] = e107::unserialize($lgsl_prefs['zone_random']);
$lgsl_prefs['zone_hide_offline'] = e107::unserialize($lgsl_prefs['zone_hide_offline']);
$lgsl_prefs['zone_title'] = e107::unserialize($lgsl_prefs['zone_title']);


/* examples for theme customization
$detail_icon = "<i class=\'fa fa-search\'></fa>";
Expand Down Expand Up @@ -106,6 +100,9 @@
$ip = isset($_GET['ip']) ? $_GET['ip'] : null;
$port = isset($_GET['port']) ? $_GET['port'] : null;


$ns->tablerender($lgsl_config['title'][0], "", 'lgsl-title');


if (is_numeric($s))
{
Expand All @@ -122,7 +119,11 @@
}
$output .= "</div>";

$ns->tablerender($lgsl_config['title'][0], $output);
if (!$lgsl_config['preloader'])
{
$ns->tablerender("", $output, 'lgsl-content' );
}


unset($output);

Expand Down
19 changes: 14 additions & 5 deletions lgsl_files/lgsl_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function lgsl_link($s = "", $p = "")
switch($lgsl_config['cms'])
{
case "e107":
$lgsl_url_path = e_PLUGIN_ABS . "lgsl/{$index}";


$link = $s ? (
$p ?
"{$lgsl_url_path}?ip={$s}&port={$p}" :
Expand Down Expand Up @@ -450,7 +449,7 @@ function lgsl_server_misc($server)

function lgsl_icon_game($type, $game)
{
global $lgsl_file_path, $lgsl_url_path;
global $lgsl_file_path, $lgsl_config, $lgsl_url_path;

$type = preg_replace("/[^a-z0-9_]/", "_", strtolower($type));
$game = preg_replace("/[^a-z0-9_]/", "_", strtolower($game));
Expand All @@ -461,12 +460,21 @@ function lgsl_icon_game($type, $game)
"icons/{$type}/{$type}.gif",
"icons/{$type}/{$type}.png");

switch ($lgsl_config['cms'])
{
case "e107":
$lgsl_image_path = e_PLUGIN_ABS . "lgsl/lgsl_files/";
break;
default:
$lgsl_image_path = $lgsl_url_path;
}

foreach ($path_list as $path)
{
if (file_exists($lgsl_file_path.$path)) { return $lgsl_url_path.$path; }
if (file_exists($lgsl_file_path.$path)) { return $lgsl_image_path.$path; }
}

return "{$lgsl_url_path}other/icon_unknown.gif";
return "{$lgsl_image_path}other/icon_unknown.gif";
}

//------------------------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -960,6 +968,7 @@ function lgsl_file_path()

$lgsl_path = str_replace("\\", "/", $lgsl_path);

// $lgsl_path = e_PLUGIN_ABS . "lgsl/lgsl_files/";
return $lgsl_path;
}

Expand Down
8 changes: 7 additions & 1 deletion lgsl_files/lgsl_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@

global $lgsl_config; $lgsl_config = array();
$lgsl_prefs = e107::pref('lgsl');

//in lgsl_config you can use e107 stuff because usebar.php
$lgsl_prefs['zone_grid'] = e107::unserialize($lgsl_prefs['zone_grid']);
$lgsl_prefs['zone_players'] = e107::unserialize($lgsl_prefs['zone_players']);
$lgsl_prefs['zone_random'] = e107::unserialize($lgsl_prefs['zone_random']);
$lgsl_prefs['zone_hide_offline'] = e107::unserialize($lgsl_prefs['zone_hide_offline']);
$lgsl_prefs['zone_title'] = e107::unserialize($lgsl_prefs['zone_title']);

//------------------------------------------------------------------------------------------------------------+
//[ FEED: 0=OFF 1=CURL OR FSOCKOPEN 2=FSOCKOPEN ONLY / LEAVE THE URL ALONE UNLESS YOU KNOW WHAT YOUR DOING ]

Expand Down
2 changes: 1 addition & 1 deletion lgsl_files/lgsl_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$server = lgsl_sort_players($server);
$server = lgsl_sort_extras($server);
$misc = lgsl_server_misc($server);
// $server = lgsl_server_html($server);
$server = lgsl_server_html($server, 0);

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

Expand Down
11 changes: 6 additions & 5 deletions lgsl_files/lgsl_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
foreach ($server_list as $server)
{
$misc = lgsl_server_misc($server);
// $server = lgsl_server_html($server); FIX ME
$server = lgsl_server_html($server, 0); //it used as parameter for detail url, no wrap
$percent = strval($server['s']['players'] == 0 || $server['s']['playersmax'] == 0 ? 0 : floor($server['s']['players']/$server['s']['playersmax']*100));
$lastupd = Date($lgsl_config['text']['tzn'], (int)$server['s']['cache_time']);
$gamelink= lgsl_build_link_params($uri, array("game" => $server['s']['game']));

$output .= "
<tr class='server_{$misc['text_status']}'>
Expand Down Expand Up @@ -91,14 +91,14 @@
</td>
<td class='details_cell'>";

if ($lgsl_config['locations']) {
$output .= "
<a href='".lgsl_location_link($server['o']['location'])."' target='_blank' class='contry_link'>
<img alt='{$misc['text_location']}' src='{$misc['icon_location']}' title='{$misc['text_location']}' class='contry_icon'>
</a>";
}

$output .= "
<a href='".lgsl_link($server['b']['ip'], $server['b']['c_port'])."' class='details_icon' title='{$lgsl_config['text']['vsd']}'></a>
</td>
Expand Down Expand Up @@ -141,4 +141,5 @@
//------ 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 0 11px 0;'><a href='https://github.com/tltneon/lgsl' style='text-decoration:none'>".lgsl_version()."</a></div>";
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

if ($lgsl_config['preloader'])
echo $output;
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<e107Plugin name="LGSL" lan="" version="6.2.1" date="2023-12-03" compatibility="2.3.3" installRequired="true" >
<e107Plugin name="LGSL" lan="" version="6.2.1" date="2023-01-06" compatibility="2.3.3" installRequired="true" >
<author name="Jimako" url="https://www.e107sk.com/" />
<summary lan="">Live Game Server List by Richard Perry, tltneon version 6.2.0 </summary>
<description lan="">Live Game Server List Richard Perry, tltneon version 6.2.0</description>
Expand Down

0 comments on commit 57780ed

Please sign in to comment.