Commit 2d2c9b99 authored by Ted Trask's avatar Ted Trask

Change listfiles filesize to size, size and mtime not user-friendly, use...

Change listfiles filesize to size, size and mtime not user-friendly, use posix.stat over fs.stat, use new format functions
parent e22d15e2
......@@ -3,20 +3,6 @@ htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>
<%
function convertsize(size)
if string.find(size, "k$") then
return tonumber(string.match(size, "[%d.]*")) * 1024.0
elseif string.find(size, "M$") then
return tonumber(string.match(size, "[%d.]*")) * 1024.0 * 1024.0
elseif string.find(size, "G$") then
return tonumber(string.match(size, "[%d.]*")) + 1024.0 * 1024.0 * 1024.0
else
return tonumber(string.match(size, "[%d.]*"))
end
end
%>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
......@@ -57,8 +43,8 @@ end %>
<tr>
<td><% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, redir=redir}, label="", option="Edit", action="edit"}), page_info, -1) %></td>
<td><%= html.html_escape(file.filename) %></td>
<td><span class="hide"><%= convertsize(file.size) %>b</span><%= html.html_escape(file.size) %></td>
<td><%= html.html_escape(file.mtime) %></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>
......
......@@ -150,7 +150,7 @@ end
mymodule.list_files = function()
local retval = {}
for file in fs.find(null, baseurl) do
local details = fs.stat(file)
local details = posix.stat(file)
if details.type == "regular" and not string.match(file, "logrotation$") and not string.match(file, "%.conf$") and not string.match(file, "%.gif$") then
details.filename = file
table.insert(retval, details)
......@@ -162,11 +162,13 @@ end
mymodule.list_config_files = function()
local list = {}
local details = fs.stat(dansguardiancfg) or {}
list[1] = { filename=dansguardiancfg, size = details.size or 0, mtime = details.mtime or "---" }
details = fs.stat(dansguardiancfg2) or {}
list[2] = { filename=dansguardiancfg2, size = details.size or 0, mtime = details.mtime or "---" }
return cfe({ type="list", value=list, label="List of Dansguardian config files" })
local details = posix.stat(dansguardiancfg) or {}
details.filename = dansguardiancfg
list[1] = details
details = posix.stat(dansguardiancfg2) or {}
details.filename = dansguardiancfg2
list[2] = details
return cfe({ type="structure", value=list, label="List of Dansguardian config files" })
end
--[[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment