From 53f91120f50579cc9c239720b75396359f6f0bb6 Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Wed, 15 Mar 2017 09:54:08 +0100 Subject: [PATCH] fixed wrong links when root_dir != DocumentRoot If the root_dir is != the DocumentRoot then files are not linked directly, but downloaded instead. This prevents broken links. Trying to guess the DocumentRoot is not really an option, because due to aliases, rewrites and fallbacks it is nearly impossible to guess the correct DocumentRoot reliably. This is related to issue #26 --- ifm.php | 13 +++++++++---- src/ifm.js | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ifm.php b/ifm.php index 2ecfe34..35adfb4 100644 --- a/ifm.php +++ b/ifm.php @@ -466,6 +466,7 @@ function IFM() { this.IFM_SCFN = ""; this.config = jQuery.parseJSON(''); // serialize the PHP config array, so we can use it in JS too + this.isDocroot = ; this.editor = null; // global ace editor this.fileChanged = false; // flag for check if file was changed already this.currentDir = ""; // this is the global variable for the current directory; it is used for AJAX requests @@ -523,16 +524,20 @@ function IFM() { else if( self.config.edit == 1 && data[i].name.toLowerCase().substr(-4) != ".zip" ) newRow += ' data-eaction="edit"'; newRow += '>"'; + if( self.isDocroot ) { + newRow += ' href="'+self.pathCombine(ifm.currentDir,data[i].name)+'"'; + if( data[i].icon.indexOf( 'file-image' ) !== -1 ) + newRow += ' data-toggle="tooltip" title=" ' + ( data[i].name == '..' ? '[ up ]' : data[i].name ) + ''; if( ( data[i].type != "dir" && self.config.download == 1 ) || ( data[i].type == "dir" && self.config.zipnload == 1 ) ) { - var guid = self.generateGuid(); newRow += '
'; newRow += ''; newRow += ''; diff --git a/src/ifm.js b/src/ifm.js index 109e908..c0a830e 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -5,6 +5,7 @@ function IFM() { this.IFM_SCFN = ""; this.config = jQuery.parseJSON(''); // serialize the PHP config array, so we can use it in JS too + this.isDocroot = ; this.editor = null; // global ace editor this.fileChanged = false; // flag for check if file was changed already this.currentDir = ""; // this is the global variable for the current directory; it is used for AJAX requests @@ -62,16 +63,20 @@ function IFM() { else if( self.config.edit == 1 && data[i].name.toLowerCase().substr(-4) != ".zip" ) newRow += ' data-eaction="edit"'; newRow += '>"'; + if( self.isDocroot ) { + newRow += ' href="'+self.pathCombine(ifm.currentDir,data[i].name)+'"'; + if( data[i].icon.indexOf( 'file-image' ) !== -1 ) + newRow += ' data-toggle="tooltip" title=" ' + ( data[i].name == '..' ? '[ up ]' : data[i].name ) + ''; if( ( data[i].type != "dir" && self.config.download == 1 ) || ( data[i].type == "dir" && self.config.zipnload == 1 ) ) { - var guid = self.generateGuid(); newRow += ''; newRow += ''; newRow += '';