tinyfilemanager
tinyfilemanager copied to clipboard
Preview images and direct links not working for user specific directories
I am using small file manager and have it xcopy relocatable across multiple instance on different O/S and hardware.
The following example specification does not work as far as popup previews, light box and direct links go. You can browser list and download only.
At bottom you will see the one line correction I have used.
$auth_users = array( 'admin' => '$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW', //admin@123 'user' => '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345 ); $readonly_users = array( 'user' ); $root_path = dirname(FILE).'/Data';
$root_url = '/files/Data';
$directories_users = array( 'user'=>dirname(FILE).'/Data/user' );
The following code corrected this. It clears what I see as a confusion between URL, which can be remapped and the actual file path.
// update $root_url based on user specific directories if (isset($_SESSION[FM_SESSION_ID]['logged']) && !empty($directories_users[$_SESSION[FM_SESSION_ID]['logged']])) { // $wd = fm_clean_path(dirname($_SERVER['PHP_SELF'])); // $root_url = $root_url.$wd.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']]; $root_url= $root_url.DIRECTORY_SEPARATOR.str_replace($root_path, '', $directories_users[$_SESSION[FM_SESSION_ID]['logged']]); }
There are two parameters. Perhaps you must change the second parameter to the subdir. Can you post the correct and wrong path of your popup previews?
// Root path for file manager // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' $root_path = $_SERVER['DOCUMENT_ROOT'] . '/';
// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' // Will not working if $root_path will be outside of server document root $root_url = '/';
example: $root_url= '/subdir/';
I have posted a similar question here. I have tried to correct the proposed line of code in the first message and it works fine ! To conclude, there is seemingly a bug with direct links when you configurate $directories_users but this line of code repairs the bug.
@ThomasMarkas @orthose This solution works for when you have users with defined folders.
Thanks !
Hi there. Sorry for asking for further clarification, but I'm experiencing the same issue - previews not working when user specific directories are specified - and I can't quite sort out the correct implementation of the suggested fix above. I'm getting a rather generic 500 error back.
Would it be too much to ask for someone to post another working example of using user specific directories AND having file previews function properly?
Thanks in advance!
Also, just to be sure, those paths above should actually be:
$root_path = dirname(FILE).'/Data';
and
$directories_users = array( 'user'=>dirname(FILE).'/Data/user' );
each with the double underscore before and after FILE, right?
So then, this added code from above is throwing the 500 error for me:
// update $root_url based on user specific directories if (isset($_SESSION[FM_SESSION_ID]['logged']) && !empty($directories_users[$_SESSION[FM_SESSION_ID]['logged']])) { $root_url= $root_url.DIRECTORY_SEPARATOR.str_replace($root_path, '', $directories_users[$_SESSION[FM_SESSION_ID]['logged']]); }
Thanks for your help.
Would still like to get the above posted fix to work if I could, just so it's an option at least, but now I'm batting around the idea of having a config file specific to each user and have that user-specific config file set a user-specific $root_path and $root_url instead of using the $directories_users array in a single config file. I'd then use a variable in tinyfilemanager.php to pull the correct user-specific config file. It might be a bit brute force, but it works, and perhaps I could convince myself that it's "better" in some ways than having multiple users and multiple user directory arrays in a single config file?
Thoughts??
Thanks... again!