Commit 4837cd73 authored by Mika Havela's avatar Mika Havela

Saving work for today.

Sketching on a idea on howto edit categories (now showing if a category exists but is not configured to be used/activated in the main config).

git-svn-id: svn://svn.alpinelinux.org/acf/dansguardian/trunk@1109 ab2d0c66-481e-0410-8bed-d214d4d58bed
parent 210f1c93
......@@ -37,19 +37,6 @@ displayinfo(myform,tags,"viewonly")
?>
</DL>
<h2>General Information</h2>
<p>
DansGuardian is web content filtering software. It works as a web proxy,
making web requests in behalf of the client, and inspecting the returned
content before passing on to the client. DansGuardian uses phraselists to
identify harmful content. This means that updated "blacklists" are
generally not necessary. DansGuardian must be used in combination with a
"smart proxy", such as squid.
</p>
<p>
This page lets you manually configure the filter rule files for DansGuardian.
</p>
<h1>Configuration</h1>
<? if (#service.cfgerr > 0) then ?>
<h2>Errors</h2>
......@@ -58,7 +45,6 @@ This page lets you manually configure the filter rule files for DansGuardian.
</DL>
<? end ?>
<h2>Files</h2>
<DL>
<TABLE>
<TR style="background:#eee;font-weight:bold;">
......
......@@ -37,61 +37,42 @@ displayinfo(myform,tags,"viewonly")
?>
</DL>
<h2>General Information</h2>
<p>DansGuardian is web content filtering software. It works as a web proxy,
making web requests in behalf of the client, and inspecting the returned
content before passing on to the client. DansGuardian uses phraselists to
identify harmful content. This means that updated "blacklists" are
generally not necessary. DansGuardian must be used in combination with a
"smart proxy", such as squid.
<b>This page lets you manually add/remove categories for DansGuardian.</b></p>
<h1>Modify Categories</h1>
<p>This process runs as a service. When you make and save changes, the configuration
files for the service are changed. However, the changes will not be <i>applied</i>
until you restart the service.</p>
<h1>Categories</h1>
<h2>Add Category</h2>
<p>
To add a category, or to add a file to an existing category, please fill in the corresponding information below.
(Due to a limitation with DansGuardian, all categories must be lowercase.)
</p>
<dl>
<dt>Category name</dt><dd><input class="text" type="text" name="newcat" value=""></dd>
<dt>Category files</dt><dd><input type="checkbox" name="cattype" value="w">weighted <input type="checkbox" name="cattype" value="b">banned <input type="checkbox" name="cattype" value="e">exception</dd>
<?
local myform = form.service
local tags = { "cmdadd", }
displayinfo(myform,tags)
?>
</dl>
<p><pre class=error><? io.write( service.cfgerr ) ?></pre></p>
<p></p>
<h2>Delete Category</h2>
<p>
Select the categories you wish to delete. Please note that this deletes the category, but does not
delete the link in the corresponding phraselist above. You will also need to edit the phraselist file
above if you delete a category.
</p>
<h2>Category list</h2>
<form action="" method="POST">
<dl>
<dt>Categories available</dt><dd>(please check the ones you want to delete)
<?
for k,v in ipairs( config ) do
io.write( "<BR><input type=\"checkbox\" name=\"cats\" value=\"" .. v .. "\"> " .. v .. "\n" )
end
?>
</DD>
<?
local myform = form.service
local tags = { "cmddelete", }
displayinfo(myform,tags)
local myform = form["service"]["config"]["categories"]["value"]
for k,v in ipairs( myform ) do
io.write("<DT ")
if not (v.active) then io.write("CLASS='error'") end
io.write("><img src='/static/tango/16x16/categories/applications-system.png' height='16' width='16'> "..v.name.."</DT>\n")
io.write("<DD><TABLE>")
if (v.option) then
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>" )
-- for k2,v2 in pairs(v1) do
--io.write(html.form(v1.type(v1)))
-- io.write("<TD>")
-- io.write("[ " ..html.link(v2) .. " ] ")
-- io.write(tostring(v2))
-- io.write("</TD>")
-- end
io.write("</TR>\n")
end
io.write("<TR><TD STYLE='font-weight:bold;' WIDTH='180px'><INPUT TYPE='text' CLASS='text'></TD><TD><INPUT TYPE='submit' CLASS='submit' VALUE='Create' disabled></TD></TD></TR>\n" )
end
io.write("</TABLE></DD>")
--io.write( "<BR><input type=\"checkbox\" name=\"cats\" value=\"" .. v .. "\"> " .. v .. "\n" )
end
?>
</dl>
</form>
<h1>MANAGEMENT</h1>
<form action="" method="POST">
<dl>
......
......@@ -2,8 +2,26 @@
module (..., package.seeall)
default_action = "general"
default_action = "status"
status = function( self )
local info = {
status=self.model.get_status(),
version = self.model.get_dansguardian_version(),
autostart = self.model.get_autostart(),
srvctrl = { value = srvctrl}
}
local option = { script = ENV["SCRIPT_NAME"],
prefix = self.conf.prefix,
controller = self.conf.controller,
action = self.conf.action,
extra = ""
}
return ( cfe ({ option = option, info = info }) )
end
general = function( self )
local service = {}
......@@ -190,21 +208,50 @@ category = function( self )
label="Action",
value="Add",
type="submit",
disabled="yes",
errtxt="This button is currently out of order",
})
service.cmddelete = cfe({
name="cmddelete",
label="Action",
value="Delete",
type="submit",
disabled="yes",
errtxt="This button is currently out of order",
service.cmdaddvalue = cfe({
name="cmdaddvalue",
value="",
type="text",
})
service.config = self.model.get_categories()
service.config = {}
service.config.categories = cfe({
name="categories",
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
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 option = { script = ENV["SCRIPT_NAME"],
prefix = self.conf.prefix,
controller = self.conf.controller,
action = self.conf.action,
extra = ""
}
return ( cfe ({ option = option, info = info }) )
end
<? local form = ...
require("viewfunctions")
?>
<?
---[[ 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>
<DL>
<?
local myform = form.info
local tags = { "status", "version", "autostart", }
displayinfo(myform,tags,"viewonly")
?>
</DL>
<? --[[ ?>
<form name="myform" action="" method="POST">
<h1>CONFIGURATION</h1>
<H2>Expert config</H2>
<h3>File details</h3>
<DL>
<?
local myform = form.file
local tags = { "filename", "filesize", "mtime", "sumerrors", }
displayinfo(myform,tags,"viewonly")
?>
</DL>
<H3>FILE CONTENT</H3>
<?
local myform = form.file
io.write('<input type="hidden" value="' .. myform.filename.value .. '" name="name">')
io.write(html.form[myform.filecontent.type](myform.filecontent))
?>
<H2>SAVE AND APPLY ABOVE SETTINGS</H2>
<DL>
<?
local tags = { "cmddelete", "cmdsave", }
displayinfo(myform,tags)
?>
</DL>
<?
-- Management buttons
local myform = form.management
local tags = { "start", "stop", "restart" }
if (myform) then
io.write("<H1>MANAGEMENT</H1>\n<DL>")
displaymanagement(myform,tags)
io.write("</DL>")
end
?>
</form>
<? --]] ?>
......@@ -37,19 +37,6 @@ displayinfo(myform,tags,"viewonly")
?>
</DL>
<h2>General Information</h2>
<p>
DansGuardian is web content filtering software. It works as a web proxy,
making web requests in behalf of the client, and inspecting the returned
content before passing on to the client. DansGuardian uses phraselists to
identify harmful content. This means that updated "blacklists" are
generally not necessary. DansGuardian must be used in combination with a
"smart proxy", such as squid.
</p><p>
This page defines the basic network configuration settings for DansGuardian.
</p>
<form action="" method="POST">
<h1>Configuration</h1>
<h2>General</h2>
......
......@@ -13,6 +13,25 @@ dansguardiancfg = "/etc/dansguardian/dansguardian.conf"
dansguardiancfg2 = "/etc/dansguardian/dansguardianf1.conf"
local processname = "dansguardian"
local packagename = "dansguardian"
local baseurl = "/etc/dansguardian" -- Without trailing /
-- ################################################################################
-- LOCAL FUNCTIONS
local function get_includes_from_file(file)
local retval = {}
for k,v in pairs(fs.read_file_as_array(file)) do
if (string.match(v, '^%s*.Include')) then
local val = string.match(v,'^%s*.Include<(.*)>%s*')
retval[val] = true
end
end
return retval
end
-- ################################################################################
-- PUBLIC FUNCTIONS
get_autostart = function()
local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname)
......@@ -355,16 +374,32 @@ 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( "/etc/dansguardian/phraselists" )
local k = ""
local v = ""
local entries = posix.dir( baseurl .. "/phraselists" )
for k,v in ipairs( entries ) do
local attrs = posix.stat( "/etc/dansguardian/phraselists/" .. v )
local attrs = posix.stat( baseurl .. "/phraselists/" .. v )
if attrs.type == "directory" and v ~= "." and v ~= ".." then
table.insert( retval, v )
local entrycontent = {}
local someactive = false
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
active = true
someactive = true
end
table.insert(entrycontent, {name=v1, active=active, mhdebug=string.match(v1,'%w*'),mhdebug2=baseurl .. "/phraselists/" .. v .."/" .. v1})
end
end
table.insert( retval, {name=v, option=entrycontent, active=someactive} )
end
end
......
<? local form = ...
require("viewfunctions")
?>
<?
--[[ 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>
<DL>
<?
local myform = form.info
local tags = { "status", "version", "autostart", }
displayinfo(myform,tags,"viewonly")
?>
</DL>
<h2>General Information</h2>
<p>DansGuardian is web content filtering software.<BR>It works as a web proxy,
making web requests in behalf of the client, and inspecting the returned
content before passing on to the client.<BR>DansGuardian uses phraselists to
identify harmful content.<BR>This means that updated "blacklists" are
generally not necessary.<BR>DansGuardian must be used in combination with a
"smart proxy", such as squid.</p>
<p>This process runs as a service.<BR>When you make and save changes, the configuration
files for the service are changed.<BR>However, the changes will not be <i>applied</i>
until you restart the service.</p>
# Prefix and controller are already known at this point
# Cat Group Tab Action
Applications 20Content_Filter Status status
Applications 20Content_Filter Basic general
Applications 20Content_Filter Advanced advanced
Applications 20Content_Filter Plain plain
......
UPDATE=dansguardian:general,dansguardian:advanced,dansguardian:plain,dansguardian:edit,dansguardian:category
READ=dansguardian:status
UPDATE=dansguardian:general,dansguardian:advanced,dansguardian:plain,dansguardian:edit,dansguardian:category,dansguardian:editcategories
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