X-Git-Url: https://git.rvb.name/lua-filemanager.git/blobdiff_plain/2ab2f7398805613c07c9d31c2968537928b87a39..8ae76db7435b037ba94af69023adc7f795f51691:/www/cgi-bin/fs-download?ds=sidebyside diff --git a/www/cgi-bin/fs-download b/www/cgi-bin/fs-download index 5ae634a..d33ec96 100755 --- a/www/cgi-bin/fs-download +++ b/www/cgi-bin/fs-download @@ -2,17 +2,9 @@ nixio = require "nixio" fs = require "nixio.fs" -uci = require("uci") util = require "luci.util" ltn12 = require "ltn12" - -local function is_in_dir(file, dir) - if file == dir then - return true - else - return file:sub(1, #dir) == dir - end -end +luafm = require "luafm" args = {} @@ -21,17 +13,14 @@ for dummy,param in pairs(util.split(nixio.getenv('QUERY_STRING'),'&')) do args[val[1]] = util.urldecode(val[2],true) end -local u_c = uci.cursor() -local basepath = u_c.get("filemanager","config","basedir") - -path = fs.realpath(basepath..'/'..args["path"]) +path = luafm.make_path(args["path"]) if path then file = io.open(path,"rb") else file = nil end -if file and is_in_dir(path,basepath) then +if file then print("Content-Type: application/octet-stream") print('Content-Disposition: attachment; filename="'..fs.basename(args["path"])..'"') print("\r")