From 4837cd73c1d79b17af443e0335cc04259505cd23 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 7 May 2008 15:10:35 +0000 Subject: 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 --- dansguardian-advanced-html.lsp | 14 ------- dansguardian-category-html.lsp | 75 ++++++++++++++---------------------- dansguardian-controller.lua | 71 ++++++++++++++++++++++++++++------ dansguardian-editcategories-html.lsp | 61 +++++++++++++++++++++++++++++ dansguardian-general-html.lsp | 13 ------- dansguardian-model.lua | 45 +++++++++++++++++++--- dansguardian-status-html.lsp | 32 +++++++++++++++ dansguardian.menu | 1 + dansguardian.roles | 3 +- 9 files changed, 223 insertions(+), 92 deletions(-) create mode 100644 dansguardian-editcategories-html.lsp create mode 100644 dansguardian-status-html.lsp 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") ?> -

General Information

-

-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. -

-

-This page lets you manually configure the filter rule files for DansGuardian. -

-

Configuration

0) then ?>

Errors

@@ -58,7 +45,6 @@ This page lets you manually configure the filter rule files for DansGuardian. -

Files

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") ?> -

General Information

-

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. -This page lets you manually add/remove categories for DansGuardian.

+

Modify Categories

-

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 applied -until you restart the service.

- -

Categories

-

Add Category

-

-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.) -

-
-
Category name
-
Category files
weighted banned exception
- -
- -

-

- -

Delete Category

-

-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. -

+

Category list

-
Categories available
(please check the ones you want to delete) " .. v .. "\n" ) - end -?> -
- "..v.name.."\n") + io.write("
") + if (v.option) then + for k1,v1 in pairs(v.option) do + io.write("" ) +-- for k2,v2 in pairs(v1) do + --io.write(html.form(v1.type(v1))) +-- io.write("") +-- end + io.write("\n") + end + io.write("\n" ) + end + io.write("
".. v1.name .. "[ Edit ]") +-- io.write("[ " ..html.link(v2) .. " ] ") +-- io.write(tostring(v2)) +-- io.write("
") +--io.write( "
" .. v .. "\n" ) +end ?>
+

MANAGEMENT

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 @@ + +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +?> + +

SYSTEM INFO

+
+ +
+ + + +

CONFIGURATION

+

Expert config

+

File details

+
+ +
+ +

FILE CONTENT

+') +io.write(html.form[myform.filecontent.type](myform.filecontent)) +?> + +

SAVE AND APPLY ABOVE SETTINGS

+
+ +
+ +MANAGEMENT\n
") + displaymanagement(myform,tags) + io.write("
") +end +?> + + + 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") ?>
-

General Information

-

-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. -

-This page defines the basic network configuration settings for DansGuardian. -

- -

Configuration

General

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 @@ + + +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +?> + +

SYSTEM INFO

+
+ +
+ +

General Information

+

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.

+ +

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 applied +until you restart the service.

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 -- cgit v1.2.3