-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Disable real file path from being shown
If you want to hide real path to the files you can mask them using connector.php
file. Instead of http://localhost/example/path/file.jpg
link shown to client, you will get connector.php?cmd=file&target=HASH_TO_FILE_PATH
.
The only thing needed to get this is to omit (disable) URL
option in connector.php
file.
This is a replacement for for the FileURL
option in the 1.x (old version).
Example:
<?php
$opts = array(
'roots' => array(
array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => '../files/', // path to files (REQUIRED)
// DISABLE 'URL' BY COMMENTING THE FOLLOWING LINE OUT
// 'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
)
)
);
TODO This section must be rewritten to not contain monkey patching of min files
You might find the connector.php?cmd=file&target=HASH_TO_FILE_PATH
path a little bit messy for the user. You can clean up the path a little bit by editing your .htaccess
file and setting a rewrite URL.
Example .htaccess
file:
RewriteEngine on
RewriteBase /
# localhost/view/target (Outputs Files)
RewriteRule ^view/([A-Za-z_0-9-]+)$ connector.php?cmd=file&target=$1
NEXT, OPEN elfinder.min.js
:
Find:
(h=c.options.url,h=h+(h.indexOf("?")===-1?"?":"&")+(c.oldAPI?"cmd=open¤t="+g.phash:"cmd=file")+"&target="+g.hash)
Replace:
(h=h+(("?")===-1?"?":"")+(c.oldAPI?"cmd=open¤t="+g.phash:"view/")+g.hash)
Find:
(n,'<a href="'+f.url(u.hash)+'" target="_blank">'+u.name+"</a>"))
Replace:
(n,'<a href="view/'+u.hash+'" target="_blank">'+u.name+"</a>"))
With the .htaccess option, users will be able to see the url as localhost.com/view/targethash/
when they open a file, instead of the choppy and complicated connector.php?cmd=file&target=targethash