diff --git a/tinyfilemanager.php b/tinyfilemanager.php index cd80110..faebe30 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -1111,7 +1111,14 @@ $all_files_size = 0;
- +
+
Browse
+ +
+
@@ -1126,7 +1133,7 @@ if ($parent !== false) { } foreach ($folders as $f) { $is_link = is_link($path . '/' . $f); - $img = $is_link ? 'icon-link_folder' : 'icon-folder'; + $img = $is_link ? 'icon-link_folder' : 'fa fa-folder-o'; $modif = date(FM_DATETIME_FORMAT, filemtime($path . '/' . $f)); $perms = substr(decoct(fileperms($path . '/' . $f)), -4); if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) { @@ -1543,6 +1550,63 @@ function scan($dir){ return $files; } +/** +* Scan directory and return tree view +* @param string $directory +* @param boolean $first_call +*/ +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); + natcasesort($file); + // Make directories first + $files = $dirs = array(); + foreach($file as $this_file) { + if( is_dir("$directory/$this_file" ) ) $dirs[] = $this_file; else $files[] = $this_file; + } + $file = array_merge($dirs, $files); + + if( count($file) > 2 ) { // Use 2 instead of 0 to account for . and .. "directories" + $php_file_tree = "" . htmlspecialchars($this_file) . ""; + $php_file_tree .= php_file_tree_dir("$directory/$this_file", false); + $php_file_tree .= ""; + } else { + // File + $ext = fm_get_file_icon_class($this_file); + $path = str_replace($_SERVER['DOCUMENT_ROOT'],"",$directory); + $link = "?p="."$path" ."&view=".urlencode($this_file); + $php_file_tree .= "
  • " . htmlspecialchars($this_file) . "
  • "; + } + } + } + $php_file_tree .= ""; + } + return $php_file_tree; +} + +/** + * Scan directory and render tree view + * @param string $directory + */ +function php_file_tree($directory) { + // Remove trailing slash + $code = ""; + if( substr($directory, -1) == "/" ) $directory = substr($directory, 0, strlen($directory) - 1); + if(function_exists('php_file_tree_dir')) { + $code .= php_file_tree_dir($directory); + return $code; + } +} + /** * Save message in session * @param string $msg @@ -1928,49 +1992,7 @@ function fm_show_header() @@ -1994,31 +2016,14 @@ function fm_show_footer() ?> - + - +
    NameSize Modified