summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-08 12:35:04 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-08 12:35:04 +0000
commit63e8c6b82c980876ddc522174970e5b1b9014b06 (patch)
tree73b04306be53adcf115d4de3cec64fe69815ea3a
parentea416afe39d2b4d796ccbfe0a7819968ef2d6f63 (diff)
downloadacf-tinydns-0.1.1.tar.bz2
acf-tinydns-0.1.1.tar.xz
Cleaning up the code.v0.1.1
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@954 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--Makefile2
-rwxr-xr-xtinydns-config-html.lsp51
-rw-r--r--tinydns-controller.lua18
-rw-r--r--tinydns-edit-html.lsp80
-rw-r--r--tinydns-expert-html.lsp50
-rw-r--r--tinydns-model.lua323
-rw-r--r--tinydns-status-html.lsp48
7 files changed, 142 insertions, 430 deletions
diff --git a/Makefile b/Makefile
index 28df3d1..1f4923e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
APP_NAME=tinydns
PACKAGE=acf-$(APP_NAME)
-VERSION=0.1.0
+VERSION=0.1.1
APP_DIST=\
tinydns* \
diff --git a/tinydns-config-html.lsp b/tinydns-config-html.lsp
index b708d93..839570e 100755
--- a/tinydns-config-html.lsp
+++ b/tinydns-config-html.lsp
@@ -1,4 +1,6 @@
-<? local form = ... ?>
+<? local form = ...
+require("viewfunctions")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -6,31 +8,6 @@ io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
?>
-<?
-function displayinfo(myform,tags,viewonly)
- io.write("<DL>")
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>\n")
- if (viewonly) then
- io.write("\t\t<DD>" .. val.value .. "\n")
- else
- io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
- end
- if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
- if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
- io.write("\t\t</DD>\n")
- end
- end
- io.write("</DL>")
-end
-?>
<H1>SYSTEM INFO</H1>
<?
@@ -111,25 +88,3 @@ displayinfo(myform,tags)
?>
</form>
-
-<? --[[ ?>
-<H1>DEGUGGING</H1>
-<?
-local myform = form.debug
-local tags = {}
-for k,v in pairs(myform) do
- table.insert(tags,k)
-end
-displayinfo(myform,tags)
-?>
-<? --]] ?>
-
-
-<?
---[[ 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>")
---]]
-?>
-
diff --git a/tinydns-controller.lua b/tinydns-controller.lua
index 502af03..47bb8d7 100644
--- a/tinydns-controller.lua
+++ b/tinydns-controller.lua
@@ -1,20 +1,17 @@
module(..., package.seeall)
+-- Set variables
local newrecordtxt = "[New]"
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
local list_redir = function (self)
self.conf.action = "status"
self.conf.type = "redir"
error (self.conf)
end
-mvc = {}
-mvc.on_load = function(self, parent)
- if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then
- self.worker[self.conf.action] = list_redir(self)
- end
-end
-
local function getstatus(self)
local status = self.model.getstatus()
if (#status.status.value > 0) then
@@ -76,6 +73,13 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
+mvc = {}
+mvc.on_load = function(self, parent)
+ if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then
+ self.worker[self.conf.action] = list_redir(self)
+ end
+end
+
function status(self)
local config = {}
config.settings = {}
diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp
index e5bb6ba..08dee18 100644
--- a/tinydns-edit-html.lsp
+++ b/tinydns-edit-html.lsp
@@ -1,4 +1,6 @@
-<? local form = ... ?>
+<? local form = ...
+require("viewfunctions")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -6,39 +8,6 @@ io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
?>
-<?
-function displayinfo(myform,tags,viewtype)
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\n\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>")
- io.write("\n\t\t<DD>")
- if (viewtype == "viewonly") then
- io.write(val.value)
- elseif (val.type == "radio") and (type(val.option) == "table") and (#val.option > 0) then
- io.write("<span style='display:inline' class='" .. ( val.class or "") .. "'>")
- for k1,v1 in pairs(val.option) do
- io.write(tostring(v1.label) .. ":")
- io.write("<input style='margin-right:20px;margin-left:5px;' type='radio' class='" .. ( val.class or "") .. "' name='" .. val.name .. "'")
- if (tostring(val.value) == tostring(v1.value)) then io.write(" checked='yes'") end
- io.write(" value='" .. v1.value .. "'>")
- end
- io.write("</input></span>")
- else
- io.write(html.form[val.type](val))
- end
- if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>") end
- if (#val.errtxt > 0) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>") end
- io.write("\n\t\t</DD>\n")
- end
- end
-end
-?>
<H1>SYSTEM INFO</H1>
<DL>
@@ -49,7 +18,6 @@ displayinfo(myform,tags,"viewonly")
?>
</DL>
-
<form name="myform" action="" method="POST">
<h1>CONFIGURATION</h1>
<H2>Expert config</H2>
@@ -77,38 +45,14 @@ displayinfo(myform,tags)
?>
</DL>
-</form>
-
-<? -- MANAGEMENT BUTTONS
-local cmdform = form.management
-local cmdresult = form.cmdmanagement
-local tags = { "start", "stop", "restart" }
-if (cmdform) and (cmdform[tags[1]]) then
-
- io.write('<form name="management" action="" method="POST">')
- io.write('<H1>MANAGEMENT</H1>')
- io.write('<dl>')
- io.write('<dt>' .. cmdform[tags[1]]["label"] .. '</dt>')
- io.write('<dd>')
- for k,v in pairs(tags) do
- if (cmdform[v]) then
- io.write(html.form[cmdform[v].type](cmdform[v]))
- end
- end
- io.write('</dd>')
-
- if (cmdresult) and (cmdresult.action) and (#cmdresult.action.descr > 0) then
- io.write('<dt>' .. cmdresult.label .. '</dt>')
- io.write('<dd><pre>' .. cmdresult.action.descr .. '</pre></dd>')
- end
- io.write('</dl></form>')
-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>")
---]]
+-- 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/tinydns-expert-html.lsp b/tinydns-expert-html.lsp
index 7744934..310d8ce 100644
--- a/tinydns-expert-html.lsp
+++ b/tinydns-expert-html.lsp
@@ -1,4 +1,6 @@
-<? local form = ... ?>
+<? local form = ...
+require("viewfunctions")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -7,31 +9,6 @@ io.write("</span>")
--]]
?>
-<?
-function displayinfo(myform,tags,viewonly)
- io.write("<DL>")
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>\n")
- if (viewonly) then
- io.write("\t\t<DD>" .. val.value .. "\n")
- else
- io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
- end
- if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
- if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
- io.write("\t\t</DD>\n")
- end
- end
- io.write("</DL>")
-end
-?>
<H1>SYSTEM INFO</H1>
<?
@@ -41,29 +18,16 @@ displayinfo(myform,tags,"viewonly")
?>
<h1>CONFIGURATION</h1>
-
<h2>Expert config</h2>
<h3>List of files</h3>
-
-<? local myform = form.status.configfiles ?>
<TABLE>
-<? --[[
- <TR style="background:#eee;font-weight:bold;">
- <TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">File</TD>
- </TR>
---]]?>
-
-<? for k,v in pairs(myform.value) do ?>
+<?
+local myform = form.status.configfiles
+for k,v in pairs(myform.value) do
+?>
<TR>
<TD style="padding-right:20px;white-space:nowrap;"><?= html.link{value = "edit?name=" .. v , label=v } ?></TD>
</TR>
<? end ?>
</TABLE>
-<?
---[[ 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>")
---]]
-?>
diff --git a/tinydns-model.lua b/tinydns-model.lua
index 24e0437..ad83798 100644
--- a/tinydns-model.lua
+++ b/tinydns-model.lua
@@ -1,15 +1,18 @@
module(..., package.seeall)
+-- Load libraries
require("procps")
require("getopts")
require("fs")
require("format")
+require("processinfo")
+-- Set variables
local configdir
local datafile
local configfiles = {}
local configitems = {}
-
+local packagename = "tinydns"
local processname = "tinydns"
local configfile = "/etc/conf.d/" .. processname
local baseurl = "/etc/tinydns"
@@ -21,26 +24,50 @@ else
configdir = "/etc/" .. processname
datafile = "/var/cache/data"
end
-
+descr = {
+ prefix={
+ ['.']="Name server for your domain (NS + A + SOA)",
+ ['&']="Deletegate subdomain (NS + A)",
+ ['=']="Host (A + PTR)",
+ ['+']="Alias (A, no PTR)",
+ ['@']="Mail exchanger (MX)",
+ ["'"]="Text record (TXT)",
+ ['^']="Reverse record (PTR)",
+ ['C']="Canonical Name (CNAME)",
+ ['Z']="SOA record (SOA)",
+ [':']="Generic record",
+ ['%']="Client location",
+ },
+ reverse={
+ ['nsourdomain']=".",
+ ['nsdomain']="&",
+ ['host']="=",
+ ['alias']="+",
+ ['mx']="@",
+ ['ptr']="^",
+ ['cname']="C",
+ ['soa']="Z",
+ [':']=":",
+ ['locations']="%",
+ },
+ fieldlabels={
+ ['.']={"Prefix", "Domain", "IP address", "Name server", "Time to live", "Timestamp", "Location", },
+ ['&']={"Prefix", "Domain", "IP address", "Name server", "Time to live", "Timestamp", "Location", },
+ ['=']={"Prefix", "Host", "IP address", "Time to live", "Timestamp", "Location", },
+ ['+']={"Prefix", "Alias", "IP address", "Time to live", "Timestamp", "Location", },
+ ['@']={"Prefix", "Domain", "IP address", "Mail exchanger", "Distance", "Time to live", "Timestamp", "Location", },
+ ['^']={"Prefix", "PTR", "Domain name", "Time to live", "Timestamp", "Location", },
+ ['C']={"Prefix", "Domain name", "Canonical name", "Time to live", "Timestamp", "Location", },
+ ['Z']={"Prefix", "Unknown", "Primary name server", "Contact address", "Serial number", "Refresh time", "Retry time", "Expire time", "Minimum time", "Time to live", "Timestamp", "Location",},
+ [':']={"Prefix", },
+ ['%']={"Prefix", },
+ },
+}
--configdir = "hidden for the moment - This row is here only for debug purpose"
-- ################################################################################
-- LOCAL FUNCTIONS
-local function get_version()
- local cmd_output_result, cmd_output_error
- local cmd = "/sbin/apk_version -vs " .. processname .." 2>/dev/null"
- local f = io.popen( cmd )
- local cmdresult = f:read("*l")
- if (cmdresult) and (#cmdresult > 0) then
- cmd_output_result = string.match(cmdresult,"^%S*") or "Unknown"
- else
- cmd_output_error = "Program not installed"
- end
- f:close()
- return cmd_output_result,cmd_output_error
-end
-
-- Return a table with the config-content of a file
-- Commented/Blank lines are ignored
local function get_value_from_file(file)
@@ -77,26 +104,12 @@ local function recursedir(path, filearray)
end
end
-local function autostarts()
- local cmd_output_result
- local cmd = "/sbin/rc_status | egrep '^S' | egrep '" .. processname .."' 2>/dev/null"
- local f = io.popen( cmd )
- local cmdresult = f:read("*a")
- if (cmdresult) and (#cmdresult > 0) then
- cmd_output_result = "Process will autostart at next boot (at sequence '" .. string.match(cmdresult,"^%a+(%d%d)") .. "')"
- else
- cmd_output_error = "Not programmed to autostart"
- end
- f:close()
- return cmd_output_result, cmd_output_error
-end
-
-- Functin to split items into a table
local function split_config_items(orgitem)
local delimiter = ":"
local output = {}
output = format.string_to_table(string.sub(orgitem,1,1) .. ":" .. string.sub(orgitem,2),delimiter)
- output.type = check_signs("prefix")
+ output.type = descr['prefix']
output.type = output.type[string.sub(orgitem,1,1)] or "unknown"
return output
end
@@ -111,14 +124,9 @@ local function searchforconfigfiles()
table.insert(configfiles, v)
end
end
-
- -- Debug option (adds the sampleconfig content)
--- table.insert(configfiles, "/usr/share/acf/app/tinydns/sampleconfig.conf")
-
end
searchforconfigfiles()
-
local function recurseoutput(table,cnt)
if not (cnt) then cnt=0 end
cnt = cnt + 1
@@ -203,6 +211,54 @@ local function validfilename(path)
return false, "Not a valid filename!"
end
+-- Example taken from PIL
+-- Sort by Keys
+local function pairsByKeys(t,f)
+ local a = {}
+
+ for n in pairs(t) do
+ -- This is to fix some bug when next table is indexnumber instead of name
+ if (tonumber(n) == nil) then
+ a[#a + 1] = n
+ end
+ end
+ table.sort(a,f)
+ local i = 0 -- iterator variable
+ return function () --iterator function
+ i = i + 1
+ return a[i], t[a[i]]
+ end
+end
+
+local function rebuild_table(t,domains_rebuilt)
+ if not (type(t) == "string") then
+ for k,v in pairs(t) do
+ if (tonumber(k)) then
+ table.insert(domains_rebuilt, v)
+ else
+ table.insert(domains_rebuilt, {label=k})
+ rebuild_table(v,domains_rebuilt[#domains_rebuilt])
+ end
+ end
+ table.sort(domains_rebuilt, function(a,b) return (a.label < b.label) end)
+ end
+end
+
+-- This function removes all records that doesn't have the filter-value
+local function filter_table(t1,domains_filtered,filter)
+ if not (type(t1) == "string") then
+ for k1,v1 in pairs(t1) do
+ for k2,v2 in pairs(v1) do
+ if (v2.label) then
+ if ( string.find(filter,v2.label) ) then
+ table.insert(domains_filtered, v2)
+ end
+ end
+ end
+ end
+ end
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -212,47 +268,9 @@ end
-- This function could be used to check that valid parameters are used in different places
function check_signs(sign)
- local output = {}
- local output = {prefix={
- ['.']="Name server for your domain (NS + A + SOA)",
- ['&']="Deletegate subdomain (NS + A)",
- ['=']="Host (A + PTR)",
- ['+']="Alias (A, no PTR)",
- ['@']="Mail exchanger (MX)",
- ["'"]="Text record (TXT)",
- ['^']="Reverse record (PTR)",
- ['C']="Canonical Name (CNAME)",
- ['Z']="SOA record (SOA)",
- [':']="Generic record",
- ['%']="Client location",
- },
- reverse={
- ['nsourdomain']=".",
- ['nsdomain']="&",
- ['host']="=",
- ['alias']="+",
- ['mx']="@",
- ['ptr']="^",
- ['cname']="C",
- ['soa']="Z",
- [':']=":",
- ['locations']="%",
- },
- fieldlabels={
- ['.']={"Prefix", "Domain", "IP address", "Name server", "Time to live", "Timestamp", "Location", },
- ['&']={"Prefix", "Domain", "IP address", "Name server", "Time to live", "Timestamp", "Location", },
- ['=']={"Prefix", "Host", "IP address", "Time to live", "Timestamp", "Location", },
- ['+']={"Prefix", "Alias", "IP address", "Time to live", "Timestamp", "Location", },
- ['@']={"Prefix", "Domain", "IP address", "Mail exchanger", "Distance", "Time to live", "Timestamp", "Location", },
- ['^']={"Prefix", "PTR", "Domain name", "Time to live", "Timestamp", "Location", },
- ['C']={"Prefix", "Domain name", "Canonical name", "Time to live", "Timestamp", "Location", },
- ['Z']={"Prefix", "Unknown", "Primary name server", "Contact address", "Serial number", "Refresh time", "Retry time", "Expire time", "Minimum time", "Time to live", "Timestamp", "Location",},
- [':']={"Prefix", },
- ['%']={"Prefix", },
- },
- }
- if (sign) then
- output = output[sign]
+ local output
+ if (sign) and (descr[sign]) then
+ output = descr[sign]
end
return output
end
@@ -260,12 +278,14 @@ end
-- Present some general status
function getstatus()
local status = {}
- local version,versionerrtxt = get_version()
+
+ local value, errtxt = processinfo.package_version(packagename)
status.version = cfe({ name = "version",
label="Program version",
- value=version,
- errtxt=versionerrtxt,
+ value=value,
+ errtxt=errtxt,
})
+
status.status = cfe({ name="status",
label="Program status",
value=procps.pidof(processname),
@@ -281,7 +301,7 @@ function getstatus()
value=configfiles,
})
- local autostart_sequense, autostart_errtxt = autostarts()
+ local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname)
status.autostart = cfe({ name="autostart",
label="Autostart sequence",
value=autostart_sequense,
@@ -297,8 +317,6 @@ function getlocations(self,filter_type)
local config = {}
local configobjects = {}
local locations = {}
- local debug
- local version,versionerrtxt = get_version()
local listenaddr = getopts.getoptsfromfile_onperline(configfile,"IP") or {}
-- Loop through all available configfiles
@@ -344,54 +362,6 @@ function getconfig(self,filter_type)
return config
end
--- Example taken from PIL
--- Sort by Keys
-local function pairsByKeys(t,f)
- local a = {}
-
- for n in pairs(t) do
- -- This is to fix some bug when next table is indexnumber instead of name
- if (tonumber(n) == nil) then
- a[#a + 1] = n
- end
- end
- table.sort(a,f)
- local i = 0 -- iterator variable
- return function () --iterator function
- i = i + 1
- return a[i], t[a[i]]
- end
-end
-
-local function rebuild_table(t,domains_rebuilt)
- if not (type(t) == "string") then
- for k,v in pairs(t) do
- if (tonumber(k)) then
- table.insert(domains_rebuilt, v)
- else
- table.insert(domains_rebuilt, {label=k})
- rebuild_table(v,domains_rebuilt[#domains_rebuilt])
- end
- end
- table.sort(domains_rebuilt, function(a,b) return (a.label < b.label) end)
- end
-end
-
--- This function removes all records that doesn't have the filter-value
-local function filter_table(t1,domains_filtered,filter)
- if not (type(t1) == "string") then
- for k1,v1 in pairs(t1) do
- for k2,v2 in pairs(v1) do
- if (v2.label) then
- if ( string.find(filter,v2.label) ) then
- table.insert(domains_filtered, v2)
- end
- end
- end
- end
- end
-end
-
-- If you enter 'filter_type' (this should be one of the options found in local function check_signs() ) then
-- the output will be filtered to only contain this type of data.
function getconfigobjects(self,filter_type, filter_levels)
@@ -409,8 +379,8 @@ function getconfigobjects(self,filter_type, filter_levels)
-- Create domain information tables
local domain
- -- * START * COMMONT SETTINGS ***************************************************************************************
- local descr=check_signs("prefix")
+ -- * START * COMMONT SETTINGS ****************************************
+ local descr=descr['prefix']
-- Use only configs that has a valid prefix
-- We filter away location-definitions
-- If function is called with some filter options... then show only the filtered values
@@ -616,7 +586,7 @@ function getconfigobjects(self,filter_type, filter_levels)
})
end
- -- * END * COMMONT SETTINGS ***************************************************************************************
+ -- * END * COMMONT SETTINGS ********************************************
-- Inject the previous data into the right table
local value = filecontent_table[2]
local currenttable
@@ -651,84 +621,6 @@ function getconfigobjects(self,filter_type, filter_levels)
return domains_filtered
end
--- Function to recursively inserts all filenames in a dir into an array
-local function recursedir(path, filearray)
- local k,v
- for k,v in pairs(posix.dir(path) or {}) do
- -- Ignore files that begins with a '.'
- if not string.match(v, "^%.") then
- local f = path .. "/" .. v
- -- If subfolder exists, list files in this subfolder
- if (posix.stat(f).type == "directory") then
- recursedir(f, filearray)
- else
- table.insert(filearray, f)
- end
- end
- end
-end
-
--- ################################################################################
--- DEBUG INFORMATION (Everything below will be deleted in the future)
-
-function getdebug()
- local debug = {}
-
---[[
- local signs = get_available_signs("prefix") or {}
- debug.debugprefixes = cfe({
- name = "debugprefixes",
- label="Available prefixes",
- option=signs,
- type="select",
- size=table.maxn(signs)+1,
- })
-
- local signs = get_available_signs("suffix") or {}
- debug.debugsuffixes = cfe({
- name = "debugsuffixes",
- label="Available suffixes",
- option=signs,
- type="select",
- size=table.maxn(signs)+1,
- })
---]]
- debug.configdir = cfe({
- name = "configdir",
- label="configdir",
- value=configdir,
- })
- debug.datafile = cfe({
- name = "datafile",
- label="datafile",
- value=datafile,
- })
-
- for k,v in pairs(configfiles) do
- local cnfcontent
- fake, cnfcontent = get_value_from_file(v)
- for kk,vv in pairs(cnfcontent) do
- table.insert(configitems,vv)
- end
- end
----[[
- debug.configitems = cfe({
- name = "configitems",
- label="configitems",
- option=configitems,
- type="select",
- })
---]]
- debug.configfiles = cfe({
- name = "configfiles",
- label="configfiles",
- option=configfiles,
- type="select",
- })
-
- return debug
-end
-
function getfilelist ()
local listed_files = {}
for k,v in pairs{baseurl} do
@@ -740,12 +632,6 @@ function getfilelist ()
end
function get_filedetails(self,path)
--- local path
--- if (num == "2") then
--- path = configfile2
--- else
--- path = configfile
--- end
if not (validfilename(path)) then
return false, "Not a valid filename!"
end
@@ -802,6 +688,7 @@ function get_filedetails(self,path)
return file
end
+
function updatefilecontent (self, filetochange)
local path = filetochange.name
local modifications = filetochange.value
diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp
index 06b5339..17a1b60 100644
--- a/tinydns-status-html.lsp
+++ b/tinydns-status-html.lsp
@@ -1,4 +1,6 @@
-<? local form = ... ?>
+<? local form = ...
+require("viewfunctions")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -6,31 +8,6 @@ io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
?>
-<?
-function displayinfo(myform,tags,viewonly)
- io.write("<DL>")
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>\n")
- if (viewonly) then
- io.write("\t\t<DD>" .. val.value .. "\n")
- else
- io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
- end
- if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
- if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
- io.write("\t\t</DD>\n")
- end
- end
- io.write("</DL>")
-end
-?>
<H1>SYSTEM INFO</H1>
<?
@@ -42,16 +19,8 @@ displayinfo(myform,tags,"viewonly")
<H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2>
<H3>Locations</H3>
<?
--- DEBUGGING
---local myform = form.config
---local tags = { "debug", }
---displayinfo(myform,tags)
-
-
local myform = form.config.locations
---displayinfo(myform,tags)
io.write("<DL>")
---for k,v in pairs(tags) do
if (myform) and (myform.value) then
local val = myform
io.write("\n\t<DT")
@@ -60,7 +29,6 @@ if (myform) and (myform.value) then
end
io.write(">" .. val.label .. "</DT>")
-
io.write("\n\t\t<DD>")
for k,v in pairs(myform.value) do
io.write("<IMG SRC='/static/tango/16x16/places/start-here.png' width='16' height='16' alt> <B>" .. tostring(k) .. "</B>")
@@ -77,7 +45,6 @@ end
io.write("</DL>")
?>
-
<?
local function recurseoutput(table,cnt)
if not (cnt) then cnt=0 end
@@ -127,12 +94,3 @@ for k,v in pairs(tags) do
end
io.write("</DL>")
?>
-
-<?
---[[ 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>")
---]]
-?>
-