From 9e3877270b72e23f9834d824147063865d814b7b Mon Sep 17 00:00:00 2001 From: Prasath Mani Date: Tue, 14 Jan 2020 17:57:32 +0530 Subject: [PATCH] Advanced Search Mouse hover image preview Upload error handling Thumbnail view for folders containing images #283 How to search inside folders. #282 Search bar with regex matching #140 Subfolder Search Feature #132 --- README.md | 6 +- tinyfilemanager.php | 217 ++++++++++++++++++++++++++++++++++++-------- translation.json | 2 +- 3 files changed, 185 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index c69341a..dca8858 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ [![Live demo](https://img.shields.io/badge/Live-Demo-brightgreen.svg?style=flat-square)](https://tinyfilemanager.github.io/demo/) -[![Live demo](https://img.shields.io/badge/Help-Docs-lightgrey.svg?style=flat-square)](https://tinyfilemanager.github.io/) +[![Live demo](https://img.shields.io/badge/Help-Docs-lightgrey.svg?style=flat-square)](https://github.com/prasathmani/tinyfilemanager/wiki) [![GitHub Release](https://img.shields.io/github/release/qubyte/rubidium.svg?style=flat-square)](https://github.com/prasathmani/tinyfilemanager/releases) [![GitHub License](https://img.shields.io/github/license/prasathmani/tinyfilemanager.svg?style=flat-square)](https://github.com/prasathmani/tinyfilemanager/blob/master/LICENSE) [![Paypal](https://img.shields.io/badge/Donate-Paypal-lightgrey.svg?style=flat-square)](https://www.paypal.me/prasathmani) -> It is web based file manager and it is a simple, fast and small file manager with a single file, multi-language ready web application for storing, uploading, editing and managing files and folders online via web browser. The Application runs on PHP 5.5+, It allows the creation of multiple users and each user can have its own directory and a build-in support for managing text files with cloud9 IDE and it supports syntax highlighting for over 150+ languages and over 35+ themes. +> TinyFileManager is web based file manager and it is a simple, fast and small file manager with a single file, multi-language ready web application for storing, uploading, editing and managing files and folders online via web browser. The Application runs on PHP 5.5+, It allows the creation of multiple users and each user can have its own directory and a build-in support for managing text files with cloud9 IDE and it supports syntax highlighting for over 150+ languages and over 35+ themes. ## Demo [Demo](https://tinyfilemanager.github.io/demo/) @@ -43,7 +43,7 @@ To enable/disable authentication set `$use_auth` to true or false. - :cd: Open Source, light and extremely simple - :iphone: Mobile friendly view for touch devices -- :information_source: Basic features likes Create, Delete, Modify, View, Quick View, Download, Copy and Move files +- :information_source: Basic features likes Create, Delete, Modify, View, Quick Preview, Download, Copy and Move files - :arrow_double_up: Ajax Upload, Ability to drag & drop, upload from URL, multiple files upload with file extensions filter - :file_folder: Ability to create folders and files - :gift: Ability to compress, extract files (`zip`, `tar`) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index eca2a68..3d27425 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -3,13 +3,13 @@ $CONFIG = '{"lang":"en","error_reporting":false,"show_hidden":false,"hide_Cols":false,"calc_folder":false}'; /** - * H3K | Tiny File Manager V2.4.0 + * H3K | Tiny File Manager V2.4.1 * CCP Programmers | ccpprogrammers@gmail.com * https://tinyfilemanager.github.io */ //TFM version -define('VERSION', '2.4.0'); +define('VERSION', '2.4.1'); //Application Title define('APP_TITLE', 'Tiny File Manager'); @@ -413,6 +413,14 @@ if (isset($_POST['ajax']) && !FM_READONLY) { fclose($fd); die(true); } + + //search : get list of files from the current folder + if(isset($_POST['type']) && $_POST['type']=="search") { + $dir = FM_ROOT_PATH; + $response = scan($_POST['path'], $_POST['content']); + echo json_encode($response); + exit(); + } // backup files if (isset($_POST['type']) && $_POST['type'] == "backup") { @@ -789,27 +797,50 @@ if (!empty($_FILES) && !FM_READONLY) { $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true; $targetPath = $path . $ds; - $fullPath = $path . '/' . $_REQUEST['fullpath']; - $folder = substr($fullPath, 0, strrpos($fullPath, "/")); + if ( is_writable($targetPath) ) { + $fullPath = $path . '/' . $_REQUEST['fullpath']; + $folder = substr($fullPath, 0, strrpos($fullPath, "/")); - if(file_exists ($fullPath) && !$override_file_name) { - $ext_1 = $ext ? '.'.$ext : ''; - $fullPath = str_replace($ext_1, '', $fullPath) .'_'. date('ymdHis'). $ext_1; - } - - if (!is_dir($folder)) { - $old = umask(0); - mkdir($folder, 0777, true); - umask($old); - } - - if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) { - if (move_uploaded_file($tmp_name, $fullPath)) { - die('Successfully uploaded'); - } else { - die(sprintf('Error while uploading files. Uploaded files: %s', $uploads)); + if(file_exists ($fullPath) && !$override_file_name) { + $ext_1 = $ext ? '.'.$ext : ''; + $fullPath = str_replace($ext_1, '', $fullPath) .'_'. date('ymdHis'). $ext_1; } + + if (!is_dir($folder)) { + $old = umask(0); + mkdir($folder, 0777, true); + umask($old); + } + + if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) { + if (move_uploaded_file($tmp_name, $fullPath)) { + // Be sure that the file has been uploaded + if ( file_exists($fullPath) ) { + $response = array ( + 'status' => 'success', + 'info' => "file upload successful" + ); + } else { + $response = array ( + 'status' => 'error', + 'info' => 'Couldn\'t upload the requested file.' + ); + } + } else { + $response = array ( + 'status' => 'error', + 'info' => "Error while uploading files. Uploaded files $uploads", + ); + } + } + } else { + $response = array ( + 'status' => 'error', + 'info' => 'The specified folder for upload isn\'t writeable.' + ); } + // Return the response + echo json_encode($response); exit(); } @@ -1114,7 +1145,10 @@ if (isset($_GET['upload']) && !FM_READONLY) { toast('Error: Server Timeout'); }); }).on("success", function (res) { - console.log('Upload Status >> ', res.status); + let _response = JSON.parse(res.xhr.response); + if(_response.status == "error") { + toast(_response.info); + } }).on("error", function(file, response) { toast(response); }); @@ -1351,7 +1385,7 @@ if (isset($_GET['help'])) {
    -
  • +
  • @@ -1870,12 +1904,19 @@ $all_files_size = 0;
- -
- ' . readlink($path . '/' . $f) . '' : '') ?>
- - - + +
+ + + + + + + + + ' . readlink($path . '/' . $f) . '' : '') ?> +
@@ -2677,7 +2718,7 @@ function fm_get_image_exts() */ function fm_get_video_exts() { - return array('webm', 'mp4', 'm4v', 'ogm', 'ogv', 'mov', 'mkv'); + return array('avi', 'webm', 'wmv', 'mp4', 'm4v', 'ogm', 'ogv', 'mov', 'mkv'); } /** @@ -2742,6 +2783,31 @@ function fm_get_onlineViewer_exts() return array('doc', 'docx', 'xls', 'xlsx', 'pdf', 'ppt', 'pptx', 'ai', 'psd', 'dxf', 'xps', 'rar', 'odt', 'ods'); } +/** + * This function scans the files and folder recursively, and return matching files + * @param string $dir + * @return json + */ + function scan($dir, $filter = '') { + $path = FM_ROOT_PATH.'/'.$dir; + $ite = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); + $rii = new RegexIterator($ite, "/(".$filter.")/i"); + + $files = array(); + foreach ($rii as $file) { + if (!$file->isDir()) { + $fileName = $file->getFilename(); + $location = str_replace(FM_ROOT_PATH, '', $file->getPath()); + $files[] = array( + "name" => $fileName, + "type" => "file", + "path" => $location, + ); + } + } + return $files; +} + /** * Class to work with zip files (using ZipArchive) */ @@ -3047,8 +3113,11 @@ function fm_show_nav_path($path) @@ -3309,6 +3378,11 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal'; @keyframes lds-facebook { 0% { top:6px;height:51px } 100%,50% { top:19px;height:26px } } + ul#search-wrapper { padding-left: 0;border: 1px solid #ecececcc; } ul#search-wrapper li { list-style: none; padding: 5px;border-bottom: 1px solid #ecececcc; } + ul#search-wrapper li:nth-child(odd){ background: #f9f9f9cc;} + .c-preview-img { + max-width: 300px; + } @@ -3349,6 +3423,33 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal';
+