[GH-ISSUE #199] Feature req: external configuration file #141

Closed
opened 2026-03-02 15:56:08 +03:00 by kerem · 5 comments
Owner

Originally created by @TheFax on GitHub (Jul 24, 2019).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/199

Feature request

Add the possibility to use an external configuration file.
For example, at every new version, I must edit your PHP file in order to set my own usename and password and the $root_path.

My proposal is to add an include or something similar, like this:
tinyfilemanager.php

[...]
// max upload file size
define('MAX_UPLOAD_SIZE', '2048');

// --------------------------------------my proposal (begin)
if (is_readable('h3k_config.php')) {
    include('h3k_config.php');
}
// --------------------------------------my proposal (end)

//--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL

// private key and session name to store to the session
if ( !defined( 'FM_SESSION_ID')) {
[...]

h3k_config.php

<?php

$auth_users = array(
    'my_personal_user1' =>  password_hash('only_an_example', PASSWORD_DEFAULT),
    'my_personal_user2' =>  password_hash('dont_use_me', PASSWORD_DEFAULT)
);

$root_path = '/folder/subfolder/';

//...other variables personalized 
?>

So, if customer want, he can put a file 'h3k_config.php' in the same directory of 'tinyfilemanager.php' and can avoid to edit your original script everytime you upload a new version.

Originally created by @TheFax on GitHub (Jul 24, 2019). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/199 ### Feature request Add the **possibility** to use an external configuration file. For example, at every new version, I must edit your PHP file in order to set my own usename and password and the $root_path. My proposal is to add an include or something similar, like this: **tinyfilemanager.php** ``` [...] // max upload file size define('MAX_UPLOAD_SIZE', '2048'); // --------------------------------------my proposal (begin) if (is_readable('h3k_config.php')) { include('h3k_config.php'); } // --------------------------------------my proposal (end) //--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL // private key and session name to store to the session if ( !defined( 'FM_SESSION_ID')) { [...] ``` **h3k_config.php** ``` <?php $auth_users = array( 'my_personal_user1' => password_hash('only_an_example', PASSWORD_DEFAULT), 'my_personal_user2' => password_hash('dont_use_me', PASSWORD_DEFAULT) ); $root_path = '/folder/subfolder/'; //...other variables personalized ?> ``` So, if customer want, he can put a file 'h3k_config.php' in the same directory of 'tinyfilemanager.php' and can avoid to edit your original script everytime you upload a new version.
kerem 2026-03-02 15:56:08 +03:00
  • closed this issue
  • added the
    duplicate
    label
Author
Owner

@joglomedia commented on GitHub (Nov 26, 2019):

@TheFax may be this is what you need?

https://github.com/PHPlayground/tinyfilemanager/tree/lemperfm_1.3.0

<!-- gh-comment-id:558727929 --> @joglomedia commented on GitHub (Nov 26, 2019): @TheFax may be this is what you need? https://github.com/PHPlayground/tinyfilemanager/tree/lemperfm_1.3.0
Author
Owner

@TheFax commented on GitHub (Apr 3, 2020):

@joglomedia
Your solution is probably the most professional.

But I see two issues:

  1. Your branch is not updated; (your code is version 2.3.8, version of prasathmani is obviously more recent, ).
    So, the main reason for my proposal was to make upgrade of TiniFileManager easier. And if I use your branch it actually not upgraded at all.

  2. TinyFileManager should be a

[...] fast and small file manager with a single file [...] web application

In your solution the presence of folder config/ is mandatory and it adds more file to the base code. This sounds bad in a project like this. In my solution, the config file is completely optional and if somebody want to keep its TinyFileManager as a single file app, it is free to do so. In fact the first line of this thread is "Add the possibility to use an external configuration file." and my code allows the possibility that the configuration file is absent.

Can we work together in order to find a real solution?

<!-- gh-comment-id:608263104 --> @TheFax commented on GitHub (Apr 3, 2020): @joglomedia Your solution is probably the most professional. But I see two issues: 1) Your branch is not updated; (your code is [version 2.3.8](https://github.com/PHPlayground/tinyfilemanager/blob/lemperfm_1.3.0/index.php#L12), version of prasathmani is obviously more recent, ). So, the main reason for my proposal was to make upgrade of TiniFileManager easier. And if I use your branch it actually not upgraded at all. 2) TinyFileManager should be a > [...] fast and small file manager with a single file [...] web application In your solution the presence of folder `config/` is **mandatory** and it adds more file to the base code. This sounds bad in a project like this. In my solution, the config file is completely optional and if somebody want to keep its TinyFileManager as a single file app, it is free to do so. In fact the first line of this thread is "Add the **possibility** to use an external configuration file." and my code allows the possibility that the configuration file is absent. Can we work together in order to find a real solution?
Author
Owner

@joglomedia commented on GitHub (Apr 7, 2020):

@TheFax
I think this is the easiest one for "optional" external configuration using my branch, if we add the custom configuration as below (just example):

if (file_exists('config/auth.php')) {
    $auth_users = include('config/auth.php');
} else {
    $auth_users = array(
        'admin' => '$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW', //admin@123
        'user' => '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345
    );
}

Those codes give more flexibility, the config folder which contain custom configurations is optional and could be excluded from TFM master branch, user can create it as needed. When there is no custom configuration, the default one still persist.

How about this idea @prasathmani ?

<!-- gh-comment-id:610216329 --> @joglomedia commented on GitHub (Apr 7, 2020): @TheFax I think this is the easiest one for "optional" external configuration using my branch, if we add the custom configuration as below (just example): ``` if (file_exists('config/auth.php')) { $auth_users = include('config/auth.php'); } else { $auth_users = array( 'admin' => '$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW', //admin@123 'user' => '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345 ); } ``` Those codes give more flexibility, the config folder which contain custom configurations is optional and could be excluded from TFM master branch, user can create it as needed. When there is no custom configuration, the default one still persist. How about this idea @prasathmani ?
Author
Owner

@D0tty commented on GitHub (May 3, 2020):

If I may add, this feature would be very nice to have a docker container that runs with our credentials with only one file needed to configure it

<!-- gh-comment-id:623052454 --> @D0tty commented on GitHub (May 3, 2020): If I may add, this feature would be very nice to have a docker container that runs with our credentials with only one file needed to configure it
Author
Owner

@prasathmani commented on GitHub (May 24, 2020):

external configuration file added in latest version

<!-- gh-comment-id:633198275 --> @prasathmani commented on GitHub (May 24, 2020): external configuration file added in latest version
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tinyfilemanager#141
No description provided.