From 210f1c930825f872aa6003f37a8908a63c2c91f5 Mon Sep 17 00:00:00 2001
From: Mika Havela
Date: Tue, 6 May 2008 15:11:55 +0000
Subject: Changing buttons to be cfe's (coming from controller) rather than
created by the view-file. Reorganized the view-files so they look a bit more
like other ACF's.
git-svn-id: svn://svn.alpinelinux.org/acf/dansguardian/trunk@1108 ab2d0c66-481e-0410-8bed-d214d4d58bed
---
dansguardian-advanced-html.lsp | 71 ++++++++++++------
dansguardian-category-html.lsp | 71 +++++++++++++-----
dansguardian-controller.lua | 161 ++++++++++++++++++++++++++++-------------
dansguardian-general-html.lsp | 88 ++++++++++++++--------
dansguardian-model.lua | 88 +++++++++++-----------
dansguardian-plain-html.lsp | 78 ++++++++++++++------
dansguardian.menu | 2 +-
7 files changed, 367 insertions(+), 192 deletions(-)
diff --git a/dansguardian-advanced-html.lsp b/dansguardian-advanced-html.lsp
index 0f6b78a..73e6015 100644
--- a/dansguardian-advanced-html.lsp
+++ b/dansguardian-advanced-html.lsp
@@ -1,4 +1,5 @@
+require("viewfunctions")
local form = ...
local data = form.option
local service = form.service
@@ -6,7 +7,7 @@
local srv1fill = ""
local srv2fill = "disabled"
- if service.status == "running" then
+ if form.info.status.value == "Enabled" then
srv1fill = "disabled"
srv2fill = ""
end
@@ -18,7 +19,24 @@
end
?>
-
DansGuardian is web content filtering software. It works as a web proxy,
@@ -32,32 +50,37 @@ generally not necessary. DansGuardian must be used in combination with a
This page lets you manually configure the filter rule files for DansGuardian.
-
Status
-
Program version
io.write( form.info.version.value ) ?>
-
Process status
io.write( form.info.status.value ) ?>
-
Process information
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.
-
+
Configuration
+ if (#service.cfgerr > 0) then ?>
+
Errors
+
Config errors
+
io.write( service.cfgerr ) ?>
+
+ end ?>
-
Configuration
-
io.write( service.cfgerr ) ?>
-
Files
-
-Click on one of the files to edit it.
-
+
Files
+
+
+
+
File
+
Size
+
Last Modified
+
-
for k,v in ipairs( config.files ) do
- io.write( "
+
diff --git a/dansguardian-category-html.lsp b/dansguardian-category-html.lsp
index bbe1a20..1edcc71 100644
--- a/dansguardian-category-html.lsp
+++ b/dansguardian-category-html.lsp
@@ -1,4 +1,5 @@
+require("viewfunctions")
local form = ...
local data = form.option
local service = form.service
@@ -6,7 +7,7 @@
local srv1fill = ""
local srv2fill = "disabled"
- if service.status == "running" then
+ if form.info.status.value == "Enabled" then
srv1fill = "disabled"
srv2fill = ""
end
@@ -18,7 +19,25 @@
end
?>
-
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
@@ -27,31 +46,27 @@ 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.
-
Status
-
-
-
io.write( service.message ) ?>
-
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
-
io.write( service.cfgerr ) ?>
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.)
DansGuardian is web content filtering software. It works as a web proxy,
@@ -31,52 +49,64 @@ generally not necessary. DansGuardian must be used in combination with a
This page defines the basic network configuration settings for DansGuardian.
-
Status
-
Program version
io.write( form.info.version.value ) ?>
-
Process status
io.write( form.info.status.value ) ?>
-
Process information
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.
-
-
-
-
io.write( service.message ) ?>
-
+
MANAGEMENT
+
diff --git a/dansguardian-model.lua b/dansguardian-model.lua
index 63694e2..b02b99b 100644
--- a/dansguardian-model.lua
+++ b/dansguardian-model.lua
@@ -1,61 +1,60 @@
--- acf model for squid
-- Copyright(c) 2007 A. Brodmann - Licensed under terms of GPL2
module (..., package.seeall)
+-- Load libraries
require "posix"
require "format"
+require("processinfo")
+require("procps")
+require("daemoncontrol")
+-- Set variables
dansguardiancfg = "/etc/dansguardian/dansguardian.conf"
dansguardiancfg2 = "/etc/dansguardian/dansguardianf1.conf"
-
-get_status = function()
-
- local retval = "stopped"
-
- local ptr = io.popen( "/bin/pidof dansguardian" )
- local pid = ptr:read( "*a" )
- ptr:close()
- if pid ~= nil then
- if #pid > 1 then
- retval = "running"
- end
- end
-
+local processname = "dansguardian"
+local packagename = "dansguardian"
+
+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
-service_control = function( control )
-
- local retval = ""
-
- local ptr = io.popen( "/etc/init.d/dansguardian " .. control, "r" )
- if ptr ~= nil then
- local retmsg = ptr:read( "*a" )
- ptr:close()
- if retmsg ~= nil then
- retval = retmsg
- else
- retval = "service_control(): Failed to read output from initscript!\n"
- end
+get_status = function()
+ local t = procps.pidof(procname)
+ local stats
+ if (t) and (#t > 0) then
+ stats = "Enabled"
else
- retval = "service_control(): Failed to start/stop/restart service!\n"
+ stats = "Disabled"
end
-
+ local retval = cfe({ name="status",
+ label="Program status",
+ value=stats,
+ })
return retval
end
-get_dansguardian_version = function()
+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
- local retval = ""
-
- local ptr = io.popen( "/usr/sbin/dansguardian -v" )
- if ptr ~= nil then
- retval = ptr:read( "*l" )
- ptr:close()
- else
- retval = "Error - Failed to program version"
- 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
end
@@ -318,7 +317,10 @@ get_file_tree = function( treetable, dir, prefix )
for k,v in ipairs( entries ) do
local attrs = posix.stat( dir .. "/" .. v )
if attrs.type == "regular" and string.sub( v, -4) ~= ".gif" then
- table.insert( treetable, prefix .. v )
+ local path = dir .. "/" .. v
+ local filedetails = fs.stat(path)
+ filedetails.path = prefix .. v
+ table.insert( treetable, filedetails )
end
end
@@ -344,7 +346,7 @@ is_valid_configfile = function( name )
get_file_tree( ftable, "/etc/dansguardian", "" )
for k,v in ipairs( ftable ) do
- if v == name then
+ if v.path == name then
retval = true
end
end
diff --git a/dansguardian-plain-html.lsp b/dansguardian-plain-html.lsp
index cf76317..7ef2847 100644
--- a/dansguardian-plain-html.lsp
+++ b/dansguardian-plain-html.lsp
@@ -1,4 +1,5 @@
+require("viewfunctions")
local form = ...
local data = form.option
local service = form.service
@@ -6,7 +7,7 @@
local srv1fill = ""
local srv2fill = "disabled"
- if service.status == "running" then
+ if form.info.status.value == "Enabled" then
srv1fill = "disabled"
srv2fill = ""
end
@@ -18,34 +19,65 @@
end
?>
+
+
+--[[ DEBUG INFORMATION
+io.write("
Modifying the DansGuardian configuration file is generally not necessary.
-You must be familiar with the configuration file before proceeding.
+
+
Warning
+
Modifying the DansGuardian configuration file is generally not necessary.
+You must be familiar with the configuration file before proceeding.
+
Information
+
These parameters define the interface and port that Dansguardian uses to accept connections.
+
-
Status
-
io.write( service.message ) ?>
+
Configuration
+
-
-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.
-
-
+
MANAGEMENT
+
diff --git a/dansguardian.menu b/dansguardian.menu
index c7f2580..d7d6be2 100644
--- a/dansguardian.menu
+++ b/dansguardian.menu
@@ -1,6 +1,6 @@
# Prefix and controller are already known at this point
# Cat Group Tab Action
-Applications 20Content_Filter Basic basic
+Applications 20Content_Filter Basic general
Applications 20Content_Filter Advanced advanced
Applications 20Content_Filter Plain plain
Applications 20Content_Filter Category category
--
cgit v1.2.3