Commit ac11c151 authored by Mika Havela's avatar Mika Havela

When looking at a category-object, you now see if the reason why it's marked...

When looking at a category-object, you now see if the reason why it's marked red or not (by clicking on the object).
You also see the content and other information about the category object.

git-svn-id: svn://svn.alpinelinux.org/acf/dansguardian/trunk@1113 ab2d0c66-481e-0410-8bed-d214d4d58bed
parent 4837cd73
......@@ -43,7 +43,7 @@ displayinfo(myform,tags,"viewonly")
<form action="" method="POST">
<dl>
<?
local myform = form["service"]["config"]["categories"]["value"]
local myform = form["service"]["config"]["categories"]
for k,v in ipairs( myform ) do
io.write("<DT ")
if not (v.active) then io.write("CLASS='error'") end
......@@ -53,7 +53,7 @@ for k,v in ipairs( myform ) do
for k1,v1 in pairs(v.option) do
io.write("<TR><TD STYLE='font-weight:bold;' WIDTH='180px' ")
if not (v1.active) then io.write("CLASS='error'") end
io.write(">".. v1.name .. "</TD><TD>[ <A HREF='editcategories?phrase=".. v.name .. "&object=".. v1.name .. "'>Edit</A> ]</TD></TD>" )
io.write(">".. v1.name .. "</TD><TD>[ <A HREF='editcategories?category=".. v.name .. "&object=".. v1.name .. "'>Edit</A> ]</TD></TD>" )
-- for k2,v2 in pairs(v1) do
--io.write(html.form(v1.type(v1)))
-- io.write("<TD>")
......
......@@ -222,28 +222,34 @@ category = function( self )
label="Categories available",
value={},
})
for k,v in pairs(self.model.get_categories()) do
local types = { weighted, banned, exception }
-- for k,v in pairs(types) do
-- if (fs.is_file(
--table.insert(weighted, cfe({type="link", value="value", name="name", label="label",}))
-- end
table.insert(service.config.categories.value, v )
end
service.config.categories = self.model.get_categories()
return ( cfe ({ option = option, service = service, info = info }) )
end
editcategories = function( self )
local info = {
status=self.model.get_status(),
version = self.model.get_dansguardian_version(),
autostart = self.model.get_autostart(),
srvctrl = { value = srvctrl}
}
local info = self.model.get_category(self.clientdata.category, self.clientdata.object)
if not (info) then
redirect(self, "category")
end
-- Add a cmd button to the view
info.cmdsave = cfe({ name="cmdsave",
label="Save/Apply above settings",
value="Save",
type="submit",
disabled="yes",
errtxt="This button is not configured to work",
})
info.cmddelete = cfe({ name="cmddelete",
label="Permanently remove object",
value="Delete",
type="submit",
disabled="yes",
errtxt="This button is not configured to work",
})
local option = { script = ENV["SCRIPT_NAME"],
prefix = self.conf.prefix,
......@@ -252,6 +258,6 @@ editcategories = function( self )
extra = ""
}
return ( cfe ({ option = option, info = info }) )
return ( cfe ({ option = option, info = info, mhdebug=self.clientdata }) )
end
......@@ -2,22 +2,59 @@
require("viewfunctions")
?>
<?
---[[ DEBUG INFORMATION
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
?>
<H1>SYSTEM INFO</H1>
<H1>INFO</H1>
<DL>
<?
local myform = form.info
local tags = { "status", "version", "autostart", }
local tags = { "configfile","mtime","category", "name", "activestatus", }
displayinfo(myform,tags,"viewonly")
?>
</DL>
<H1>CONFIGURE</H1>
<H2>General</H2>
<DL>
<?
local myform = form.info
local tags = { "activate" }
displayinfo(myform,tags)
?>
</DL>
<H2>Details</H2>
<?
local myform = form.info
io.write('<input type="hidden" value="' .. myform.filename.value .. '" name="name">')
io.write(html.form[myform.filecontent.type](myform.filecontent))
?>
<H2>Save</H2>
<DL>
<?
local myform = form.info
local tags = { "cmdsave" }
displayinfo(myform,tags)
?>
</DL>
<H1>Delete</H1>
<p>You can delete this object. This will result in erazing instead of deactivating it.</p>
<p>When deleting a object, you will not be able to get it back! If you are unsure, it's better to only deactivate this object instead of deleting it.</p>
<DL>
<?
local myform = form.info
local tags = { "cmddelete" }
displayinfo(myform,tags)
?>
</DL>
<? --[[ ?>
<form name="myform" action="" method="POST">
<h1>CONFIGURATION</h1>
......
......@@ -6,7 +6,9 @@ require "posix"
require "format"
require("processinfo")
require("procps")
require("fs")
require("daemoncontrol")
require("validator")
-- Set variables
dansguardiancfg = "/etc/dansguardian/dansguardian.conf"
......@@ -14,7 +16,11 @@ dansguardiancfg2 = "/etc/dansguardian/dansguardianf1.conf"
local processname = "dansguardian"
local packagename = "dansguardian"
local baseurl = "/etc/dansguardian" -- Without trailing /
local categoryfiles = {
['weighted'] = tostring(baseurl .. "/weightedphraselist"),
['banned'] = tostring(baseurl .. "/bannedphraselist"),
['exception'] = tostring(baseurl .. "/exceptionphraselist"),
}
-- ################################################################################
-- LOCAL FUNCTIONS
......@@ -30,6 +36,13 @@ local function get_includes_from_file(file)
return retval
end
local categoryfilecontent = {
['weighted'] = get_includes_from_file(categoryfiles['weighted']),
['banned'] = get_includes_from_file(categoryfiles['banned']),
['exception'] = get_includes_from_file(categoryfiles['exception']),
}
-- ################################################################################
-- PUBLIC FUNCTIONS
......@@ -374,11 +387,6 @@ is_valid_configfile = function( name )
end
get_categories = function()
local phrases = {}
phrases.weighted = get_includes_from_file(baseurl .. "/weightedphraselist")
phrases.banned = get_includes_from_file(baseurl .. "/bannedphraselist")
phrases.exception = get_includes_from_file(baseurl .. "/exceptionphraselist")
local retval = {}
local entries = posix.dir( baseurl .. "/phraselists" )
......@@ -392,7 +400,7 @@ get_categories = function()
for k1,v1 in pairs(posix.dir( baseurl .. "/phraselists/" .. v )) do
if not string.match(v1, "^%.") then
local active
if (phrases[string.match(v1,'%w*')][baseurl .. "/phraselists/" .. v .."/" .. v1]) then
if (categoryfilecontent[string.match(v1,'%w*')][baseurl .. "/phraselists/" .. v .."/" .. v1]) then
active = true
someactive = true
end
......@@ -406,3 +414,65 @@ get_categories = function()
return retval
end
get_category = function(category, object)
local filename = baseurl .. "/phraselists/" .. category .. "/" .. object
if not (categoryfilecontent[string.match(object,'%w*')]) or
not (fs.is_file(filename)) or
not (validator.is_valid_filename(filename, baseurl)) then
return nil, "Something went wrong."
end
local retval = {}
retval.activate = cfe({
label="Activate this object",
type="checkbox",
checked="yes",
})
if not (categoryfilecontent[string.match(object,'%w*')][filename]) then
retval.activestatus = cfe({
label="Category object is currently",
errtxt = "Deactivated",
})
retval.activate.checked=nil
end
retval.configfile = cfe({
label="Activation is done in",
value=categoryfiles[string.match(object,'%w*')],
})
local filedetails = fs.stat(filename)
retval.mtime = cfe({
label="Modify date",
value=filedetails.mtime,
})
retval.category = cfe({
name="category",
label="Category name",
value=category,
})
retval.name = cfe({
name="name",
label="Object name",
value=object,
})
retval.filename = cfe({
name="filename",
label="Filename",
type="hidden",
value=filename,
})
retval.filecontent = cfe({
label="Filename",
value=fs.read_file(filename),
type="longtext",
})
return retval
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