summaryrefslogtreecommitdiffstats
path: root/tinydns-status-html.lsp
blob: dd7a720609a26264823b48f723b67aeb17a48951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<? local form = ... ?>
<?
--[[ 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>")
--]]
?>
<?
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>
<? 
local myform = form.status 
local tags = { "status", "version", }
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")
	if (#val.errtxt > 0) then 
		io.write(" class='error'")
	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>")
		for kk,vv in pairs(v) do 
			io.write(tostring("<BR><SPAN STYLE='margin-left:30px;'>" .. vv .. "</SPAN>\n"))
		end
		io.write("<BR>")
	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>")
end
io.write("</DL>")
?>


<? 
local function recurseoutput(table,cnt)
	if not (cnt) then cnt=0 end
	cnt = cnt + 1
	for k,v in pairs(table or {}) do
		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 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
		else
			io.write("\n\t\t\t<SPAN STYLE='margin-left:"..cnt.."0px;font-weight:bold;'> ".. 
				tostring(table[k].label) .. "</SPAN><BR>")
			recurseoutput(v,cnt)
		end
		end
	end
end
?>

<H3>Records</H3>
<? 
local tags = {"nsourdomain", "nsdomain", "host", "alias", "mx", "ptr", "cname", "soa", "generic", "all" }
local myform = form.config.settings
io.write("<DL>")
for k,v in pairs(tags) do 
	local myform = myform[v]
	if (myform) and (myform.value) then
		io.write("\n\t<DT")
		io.write(">" .. myform.label .. "</DT>")
		io.write("\n\t\t<DD>")

		for k,v in pairs(myform.value) do 
			recurseoutput(v)
		end
		io.write("\n\t\t</DD>")
	end
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>")
--]]
?>