From 65ed3818ec0b25d2f2093a08935003a7a07ddb3f Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 3 Mar 2022 19:29:56 +0100 Subject: Use correct base url for stylesheets and js. Use z_root instead of script_path when formatting stylesheet and javascript links for the head section. script_path does not preserve information about the port if the site uses a nonstandard port. --- include/plugin.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index 25fa22e10..f0ae1ecb1 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -941,9 +941,7 @@ function head_get_links() { function format_css_if_exists($source) { - // script_path() returns https://yoursite.tld - - $path_prefix = script_path(); + $path_prefix = z_root(); $script = $source[0]; @@ -1054,7 +1052,7 @@ function head_get_main_js() { } function format_js_if_exists($source) { - $path_prefix = script_path(); + $path_prefix = z_root(); if(strpos($source,'/') !== false) { // The source is a known path on the system -- cgit v1.2.3 From 34ffff3947b8e89a667367277f0fde9c626fd143 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 3 Mar 2022 19:50:07 +0100 Subject: Remove now unused function script_path. --- include/plugin.php | 38 -------------------------------------- 1 file changed, 38 deletions(-) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index f0ae1ecb1..f9cee7ed6 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -963,44 +963,6 @@ function format_css_if_exists($source) { } } -/** - * This basically calculates the baseurl. We have other functions to do that, but - * there was an issue with script paths and mixed-content whose details are arcane - * and perhaps lost in the message archives. The short answer is that we're ignoring - * the URL which we are "supposed" to use, and generating script paths relative to - * the URL which we are currently using; in order to ensure they are found and aren't - * blocked due to mixed content issues. - * - * @return string - */ -function script_path() { - if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS']) - $scheme = 'https'; - elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) - $scheme = 'https'; - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') - $scheme = 'https'; - else - $scheme = 'http'; - - // Some proxy setups may require using http_host - - if(isset(App::$config['system']['script_path_use_http_host']) && intval(App::$config['system']['script_path_use_http_host'])) - $server_var = 'HTTP_HOST'; - else - $server_var = 'SERVER_NAME'; - - - if(x($_SERVER,$server_var)) { - $hostname = $_SERVER[$server_var]; - } - else { - return z_root(); - } - - return $scheme . '://' . $hostname; -} - function head_add_js($src, $priority = 0) { if(isset(App::$js_sources[$priority]) && !is_array(App::$js_sources[$priority])) App::$js_sources[$priority] = []; -- cgit v1.2.3