diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 65ca50f..5a2bf79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # how to use? # docker run -d -v /absolute/path:/var/www/html/data -p 80:80 --restart=always --name tinyfilemanager tinyfilemanager/tinyfilemanager:master -FROM php:8.3.26-cli-alpine +FROM php:8.4.16-cli-alpine RUN apk update && apk upgrade --no-cache @@ -15,5 +15,6 @@ RUN docker-php-ext-install \ WORKDIR /var/www/html COPY tinyfilemanager.php index.php +COPY pwd.html ./pwd.html CMD ["sh", "-c", "php -S 0.0.0.0:80"] diff --git a/README.md b/README.md index 65c6905..7553c43 100644 --- a/README.md +++ b/README.md @@ -1,75 +1,44 @@ # Tiny File Manager -[![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://github.com/prasathmani/tinyfilemanager/wiki) -[![GitHub Release](https://img.shields.io/github/release/prasathmani/tinyfilemanager.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) -![GitHub Sponsors](https://img.shields.io/github/sponsors/prasathmani) +This repository is built on top of [prasathmani/tinyfilemanager](https://github.com/prasathmani/tinyfilemanager). The manager can be ran using PHP, Docker, or Kubernetes. -> TinyFileManager is a versatile web-based PHP file manager designed for simplicity and efficiency. This lightweight single-file PHP application can be effortlessly integrated into any server directory, allowing users to store, upload, edit, and manage files and folders directly through their web browser. -With multi-language support and compatibility with PHP 5.5+, TinyFileManager enables the creation of individual user accounts, each with its dedicated directory. The platform also includes built-in functionality for handling text files using the Cloud9 IDE. -Featuring syntax highlighting for over 150 languages and more than 35 themes, TinyFileManager offers a comprehensive solution for file management in an online environment. +## Adding Users -**Caution!** _Avoid utilizing this script as a standard file manager in public spaces. It is imperative to remove this script from the server after completing any tasks._ +> [!CAUTION] +> Do not use the example passwords in production environments, use the [Password Generator](pwd.html) to create unique passwords. +> Default username/password: **admin/admin@123** and **user/12345**. -## Demo +1. If running locally users can be added by setting the `USERS` JSON object array environment variable in `sample.env`, rename this to `.env`. -[Demo](https://tinyfilemanager.github.io/demo/) + ```bash + #inside .env + USERS='{"admin": "ADMIN_PASSWORD_HASH","user": "USER_PASSWORD_HAS"}' + ``` +2. Set the environment variable `USERS` using a JSON object array `'{"USER_NAME": "PASSWORD_HASH"}'`. -## Documentation - -Tinyfilemanager is highly documented on the [wiki pages](https://github.com/prasathmani/tinyfilemanager/wiki). - -[![Tiny File Manager](screenshot.gif)](screenshot.gif) - -## Requirements - -- PHP 5.5.0 or higher. -- Fileinfo, iconv, zip, tar and mbstring extensions are strongly recommended. - -## How to use - -Download ZIP with latest version from master branch. - -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@123** and **user/12345**. - -:warning: 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](https://tinyfilemanager.github.io/docs/pwd.html) + a. Docker Compose - set in the `docker-compose.yml` + b. Docker - set on the system or pass in the value + c. Kubernetes - in the deployment YAML set using a secret with `envFrom` or as an environment variable To enable/disable authentication set `$use_auth` to true or false. -:information_source: Add your own configuration file [config.php](https://tinyfilemanager.github.io/config-sample.txt) in the same folder to use as additional configuration file. +## How to run -:information_source: To work offline without CDN resources, use [offline](https://github.com/prasathmani/tinyfilemanager/tree/offline) branch +Run it locally within the directory with PHP. -### :loudspeaker: Features + ```bash + # use the development server + php -S localhost:8080 + ``` -- :cd: **Open Source:** Lightweight, minimalist, and extremely simple to set up. -- :iphone: **Mobile Friendly:** Optimized for touch devices and mobile viewing. -- :information_source: **Core Features:** Easily create, delete, modify, view, download, copy, and move files. -- :arrow_double_up: **Advanced Upload Options:** Ajax-powered uploads with drag-and-drop support, URL imports, and multi-file uploads with extension filtering. -- :file_folder: **Folder & File Management:** Create and organize folders and files effortlessly. -- :gift: **Compression Tools:** Compress and extract files in `zip` and `tar` formats. -- :sunglasses: **User Permissions:** User-specific root folder mapping and session-based access control. -- :floppy_disk: **Direct URLs:** Easily copy direct URLs for files. -- :pencil2: **Code Editor:** Includes Cloud9 IDE with syntax highlighting for 150+ languages and 35+ themes. -- :page_facing_up: **Document Preview:** Google/Microsoft document viewer for PDF/DOC/XLS/PPT, supporting previews up to 25 MB. -- :zap: **Security Features:** Backup capabilities, IP blacklisting, and whitelisting. -- :mag_right: **Search Functionality:** Use `datatable.js` for fast file search and filtering. -- :file_folder: **Customizable Listings:** Exclude specific folders and files from directory views. -- :globe_with_meridians: **Multi-language Support:** Translations available in 35+ languages with `translation.json`. -- :bangbang: **And Much More!** +For Docker, set the `USERS` environment variable in the system or pass in the value. -### [Deploy by Docker](https://github.com/prasathmani/tinyfilemanager/wiki/Deploy-by-Docker) + ```bash + docker run --name tfm -p 8080:80 britslampe/tfm:2.0 -### 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, and DataTable js_ -- To report a bug or request a feature, please file an [issue](https://github.com/prasathmani/tinyfilemanager/issues) -- [Contributors](https://github.com/prasathmani/tinyfilemanager/wiki/Authors-and-Contributors) + # OR + + docker run --name tfm --env USERS='{"admin": "ADMIN_PASSWORD_HASH"}' -p 8080:80 britslampe/tfm:2.0 + + ``` diff --git a/pwd.html b/pwd.html new file mode 100644 index 0000000..c79fed9 --- /dev/null +++ b/pwd.html @@ -0,0 +1,198 @@ + + + + + + + + + + TINY PHP5 PASSWORD HASH GENERATOR + + + + +
+ +
+ +
+
+ +
+
TINY FILE MANAGER
+
+
PHP5 PASSWORD HASH GENERATOR
+

PHP5 password_hash() is a predefined (built in) function on php 5.5 and above. Verifiable with password_verify() but non reversable.

+ + + +
+
+ +
+ +
+
+
HOW TO USE
+
+ +

or you can use directly use password with hash in $auth_users

+ +
+
+
+
+
+ +
+ —— © Tiny File Manager —— +
+ + +
+ + + + + + + diff --git a/sample.env b/sample.env new file mode 100644 index 0000000..c7dbf69 --- /dev/null +++ b/sample.env @@ -0,0 +1,2 @@ +# Remove this line: Replace the default passwords with unique ones. Open pwd.html in the browswer. +USERS='{"admin": "$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW", "user": "$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO"}' \ No newline at end of file diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 3b111b4..7eed73c 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -2,6 +2,9 @@ //Default Configuration $CONFIG = '{"lang":"en","error_reporting":false,"show_hidden":false,"hide_Cols":false,"theme":"light"}'; +// If running locally with PHP, use the env variable +// $env = parse_ini_file('.env'); + /** * H3K ~ Tiny File Manager V2.6 * @author CCP Programmers @@ -24,11 +27,8 @@ $use_auth = true; // Login user name and password // Users: array('Username' => 'Password', 'Username2' => 'Password2', ...) -// Generate secure password hash - https://tinyfilemanager.github.io/docs/pwd.html -$auth_users = array( - 'admin' => '$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW', //admin@123 - 'user' => '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345 -); +// Generate secure password hash - pwd.html +$auth_users = json_decode(getenv('USERS'), true); // Readonly users // e.g. array('users', 'guest', ...) @@ -213,7 +213,7 @@ if ($report_errors == true) { // if fm included if (defined('FM_EMBED')) { - $use_auth = false; + $use_auth = true; $sticky_navbar = false; } else { @set_time_limit(600);