diff --git a/README.md b/README.md index 1a6c494..a3fb5e4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ -# Tiny PHP File Manager -It is a simple, fast and small file manager with single php file. It is also a web code editor. It'll run either online or locally, on Linux, Windows or Mac based platforms. The only requirement is to have PHP 5.5+ available. +# Tiny File Manager + + +[![Live demo](https://img.shields.io/badge/Live-Demo-brightgreen.svg?style=flat-square)](https://tinyfilemanager.eu-gb.mybluemix.net/Demo/) +[![Live demo](https://img.shields.io/badge/Help-Docs-lightgrey.svg?style=flat-square)](https://tinyfilemanager.github.io/) +[![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) +[![Beerpay](https://beerpay.io/prasathmani/tinyfilemanager/badge.svg?style=flat-square)](https://beerpay.io/prasathmani/tinyfilemanager) +> It is a simple, fast and small file manager with single php file. It is also a web code editor. It'll run either online or locally, on Linux, Windows or Mac based platforms. The only requirement is to have PHP 5.5+ available. ## Demo -tinyfilemanager.herokuapp.com +[Demo](https://tinyfilemanager.eu-gb.mybluemix.net/Demo/) - Login Details : admin/admin | user/12345 + Login Details : admin/admin@123 | user/12345 ## Documents @@ -23,13 +30,14 @@ It is a simple, fast and small file manager with single php file. It is also a w 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). +Just copy the tinyfilemanager.php to your webspace - thats all :) +You can also change the file name from "tinyfilemanager.php" to something else, you know what i meant for. -Default username/password: admin/admin and user/12345. +Default username/password: admin/admin@123 and user/12345. -Warning: Please set your own username and password in $auth_users before use. password is encrypted with password_hash(). to generate new password hash here +Warning: Please set your own username and password in `$auth_users` before use. password is encrypted with password_hash(). to generate new password hash here -To enable/disable authentication set $use_auth to true or false. +To enable/disable authentication set `$use_auth` to true or false. ### Supported constants: @@ -46,10 +54,11 @@ To enable/disable authentication set $use_auth to true or false. ### :loudspeaker: Features -###### CDN Used +### License, Credit + +- Available under the [GNU license](https://github.com/prasathmani/tinyfilemanager/blob/master/LICENSE) +- Original concept and development by github.com/alexantr/filemanager +- CDN Used - jQuery, Bootstrap, Font Awesome, Highlight js, ace js, DropZone js, DataTable js +- To report a bug or request a feature, please file an [issue](https://github.com/prasathmani/tinyfilemanager/issues) +- We hope our tools will be helpful for you. If you find Tiny File Manager useful for your personal or commercial projects, Help me out for a couple of +[![Beerpay](https://beerpay.io/prasathmani/tinyfilemanager/badge.svg?style=flat-square)](https://beerpay.io/prasathmani/tinyfilemanager) - `jQuery | Bootstrap | Font Awesome | Highlight js | ace js | DropZone js | DataTable js` -## Support Us -If you find Tiny FIle Manager useful for your personal or commerical projects, please consider buying the founders a :beers:! -[![Beerpay](https://beerpay.io/prasathmani/tinyfilemanager/badge.svg?style=beer-square)](https://beerpay.io/prasathmani/tinyfilemanager) diff --git a/screenshot.gif b/screenshot.gif index 3afb376..d44818f 100644 Binary files a/screenshot.gif and b/screenshot.gif differ diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 658d021..ba85abd 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -1,21 +1,20 @@ 'Password', 'Username2' => 'Password2', ...) // Generate secure password hash - https://tinyfilemanager.github.io/docs/pwd.html $auth_users = array( - 'admin' => '$2y$10$1wXHgLfTggq4SUTkm5YGUuO771X106e.B0WgHXXkH72C0/LuY6ZSW', //admin + 'admin' => '$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW', //admin@123 'user' => '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345 ); @@ -28,9 +27,6 @@ $readonly_users = array( // array('Username' => 'Directory path', 'Username2' => 'Directory path', ...) $directories_users = array(); -// Show or hide files and folders that starts with a dot -$show_hidden_files = true; - // Enable highlight.js (https://highlightjs.org/) on view's page $use_highlightjs = true; @@ -68,13 +64,24 @@ $GLOBALS['exclude_items'] = array(); // Google Docs Viewer $GLOBALS['online_viewer'] = true; -// Turn on/off PHP error reporting -$report_errors = true; // false = Turns off Errors, true = Turns on Errors -// include user config php file -if (defined('FM_CONFIG') && is_file(FM_CONFIG)) { - include(FM_CONFIG); -} +//Configuration +$cfg = new FM_Config(); + +// Default language +$lang = isset($cfg->data['lang']) ? $cfg->data['lang'] : 'en'; + +// Show or hide files and folders that starts with a dot +$show_hidden_files = isset($cfg->data['show_hidden']) ? $cfg->data['show_hidden'] : true; + +// PHP error reporting - false = Turns off Errors, true = Turns on Errors +$report_errors = isset($cfg->data['error_reporting']) ? $cfg->data['error_reporting'] : true; + +//available languages +$lang_list = array( + 'en' => 'English', + 'fr' => 'French' +); //--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL @@ -87,8 +94,7 @@ if ($report_errors == true) { } //Set Cookie -$cache = isset($_COOKIE['fm_cache']) ? 1 : 0; -setcookie('fm_cache', $cache, time() + 3600); +setcookie('fm_cache', true, 2147483647, "/"); // if fm included if (defined('FM_EMBED')) { @@ -108,7 +114,7 @@ if (defined('FM_EMBED')) { session_cache_limiter(''); session_name('filemanager'); - session_start(); + @session_start(); } if (empty($auth_users)) { @@ -143,14 +149,18 @@ if ($use_auth) { } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) { // Logging In sleep(1); - if (isset($auth_users[$_POST['fm_usr']]) && password_verify($_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='); + if(function_exists(password_verify)) { + if (isset($auth_users[$_POST['fm_usr']]) && isset($_POST['fm_pwd']) && password_verify($_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='); + } else { + unset($_SESSION['logged']); + fm_set_msg('Login failed. Invalid username or password', 'error'); + fm_redirect(FM_SELF_URL); + } } else { - unset($_SESSION['logged']); - fm_set_msg('Wrong password', 'error'); - fm_redirect(FM_SELF_URL); + fm_set_msg('password_hash not supported, Upgrade PHP version', 'error');; } } else { // Form @@ -163,44 +173,48 @@ if ($use_auth) {
- H3K File Manager + + + + + +
-

Tiny File Manager

+

@@ -270,6 +284,39 @@ if (isset($_POST['ajax']) && !FM_READONLY) { echo "Backup $newFile Created"; } + // Save Config + if (isset($_POST['type']) && $_POST['type'] == "settings") { + global $cfg, $lang, $report_errors, $show_hidden_files, $lang_list; + $newLng = $_POST['js-language']; + if (!array_key_exists($newLng, $lang_list)) { + $newLng = 'en'; + } + + $erp = isset($_POST['js-error-report']) && $_POST['js-error-report'] == "true" ? true : false; + $shf = isset($_POST['js-show-hidden']) && $_POST['js-show-hidden'] == "true" ? true : false; + + if ($cfg->data['lang'] != $newLng) { + $cfg->data['lang'] = $newLng; + $lang = $newLng; + } + if ($cfg->data['error_reporting'] != $erp) { + $cfg->data['error_reporting'] = $erp; + $report_errors = $erp; + } + if ($cfg->data['show_hidden'] != $shf) { + $cfg->data['show_hidden'] = $shf; + $show_hidden_files = $shf; + } + $cfg->save(); + echo true; + } + + // new password hash + if (isset($_POST['type']) && $_POST['type'] == "pwdhash") { + $res = isset($_POST['inputPassword2']) && !empty($_POST['inputPassword2']) ? password_hash($_POST['inputPassword2'], PASSWORD_DEFAULT) : ''; + echo $res; + } + exit(); } @@ -746,9 +793,9 @@ if (is_array($objects)) { continue; } $new_path = $path . '/' . $file; - if (is_file($new_path) && !in_array($file, $GLOBALS['exclude_items'])) { + if (@is_file($new_path) && !in_array($file, $GLOBALS['exclude_items'])) { $files[] = $file; - } elseif (is_dir($new_path) && $file != '.' && $file != '..' && !in_array($file, $GLOBALS['exclude_items'])) { + } elseif (@is_dir($new_path) && $file != '.' && $file != '..' && !in_array($file, $GLOBALS['exclude_items'])) { $folders[] = $file; } } @@ -786,12 +833,12 @@ if (isset($_GET['upload']) && !FM_READONLY) {
- Uploading files + +

- Back | - Destination folder: + :

-

Copying

- - - - ' . PHP_EOL; - } - ?> -

Files: , ', $copy_files) ?>

-

Source folder:
- - / -

-

-

-   - Cancel -

- +
+
+
+
+
+
+ + + ' . PHP_EOL; + } + ?> +

: , ', $copy_files) ?>

+

:
+ + / +

+

+

+   + +

+ +
+
+ +
+
+
+ + +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
+ +
+
+
+
+
+
+

- Download   - Open +   +   - UnZip   +   - UnZip to folder   +   - Edit   - Advanced Edit   +   +   - Back +

Back + href="?p=&view="> Backup + href="javascript:backup('','')"> Advanced Editor + href="?p=&edit=&env=ace"> Plain Editor - @@ -1174,48 +1351,52 @@ if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) { ?>
-

-

-
-

-
- - +
+
+ +
+
+

+ Full path:
+

+ + + - - - - - - - - - - - - - - - - - - - - - - - - - -
OwnerGroupOther
Read
Write
Execute
- -

-   - Cancel -

- - + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+   + +

+ +
+
- +
- Name - Size - Modified + + + - Perms - Owner - Actions + + + - .. + .. @@ -1289,7 +1470,7 @@ $all_files_size = 0; ?> - +
@@ -1299,7 +1480,7 @@ $all_files_size = 0;
' . readlink($path . '/' . $f) . '' : '') ?>
- Folder + @@ -1307,11 +1488,11 @@ $all_files_size = 0; - - - + + + - + - +
@@ -1357,13 +1538,13 @@ $all_files_size = 0; - - - + + - - + + - + @@ -1757,6 +1938,21 @@ function fm_convert_win($filename) return $filename; } +/** + * @param $obj + * @return array + */ +function fm_object_to_array($obj) +{ + if (!is_object($obj) && !is_array($obj)) { + return $obj; + } + if (is_object($obj)) { + $obj = get_object_vars($obj); + } + return array_map('fm_object_to_array', $obj); +} + /** * Get CSS classname for file * @param string $path @@ -2218,6 +2414,61 @@ class FM_Zipper_Tar } } + + +/** + * Save Configuration + */ + class FM_Config +{ + var $data; + + function __construct() + { + global $root_path, $root_url, $CONFIG; + $fm_url = $root_url.$_SERVER["PHP_SELF"]; + $this->data = array( + 'lang' => 'en', + 'error_reporting' => true, + 'show_hidden' => true + ); + $data = false; + if (strlen($CONFIG)) { + $data = fm_object_to_array(json_decode($CONFIG)); + } else { + $msg = 'Tiny File Manager
Error: Cannot load configuration'; + if (substr($fm_url, -1) == '/') { + $fm_url = rtrim($fm_url, '/'); + $msg .= '
'; + $msg .= '
Seems like you have a trailing slash on the URL.'; + $msg .= '
Try this link: ' . $fm_url . ''; + } + die($msg); + } + if (is_array($data) && count($data)) $this->data = $data; + else $this->save(); + } + + function save() + { + global $root_path; + $fm_file = $root_path.$_SERVER["PHP_SELF"]; + $var_name = '$CONFIG'; + $var_value = var_export(json_encode($this->data), true); + $config_string = "