From 57780ed9464ebf234fb89b722307e1c9d105b6b3 Mon Sep 17 00:00:00 2001 From: Jimako Date: Sat, 6 Jan 2024 21:55:55 +0100 Subject: [PATCH] attempt to fix paths, --- README.md | 9 +-- admin_config.php | 114 +++++++++--------------------------- e_url.php | 9 ++- index.php | 17 +++--- lgsl_files/lgsl_class.php | 19 ++++-- lgsl_files/lgsl_config.php | 8 ++- lgsl_files/lgsl_details.php | 2 +- lgsl_files/lgsl_list.php | 11 ++-- plugin.xml | 2 +- 9 files changed, 80 insertions(+), 111 deletions(-) diff --git a/README.md b/README.md index 5e599c1..0f2720b 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/admin_config.php b/admin_config.php index e857115..9a29603 100644 --- a/admin_config.php +++ b/admin_config.php @@ -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 @@ -409,10 +412,6 @@ public function renderHelp() public function customPage() { - - define("LGSL_ADMIN", "1"); - - $output = "
"; require "lgsl_files/lgsl_admin.php"; $output .= "
"; @@ -425,94 +424,25 @@ public function linksPage() $output = "
"; $output .= 'SITEURL:
' . SITEURL . '
'; - $link = e107::url('lgsl', 'index'); + $link = e107::url('lgsl', 'index', array(), ['mode'=>'full']); $output .= 'SEF URL (you can change alias/name in URL configuration):
' . $link . '
'; $link = e_PLUGIN . "lgsl/index.php"; $output .= 'LEGACY URLs :
' . $link . '
'; $link = e_PLUGIN_ABS . "lgsl/index.php"; $output .= 'LEGACY URLs :
' . $link . '
'; - $link = e107::url('lgsl', 'detail', array('query_path' => '?s=1')); - $output .= 'SEF URL DETAIL s=1:
' . $link . '
'; + /* $link = e107::url('lgsl', 'detail', array('query_path' => '?s=1')); + $output .= 'SEF URL DETAIL s=1:
' . $link . '
';*/ $link = e_PLUGIN . "lgsl/index.php?s=1"; $output .= 'LEGACY URLs :
' . $link . '
'; - //result of lgsl_url_path() - $link = $this->lgsl_url_path(); - $output .= 'LGSL URL PATH (simulated) :
' . $link . '
'; + $link = lgsl_url_path(); + $output .= 'LGSL URL PATH (path to core lgsl files):
' . $link . '
'; $output .= "
"; + 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); - } + } @@ -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) diff --git a/e_url.php b/e_url.php index 658f0f9..efbb9a8 100644 --- a/e_url.php +++ b/e_url.php @@ -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}/\?(.*)$', diff --git a/index.php b/index.php index c311c83..63c6d99 100644 --- a/index.php +++ b/index.php @@ -24,7 +24,6 @@ require("lgsl_files/lgsl_config.php"); - if ($lgsl_prefs['style']) { e107::css('lgsl', 'lgsl_files/styles/' . $lgsl_prefs['style']); @@ -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 = ""; @@ -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)) { @@ -122,7 +119,11 @@ } $output .= ""; -$ns->tablerender($lgsl_config['title'][0], $output); +if (!$lgsl_config['preloader']) +{ + $ns->tablerender("", $output, 'lgsl-content' ); +} + unset($output); diff --git a/lgsl_files/lgsl_class.php b/lgsl_files/lgsl_class.php index db9b958..e81978f 100644 --- a/lgsl_files/lgsl_class.php +++ b/lgsl_files/lgsl_class.php @@ -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}" : @@ -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)); @@ -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"; } //------------------------------------------------------------------------------------------------------------+ @@ -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; } diff --git a/lgsl_files/lgsl_config.php b/lgsl_files/lgsl_config.php index 75f1e52..d88abdc 100644 --- a/lgsl_files/lgsl_config.php +++ b/lgsl_files/lgsl_config.php @@ -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 ] diff --git a/lgsl_files/lgsl_details.php b/lgsl_files/lgsl_details.php index ed94b5d..7e9e1ed 100644 --- a/lgsl_files/lgsl_details.php +++ b/lgsl_files/lgsl_details.php @@ -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); //------------------------------------------------------------------------------------------------------------+ diff --git a/lgsl_files/lgsl_list.php b/lgsl_files/lgsl_list.php index 8493b73..8d8ffde 100644 --- a/lgsl_files/lgsl_list.php +++ b/lgsl_files/lgsl_list.php @@ -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 .= " @@ -91,14 +91,14 @@ "; - + if ($lgsl_config['locations']) { $output .= " {$misc[ "; } - + $output .= " @@ -141,4 +141,5 @@ //------ WANNA BE HERE? https://github.com/tltneon/lgsl/wiki/Who-uses-LGSL -> LET CREDITS STAY :P --------------------------------------------------------------------------------------------------+ $output .= "
".lgsl_version()."
"; //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - \ No newline at end of file +if ($lgsl_config['preloader']) + echo $output; \ No newline at end of file diff --git a/plugin.xml b/plugin.xml index 92d64fa..3e834a1 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + Live Game Server List by Richard Perry, tltneon version 6.2.0 Live Game Server List Richard Perry, tltneon version 6.2.0