diff --git a/README.md b/README.md index c41ab56..5246ae2 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Download ZIP with latest version from master branch. Copy tinyfilemanager.php to your website folder and open it with web browser (e.g. http://yoursite/any_path/tinyfilemanager.php). -Default username/password: admin/admin and user/12345. password has encripted with MD5. +Default username/password: admin/admin and user/12345. Warning: Please set your own username and password in $auth_users before use. @@ -46,7 +46,15 @@ To enable/disable authentication set $use_auth to true or false.
  • :pencil2: Edit text formats file using advanced editor
  • :zap: Backup files
  • :mag_right: Search - Advanced Ajax based seach
  • -
  • :palm_tree: Tree file view
  • :file_folder: Exclude folders from listing
  • :bangbang: lots more...
  • + +### CDN Used + + - jQuery + - Bootstrap + - Font Awesome + - Highlight.js + - ace.js + - DropZone.js diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 337f78f..1215c70 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -1,7 +1,7 @@ 'Password', 'Username2' => 'Password2', ...), Password has to be encrypted into MD5 +// Users: array('Username' => 'Password', 'Username2' => 'Password2', ...) $auth_users = array( - 'admin' => '21232f297a57a5a743894a0e4a801fc3', //admin - 'user' => '827ccb0eea8a706c4c34a16891f84e7b', //12345 + 'admin' => 'admin', + 'user' => '12345', ); // Readonly users (usernames array) @@ -39,12 +39,6 @@ $highlightjs_style = 'vs'; // Enable ace.js (https://ace.c9.io/) on view's page $edit_files = true; -// Send files though mail -$send_mail = false; - -// Send files though mail -$toMailId = ""; //yourmailid@mail.com - // Default timezone for date() and time() - http://php.net/manual/en/timezones.php $default_timezone = 'Etc/UTC'; // UTC @@ -67,16 +61,12 @@ $datetime_format = 'd.m.y H:i'; // allowed upload file extensions $upload_extensions = ''; // 'gif,png,jpg' -// show or hide the left side tree view -$show_tree_view = false; - //Array of folders excluded from listing -$GLOBALS['exclude_folders'] = array( -); +$GLOBALS['exclude_folders'] = array(); // include user config php file -if (defined('FM_CONFIG') && is_file(FM_CONFIG) ) { - include(FM_CONFIG); +if (defined('FM_CONFIG') && is_file(FM_CONFIG)) { + include(FM_CONFIG); } //--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL @@ -134,7 +124,7 @@ if ($use_auth) { } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) { // Logging In sleep(1); - if (isset($auth_users[$_POST['fm_usr']]) && md5($_POST['fm_pwd']) === $auth_users[$_POST['fm_usr']]) { + if (isset($auth_users[$_POST['fm_usr']]) && $_POST['fm_pwd'] === $auth_users[$_POST['fm_usr']]) { $_SESSION['logged'] = $_POST['fm_usr']; fm_set_msg('You are logged in'); fm_redirect(FM_SELF_URL . '?p='); @@ -149,12 +139,21 @@ if ($use_auth) { fm_show_header_login(); fm_show_message(); ?> -
    - H3K File Manager -
    -
    -
    - +
    + + H3K File Manager +

    File Manager

    + + + + +
    + +
    + +

    © CCP Programmers

    %s created', fm_enc($new))); } else { fm_set_msg(sprintf('File %s already exists', fm_enc($new)), 'alert'); @@ -474,7 +467,7 @@ if (!empty($_FILES) && !FM_READONLY) { $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true; $targetPath = $path . $ds; - $fullPath = $path.'/'.$_REQUEST['fullpath']; + $fullPath = $path . '/' . $_REQUEST['fullpath']; $folder = substr($fullPath, 0, strrpos($fullPath, "/")); if (!is_dir($folder)) { @@ -710,16 +703,26 @@ if (isset($_GET['upload']) && !FM_READONLY) {

    Uploading files

    Destination folder:

    -
    Files: , ', $copy_files) ?>

    Source folder:
    - / + /

    -   +   Cancel

    @@ -786,8 +790,10 @@ if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) { Destination folder:

    - Copy   - Move   + Copy   + Move   Cancel

    Select folder

    @@ -795,13 +801,16 @@ if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) { -
  • ..
  • - .. + -
  • - + + @@ -864,8 +873,10 @@ if (isset($_GET['view'])) {

    ""

    Full path:
    - File size: = 1000): ?> ()
    - MIME-type:
    + File + size: = 1000): ?> () +
    + MIME-type:

    - Download   - Open   + Download   + Open +   - UnZip   - - UnZip to folder   + UnZip   + + UnZip to folder   - Edit   - Advanced Edit   - - Mail   + if ($is_text && !FM_READONLY) { + ?> + Edit   + Advanced Edit   Back

    @@ -1002,16 +1015,16 @@ if (isset($_GET['edit'])) { //normal editer $isNormalEditor = true; - if(isset($_GET['env'])) { - if($_GET['env'] == "ace") { + if (isset($_GET['env'])) { + if ($_GET['env'] == "ace") { $isNormalEditor = false; } } //Save File - if(isset($_POST['savedata'])) { + if (isset($_POST['savedata'])) { $writedata = $_POST['savedata']; - $fd=fopen($file_path,"w"); + $fd = fopen($file_path, "w"); @fwrite($fd, $writedata); fclose($fd); fm_set_msg('File Saved Successfully', 'alert'); @@ -1031,23 +1044,35 @@ if (isset($_GET['edit'])) { ?>
    '. htmlspecialchars($content) .''; + echo ''; } elseif ($is_text) { - echo '
    '. htmlspecialchars($content) .'
    '; + echo '
    ' . htmlspecialchars($content) . '
    '; } else { fm_set_msg('FILE EXTENSION HAS NOT SUPPORTED', 'error'); } @@ -1095,21 +1120,30 @@ if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) { Read - - - + + + Write - - - + + + Execute - - - + + + @@ -1137,129 +1171,201 @@ $num_files = count($files); $num_folders = count($folders); $all_files_size = 0; ?> -
    - - - -
    -
    Browse
    - -
    - - - - - - - - - - '?'); - $group = array('name' => '?'); - } - ?> - - - - - - - - - - + + +
    +
    NameSizeModifiedPermsOwnerActions
    ..
    ' . readlink($path . '/' . $f) . '' : '') ?>
    Folder - - - - - -
    + + + + + + + + + + + + + + + + + + + '?'); + $group = array('name' => '?'); + } + ?> + + + + + + + + + + + + + '?'); + $group = array('name' => '?'); + } + ?> + + + + + + + + + + + + + '?'); - $group = array('name' => '?'); - } - ?> - - - - - - - - - - - + + + + + + + + + + + + + + +
    +
    + + +
    +
    NameSizeModifiedPermsOwnerActions
    ..
    +
    + + +
    +
    +
    + ' . readlink($path . '/' . $f) . '' : '') ?>
    +
    Folder + + + + + + +
    +
    + + +
    +
    +
    + ' . readlink($path . '/' . $f) . '' : '') ?>
    +
    + + + + + + + + +
    ' . readlink($path . '/' . $f) . '' : '') ?>
    - - - - - - - -
    + Full size: , + files: , + folders: +
    +
    + +
    + + -if (empty($folders) && empty($files)) { - ?> - - - -Full size: , -files: , -folders: - - - - - - + $f, "type" => "folder", - "path" => $_dir.'/'.$f, + "path" => $_dir . '/' . $f, "items" => scan($dir . '/' . $f), // Recursively get the contents of the folder ); } else { @@ -1581,70 +1688,6 @@ 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" ) ) { - if(!in_array($this_file, $GLOBALS['exclude_folders'])){ - $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 @@ -1690,50 +1733,121 @@ function fm_get_file_icon_class($path) $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); switch ($ext) { - case 'ico': case 'gif': case 'jpg': case 'jpeg': case 'jpc': case 'jp2': - case 'jpx': case 'xbm': case 'wbmp': case 'png': case 'bmp': case 'tif': - case 'tiff': case 'svg': + case 'ico': + case 'gif': + case 'jpg': + case 'jpeg': + case 'jpc': + case 'jp2': + case 'jpx': + case 'xbm': + case 'wbmp': + case 'png': + case 'bmp': + case 'tif': + case 'tiff': + case 'svg': $img = 'fa fa-picture-o'; break; - case 'passwd': case 'ftpquota': case 'sql': case 'js': case 'json': case 'sh': - case 'config': case 'twig': case 'tpl': case 'md': case 'gitignore': - case 'c': case 'cpp': case 'cs': case 'py': case 'map': case 'lock': case 'dtd': + case 'passwd': + case 'ftpquota': + case 'sql': + case 'js': + case 'json': + case 'sh': + case 'config': + case 'twig': + case 'tpl': + case 'md': + case 'gitignore': + case 'c': + case 'cpp': + case 'cs': + case 'py': + case 'map': + case 'lock': + case 'dtd': $img = 'fa fa-file-code-o'; break; - case 'txt': case 'ini': case 'conf': case 'log': case 'htaccess': + case 'txt': + case 'ini': + case 'conf': + case 'log': + case 'htaccess': $img = 'fa fa-file-text-o'; break; - case 'css': case 'less': case 'sass': case 'scss': + case 'css': + case 'less': + case 'sass': + case 'scss': $img = 'fa fa-css3'; break; - case 'zip': case 'rar': case 'gz': case 'tar': case '7z': + case 'zip': + case 'rar': + case 'gz': + case 'tar': + case '7z': $img = 'fa fa-file-archive-o'; break; - case 'php': case 'php4': case 'php5': case 'phps': case 'phtml': + case 'php': + case 'php4': + case 'php5': + case 'phps': + case 'phtml': $img = 'fa fa-code'; break; - case 'htm': case 'html': case 'shtml': case 'xhtml': + case 'htm': + case 'html': + case 'shtml': + case 'xhtml': $img = 'fa fa-html5'; break; - case 'xml': case 'xsl': + case 'xml': + case 'xsl': $img = 'fa fa-file-excel-o'; break; - case 'wav': case 'mp3': case 'mp2': case 'm4a': case 'aac': case 'ogg': - case 'oga': case 'wma': case 'mka': case 'flac': case 'ac3': case 'tds': + case 'wav': + case 'mp3': + case 'mp2': + case 'm4a': + case 'aac': + case 'ogg': + case 'oga': + case 'wma': + case 'mka': + case 'flac': + case 'ac3': + case 'tds': $img = 'fa fa-music'; break; - case 'm3u': case 'm3u8': case 'pls': case 'cue': + case 'm3u': + case 'm3u8': + case 'pls': + case 'cue': $img = 'fa fa-headphones'; break; - case 'avi': case 'mpg': case 'mpeg': case 'mp4': case 'm4v': case 'flv': - case 'f4v': case 'ogm': case 'ogv': case 'mov': case 'mkv': case '3gp': - case 'asf': case 'wmv': + case 'avi': + case 'mpg': + case 'mpeg': + case 'mp4': + case 'm4v': + case 'flv': + case 'f4v': + case 'ogm': + case 'ogv': + case 'mov': + case 'mkv': + case '3gp': + case 'asf': + case 'wmv': $img = 'fa fa-file-video-o'; break; - case 'eml': case 'msg': + case 'eml': + case 'msg': $img = 'fa fa-envelope-o'; break; - case 'xls': case 'xlsx': + case 'xls': + case 'xlsx': $img = 'fa fa-file-excel-o'; break; case 'csv': @@ -1742,22 +1856,35 @@ function fm_get_file_icon_class($path) case 'bak': $img = 'fa fa-clipboard'; break; - case 'doc': case 'docx': + case 'doc': + case 'docx': $img = 'fa fa-file-word-o'; break; - case 'ppt': case 'pptx': + case 'ppt': + case 'pptx': $img = 'fa fa-file-powerpoint-o'; break; - case 'ttf': case 'ttc': case 'otf': case 'woff':case 'woff2': case 'eot': case 'fon': + case 'ttf': + case 'ttc': + case 'otf': + case 'woff': + case 'woff2': + case 'eot': + case 'fon': $img = 'fa fa-font'; break; case 'pdf': $img = 'fa fa-file-pdf-o'; break; - case 'psd': case 'ai': case 'eps': case 'fla': case 'swf': + case 'psd': + case 'ai': + case 'eps': + case 'fla': + case 'swf': $img = 'fa fa-file-image-o'; break; - case 'exe': case 'msi': + case 'exe': + case 'msi': $img = 'fa fa-file-o'; break; case 'bat': @@ -1958,37 +2085,55 @@ function fm_show_nav_path($path) { global $lang; ?> -