diff options
-rw-r--r-- | tcpproxy-listsmtpfiles-html.lsp | 8 | ||||
-rw-r--r-- | tcpproxy-model.lua | 30 |
2 files changed, 26 insertions, 12 deletions
diff --git a/tcpproxy-listsmtpfiles-html.lsp b/tcpproxy-listsmtpfiles-html.lsp index a303f47..ac8de32 100644 --- a/tcpproxy-listsmtpfiles-html.lsp +++ b/tcpproxy-listsmtpfiles-html.lsp @@ -29,6 +29,8 @@ html = require("acf.html") <tr> <th>Action</th> <th>File</th> + <th>Size</th> + <th>Last Modified</th> </tr> </thead><tbody> <% local filename = cfe({ type="hidden", value="" }) %> @@ -37,7 +39,7 @@ html = require("acf.html") <tr> <td> <% - filename.value = file + filename.value = file.filename if viewlibrary.check_permission("editsmtpfile") then htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, redir=redir}, label="", option="Edit", action="editsmtpfile"}), page_info, -1) end @@ -46,7 +48,9 @@ html = require("acf.html") end %> </td> - <td><%= html.html_escape(file) %></td> + <td><%= html.html_escape(file.filename) %></td> + <td><span class="hide"><%= html.html_escape(file.size or 0) %>b</span><%= format.formatfilesize(file.size) %></td> + <td><%= format.formattime(file.mtime) %></td> </tr> <% end %> </tbody></table> diff --git a/tcpproxy-model.lua b/tcpproxy-model.lua index ecd7017..299d29e 100644 --- a/tcpproxy-model.lua +++ b/tcpproxy-model.lua @@ -186,6 +186,17 @@ local function getsmtpcmd(ipaddr) return exec end +local getfilelist = function() + local filelist = {} + if not fs.is_dir(smtpdirectory) then fs.create_directory(smtpdirectory) end + for file in posix.files(smtpdirectory) do + if fs.is_file(smtpdirectory .. file) then + table.insert(filelist, smtpdirectory .. file) + end + end + return filelist +end + -- ################################################################################ -- PUBLIC FUNCTIONS @@ -256,17 +267,17 @@ end function mymodule.readsmtpentry(ipaddr) local exec = getsmtpcmd(ipaddr) - local listfiles = mymodule.listsmtpfiles() - table.insert(listfiles.value, 1, "") + local listfiles = getfilelist() + table.insert(listfiles, 1, "") local ipaddrcfe = cfe({ value=ipaddr, label="Interface / IP Address", readonly=true, seq=0 }) local server = cfe({ label="SMTP Server", descr="Domain name / address of different machine or local binary", seq=1 }) local addressonly = cfe({ type="boolean", value=false, label="Address Only", descr="Removes everything in the from field except address", seq=2 }) local domain = cfe({ label="Custom Domain", seq=3 }) local optionalserver = cfe({ label="Custom Domain Server", descr="Use this SMTP server[:port] for e-mails to Custom Domain", seq=4 }) - local optionalrewritelist = cfe({ type="select", label="Custom Domain Rewrite List", descr="File with a list for sender rewriting for Custom Domain", option=listfiles.value, seq=5 }) - local senderlistfile = cfe({ type="select", label="Sender List File", descr="File with a list for sender rewriting (and valid senders)", option=listfiles.value, seq=6 }) - local rcptlistfile = cfe({ type="select", label="Recipient List File", descr="File with a list for recipient rewriting (and valid recipients)", option=listfiles.value, seq=7 }) + local optionalrewritelist = cfe({ type="select", label="Custom Domain Rewrite List", descr="File with a list for sender rewriting for Custom Domain", option=listfiles, seq=5 }) + local senderlistfile = cfe({ type="select", label="Sender List File", descr="File with a list for sender rewriting (and valid senders)", option=listfiles, seq=6 }) + local rcptlistfile = cfe({ type="select", label="Recipient List File", descr="File with a list for recipient rewriting (and valid recipients)", option=listfiles, seq=7 }) if exec and exec ~= "" then local options = parsesmtpcmd(exec) @@ -347,11 +358,10 @@ end function mymodule.listsmtpfiles() local retval = cfe({ type="list", value={}, label="SMTP Proxy Files" }) - if not fs.is_dir(smtpdirectory) then fs.create_directory(smtpdirectory) end - for file in posix.files(smtpdirectory) do - if fs.is_file(smtpdirectory .. file) then - table.insert(retval.value, smtpdirectory .. file) - end + for i,file in ipairs(getfilelist()) do + local filedetails = posix.stat(file) + filedetails.filename = file + table.insert(retval.value, filedetails) end return retval end |