diff options
-rw-r--r-- | dansguardian-advanced-html.lsp | 14 | ||||
-rw-r--r-- | dansguardian-category-html.lsp | 75 | ||||
-rw-r--r-- | dansguardian-controller.lua | 71 | ||||
-rw-r--r-- | dansguardian-editcategories-html.lsp | 61 | ||||
-rw-r--r-- | dansguardian-general-html.lsp | 13 | ||||
-rw-r--r-- | dansguardian-model.lua | 45 | ||||
-rw-r--r-- | dansguardian-status-html.lsp | 32 | ||||
-rw-r--r-- | dansguardian.menu | 1 | ||||
-rw-r--r-- | dansguardian.roles | 3 |
9 files changed, 223 insertions, 92 deletions
diff --git a/dansguardian-advanced-html.lsp b/dansguardian-advanced-html.lsp index 73e6015..6c67f47 100644 --- a/dansguardian-advanced-html.lsp +++ b/dansguardian-advanced-html.lsp @@ -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;"> diff --git a/dansguardian-category-html.lsp b/dansguardian-category-html.lsp index 1edcc71..66c972d 100644 --- a/dansguardian-category-html.lsp +++ b/dansguardian-category-html.lsp @@ -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> diff --git a/dansguardian-controller.lua b/dansguardian-controller.lua index 9b19314..e647954 100644 --- a/dansguardian-controller.lua +++ b/dansguardian-controller.lua @@ -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 + diff --git a/dansguardian-editcategories-html.lsp b/dansguardian-editcategories-html.lsp new file mode 100644 index 0000000..1421cf4 --- /dev/null +++ b/dansguardian-editcategories-html.lsp @@ -0,0 +1,61 @@ +<? 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> +<? --]] ?> + diff --git a/dansguardian-general-html.lsp b/dansguardian-general-html.lsp index 2a4ca5c..a5c1aa0 100644 --- a/dansguardian-general-html.lsp +++ b/dansguardian-general-html.lsp @@ -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> diff --git a/dansguardian-model.lua b/dansguardian-model.lua index b02b99b..73c2b2c 100644 --- a/dansguardian-model.lua +++ b/dansguardian-model.lua @@ -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 diff --git a/dansguardian-status-html.lsp b/dansguardian-status-html.lsp new file mode 100644 index 0000000..2b35a51 --- /dev/null +++ b/dansguardian-status-html.lsp @@ -0,0 +1,32 @@ +<? 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> diff --git a/dansguardian.menu b/dansguardian.menu index d7d6be2..e4e6a4e 100644 --- a/dansguardian.menu +++ b/dansguardian.menu @@ -1,5 +1,6 @@ # 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 diff --git a/dansguardian.roles b/dansguardian.roles index 4ce3b76..a8db1c9 100644 --- a/dansguardian.roles +++ b/dansguardian.roles @@ -1 +1,2 @@ -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 |