From e95351852fca0506e26476c07f6001c89f983e60 Mon Sep 17 00:00:00 2001 From: Prasath Mani Date: Thu, 14 Dec 2017 14:03:26 +0530 Subject: [PATCH] Array of folders excluded from listing --- tinyfilemanager.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 703ed63..6c9451e 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -66,6 +66,10 @@ $upload_extensions = ''; // 'gif,png,jpg' // show or hide the left side tree view $show_tree_view = true; +//Array of folders excluded from listing +$GLOBALS['exclude_folders'] = array( +); + // include user config php file if (defined('FM_CONFIG') && is_file(FM_CONFIG) ) { include(FM_CONFIG); @@ -451,7 +455,7 @@ if (isset($_POST['upl']) && !FM_READONLY) { $errors = 0; $uploads = 0; $total = count($_FILES['upload']['name']); - $allowed = (FM_EXTENSION) ? explode(',', FM_EXTENSION) : false; + $allowed = (FM_EXTENSION) ? explode(',', FM_EXTENSION) : false; for ($i = 0; $i < $total; $i++) { $filename = $_FILES['upload']['name'][$i]; @@ -663,7 +667,7 @@ $folders = array(); $files = array(); if (is_array($objects)) { foreach ($objects as $file) { - if ($file == '.' || $file == '..') { + if ($file == '.' || $file == '..' && in_array($file, $GLOBALS['exclude_folders'])) { continue; } if (!FM_SHOW_HIDDEN && substr($file, 0, 1) === '.') { @@ -672,7 +676,7 @@ if (is_array($objects)) { $new_path = $path . '/' . $file; if (is_file($new_path)) { $files[] = $file; - } elseif (is_dir($new_path) && $file != '.' && $file != '..') { + } elseif (is_dir($new_path) && $file != '.' && $file != '..' && !in_array($file, $GLOBALS['exclude_folders'])) { $folders[] = $file; } } @@ -1572,6 +1576,7 @@ function scan($dir){ */ function php_file_tree_dir($directory, $first_call = true) { // Recursive function called by php_file_tree() to list directories/files + $php_file_tree = ""; // Get and sort directories/files if( function_exists("scandir") ) $file = scandir($directory); @@ -1579,7 +1584,13 @@ function php_file_tree_dir($directory, $first_call = true) { // Make directories first $files = $dirs = array(); foreach($file as $this_file) { - if( is_dir("$directory/$this_file" ) ) $dirs[] = $this_file; else $files[] = $this_file; + if( is_dir("$directory/$this_file" ) ) { + if(!in_array($this_file, $GLOBALS['exclude_folders'])){ + $dirs[] = $this_file; + } + } else { + $files[] = $this_file; + } } $file = array_merge($dirs, $files);