From a8aae96f5c2dd05043e8b164c8e3f5ada0b70894 Mon Sep 17 00:00:00 2001 From: Michael Gebetsroither Date: Thu, 16 Feb 2023 01:45:46 +0100 Subject: [PATCH] implement static_url to direct link to ressources if reachable via different url --- tinyfilemanager.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 5b57b7b..0e82c1c 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -66,6 +66,12 @@ $root_path = $_SERVER['DOCUMENT_ROOT']; // Will not working if $root_path will be outside of server document root $root_url = ''; +// Static ressource URL used only for direct links +// comes in handy if fm handles files that are public, but on a different URL +// gives users a copy&paste able direct link they can use +// eg. https://example.org/foo/file.png where fm is hosted on https://backend.example.org/files/index.php +$static_url = ''; + // Server hostname. Can set manually if wrong // $_SERVER['HTTP_HOST'].'/folder' $http_host = $_SERVER['HTTP_HOST']; @@ -238,6 +244,10 @@ $root_url = fm_clean_path($root_url); defined('FM_ROOT_URL') || define('FM_ROOT_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . (!empty($root_url) ? '/' . $root_url : '')); defined('FM_SELF_URL') || define('FM_SELF_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . $_SERVER['PHP_SELF']); +// only used to directly link to ressources +//$static_url = fm_clean_path($static_url); +defined('FM_STATIC_URL') || define('FM_STATIC_URL', !empty($static_url) ? $static_url : $FM_ROOT_URL); + // logout if (isset($_GET['logout'])) { unset($_SESSION[FM_SESSION_ID]['logged']); @@ -2059,7 +2069,7 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white - + ..." href="?p=&copy="> - +