blob: e637023a1930fc690dc856f8ff002441ef30a212 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-- acf model for displaying logfiles recusivly
module (..., package.seeall)
local function set_skins(skin)
local cmd = "/bin/sed -i 's/skin=.*/skin=" .. skin .. "/' /etc/acf/acf.conf"
local f, errtxt = io.popen(cmd)
local cmdoutput = f:read("*a")
f:close()
return cfe({ value=cmdoutput, errtxt=errtxt, label="Set skin result" })
end
local function list_skins()
local path = "/usr/share/acf/www/skins/"
local skinarray = {}
for i,file in ipairs(posix.dir(path) or {}) do
-- Ignore files that begins with a '.' and 'cgi-bin' and only list folders
if not ((string.match(file, "^%.")) or (string.match(file, "^cgi[-]bin")) or (string.match(file, "^static")) or (posix.stat(path .. file).type ~= "directory")) then
local entry = cfe({ value=file, label="Skin name" })
local current = conf.skin
entry.inuse = (file == current)
table.insert(skinarray, entry)
end
end
return cfe({ type="list", value=skinarray, label="Skins" })
end
get = function ()
return list_skins()
end
update = function (newskin)
-- Make sure no one can inject code into the model.
local availableskins = list_skins()
for i,skin in ipairs(availableskins.value) do
if ( skin.value == newskin) then
return set_skins(newskin)
end
end
end
|