From f182e378e38658804b4b4cddd9c8ce5be398b4aa Mon Sep 17 00:00:00 2001
From: safraja <63454672+safraja@users.noreply.github.com>
Date: Tue, 1 Jun 2021 06:41:15 +0200
Subject: [PATCH 1/3] PHP8 fix and few other changes (#562)
---
tinyfilemanager.php | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index a7c5ec6..f5caa90 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -1673,7 +1673,7 @@ if (isset($_GET['view'])) {
}
} elseif ($is_image) {
// Image content
- if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg'))) {
+ if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg', 'webp', 'avif'))) {
echo '
';
}
} elseif ($is_audio) {
@@ -2020,7 +2020,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'))): ?>
@@ -2401,7 +2401,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);
}
@@ -2663,6 +2663,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;
@@ -2822,7 +2824,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');
}
/**
@@ -2909,6 +2911,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';
@@ -3624,7 +3628,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 }
}
From e843adcf0b2443cda4d3bae18ec76372aa158cd9 Mon Sep 17 00:00:00 2001
From: sbivol
Date: Sat, 5 Jun 2021 04:03:57 +0100
Subject: [PATCH 2/3] Fix function name and add extensions for icons (#567)
* Set icons for more file extensions
* Fix function name
---
tinyfilemanager.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index f5caa90..bb35f1c 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -360,7 +360,7 @@ if ($use_auth && isset($_SESSION[FM_SESSION_ID]['logged'])) {
$root_path = rtrim($root_path, '\\/');
$root_path = str_replace('\\', '/', $root_path);
if (!@is_dir($root_path)) {
- echo "".lang('Root path')." \"{$root_path}\" ".lang('not found!')." ";
+ echo "".lng('Root path')." \"{$root_path}\" ".lng('not found!')." ";
exit;
}
@@ -2683,6 +2683,7 @@ function fm_get_file_icon_class($path)
case 'cpp':
case 'cs':
case 'py':
+ case 'rs':
case 'map':
case 'lock':
case 'dtd':
@@ -2701,11 +2702,13 @@ function fm_get_file_icon_class($path)
case 'scss':
$img = 'fa fa-css3';
break;
+ case 'bz2':
case 'zip':
case 'rar':
case 'gz':
case 'tar':
case '7z':
+ case 'xz':
$img = 'fa fa-file-archive-o';
break;
case 'php':
@@ -2743,6 +2746,7 @@ function fm_get_file_icon_class($path)
case 'm3u8':
case 'pls':
case 'cue':
+ case 'xspf':
$img = 'fa fa-headphones';
break;
case 'avi':
@@ -2774,6 +2778,7 @@ function fm_get_file_icon_class($path)
$img = 'fa fa-file-text-o';
break;
case 'bak':
+ case 'swp':
$img = 'fa fa-clipboard';
break;
case 'doc':
From 8158333d936c333abefff772d03c20cf9f67ae54 Mon Sep 17 00:00:00 2001
From: schmigz <75388888+schmigz@users.noreply.github.com>
Date: Sat, 5 Jun 2021 02:27:53 -0400
Subject: [PATCH 3/3] Update tinyfilemanager.php (#568)
fm_get_file_mimes() was causing errors for unknown extensions as it was causing an error as array element was not defined and return value was never checked. According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types and several other resources, application/octet-stream is the default value for all other cases. An unknown file type should use this type. I put a check in there to use that by default so a valid value is always returned.
It might be useful to replace this function with the built-in PHP function mime_content_type() but that adds some additional dependencies as it does not always work out of the box with PHP.
---
tinyfilemanager.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index bb35f1c..d0fe6db 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -2945,6 +2945,10 @@ function fm_get_file_mimes($extension)
$fileTypes['php'] = ['application/x-php'];
$fileTypes['html'] = ['text/html'];
$fileTypes['txt'] = ['text/plain'];
+ //Unknown mime-types should be 'application/octet-stream'
+ if(empty($fileTypes[$extension])) {
+ $fileTypes[$extension] = ['application/octet-stream'];
+ }
return $fileTypes[$extension];
}
|