[GH-ISSUE #218] Open / Direct link wrong if directories_users is used #154

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

Originally created by @neilf-qmul on GitHub (Sep 3, 2019).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/218

if tinyfilemanager content is in a subfolder (/var/www/html/tinyfilemanager-master) of the document root (/var/www/html) and I specify a folder for a user neil (/var/www/html/test)
$directories_users = array(
'neil' => '../test',
);
The href / Direct link for any files in the users folder (/var/www/html/test) are always relative to where the tinyfilemanager is executing rather than the document root
so for host manage-test.ac.uk and file /var/www/html/test/test.html
the href or direct link is: http://manage-test.ac.uk/tinyfilemanager-master/test/test.html
I have tried changing $http_host = $_SERVER['SERVER_NAME']; but this didn't fix the problem!

Originally created by @neilf-qmul on GitHub (Sep 3, 2019). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/218 if tinyfilemanager content is in a subfolder (/var/www/html/tinyfilemanager-master) of the document root (/var/www/html) and I specify a folder for a user neil (/var/www/html/test) $directories_users = array( 'neil' => '../test', ); The href / Direct link for any files in the users folder (/var/www/html/test) are always relative to where the tinyfilemanager is executing rather than the document root so for host manage-test.ac.uk and file /var/www/html/test/test.html the href or direct link is: http://manage-test.ac.uk/tinyfilemanager-master/test/test.html I have tried changing $http_host = $_SERVER['SERVER_NAME']; but this didn't fix the problem!
kerem 2026-03-02 15:56:16 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@neilf-qmul commented on GitHub (Sep 3, 2019):

think I have a solution, removed $wd from line 189 so it becomes:
$root_url = $root_url.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']];
and all works fine, not sure why it was there in the first place!, this also means you can remove line 188 as wd is not referenced anywhere else.

<!-- gh-comment-id:527486199 --> @neilf-qmul commented on GitHub (Sep 3, 2019): think I have a solution, removed $wd from line 189 so it becomes: $root_url = $root_url.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']]; and all works fine, not sure why it was there in the first place!, this also means you can remove line 188 as wd is not referenced anywhere else.
Author
Owner

@neilf-qmul commented on GitHub (Sep 3, 2019):

ok slight change, but this works for all cases:
if (isset($_SESSION[FM_SESSION_ID]['logged']) && !empty($directories_users[$_SESSION[FM_SESSION_ID]['logged']])) {
$root_url = $root_url.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']];
}else{
$wd = fm_clean_path(dirname($_SERVER['PHP_SELF']));
$root_url = $root_url.$wd;
}

<!-- gh-comment-id:527495410 --> @neilf-qmul commented on GitHub (Sep 3, 2019): ok slight change, but this works for all cases: if (isset($_SESSION[FM_SESSION_ID]['logged']) && !empty($directories_users[$_SESSION[FM_SESSION_ID]['logged']])) { $root_url = $root_url.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']]; }else{ $wd = fm_clean_path(dirname($_SERVER['PHP_SELF'])); $root_url = $root_url.$wd; }
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#154
No description provided.