mirror of
https://github.com/prasathmani/tinyfilemanager
synced 2024-06-12 19:02:13 +02:00
Add support to change to root_path to any folder.
Make image preview work. Disable open option if $root_path is not a substring of DOCUMENT_ROOT Define ROOT_FS environment variable to change the DOCUMENT_ROOT.
This commit is contained in:
parent
56e5e5e489
commit
3e9ecc8abe
|
@ -77,7 +77,7 @@ $default_timezone = 'Etc/UTC'; // UTC
|
|||
|
||||
// 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_path = getenv('ROOT_FS')==false ? $_SERVER['DOCUMENT_ROOT'] : getenv('ROOT_FS');
|
||||
|
||||
// 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
|
||||
|
|
|
@ -1550,6 +1550,8 @@ if (isset($_GET['view'])) {
|
|||
$file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
|
||||
$file_path = $path . '/' . $file;
|
||||
|
||||
$download_url = '?p=' .urlencode(FM_PATH) . '&dl=' . urlencode($file);
|
||||
|
||||
$ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
|
||||
$mime_type = fm_get_mime_type($file_path);
|
||||
$filesize_raw = fm_get_size($file_path);
|
||||
|
@ -1641,9 +1643,14 @@ if (isset($_GET['view'])) {
|
|||
</p>
|
||||
<p>
|
||||
<b><a href="?p=<?php echo urlencode(FM_PATH) ?>&dl=<?php echo urlencode($file) ?>"><i class="fa fa-cloud-download"></i> <?php echo lng('Download') ?></a></b>
|
||||
<?php
|
||||
// Disable Open option if $root_path is not a substring of DOCUMENT_ROOT
|
||||
if ( substr($root_path, 0, strlen($_SERVER['DOCUMENT_ROOT'])) == $_SERVER['DOCUMENT_ROOT']) {
|
||||
?>
|
||||
<b><a href="<?php echo fm_enc($file_url) ?>" target="_blank"><i class="fa fa-external-link-square"></i> <?php echo lng('Open') ?></a></b>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
// ZIP actions
|
||||
if (!FM_READONLY && ($is_zip || $is_gzip) && $filenames !== false) {
|
||||
$zip_name = pathinfo($file_path, PATHINFO_FILENAME);
|
||||
|
@ -1689,7 +1696,7 @@ if (isset($_GET['view'])) {
|
|||
} elseif ($is_image) {
|
||||
// Image content
|
||||
if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg', 'webp'))) {
|
||||
echo '<p><img src="' . fm_enc($file_url) . '" alt="" class="preview-img"></p>';
|
||||
echo '<p><img src="' . $download_url . '" alt="" class="preview-img"></p>';
|
||||
}
|
||||
} elseif ($is_audio) {
|
||||
// Audio content
|
||||
|
@ -2118,7 +2125,7 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white
|
|||
<div class="filename">
|
||||
<?php
|
||||
if (in_array(strtolower(pathinfo($f, PATHINFO_EXTENSION)), array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg', 'webp'))): ?>
|
||||
<?php $imagePreview = fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f); ?>
|
||||
<?php $imagePreview = '?p=' .urlencode(FM_PATH) . '&dl=' . urlencode($f); ?>
|
||||
<a href="<?php echo $filelink ?>" data-preview-image="<?php echo $imagePreview ?>" title="<?php echo fm_enc($f) ?>">
|
||||
<?php else: ?>
|
||||
<a href="<?php echo $filelink ?>" title="<?php echo $f ?>">
|
||||
|
|
Loading…
Reference in a new issue