From 8486c7a240f7e2757d8f0a74ab15e142bc527cca Mon Sep 17 00:00:00 2001 From: DannyDaemonic Date: Wed, 26 Apr 2023 08:16:52 -0700 Subject: [PATCH] Add configurable path display modes for better privacy and clarity (#1034) --- tinyfilemanager.php | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 47c248f..24e8973 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -77,6 +77,12 @@ $iconv_input_encoding = 'UTF-8'; // Doc - https://www.php.net/manual/en/function.date.php $datetime_format = 'm/d/Y g:i A'; +// Path display mode when viewing file information +// 'full' => show full path +// 'relative' => show path relative to root_path +// 'host' => show path on the host +$path_display_mode = 'full'; + // Allowed file extensions for create and rename files // e.g. 'txt,html,css,js' $allowed_file_extensions = ''; @@ -1684,7 +1690,8 @@ if (isset($_GET['view'])) {

""

- Full path:
+ + :
File size:
MIME-type:

- Full path:
+ + :

@@ -2514,6 +2522,30 @@ function fm_get_parent_path($path) return false; } +function fm_get_display_path($file_path) +{ + global $path_display_mode, $root_path, $root_url; + switch ($path_display_mode) { + case 'relative': + return array( + 'label' => 'Path', + 'path' => fm_enc(fm_convert_win(str_replace($root_path, '', $file_path))) + ); + case 'host': + $relative_path = str_replace($root_path, '', $file_path); + return array( + 'label' => 'Host Path', + 'path' => fm_enc(fm_convert_win('/' . $root_url . '/' . ltrim(str_replace('\\', '/', $relative_path), '/'))) + ); + case 'full': + default: + return array( + 'label' => 'Full Path', + 'path' => fm_enc(fm_convert_win($file_path)) + ); + } +} + /** * Check file is in exclude list * @param string $file