From 37111e31f36279a069136c5a30e9f6ecd796b0ab Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Wed, 20 May 2020 18:05:30 +0200 Subject: [PATCH] Add option to force proxying of files Signed-off-by: Marco Dickert --- build/libifm.php | 9 ++++++--- ifm.php | 9 ++++++--- src/ifm.js | 2 +- src/main.php | 7 +++++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/build/libifm.php b/build/libifm.php index 0adfce3..521fc29 100644 --- a/build/libifm.php +++ b/build/libifm.php @@ -53,7 +53,8 @@ class IFM { "showpath" => 0, "contextmenu" => 1, "disable_mime_detection" => 0, - "showrefresh" => 1 + "showrefresh" => 1, + "forceproxy" => 0 ); private $config = array(); @@ -101,6 +102,7 @@ class IFM { $this->config['contextmenu'] = getenv('IFM_GUI_CONTEXTMENU') !== false ? intval( getenv('IFM_GUI_CONTEXTMENU') ) : $this->config['contextmenu'] ; $this->config['search'] = getenv('IFM_API_SEARCH') !== false ? intval( getenv('IFM_API_SEARCH') ) : $this->config['search'] ; $this->config['showrefresh'] = getenv('IFM_GUI_REFRESH') !== false ? intval( getenv('IFM_GUI_REFRESH') ) : $this->config['showrefresh'] ; + $this->config['forceproxy'] = getenv('IFM_GUI_FORCEPROXY') !== false ? intval( getenv('IFM_GUI_FORCEPROXY') ) : $this->config['forceproxy'] ; // optional settings if( getenv('IFM_SESSION_LIFETIME') !== false ) @@ -1507,7 +1509,7 @@ function IFM(params) { } } item.download.link = self.api+"?api="+item.download.action+"&dir="+self.hrefEncode(self.currentDir)+"&filename="+self.hrefEncode(item.download.name); - if( self.config.isDocroot ) + if( self.config.isDocroot && !self.config.forceproxy ) item.link = self.hrefEncode( self.pathCombine( window.location.path, self.currentDir, item.name ) ); else if (self.config.download && self.config.zipnload) { if (self.config.root_public_url) { @@ -3494,7 +3496,8 @@ f00bar; private function getConfig() { $ret = $this->config; $ret['inline'] = ( $this->mode == "inline" ) ? true : false; - $ret['isDocroot'] = ( $this->getRootDir() == $this->getScriptRoot() ) ? true : false; + $ret['isDocroot'] = ($this->getRootDir() == $this->getScriptRoot); + foreach (array("auth_source", "root_dir") as $field) { unset($ret[$field]); } diff --git a/ifm.php b/ifm.php index 9ae7f9b..9a89a48 100644 --- a/ifm.php +++ b/ifm.php @@ -53,7 +53,8 @@ class IFM { "showpath" => 0, "contextmenu" => 1, "disable_mime_detection" => 0, - "showrefresh" => 1 + "showrefresh" => 1, + "forceproxy" => 0 ); private $config = array(); @@ -101,6 +102,7 @@ class IFM { $this->config['contextmenu'] = getenv('IFM_GUI_CONTEXTMENU') !== false ? intval( getenv('IFM_GUI_CONTEXTMENU') ) : $this->config['contextmenu'] ; $this->config['search'] = getenv('IFM_API_SEARCH') !== false ? intval( getenv('IFM_API_SEARCH') ) : $this->config['search'] ; $this->config['showrefresh'] = getenv('IFM_GUI_REFRESH') !== false ? intval( getenv('IFM_GUI_REFRESH') ) : $this->config['showrefresh'] ; + $this->config['forceproxy'] = getenv('IFM_GUI_FORCEPROXY') !== false ? intval( getenv('IFM_GUI_FORCEPROXY') ) : $this->config['forceproxy'] ; // optional settings if( getenv('IFM_SESSION_LIFETIME') !== false ) @@ -1507,7 +1509,7 @@ function IFM(params) { } } item.download.link = self.api+"?api="+item.download.action+"&dir="+self.hrefEncode(self.currentDir)+"&filename="+self.hrefEncode(item.download.name); - if( self.config.isDocroot ) + if( self.config.isDocroot && !self.config.forceproxy ) item.link = self.hrefEncode( self.pathCombine( window.location.path, self.currentDir, item.name ) ); else if (self.config.download && self.config.zipnload) { if (self.config.root_public_url) { @@ -3494,7 +3496,8 @@ f00bar; private function getConfig() { $ret = $this->config; $ret['inline'] = ( $this->mode == "inline" ) ? true : false; - $ret['isDocroot'] = ( $this->getRootDir() == $this->getScriptRoot() ) ? true : false; + $ret['isDocroot'] = ($this->getRootDir() == $this->getScriptRoot); + foreach (array("auth_source", "root_dir") as $field) { unset($ret[$field]); } diff --git a/src/ifm.js b/src/ifm.js index f24d23d..7576d49 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -166,7 +166,7 @@ function IFM(params) { } } item.download.link = self.api+"?api="+item.download.action+"&dir="+self.hrefEncode(self.currentDir)+"&filename="+self.hrefEncode(item.download.name); - if( self.config.isDocroot ) + if( self.config.isDocroot && !self.config.forceproxy ) item.link = self.hrefEncode( self.pathCombine( window.location.path, self.currentDir, item.name ) ); else if (self.config.download && self.config.zipnload) { if (self.config.root_public_url) { diff --git a/src/main.php b/src/main.php index 47c227b..7a0d3b7 100644 --- a/src/main.php +++ b/src/main.php @@ -54,7 +54,8 @@ class IFM { "showpath" => 0, "contextmenu" => 1, "disable_mime_detection" => 0, - "showrefresh" => 1 + "showrefresh" => 1, + "forceproxy" => 0 ); private $config = array(); @@ -102,6 +103,7 @@ class IFM { $this->config['contextmenu'] = getenv('IFM_GUI_CONTEXTMENU') !== false ? intval( getenv('IFM_GUI_CONTEXTMENU') ) : $this->config['contextmenu'] ; $this->config['search'] = getenv('IFM_API_SEARCH') !== false ? intval( getenv('IFM_API_SEARCH') ) : $this->config['search'] ; $this->config['showrefresh'] = getenv('IFM_GUI_REFRESH') !== false ? intval( getenv('IFM_GUI_REFRESH') ) : $this->config['showrefresh'] ; + $this->config['forceproxy'] = getenv('IFM_GUI_FORCEPROXY') !== false ? intval( getenv('IFM_GUI_FORCEPROXY') ) : $this->config['forceproxy'] ; // optional settings if( getenv('IFM_SESSION_LIFETIME') !== false ) @@ -418,7 +420,8 @@ f00bar; private function getConfig() { $ret = $this->config; $ret['inline'] = ( $this->mode == "inline" ) ? true : false; - $ret['isDocroot'] = ( $this->getRootDir() == $this->getScriptRoot() ) ? true : false; + $ret['isDocroot'] = ($this->getRootDir() == $this->getScriptRoot); + foreach (array("auth_source", "root_dir") as $field) { unset($ret[$field]); }