diff options
-rwxr-xr-x | tinydns-config-html.lsp | 82 | ||||
-rw-r--r-- | tinydns-controller.lua | 433 | ||||
-rw-r--r-- | tinydns-model.lua | 114 | ||||
-rw-r--r-- | tinydns-status-html.lsp | 25 | ||||
-rw-r--r-- | tinydns.menu | 2 |
5 files changed, 537 insertions, 119 deletions
diff --git a/tinydns-config-html.lsp b/tinydns-config-html.lsp index b3f9053..49cfa8c 100755 --- a/tinydns-config-html.lsp +++ b/tinydns-config-html.lsp @@ -43,53 +43,73 @@ displayinfo(myform,tags,"viewonly") <H2>General settings</H2> <? local myform = form.config -local tags = { "listen", } +local tags = { "listen","cmdeditlisten", } displayinfo(myform,tags) ?> <H2>Locations</H2> -<? -local v = "locations" ---displayinfo(myform,tags) -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") - +<? +local tags = { "locations","cmdeditlocations", "cmdnewlocations", } +displayinfo(myform,tags) +?> - io.write("\t\t<DD>\n") - for k,v in pairs(myform[v]["value"]) do - io.write("<IMG SRC='/static/tango/16x16/places/start-here.png' width='16' height='16' alt> <B>" .. tostring(k) .. "</B>") - for kk,vv in pairs(v) do - io.write(tostring("<BR>" ..vv.option[3]).. "\n") - end - io.write("<BR>") - 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>") +<H2>Records</H2> +<H3><? io.write(tostring(form.config.nsourdomain.label) or "NS record") ?></H3> +<? +local tags = { "nsourdomain","cmdeditnsourdomain", } +displayinfo(myform,tags) ?> +<H3><? io.write(tostring(form.config.nsdomain.label) or "NS record") ?></H3> +<? +local tags = { "nsdomain","cmdeditnsdomain", } +displayinfo(myform,tags) +?> +<H3><? io.write(tostring(form.config.host.label) or "Hosts record") ?></H3> +<? +local tags = { "host","cmdedithost", } +displayinfo(myform,tags) +?> +<H3><? io.write(tostring(form.config.alias.label) or "Alias record") ?></H3> +<? +local tags = { "alias","cmdeditalias", } +displayinfo(myform,tags) +?> +<H3><? io.write(tostring(form.config.mx.label) or "MX record") ?></H3> +<? +local tags = { "mx","cmdeditmx", } +displayinfo(myform,tags) +?> +<H3><? io.write(tostring(form.config.ptr.label) or "PTR record") ?></H3> +<? +local tags = { "ptr","cmdeditptr", } +displayinfo(myform,tags) +?> +<H3><? io.write(tostring(form.config.cname.label) or "CNAME record") ?></H3> +<? +local tags = { "cname","cmdeditcname", } +displayinfo(myform,tags) +?> +<H3><? io.write(tostring(form.config.soa.label) or "SOA record") ?></H3> +<? +local tags = { "soa","cmdeditsoa", } +displayinfo(myform,tags) +?> +<H3><? io.write(tostring(form.config.generic.label) or "GENERIC record") ?></H3> +<? +local tags = { "generic","cmdeditgeneric", } +displayinfo(myform,tags) +?> - -<? ---[[ ?> +<? --[[ ?> <H1>DEGUGGING</H1> <? local myform = form.debug diff --git a/tinydns-controller.lua b/tinydns-controller.lua index 030257f..122470d 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -1,7 +1,5 @@ module(..., package.seeall) -local pvt = {} - local list_redir = function (self) self.conf.action = "status" self.conf.type = "redir" @@ -26,21 +24,51 @@ local function getstatus(self) return status end +local function filtertable(t,limit,counter) + if not (counter) then counter = 0 end + counter = counter + 1 + + if (t) then + for k,v in pairs(t) do + if (counter > (limit + 2)) then + t[k] = nil + end + if (type(t[k]) == "table") then + filtertable(v,limit,counter) + end + end + end +end + +local function unpackoptions(t,array,descrfield) + for k,v in pairs(t) do + if not (v.option) then + if (type(v) == "table") then + unpackoptions(v,array,descrfield) + end + else + if (v.option[descrfield]) and (v.option[descrfield].value) then + table.insert(array, v.label .. " (" .. v.option[descrfield].value .. ")") + else + table.insert(array, v.label) + end + end + end +end + function status(self) local config = {} config.settings = {} --- local array = {} local locations=self.model.getlocations(self) local availablesigns = self.model.check_signs("prefix") - config.locations = cfe ({ name="locations", - label="Locations", + label="Defining locations", value=locations, }) ---[[ +---[[ local prefix = "." config.settings.nsourdomain = cfe ({ name="nsourdomain", @@ -105,69 +133,366 @@ function status(self) }) --]] +--[[ config.settings.all = cfe ({ name="generic", label="All available records", value=self.model.getconfigobjects(self), }) - +--]] local counter --- colapse_output(config.settings, pvt) ----[[ - -- We count the rows of the previous columns - -- This counter is then used to set the default filter (when user has not entered any values) - -- FIXME: This is a uggly way of doing things. It's just a way to get going faster - local filterstage = 3 - - local mytable = config.settings - for k1,v1 in pairs(mytable) do - if not (counter) then counter = 0 end - if (type(v1) == "table") then - for k2,v2 in pairs(v1) do - if (type(v2) == "table") then - for s1,vs1 in pairs(v2) do - if (type(vs1) == "table") then - for s2,vs2 in pairs(vs1) do - if (filterstage) and (filterstage == 2) then - mytable[k1][k2][s1][s2] = {} -- Removes stage2 and above - else - - if (type(vs2) == "table") then - for s3,vs3 in pairs(vs2) do - if (filterstage) and (filterstage == 3) and not (vs3.name) then - mytable[k1][k2][s1][s2][s3] = {} -- Removes stage3 and above - end - end - end - - end - end - end - end - end - end - end + return { + status=getstatus(self), + config=config, + } +end + +function config(self) + local config = self.model.getconfig(self) + local debug = self.model.getdebug(self) + local availablesigns = self.model.check_signs("prefix") +-- local debug = self..status(self) +-- debug = self + + -- LISTEN _________________________________________________________ + -- Add button + config.cmdeditlisten = cfe ({ + name="cmdeditlisten", + label="Save above changes", + value="Save", + type="submit", + disabled="yes", + }) + + + -- LOCATIONS _________________________________________________________ + local locations=self.model.getlocations(self) + config.locations = cfe ({ + name="locations", + label="Locations", + option={}, + type="select", + }) + -- Add options + for n in pairs(locations) do + table.insert(config.locations.option, n) end ---]] - config.debug = cfe ({ - name="debug", - label="Counted rows", - value=pvt, - errtxt=" ", + -- Add a [New] record to the options + table.insert(config.locations.option, "[New]") + -- Set size of the inputbox + config.locations.size = #config.locations.option + if (#config.locations.option == 1) then + config.locations.size = #config.locations.option + 1 + end + + -- Add button + config.cmdeditlocations = cfe ({ + name="cmdeditlocations", + label="Edit above location", + value="Edit", + descr="Mark a item in '" .. config.locations.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", }) + -- Nameservers _________________________________________________________ + local prefix = "." + local domainopts = {} + local domainoptions = self.model.getconfigobjects(self,prefix) + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.nsourdomain = cfe ({ + name="nsourdomain", + type="select", + label=availablesigns[prefix], + option=domainopts, + descr="Above records look like '.fqdn:ip:x:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add a [New] record to the options + table.insert(config.nsourdomain.option, "[New]") + -- Set size of the inputbox + config.nsourdomain.size = #config.nsourdomain.option + if (#config.nsourdomain.option == 1) then + config.nsourdomain.size = #config.nsourdomain.option + 1 + end + + -- Add button + config.cmdeditnsourdomain = cfe ({ + name="cmdeditnsourdomain", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.nsourdomain.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + -- Nameservers _________________________________________________________ + local prefix = "&" + local domainoptions = self.model.getconfigobjects(self,prefix) + local domainopts = {} + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.nsdomain = cfe ({ + name="nsdomain", + label=availablesigns[prefix], + type="select", + option=domainopts, + descr="Above records look like '&fqdn:ip:x:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add options +-- for n in pairs(locations) do +-- table.insert(config.nsdomain.option, n) +-- end + -- Add a [New] record to the options + table.insert(config.nsdomain.option, "[New]") + -- Set size of the inputbox + config.nsdomain.size = #config.nsdomain.option + if (#config.nsdomain.option == 1) then + config.nsdomain.size = #config.nsdomain.option + 1 + end + + -- Add button + config.cmdeditnsdomain = cfe ({ + name="cmdeditnsdomain", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.nsdomain.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + -- Host _________________________________________________________ + local prefix = "=" + local domainoptions = self.model.getconfigobjects(self,prefix) + local domainopts = {} + -- Filter out options + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.host = cfe ({ + name="host", + label=availablesigns[prefix], + type="select", + option=domainopts, + descr="Above records look like '=fqdn:ip:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add a [New] record to the options + table.insert(config.host.option, "[New]") + -- Set size of the inputbox + config.host.size = #config.host.option + if (#config.host.option == 1) then + config.host.size = #config.host.option + 1 + end + + -- Add button + config.cmdedithost = cfe ({ + name="cmdedithost", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.host.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + -- Alias _________________________________________________________ + local prefix = "+" + local domainoptions = self.model.getconfigobjects(self,prefix) + local domainopts = {} + -- Filter out options + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.alias = cfe ({ + name="alias", + label=availablesigns[prefix], + type="select", + option=domainopts, + descr="Above records look like '+fqdn:ip:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add a [New] record to the options + table.insert(config.alias.option, "[New]") + -- Set size of the inputbox + config.alias.size = #config.alias.option + if (#config.alias.option == 1) then + config.alias.size = #config.alias.option + 1 + end + + -- Add button + config.cmdeditalias = cfe ({ + name="cmdeditalias", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.alias.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + -- MX _________________________________________________________ + local prefix = "@" + local domainoptions = self.model.getconfigobjects(self,prefix) + local domainopts = {} + -- Filter out options + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.mx = cfe ({ + name="mx", + label=availablesigns[prefix], + type="select", + option=domainopts, + descr="Above records look like '@fqdn:ip:x:dist:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add a [New] record to the options + table.insert(config.mx.option, "[New]") + -- Set size of the inputbox + config.mx.size = #config.mx.option + if (#config.mx.option == 1) then + config.mx.size = #config.mx.option + 1 + end + + -- Add button + config.cmdeditmx = cfe ({ + name="cmdeditmx", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.mx.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + -- PTR _________________________________________________________ + local prefix = "^" + local domainoptions = self.model.getconfigobjects(self,prefix) + local domainopts = {} + -- Filter out options + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.ptr = cfe ({ + name="ptr", + label=availablesigns[prefix], + type="select", + option=domainopts, + descr="Above records look like '^fqdn:p:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add a [New] record to the options + table.insert(config.ptr.option, "[New]") + -- Set size of the inputbox + config.ptr.size = #config.ptr.option + if (#config.ptr.option == 1) then + config.ptr.size = #config.ptr.option + 1 + end + + -- Add button + config.cmdeditptr = cfe ({ + name="cmdeditptr", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.ptr.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + -- Cname _________________________________________________________ + local prefix = "C" + local domainoptions = self.model.getconfigobjects(self,prefix) + local domainopts = {} + -- Filter out options + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.cname = cfe ({ + name="cname", + label=availablesigns[prefix], + type="select", + option=domainopts, + descr="Above records look like 'Cfqdn:p:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add a [New] record to the options + table.insert(config.cname.option, "[New]") + -- Set size of the inputbox + config.cname.size = #config.cname.option + if (#config.cname.option == 1) then + config.cname.size = #config.cname.option + 1 + end + + -- Add button + config.cmdeditcname = cfe ({ + name="cmdeditcname", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.cname.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + -- SOA _________________________________________________________ + local prefix = "Z" + local domainoptions = self.model.getconfigobjects(self,prefix) + local domainopts = {} + -- Filter out options + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.soa = cfe ({ + name="soa", + label=availablesigns[prefix], + type="select", + option=domainopts, + descr="Above records look like 'Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add a [New] record to the options + table.insert(config.soa.option, "[New]") + -- Set size of the inputbox + config.soa.size = #config.soa.option + if (#config.soa.option == 1) then + config.soa.size = #config.soa.option + 1 + end + + -- Add button + config.cmdeditsoa = cfe ({ + name="cmdeditsoa", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.soa.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + -- GENERIC _________________________________________________________ + local prefix = ":" + local domainoptions = self.model.getconfigobjects(self,prefix) + local domainopts = {} + -- Filter out options + local descrfield = 2 -- This is the filed that is shown as description (in the select-box) + unpackoptions(domainoptions, domainopts,descrfield) + config.generic = cfe ({ + name="generic", + label=availablesigns[prefix], + type="select", + option=domainopts, + descr="Above records look like ':fqdn:n:rdata:ttl:timestamp:lo' when they are in the config-file.", + }) + -- Add a [New] record to the options + table.insert(config.generic.option, "[New]") + -- Set size of the inputbox + config.generic.size = #config.generic.option + if (#config.generic.option == 1) then + config.generic.size = #config.generic.option + 1 + end + + -- Add button + config.cmdeditgeneric = cfe ({ + name="cmdeditgeneric", + label="Edit above item", + value="Edit", + descr="Mark a item in '" .. config.generic.label .. "'-list before pressing [Edit]", + type="submit", + disabled="yes", + }) + + - return { status=getstatus(self), config=config } -end -function config(self) - local config = self.model.getconfigobjects(self) - local debug = self.model.getdebug(self) return ({ status=getstatus(self), config=config, - debug=debug, +-- debug=debug, }) end diff --git a/tinydns-model.lua b/tinydns-model.lua index a073011..a68cda8 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -272,6 +272,39 @@ 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 + -- 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) @@ -304,14 +337,9 @@ function getconfigobjects(self,filter_type) domain[i-1] = domain[i-1] .. "." .. domain[i] end - -- This is the main information on each object - domaindetails = cfe ({ - name=filecontent_table[2], - label=filecontent_table[2], - }) - + local domainoptions = {} -- Add details to the previous object - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name="type", label="Type", value=descr[filecontent_table[1]], @@ -334,7 +362,7 @@ function getconfigobjects(self,filter_type) label = "Type of record" end if (filecontent_table[3]) and (#filecontent_table[3]> 0) and (name) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name=name, label=label, value=filecontent_table[3], @@ -358,7 +386,7 @@ function getconfigobjects(self,filter_type) label = "Contact address" end if (filecontent_table[4]) and (#filecontent_table[4]> 0) and (name) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name=name, label=label, value=filecontent_table[4], @@ -382,7 +410,7 @@ function getconfigobjects(self,filter_type) label = "Serial number" end if (filecontent_table[5]) and (#filecontent_table[5]> 0) and (name) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name=name, label=label, value=filecontent_table[5], @@ -407,7 +435,7 @@ function getconfigobjects(self,filter_type) end if (filecontent_table[6]) and (#filecontent_table[6]> 0) and (name) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name=name, label=label, value=filecontent_table[6], @@ -431,7 +459,7 @@ function getconfigobjects(self,filter_type) label = "Retry time" end if (filecontent_table[7]) and (#filecontent_table[7]> 0) and (name) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name=name, label=label, value=filecontent_table[7], @@ -451,7 +479,7 @@ function getconfigobjects(self,filter_type) label = "Expire time" end if (filecontent_table[8]) and (#filecontent_table[8]> 0) and (name) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name=name, label=label, value=filecontent_table[8], @@ -461,28 +489,28 @@ function getconfigobjects(self,filter_type) -- Set values and labels for field #9-12 if (filecontent_table[1] == "Z") then if (filecontent_table[9]) and (#filecontent_table[9]> 0) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name="min", label="Minimum time", value=filecontent_table[9], })) end if (filecontent_table[10]) and (#filecontent_table[10]> 0) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name="ttl", label="Time to live", value=filecontent_table[10], })) end if (filecontent_table[11]) and (#filecontent_table[11]> 0) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name="timestamp", label="Time stamp", value=filecontent_table[11], })) end if (filecontent_table[12]) and (#filecontent_table[12]> 0) then - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name="location", label="Location", value=filecontent_table[12], @@ -491,8 +519,15 @@ function getconfigobjects(self,filter_type) end + -- This is the main information on each object + domaindetails = cfe ({ + name=filecontent_table[2], + label=filecontent_table[2], + option=domainoptions, + }) + --[[ - table.insert(domaindetails, cfe ({ + table.insert(domainoptions, cfe ({ name="debug", label="Debug", value=filter_type, @@ -500,7 +535,6 @@ function getconfigobjects(self,filter_type) --]] end -- * END * COMMONT SETTINGS *************************************************************************************** - -- Inject the previous data into the right table local value = filecontent_table[2] local currenttable @@ -508,10 +542,11 @@ function getconfigobjects(self,filter_type) currenttable = recursedomains(domain, domains, table.maxn(domain)) end +---[[ if (domaindetails.value) then table.insert (currenttable , domaindetails) end - +--]] end end @@ -519,8 +554,45 @@ function getconfigobjects(self,filter_type) -- TODO: Sort the domains table! -- Sorting is not possible when things is done as they are (se above) -- problem comese when we use keynames instead of [1], [2], ... + -- Next we rebuild the domains table and do it so it can be sorted + local domains_sorted = {} + + local domains_rebuilt = {} + rebuild_table(domains,domains_rebuilt) + +--[==[ + for k1,v1 in pairsByKeys(domains) do + table.insert(domains_sorted, { name=k1 }) + for k2,v2 in pairsByKeys(v1) do + table.insert(domains_sorted[#domains_sorted], { name=k2 }) +---[=[ + if (v2) and (type(v2) == "table") then +-- if not (v2.type) then + for k3,v3 in pairsByKeys(v2) do + if (v2[k3]["value"]) then + if not (domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"]) then + domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"] = {} + end +-- table.insert(domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"], domains[k1][k2] ) + else + table.insert(domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]], { name=k3 }) + end + end +-- else +-- if not (domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"]) then +-- domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"] = {} +-- end +-- table.insert(domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"], { name=v2, name=k3 } ) +-- end + end +--]=] + end + end +-- table.sort(domains_sorted) + +--]==] - return domains + return domains_rebuilt end diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp index 37a7c53..5ceb8ea 100644 --- a/tinydns-status-html.lsp +++ b/tinydns-status-html.lsp @@ -55,7 +55,6 @@ if (myform) and (myform.value) then local val = myform io.write("\n\t<DT") if (#val.errtxt > 0) then --- val.class = "error" io.write(" class='error'") end io.write(">" .. val.label .. "</DT>") @@ -65,7 +64,7 @@ if (myform) and (myform.value) then 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>") for kk,vv in pairs(v) do - io.write(tostring("<BR>" .. vv .. "\n")) + io.write(tostring("<BR><SPAN STYLE='margin-left:30px;'>" .. vv .. "</SPAN>\n")) end io.write("<BR>") end @@ -74,7 +73,6 @@ if (myform) and (myform.value) then 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>") end ---end io.write("</DL>") ?> @@ -84,23 +82,26 @@ local function recurseoutput(table,cnt) if not (cnt) then cnt=0 end cnt = cnt + 1 for k,v in pairs(table or {}) do - if (type(v["name"]) == "string") then - io.write("\n\t\t\t<IMG SRC='/static/tango/16x16/devices/computer.png' width='16' height='16' alt STYLE='margin-left:"..cnt.. - "0px'><SPAN STYLE=''> ".. tostring(v["label"]) .. "</SPAN><BR>") - if (#v > 0) then + if (table[k].label) then + if not (tonumber(k)) or (v.value) then +-- if v.label then + io.write("\n\t\t\t<IMG SRC='/static/tango/16x16/devices/computer.png' width='16' height='16' alt STYLE='margin-left:"..cnt.. + "0px'><SPAN STYLE=''> " .. tostring(v.label) .. "</SPAN><BR>") io.write("\n\t\t\t<TABLE STYLE='margin-left:90px;'>") - for i=1,#v do - if (type(v[i]["label"]) == "string") then - io.write("\n\t\t\t\t<TR>\n\t\t\t\t\t<TD WIDTH='160px' STYLE=''>".. tostring(v[i]["label"]) .. ":</TD>\n\t\t\t\t\t<TD>".. tostring(v[i]["value"]) .."</TD>\n\t\t\t\t</TR>") + for k1,v1 in pairs(v.option) do + if (v1.label) then + io.write("\n\t\t\t\t<TR>\n\t\t\t\t\t<TD WIDTH='160px' STYLE=''>".. tostring(v1.label) .. + ":</TD>\n\t\t\t\t\t<TD>".. tostring(v1.value) .."</TD>\n\t\t\t\t</TR>") end end io.write("\n\t\t\t</TABLE>") - end +-- end else io.write("\n\t\t\t<SPAN STYLE='margin-left:"..cnt.."0px;font-weight:bold;'> ".. - tostring(k) .. "</SPAN><BR>") + tostring(table[k].label) .. "</SPAN><BR>") recurseoutput(v,cnt) end + end end end ?> diff --git a/tinydns.menu b/tinydns.menu index de2ee2c..705c58b 100644 --- a/tinydns.menu +++ b/tinydns.menu @@ -1,3 +1,3 @@ #CAT GROUP/DESC TAB ACTION Networking 10DNS Status status -#Networking 10DNS Config config +Networking 10DNS Config config |