From 3c6ba77be98feecad92a2b05c9f69cf68d28026c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 9 Nov 2024 18:09:56 -0500 Subject: [PATCH 1/2] If no path given, if there is 1 storage area, default to it otherwise list available storage areas --- web/skins/classic/views/files.php | 112 +++++++++++++++++------------- 1 file changed, 65 insertions(+), 47 deletions(-) diff --git a/web/skins/classic/views/files.php b/web/skins/classic/views/files.php index df566e375d..6a27237f95 100644 --- a/web/skins/classic/views/files.php +++ b/web/skins/classic/views/files.php @@ -23,23 +23,34 @@ return; } -$path = (!empty($_REQUEST['path'])) ? detaintPathAllowAbsolute($_REQUEST['path']) : ZM_DIR_EVENTS; +$storage_areas = ZM\Storage::find(); $is_ok_path = false; -foreach (ZM\Storage::find() as $storage) { - $rc = strstr($path, $storage->Path(), true); - ZM\Debug("rc from strstr ($rc) $path ".$storage->Path()); - if ((false !== $rc) and ($rc == '')) { - # Must be at the beginning - $is_ok_path = true; +$path = (!empty($_REQUEST['path'])) ? detaintPathAllowAbsolute($_REQUEST['path']) : ''; +if (!$path) { + if (count($storage_areas)==0) { + $path = ZM_DIR_EVENTS; + } else if (count($storage_areas)==0) { + $path = $storage_areas[0]->Path(); } } -$path_parts = pathinfo($path); -if (@is_file($path)) { - if (output_file($path)) - return; - $path = $path_parts['dirname']; -} +if ($path) { + foreach ($storage_areas as $storage) { + $rc = strstr($path, $storage->Path(), true); + if ((false !== $rc) and ($rc == '')) { + # Must be at the beginning + $is_ok_path = true; + } + } + $path_parts = pathinfo($path); + + if (@is_file($path)) { + if (output_file($path)) + return; + $path = $path_parts['dirname']; + } +} # end if path + $show_hidden = isset($_REQUEST['show_hidden']) ? $_REQUEST['show_hidden'] : 0; function guess_material_icon($file) { @@ -63,24 +74,30 @@ function guess_material_icon($file) {
Path is not valid. Path must be below a designated Storage area.
'; -} else { -$exploded = explode('/', $path); -ZM\Debug(print_r($exploded, true)); -$array = array(); +$files = array(); +$folders = array(); $parent = ''; -for ($i = 0; $i < count($exploded); $i++) { - if ($exploded[$i]) - $parent = $parent . '/' . $exploded[$i]; - $parent_enc = urlencode($parent); - $array[] = "" . validHtmlStr($exploded[$i]) . ''; -} -array_pop($exploded); -$parent = implode('/', $exploded); -$sep = ' / '; -echo implode($sep, $array).'
'; +if ($path) { + if (!$is_ok_path) { + echo '
Path is not valid. Path must be below a designated Storage area.
'; + $path = ''; + } else { + $exploded = explode('/', $path); + $array = array(); + for ($i = 0; $i < count($exploded); $i++) { + if ($exploded[$i]) + $parent = $parent . '/' . $exploded[$i]; + $parent_enc = urlencode($parent); + $array[] = "" . validHtmlStr($exploded[$i]) . ''; + } + array_pop($exploded); + + $parent = implode('/', $exploded); + $sep = ' / '; + echo implode($sep, $array).'
'; + } +} # end if path ?> @@ -91,21 +108,25 @@ function guess_material_icon($file) { Path(); } } natcasesort($files); @@ -118,7 +139,7 @@ function guess_material_icon($file) { '; } foreach ($folders as $folder) { - $url = urlencode($path.'/'.$folder); + $url = urlencode(($path?$path.'/':'').$folder); echo ' @@ -135,9 +156,6 @@ function guess_material_icon($file) { ?>
-