From 2ab2f7398805613c07c9d31c2968537928b87a39 Mon Sep 17 00:00:00 2001 From: Roman Bazalevskiy Date: Wed, 10 Oct 2018 10:17:08 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20?= =?utf8?q?=D0=BF=D1=80=D0=B0=D0=B2,=20=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20?= =?utf8?q?=D0=BD=D0=B5=20=D0=BF=D1=8B=D1=82=D0=B0=D1=82=D1=8C=D1=81=D1=8F?= =?utf8?q?=20=D1=87=D0=B8=D1=82=D0=B0=D1=82=D1=8C=20=D0=BD=D0=B5=D0=B4?= =?utf8?q?=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=B0?= =?utf8?q?=D1=82=D0=B0=D0=BB=D0=BE=D0=B3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- www/cgi-bin/fs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) 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 -- 2.34.1