From 6c7535292be50625ce01d10d2c7e2512e605cf9f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 25 Oct 2010 23:19:00 +0000 Subject: [PATCH] applications/luci-vnstat: minor tweaks --- applications/luci-vnstat/luasrc/view/vnstat.htm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/applications/luci-vnstat/luasrc/view/vnstat.htm b/applications/luci-vnstat/luasrc/view/vnstat.htm index 440252caa..91fd33223 100644 --- a/applications/luci-vnstat/luasrc/view/vnstat.htm +++ b/applications/luci-vnstat/luasrc/view/vnstat.htm @@ -28,9 +28,12 @@ style = (style and #style > 0) and style or "s" -- render image -- if iface then + style = style:gsub("[^%w]", "") + iface = iface:gsub("[^%w%.%-]", "") + luci.http.prepare_content("image/png") - local png = io.popen("vnstati -i %q -%q -o -" % { iface, style }) + local png = io.popen("vnstati -i '%s' '-%s' -o -" % { iface, style }) luci.http.write(png:read("*a")) png:close() @@ -79,10 +82,18 @@ dbdir = dbdir or "/var/lib/vnstat"


-<% for iface in fs.dir(dbdir) do if iface:sub(1,1) ~= "." then %> +<% empty = true + for iface in fs.dir(dbdir) do if iface:sub(1,1) ~= "." then + empty = false +%>

<% end end %> + +<% if empty then %> +

<%:No database has been set up yet. Go to the VnStat configuration and enable monitoring for one or more interfaces.%>

+<% end %> +
<%+footer%> -- 2.11.0