summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-08-12 15:53:20 +0000
committerTed Trask <ttrask01@yahoo.com>2008-08-12 15:53:20 +0000
commit7ccca7213d3137b0764ef02165c44f4bd3373f45 (patch)
tree72f8ec88e7e5242abc5196043f21552d07e66f0f
parenta538c188976821b77959aadbcfc7ce0639f0aa24 (diff)
downloadacf-dansguardian-7ccca7213d3137b0764ef02165c44f4bd3373f45.tar.bz2
acf-dansguardian-7ccca7213d3137b0764ef02165c44f4bd3373f45.tar.xz
Modified dansguardian to use new status, startstop, and expert (replaced plain) actions.
git-svn-id: svn://svn.alpinelinux.org/acf/dansguardian/trunk@1380 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--dansguardian-advanced-html.lsp40
-rw-r--r--dansguardian-category-html.lsp42
-rw-r--r--dansguardian-controller.lua152
-rw-r--r--dansguardian-edit-html.lsp15
l---------dansguardian-expert-html.lsp1
-rw-r--r--dansguardian-general-html.lsp39
-rw-r--r--dansguardian-model.lua81
-rw-r--r--dansguardian-plain-html.lsp83
l---------dansguardian-startstop-html.lsp1
l---------[-rw-r--r--]dansguardian-status-html.lsp33
-rw-r--r--dansguardian.menu2
-rw-r--r--dansguardian.roles2
12 files changed, 49 insertions, 442 deletions
diff --git a/dansguardian-advanced-html.lsp b/dansguardian-advanced-html.lsp
index 7316774..24dd8fb 100644
--- a/dansguardian-advanced-html.lsp
+++ b/dansguardian-advanced-html.lsp
@@ -1,26 +1,13 @@
<%
require("viewfunctions")
- local form = ...
+ local form, viewlibrary = ...
local data = form.option
local service = form.service
local config = form.service.config
- local srv1fill = ""
- local srv2fill = "disabled"
- if form.info.status.value == "Enabled" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
- local ifthen = function( variable, value, result )
- if variable == value then
- io.write( result )
- end
- end
-
%>
-<%
+<%
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
io.write(html.cfe_unpack(form))
@@ -28,14 +15,9 @@ io.write("</span>")
--]]
%>
-<H1>SYSTEM INFO</H1>
-<DL>
-<%
-local myform = form.info
-local tags = { "status", "version", "autostart", }
-displayinfo(myform,tags,"viewonly")
-%>
-</DL>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
<h1>Configuration</h1>
<% if (#service.cfgerr > 0) then %>
@@ -59,12 +41,6 @@ displayinfo(myform,tags,"viewonly")
%>
</TABLE>
-<h1>MANAGEMENT</h1>
-<form action="" method="POST">
-<dl>
-<DT>Daemon control</DT><dd><input class="submit" type="submit" name="srvcmd" value="start" <% io.write( srv1fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="stop" <% io.write( srv2fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="restart" <% io.write( srv2fill ) %>>
-<% if (service.message) and (service.message.descr) and (#service.message.descr > 0) then %><pre><% io.write( service.message.descr ) %></pre><% end %></dd>
-</dl>
-</form>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/dansguardian-category-html.lsp b/dansguardian-category-html.lsp
index 6d6115c..2f94048 100644
--- a/dansguardian-category-html.lsp
+++ b/dansguardian-category-html.lsp
@@ -1,23 +1,6 @@
<%
require("viewfunctions")
- local form = ...
- local data = form.option
- local service = form.service
- local config = form.service.config
-
- local srv1fill = ""
- local srv2fill = "disabled"
- if form.info.status.value == "Enabled" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
- local ifthen = function( variable, value, result )
- if variable == value then
- io.write( result )
- end
- end
-
+ local form, viewlibrary = ...
%>
<%
@@ -28,14 +11,9 @@ io.write("</span>")
--]]
%>
-<H1>SYSTEM INFO</H1>
-<DL>
-<%
-local myform = form.info
-local tags = { "status", "version", "autostart", }
-displayinfo(myform,tags,"viewonly")
-%>
-</DL>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
<h1>Modify Categories</h1>
@@ -73,12 +51,6 @@ end
</form>
-<h1>MANAGEMENT</h1>
-<form action="" method="POST">
-<dl>
-<DT>Daemon control</DT><dd><input class="submit" type="submit" name="srvcmd" value="start" <% io.write( srv1fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="stop" <% io.write( srv2fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="restart" <% io.write( srv2fill ) %>>
-<% if (service.message) and (service.message.descr) and (#service.message.descr > 0) then %><pre><% io.write( service.message.descr ) %></pre><% end %></dd>
-</dl>
-</form>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/dansguardian-controller.lua b/dansguardian-controller.lua
index c88743f..97e2849 100644
--- a/dansguardian-controller.lua
+++ b/dansguardian-controller.lua
@@ -2,50 +2,22 @@
module (..., package.seeall)
+require("controllerfunctions")
+
default_action = "status"
status = function( self )
+ return self.model.get_status()
+end
- local info = {
- status=self.model.get_status(),
- version = self.model.get_dansguardian_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
- return ( cfe ({ option = option, info = info }) )
+startstop = function( self )
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.get_status, self.clientdata)
end
+
general = function( self )
local service = {}
- if self.clientdata.srvcmd then
- local srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.srvcmdresult, service.message = self.model.service_control( srvcmd )
- end
- end
- local info = {
- status=self.model.get_status(),
- version = self.model.get_dansguardian_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
-- Add a cmd button to the view
service.cmdsave = cfe({ name="cmdsave",
label="Save/Apply above settings",
@@ -64,29 +36,15 @@ general = function( self )
service.cmdsave.descr="* Changes has been saved!"
end
- service.status = self.model.get_status()
service.config, service.cfgerr = self.model.get_general_config()
- return ( cfe ({ option = option, service = service, info = info }) )
+ return ( cfe ({ service = service }) )
end
advanced = function( self )
local service = {}
- if self.clientdata.srvcmd then
- local srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.srvcmdresult, service.message = self.model.service_control( srvcmd )
- end
- end
- local info = {
- status=self.model.get_status(),
- version = self.model.get_dansguardian_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
local option = { script = self.conf.script,
prefix = self.conf.prefix,
controller = self.conf.controller,
@@ -94,54 +52,13 @@ advanced = function( self )
extra = ""
}
- service.status = self.model.get_status()
service.config, service.cfgerr = self.model.get_advanced_config()
- return ( cfe ({ option = option, service = service, info = info }) )
+ return ( cfe ({ option = option, service = service }) )
end
-plain = function( self )
-
- local service = {}
- if self.clientdata.srvcmd then
- local srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.srvcmdresult, service.message = self.model.service_control( srvcmd )
- end
- end
-
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
- local info = {
- status=self.model.get_status(),
- version = self.model.get_dansguardian_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
- -- Add a cmd button to the view
- service.cmdsave = cfe({ name="cmdsave",
- label="Save/Apply above settings",
- value="Save",
- type="submit",
- })
-
- if self.clientdata.cmdsave then
- local conf = self.clientdata
- local config = conf.config
- self.model.update_plain_config( config )
- service.cmdsave.descr="* Changes has been saved!"
- end
-
- service.status = self.model.get_status()
- service.config, service.cfgerr = self.model.get_plain_config()
-
- return ( cfe ({ option = option, service = service, info = info }) )
+expert = function( self )
+ return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.updateconfigfile, self.clientdata, "Save", "Edit Config", "Configuration Set")
end
edit = function( self )
@@ -150,13 +67,6 @@ edit = function( self )
redirect( self )
end
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
local service = { message="", status="", config="" }
if self.clientdata.cmd then
@@ -166,7 +76,6 @@ edit = function( self )
end
end
- service.status = self.model.get_status()
service.config, service.cfgerr = self.model.get_edit_config( self.clientdata.name )
service.name = self.clientdata.name
@@ -174,48 +83,13 @@ edit = function( self )
redirect( self )
end
- return ( cfe ({ option = option, service = service }) )
+ return ( cfe ({ service = service }) )
end
category = function( self )
local service = { message="", status="", config="", cfgerr="" }
- if self.clientdata.srvcmd then
- local srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.srvcmdresult, service.message = self.model.service_control( srvcmd )
- end
- end
-
- local info = {
- status=self.model.get_status(),
- version = self.model.get_dansguardian_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
- -- Add a cmd button to the view
- service.cmdadd = cfe({
- name="cmdadd",
- label="Action",
- value="Add",
- type="submit",
- })
-
- service.cmdaddvalue = cfe({
- name="cmdaddvalue",
- value="",
- type="text",
- })
-
service.config = {}
service.config.categories = cfe({
name="categories",
@@ -224,7 +98,7 @@ category = function( self )
})
service.config.categories = self.model.get_categories()
- return ( cfe ({ option = option, service = service, info = info }) )
+ return ( cfe ({ service = service }) )
end
editcategories = function( self )
diff --git a/dansguardian-edit-html.lsp b/dansguardian-edit-html.lsp
index 3d1c0e6..99cf55a 100644
--- a/dansguardian-edit-html.lsp
+++ b/dansguardian-edit-html.lsp
@@ -1,21 +1,6 @@
<%
local form = ...
- local data = form.option
local service = form.service
- local config = form.service.config
-
- local srv1fill = ""
- local srv2fill = "disabled"
- if service.status == "running" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
- local ifthen = function( variable, value, result )
- if variable == value then
- io.write( result )
- end
- end
%>
<h1>Content Filter (<% io.write( service.name ) %>)</h1>
diff --git a/dansguardian-expert-html.lsp b/dansguardian-expert-html.lsp
new file mode 120000
index 0000000..207f324
--- /dev/null
+++ b/dansguardian-expert-html.lsp
@@ -0,0 +1 @@
+../expert-html.lsp \ No newline at end of file
diff --git a/dansguardian-general-html.lsp b/dansguardian-general-html.lsp
index 09d1600..6c0ca60 100644
--- a/dansguardian-general-html.lsp
+++ b/dansguardian-general-html.lsp
@@ -1,23 +1,9 @@
<%
require("viewfunctions")
- local form = ...
- local data = form.option
+ local form, viewlibrary = ...
local service = form.service
local config = form.service.config
- local srv1fill = ""
- local srv2fill = "disabled"
- if form.info.status.value == "Enabled" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
- local ifthen = function( variable, value, result )
- if variable == value then
- io.write( result )
- end
- end
-
%>
<%
@@ -28,14 +14,9 @@ io.write("</span>")
--]]
%>
-<H1>SYSTEM INFO</H1>
-<DL>
-<%
-local myform = form.info
-local tags = { "status", "version", "autostart", }
-displayinfo(myform,tags,"viewonly")
-%>
-</DL>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
<form action="" method="POST">
<h1>Configuration</h1>
@@ -88,12 +69,6 @@ until you restart the service.</DD>
</form>
-<h1>MANAGEMENT</h1>
-<form action="" method="POST">
-<dl>
-<DT>Daemon control</DT><dd><input class="submit" type="submit" name="srvcmd" value="start" <% io.write( srv1fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="stop" <% io.write( srv2fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="restart" <% io.write( srv2fill ) %>>
-<% if (service.message) and (service.message.descr) and (#service.message.descr > 0) then %><pre><% io.write( service.message.descr ) %></pre><% end %></dd>
-</dl>
-</form>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/dansguardian-model.lua b/dansguardian-model.lua
index 3159644..7fb76a1 100644
--- a/dansguardian-model.lua
+++ b/dansguardian-model.lua
@@ -2,6 +2,7 @@
module (..., package.seeall)
-- Load libraries
+require("modelfunctions")
require "posix"
require "format"
require("processinfo")
@@ -46,48 +47,12 @@ local categoryfilecontent = {
-- ################################################################################
-- PUBLIC FUNCTIONS
-get_autostart = function()
- local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname)
- local retval = cfe({ name="autostart",
- label="Autostart sequence",
- value=autostart_sequense,
- errtxt=autostart_errtxt,
- })
- return retval
-end
-
get_status = function()
- local t = procps.pidof(procname)
- local stats
- if (t) and (#t > 0) then
- stats = "Enabled"
- else
- stats = "Disabled"
- end
- local retval = cfe({ name="status",
- label="Program status",
- value=stats,
- })
- return retval
+ return modelfunctions.getstatus(processname, packagename, "Dans Guardian Status")
end
-service_control = function( cmd )
- local action = {value=cmd}
- local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, cmd)
- action.descr=cmdmessage
- action.errtxt=cmderror
- return cmdresult,action
-end
-
-
-get_dansguardian_version = function()
- local value, errtxt = processinfo.package_version(packagename)
- local retval = cfe({ name = "version",
- label="Program version",
- value=value,
- errtxt=errtxt,
- })
- return retval
+startstop_service = function( action )
+ return modelfunctions.startstop_service(processname, action)
end
get_general_config = function()
@@ -146,24 +111,8 @@ get_general_config = function()
return retval, error
end
-get_plain_config = function()
-
- local retval = ""
- local error = ""
-
- local fptr = io.open( dansguardiancfg, "r" )
- if fptr ~= nil then
- retval = fptr:read( "*a" )
- fptr:close()
- if retval == nil then
- retval = ""
- error = "Failed to read " .. dansguardiancfg .. " file!"
- end
- else
- error = "Failed to open " .. dansguardiancfg .. " file!"
- end
-
- return retval, error
+getconfigfile = function()
+ return modelfunctions.getfiledetails(dansguardiancfg)
end
get_edit_config = function( name )
@@ -283,21 +232,9 @@ update_general_config = function( config )
return retval
end
-update_plain_config = function( config )
-
- local retval = ""
- local cfgptr = -1
- local error = ""
-
- cfgptr = io.open( dansguardiancfg, "wb+" )
- if cfgptr ~= nil then
- cfgptr:write( config )
- cfgptr:close()
- else
- retval = "Failed to open " .. dansguardiancfg .. " file!"
- end
-
- return retval
+updateconfigfile = function( filedetails )
+ filedetails.value.filename.value = dansguardiancfg
+ return modelfunctions.setfiledetails(dansguardiancfg)
end
get_cfg_value = function( str )
diff --git a/dansguardian-plain-html.lsp b/dansguardian-plain-html.lsp
deleted file mode 100644
index 5ad57b9..0000000
--- a/dansguardian-plain-html.lsp
+++ /dev/null
@@ -1,83 +0,0 @@
-<%
-require("viewfunctions")
- local form = ...
- local data = form.option
- local service = form.service
- local config = form.service.config
-
- local srv1fill = ""
- local srv2fill = "disabled"
- if form.info.status.value == "Enabled" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
- local ifthen = function( variable, value, result )
- if variable == value then
- io.write( result )
- end
- end
-
-%>
-
-<%
---[[ 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>
-
-<h1>Content Filter (Plain Config File)</h1>
-<DL>
-<DT>Warning</DT>
-<DD class=warning>Modifying the DansGuardian configuration file is generally not necessary.
-You must be familiar with the configuration file before proceeding.</DD>
-<DT>Information</DT>
-<DD>These parameters define the interface and port that Dansguardian uses to accept connections.</DD>
-</DL>
-
-<form action="" method="POST">
-<h2>Configuration</h2>
-<textarea name="config"><% io.write( service.config ) %></textarea>
-
-
-<h2>Save changes</h2>
-<dl>
-<%
-local myform = form.service
-local tags = { "cmdsave", }
-displayinfo(myform,tags)
-%>
-<% if (service) and (service.error) and (#service.error > 0) then %>
-<DT>Config status</DT><DD class="error"><% io.write(service.error ) %></DD>
-<% end %>
-<% if (service) and (service.cfgerr) and (#service.cfgerr > 0) then %>
-<DT>Config status</DT><DD class="error"><% io.write(service.cfgerr ) %></DD>
-<% end %>
-
-<DT>Process information</DT><DD>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.</DD>
-
-</dl>
-</form>
-
-<h1>MANAGEMENT</h1>
-<form action="" method="POST">
-<dl>
-<DT>Daemon control</DT><dd><input class="submit" type="submit" name="srvcmd" value="start" <% io.write( srv1fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="stop" <% io.write( srv2fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="restart" <% io.write( srv2fill ) %>>
-<% if (service.message) and (service.message.descr) and (#service.message.descr > 0) then %><pre><% io.write( service.message.descr ) %></pre><% end %></dd>
-</dl>
-</form>
diff --git a/dansguardian-startstop-html.lsp b/dansguardian-startstop-html.lsp
new file mode 120000
index 0000000..0ea2627
--- /dev/null
+++ b/dansguardian-startstop-html.lsp
@@ -0,0 +1 @@
+../startstop-html.lsp \ No newline at end of file
diff --git a/dansguardian-status-html.lsp b/dansguardian-status-html.lsp
index 33efc1b..b2f8480 100644..120000
--- a/dansguardian-status-html.lsp
+++ b/dansguardian-status-html.lsp
@@ -1,32 +1 @@
-<% 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>
+../status-html.lsp \ No newline at end of file
diff --git a/dansguardian.menu b/dansguardian.menu
index e4e6a4e..a679ad7 100644
--- a/dansguardian.menu
+++ b/dansguardian.menu
@@ -3,5 +3,5 @@
Applications 20Content_Filter Status status
Applications 20Content_Filter Basic general
Applications 20Content_Filter Advanced advanced
-Applications 20Content_Filter Plain plain
Applications 20Content_Filter Category category
+Applications 20Content_Filter Expert expert
diff --git a/dansguardian.roles b/dansguardian.roles
index a8db1c9..e19712f 100644
--- a/dansguardian.roles
+++ b/dansguardian.roles
@@ -1,2 +1,2 @@
READ=dansguardian:status
-UPDATE=dansguardian:general,dansguardian:advanced,dansguardian:plain,dansguardian:edit,dansguardian:category,dansguardian:editcategories
+UPDATE=dansguardian:general,dansguardian:advanced,dansguardian:expert,dansguardian:edit,dansguardian:category,dansguardian:editcategories,dansguardian:startstop