[GH-ISSUE #478] Global variables are null / Config file not readable #353

Open
opened 2026-03-02 15:58:04 +03:00 by kerem · 1 comment
Owner

Originally created by @sharif-elshobkshy on GitHub (Dec 30, 2020).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/478

Thanks for the web file manager.

We detected several issues.

1) Global variables/scope.

Global variables that are not defined using the "define" function are not available (NULL) in any class or functions. Using global just returns NULL variables.

Function example:

class FM_Config
{
     var $data;
    function __construct()
    {
        global $root_path, $root_url, $CONFIG;
        var_dump($root_path); // NULL
        var_dump($root_url);  // NULL
        var_dump($CONFIG);  // NULL
    }
} 

2) Config file.

a) The config file not readable. The following condition returns FALSE.

$config_file = './config.php';
if (is_readable($config_file)) {
    @include($config_file);
}

b) Installing/Downloading this library with composer.
The config file should allow a custom directory (IMHO) so that we can have an external config file outside of the repo.
Changing the config file in this repo can cause issues when updating to a new tinyFileManager version (changes in the config file would be lost).

3) Base path for Tiny File Manager cannot be set.

This causes PHP_SELF to return index.php. This basepath is incorrect when rendering the web file manager is a different URL.
In our case, we were using /browse-files but $_SERVER['PHP_SELF'] still returned index.php

Added a new config variable $fm_base_path to allow user to set a custom FM base path. By default $fm_base_path variable is empty. $_SERVER['PHP_SELF'] (existing approach) will be used unless value is set to $fm_base_path. This way we don't change current behavior (unless desired).

Thanks in advance.

Originally created by @sharif-elshobkshy on GitHub (Dec 30, 2020). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/478 Thanks for the web file manager. We detected several issues. **1) Global variables/scope.** Global variables that are not defined using the "define" function are not available (NULL) in any class or functions. Using **global** just returns NULL variables. Function example: ``` class FM_Config { var $data; function __construct() { global $root_path, $root_url, $CONFIG; var_dump($root_path); // NULL var_dump($root_url); // NULL var_dump($CONFIG); // NULL } } ``` **2) Config file.** a) The config file not readable. The following condition returns FALSE. ``` $config_file = './config.php'; if (is_readable($config_file)) { @include($config_file); } ``` b) Installing/Downloading this library with composer. The config file should allow a custom directory (IMHO) so that we can have an external config file outside of the repo. Changing the config file in this repo can cause issues when updating to a new tinyFileManager version (changes in the config file would be lost). **3) Base path for Tiny File Manager cannot be set.** This causes PHP_SELF to return index.php. This basepath is incorrect when rendering the web file manager is a different URL. In our case, we were using /browse-files but `$_SERVER['PHP_SELF']` still returned index.php Added a new config variable `$fm_base_path` to allow user to set a custom FM base path. By default `$fm_base_path` variable is empty. `$_SERVER['PHP_SELF']` (existing approach) will be used unless value is set to `$fm_base_path`. This way we don't change current behavior (unless desired). Thanks in advance.
Author
Owner

@sharif-elshobkshy commented on GitHub (Jan 5, 2021):

Changes addressed in the following PR.

Refactor tinyFileManager - Global Variables - Config File

Thanks.

<!-- gh-comment-id:754695805 --> @sharif-elshobkshy commented on GitHub (Jan 5, 2021): Changes addressed in the following PR. [Refactor tinyFileManager - Global Variables - Config File](https://github.com/prasathmani/tinyfilemanager/pull/480/files) Thanks.
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#353
No description provided.