X-Git-Url: https://git.rvb.name/lua-filemanager.git/blobdiff_plain/58d2e066a4ba8b791001a5dd44e7102a55b48cf0..2ab2f7398805613c07c9d31c2968537928b87a39:/www/cgi-bin/fs?ds=sidebyside diff --git a/www/cgi-bin/fs b/www/cgi-bin/fs index 669ebd0..cee5f0f 100755 --- a/www/cgi-bin/fs +++ b/www/cgi-bin/fs @@ -91,22 +91,25 @@ 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