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-upload
diff --git
a/www/cgi-bin/fs-upload
b/www/cgi-bin/fs-upload
index 46d047ea026b841c4ad24a711b37af0e091067fe..101c841d27f1182a509b18c2863449a926dbe868 100755
(executable)
--- a/
www/cgi-bin/fs-upload
+++ b/
www/cgi-bin/fs-upload
@@
-1,21
+1,11
@@
#!/usr/bin/lua
local cgi = require "cgi"
#!/usr/bin/lua
local cgi = require "cgi"
-local uci = require("uci")
-local fs = require("nixio.fs")
-local os = require("os")
-local json = require("json")
+local fs = require "nixio.fs"
+local luafm = require "luafm"
local req = {}
local req = {}
-local function is_in_dir(file, dir)
- if file == dir then
- return true
- else
- return file:sub(1, #dir) == dir
- end
-end
-
print("\r")
cgi.new(req)
print("\r")
cgi.new(req)
@@
-27,15
+17,11
@@
end
destfile=io.open(req.post["destination"][1]["tempname"],"r")
destination=destfile:read("*all")
destfile=io.open(req.post["destination"][1]["tempname"],"r")
destination=destfile:read("*all")
-local u_c = uci.cursor()
-local basepath = u_c.get("filemanager","config","basedir")
-
for k, v in pairs(req.post) do
for j, v in pairs(req.post[k]) do
if v["filename"] then
for k, v in pairs(req.post) do
for j, v in pairs(req.post[k]) do
if v["filename"] then
- path = basepath..destination..'/'..v.filename
- dir = fs.realpath(fs.dirname(path))
- if dir and is_in_dir(dir,basepath) then
+ path = luafm.make_new_path(destination..'/'..v.filename)
+ if path then
fs.copy(req.post[k][j].tempname, path)
end
end
fs.copy(req.post[k][j].tempname, path)
end
end