From 76b7bcd83354836281676705a8c8a6467b05e410 Mon Sep 17 00:00:00 2001 From: EV-soft Date: Sat, 5 Jun 2021 09:55:53 +0200 Subject: [PATCH] Automatically hide column "Owner" when nothing can be displayed Test only once for posix functions, instead of for each line in the file table --- tinyfilemanager.php | 66 +++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 8bd40da..4b9b531 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -1,6 +1,6 @@

'; } } elseif ($is_audio) { @@ -1892,6 +1892,10 @@ fm_show_message(); $num_files = count($files); $num_folders = count($folders); $all_files_size = 0; +$posix = (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')); +$owner = array('name' => '?'); +$group = array('name' => '?'); + $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white"; ?>
@@ -1913,7 +1917,9 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white + + @@ -1934,29 +1940,25 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white '?'); - $group = array('name' => '?'); } ?> @@ -1971,14 +1973,16 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white
' . readlink($path . '/' . $f) . '' : '') ?>
- - a-'.str_pad($filesize_raw, 18, "0", STR_PAD_LEFT).''. $filesize; ?> + "> + - + + + @@ -2003,12 +2007,9 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white $filelink = '?p=' . urlencode(FM_PATH) . '&view=' . urlencode($f); $all_files_size += $filesize_raw; $perms = substr(decoct(fileperms($path . '/' . $f)), -4); - if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) { + if ($posix) { $owner = posix_getpwuid(fileowner($path . '/' . $f)); $group = posix_getgrgid(filegroup($path . '/' . $f)); - } else { - $owner = array('name' => '?'); - $group = array('name' => '?'); } ?> @@ -2022,7 +2023,7 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white
+ if (in_array(strtolower(pathinfo($f, PATHINFO_EXTENSION)), array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg', 'webp', 'avif'))): ?> @@ -2033,14 +2034,16 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white ' . readlink($path . '/' . $f) . '' : '') ?>
- - b-'.str_pad($filesize_raw, 18, "0", STR_PAD_LEFT).''. $filesize; ?> + "> + - + + + @@ -2403,7 +2406,7 @@ function fm_get_parent_path($path) */ function fm_is_exclude_items($file) { $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); - if (sizeof($exclude_items)) { + if (isset($exclude_items) and sizeof($exclude_items)) { unset($exclude_items); } @@ -2502,9 +2505,9 @@ function fm_get_size($file) function fm_get_filesize($size) { $size = (float) $size; - $units = array(' B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); + $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $power = $size > 0 ? floor(log($size, 1024)) : 0; - return sprintf('%s %s', number_format(round($size / pow(1024, $power), 2),2), $units[$power]); + return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]); } /** @@ -2522,8 +2525,8 @@ function fm_get_directorysize($directory) { $count++; } else if ($file->isDir()) { $dirCount++; } - return [$size, $count, $dirCount]; - // return $size; + // return [$size, $count, $dirCount]; + return $size; } else return 'Folder'; // Quick output } @@ -2665,6 +2668,8 @@ function fm_get_file_icon_class($path) case 'bmp': case 'tif': case 'tiff': + case 'webp': + case 'avif': case 'svg': $img = 'fa fa-picture-o'; break; @@ -2824,7 +2829,7 @@ function fm_get_file_icon_class($path) */ function fm_get_image_exts() { - return array('ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd', 'svg'); + return array('ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd', 'svg', 'webp', 'avif'); } /** @@ -2911,6 +2916,8 @@ function fm_get_file_mimes($extension) $fileTypes['png'] = 'image/png'; $fileTypes['jpeg'] = 'image/jpg'; $fileTypes['jpg'] = 'image/jpg'; + $fileTypes['webp'] = 'image/webp'; + $fileTypes['avif'] = 'image/avif'; $fileTypes['rar'] = 'application/rar'; $fileTypes['ra'] = 'audio/x-pn-realaudio'; @@ -3626,7 +3633,7 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal'; .lds-facebook div { position:absolute;left:6px;width:13px;background:#007bff;animation:lds-facebook 1.2s cubic-bezier(0,.5,.5,1) infinite } .lds-facebook div:nth-child(1) { left:6px;animation-delay:-.24s } .lds-facebook div:nth-child(2) { left:26px;animation-delay:-.12s } - .lds-facebook div:nth-child(3) { left:45px;animation-delay:0 } + .lds-facebook div:nth-child(3) { left:45px;animation-delay:0s } @keyframes lds-facebook { 0% { top:6px;height:51px } 100%,50% { top:19px;height:26px } } @@ -3749,6 +3756,7 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal'; +