From 1a19f2d502caa3b4d3087bffb3ed227f8bd49c92 Mon Sep 17 00:00:00 2001 From: Joubert Date: Sun, 25 Aug 2013 22:32:37 -0300 Subject: [PATCH 1/6] A Small fix on a send header instruction to implement a header to lighttpd server version 1.4.X. More info in http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file --- core/src/plugins/access.fs/class.fsAccessDriver.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/plugins/access.fs/class.fsAccessDriver.php b/core/src/plugins/access.fs/class.fsAccessDriver.php index 42823f8a43..23c7077ebe 100644 --- a/core/src/plugins/access.fs/class.fsAccessDriver.php +++ b/core/src/plugins/access.fs/class.fsAccessDriver.php @@ -1231,7 +1231,13 @@ function readFile($filePathOrData, $headerType="plain", $localName="", $data=fal if($this->getFilteredOption("USE_XSENDFILE", $this->repository->getId()) && $this->wrapperClassName == "fsAccessWrapper"){ if(!$realfileSystem) $filePathOrData = fsAccessWrapper::getRealFSReference($filePathOrData); $filePathOrData = str_replace("\\", "/", $filePathOrData); - header("X-Sendfile: ".SystemTextEncoding::toUTF8($filePathOrData)); + $server_name = $_SERVER["SERVER_SOFTWARE"]; + $regex = '/^(lighttpd\/1.4).([0-9]{2}$|[0-9]{3}$|[0-9]{4}$)+/'; + if(preg_match($regex, $server_name)) + $header_sendfile = "X-LIGHTTPD-send-file"; + else + $header_sendfile = "X-Sendfile"; + header($header_sendfile.": ".SystemTextEncoding::toUTF8($filePathOrData)); header("Content-type: application/octet-stream"); header('Content-Disposition: attachment; filename="' . basename($filePathOrData) . '"'); return; From 37cdd5a793f9b157da43142479c2268edce583f3 Mon Sep 17 00:00:00 2001 From: Etienne CHAMPETIER Date: Fri, 19 Jul 2013 15:24:17 +0200 Subject: [PATCH 2/6] Add configurable limit for action.share plugin With this patch you can set a maximum time and maximum download time for every new file share Signed-off-by: Etienne CHAMPETIER --- .../plugins/action.share/class.ShareCenter.js | 16 ++++++++++++++++ .../plugins/action.share/class.ShareCenter.php | 14 ++++++++++++-- core/src/plugins/action.share/manifest.xml | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/core/src/plugins/action.share/class.ShareCenter.js b/core/src/plugins/action.share/class.ShareCenter.js index c7feebcd16..6c73092073 100644 --- a/core/src/plugins/action.share/class.ShareCenter.js +++ b/core/src/plugins/action.share/class.ShareCenter.js @@ -383,6 +383,14 @@ Class.create("ShareCenter", { }.bind(this)); this.updateDialogButtons(oForm.down("div.dialogButtons"), "file"); }else{ + this.maxexpiration = parseInt(ajaxplorer.getPluginConfigs("ajxp_plugin[@name='share']").get("FILE_MAX_EXPIRATION")); + if(this.maxexpiration > 0){ + oForm.down("[name='expiration']").setValue(this.maxexpiration); + } + this.maxdownload = parseInt(ajaxplorer.getPluginConfigs("ajxp_plugin[@name='share']").get("FILE_MAX_DOWNLOAD")); + if(this.maxdownload > 0){ + oForm.down("[name='downloadlimit']").setValue(this.maxdownload); + } var button = $(oForm).down('div#generate_publiclet'); button.observe("click", this.generatePublicLinkCallback.bind(this)); } @@ -557,6 +565,14 @@ Class.create("ShareCenter", { ajaxplorer.displayMessage("ERROR", MessageHash["share_center.75"]); return; } + if(this.maxexpiration > 0 && !(serialParams["expiration"] > 0 && serialParams["expiration"] <= this.maxexpiration) ){ + ajaxplorer.displayMessage("ERROR", "Expiration must be between 1 and " + this.maxexpiration); + return; + } + if(this.maxdownload > 0 && !(serialParams["downloadlimit"] > 0 && serialParams["downloadlimit"] <= this.maxdownload) ){ + ajaxplorer.displayMessage("ERROR", "Download limit must be between 1 and " + this.maxdownload); + return; + } oForm.down('img#generate_image').src = window.ajxpResourcesFolder+"/images/autocompleter-loader.gif"; conn.setParameters(serialParams); diff --git a/core/src/plugins/action.share/class.ShareCenter.php b/core/src/plugins/action.share/class.ShareCenter.php index 9905085a41..32f0b3a858 100644 --- a/core/src/plugins/action.share/class.ShareCenter.php +++ b/core/src/plugins/action.share/class.ShareCenter.php @@ -144,9 +144,19 @@ function switchAction($action, $httpVars, $fileVars){ } print($url); }else{ - if(!isSet($httpVars["downloadlimit"])){ - $httpVars["downloadlimit"] = 0; + $maxdownload = $this->getFilteredOption("FILE_MAX_DOWNLOAD", $this->repository->getId()); + if(!isSet($httpVars["downloadlimit"]) || $httpVars["downloadlimit"] == 0){ + $httpVars["downloadlimit"] = $maxdownload; + }else{ + $httpVars["downloadlimit"] = min($maxdownload,floor(abs($httpVars["downloadlimit"]))); + } + $maxexpiration = $this->getFilteredOption("FILE_MAX_EXPIRATION", $this->repository->getId()); + if(!isSet($httpVars["expiration"]) || $httpVars["expiration"] == 0){ + $httpVars["expiration"] = $maxexpiration; + }else{ + $httpVars["expiration"] = min($maxexpiration,floor(abs($httpVars["expiration"]))); } + $data = $this->accessDriver->makePublicletOptions($file, $httpVars["password"], $httpVars["expiration"], $httpVars["downloadlimit"], $this->repository); $customData = array(); foreach($httpVars as $key => $value){ diff --git a/core/src/plugins/action.share/manifest.xml b/core/src/plugins/action.share/manifest.xml index 753e8b4cb2..1b9a60e50b 100644 --- a/core/src/plugins/action.share/manifest.xml +++ b/core/src/plugins/action.share/manifest.xml @@ -3,6 +3,8 @@ + +