projects
/
lua-filemanager.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Приведение в более приличный вид с выносом используемых базовых функций в отдельную...
[lua-filemanager.git]
/
www
/
cgi-bin
/
fs-download
diff --git
a/www/cgi-bin/fs-download
b/www/cgi-bin/fs-download
index 5ae634a5335dcafaba5a958af4791d80bf4eb9d8..d33ec96c98f335a3efa89f7ffcf619acf317d4c5 100755
(executable)
--- a/
www/cgi-bin/fs-download
+++ b/
www/cgi-bin/fs-download
@@
-2,17
+2,9
@@
nixio = require "nixio"
fs = require "nixio.fs"
nixio = require "nixio"
fs = require "nixio.fs"
-uci = require("uci")
util = require "luci.util"
ltn12 = require "ltn12"
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 = {}
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
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 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")
print("Content-Type: application/octet-stream")
print('Content-Disposition: attachment; filename="'..fs.basename(args["path"])..'"')
print("\r")