X-Git-Url: https://git.rvb.name/lua-filemanager.git/blobdiff_plain/65a51927aff4f6341465667275a5d8fb30f5b782..2ab2f7398805613c07c9d31c2968537928b87a39:/www/cgi-bin/fs?ds=inline diff --git a/www/cgi-bin/fs b/www/cgi-bin/fs index 6e7d572..cee5f0f 100755 --- a/www/cgi-bin/fs +++ b/www/cgi-bin/fs @@ -91,26 +91,29 @@ if action == "list" then path = fs.realpath(basepath..'/'..params["path"]) - if is_in_dir(path,basepath) then + if path and is_in_dir(path,basepath) and fs.access(path,"r") then files = {} local rec for name in fs.dir(path) do - fstat=fs.stat(fs.realpath(path..'/'..name)) - if fstat["type"]=="reg" then - ftype="file" - elseif fstat["type"]=="dir" then - ftype="dir" - else - ftype="" - end - if ftype then - rec={name=name,rights=fstat["modestr"],size=fstat["size"],type=ftype,date=os.date('%Y-%m-%d %H:%M:%S',fstat["mtime"])} - table.insert(files,rec) - end + basename=fs.realpath(path..'/'..name) + if basename then + fstat=fs.stat(fs.realpath(path..'/'..name)) + if fstat["type"]=="reg" then + ftype="file" + elseif fstat["type"]=="dir" then + ftype="dir" + else + ftype="" + end + if ftype then + rec={name=name,rights=fstat["modestr"],size=fstat["size"],type=ftype,date=os.date('%Y-%m-%d %H:%M:%S',fstat["mtime"])} + table.insert(files,rec) + end + end end result = { result = files } else - result = { result = { success=false, error="Invalid path request" } } + result = { result = {} } end elseif action == "rename" then