From 87b48406a138a7ea6a35320be5d8351e35244f61 Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Wed, 9 Apr 2025 15:13:55 -0400 Subject: [PATCH 1/7] Fix: Handle edge cases on dashboard counting disks previously exported --- emhttp/plugins/dynamix/DashStats.page | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index e1d1e24b2..2746c9ace 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -121,17 +121,25 @@ $names = []; $SMBpublic = $NFSpublic= 0; foreach ($sec as $share => $prop) { if ( $prop['export'] == "-") continue; - if ( $prop['security'] == "public") $SMBpublic++; - if ( ($var['shareDisk']??"") == "no" && $share !=="flash" ) continue; + if ( $prop['security'] == "public") { + if ( $share == "flash" || (! isset($disks[$share]) || (isset($disks[$share]) && ($var['shareDisk']??"") == "yes" && $share !=="flash") ) ) + $SMBpublic++; + } + if ( ($var['shareDisk']??"") !== "yes" && $share !=="flash" ) continue; if ( ! $started && isset($disks[$share]) && $share !=="flash" ) continue; - if ( ! isset($shares[$share]) && isset($disks[$share]) ) {$shares[$share]=$disks[$share]; $shares[$share]['diskexport'] = true;} + if ( (! isset($shares[$share]) && isset($disks[$share]) && ($var['shareDisk']??"") == "yes" ) || $share == "flash" ) {$shares[$share]=$disks[$share]; $shares[$share]['diskexport'] = true;} } -foreach ($sec_nfs as $share => $prop) { - if ( $prop['export'] == "-") continue; - if ( $prop['security'] == "public") $NFSpublic++; - if ( ($var['shareDisk']??"") == "no" && $share !=="flash" ) continue; - if ( ! $started && isset($disks[$share]) && $share !=="flash" ) continue; - if ( ! isset($shares[$share]) && isset($disks[$share]) ) {$shares[$share]=$disks[$share]; $shares[$share]['diskexport'] = true;} +if ($var['shareNFSEnabled']=='yes') { + foreach ($sec_nfs as $share => $prop) { + if ( $prop['export'] == "-") continue; + if ( $prop['security'] == "public") { + if ( $share == "flash" || (! isset($disks[$share]) || (isset($disks[$share]) && ($var['shareDisk']??"") == "yes" && $share !== "flash" ) ) ) + $NFSpublic++; + } + if ( ($var['shareDisk']??"") == "no" && $share !=="flash" ) continue; + if ( ! $started && isset($disks[$share]) && $share !=="flash" ) continue; + if ( ( ! isset($shares[$share]) && isset($disks[$share]) && ($var['shareDisk']??"") == "yes") || $share == "flash" ) {$shares[$share]=$disks[$share]; $shares[$share]['diskexport'] = true;} + } } $passwd = $nopass = 0; From 78feb2af04f32cd7ca2bf1c3f10d2db603a9e3eb Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 10 Apr 2025 16:22:22 +0200 Subject: [PATCH 2/7] file manager: add UD selection --- emhttp/plugins/dynamix/Browse.page | 12 +++---- emhttp/plugins/dynamix/include/FileTree.php | 36 +++++++++++++-------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/emhttp/plugins/dynamix/Browse.page b/emhttp/plugins/dynamix/Browse.page index 8b7cd83cb..1d18c2a97 100644 --- a/emhttp/plugins/dynamix/Browse.page +++ b/emhttp/plugins/dynamix/Browse.page @@ -360,10 +360,10 @@ function doAction(action, title, id) { if (!access.includes(path[0])) return; var user = /^(user0?|rootshare)$/.test(path[1]); var root = '/'+path[0]+(user ? '/'+path[1] : ''); - var share = user||!path[2]||(link&&path.length==3) ? '' : path[2]+'/'; + var share = user || !path[2] || (link && path.length==3) ? '' : path[2]+'/'; var ud = ['disks','remotes'].includes(path[1]); // unassigned devices - var match = ud||user ? '' : '^(?!\\/mnt\\/user0?\\/).*$'; - var name = path.pop()||path.pop(); + var match = ud || user ? '' : '^(?!\\/mnt\\/(user0?|rootshare)\\/).*$'; + var name = path.pop() || path.pop(); var hdlink = ""; dfm.window = $("#dfm_dialogWindow"); switch (action) { @@ -625,10 +625,10 @@ function doActions(action, title) { if (!access.includes(path[0])) return; var user = /^(user0?|rootshare)$/.test(path[1]); var root = '/'+path[0]+(user ? '/'+path[1] : ''); - var share = user||!path[2] ? '' : path[2]+'/'; + var share = user || !path[2] ? '' : path[2]+'/'; var ud = ['disks','remotes'].includes(path[1]); // unassigned devices - var match = ud||user ? '' : '^(?!.*(user0?|rootshare)).*$'; - var name = path.pop()||path.pop(); + var match = ud || user ? '' : '^(?!\\/mnt\\/(user0?|rootshare)\\/).*$'; + var name = path.pop() || path.pop(); var hdlink = ""; var u = false; var d = false; diff --git a/emhttp/plugins/dynamix/include/FileTree.php b/emhttp/plugins/dynamix/include/FileTree.php index 33e9dab7b..663bd6f1b 100644 --- a/emhttp/plugins/dynamix/include/FileTree.php +++ b/emhttp/plugins/dynamix/include/FileTree.php @@ -27,15 +27,15 @@ */ function path($dir) { - return mb_substr($dir,-1)=='/' ? $dir : $dir.'/'; + return mb_substr($dir,-1) == '/' ? $dir : $dir.'/'; } function is_top($dir) { global $root; - return mb_strlen($dir)>mb_strlen($root); + return mb_strlen($dir) > mb_strlen($root); } function is_low($dir) { global $root; - return mb_substr($dir,0,mb_strlen($root))==$root; + return mb_substr($dir,0,mb_strlen($root)) == $root; } $root = path(realpath($_POST['root'])); @@ -47,36 +47,46 @@ require_once "$docroot/webGui/include/Secure.php"; $rootdir = path(realpath($_POST['dir'])); $filters = (array)$_POST['filter']; $match = $_POST['match']; -$checkbox = $_POST['multiSelect']=='true' ? "" : ""; +$checkbox = $_POST['multiSelect'] == 'true' ? "" : ""; /* Excluded folders to not show in the dropdown in the '/mnt/' directory only. */ -$excludedFolders = ["RecycleBin", "addons", "rootshare", "user0"]; +$excludedFolders = ['RecycleBin', 'addons', 'rootshare']; + +$udShares = ['addons','disks','remotes']; echo "