summaryrefslogtreecommitdiffstats
path: root/tinydns-status-html.lsp
blob: 5d5bd1dfef1c22aaab7a5992c0631bf8776bbb02 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<? 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>
<? 
local myform = form.status.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("\t<DT")
	if (#val.errtxt > 0) then 
--		val.class = "error"
		io.write(" class='error'")
	end
	io.write(">" .. val.label .. "</DT>\n")


	io.write("\t\t<DD>\n")
	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"))
		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>")
?>


<? 
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) == "string") then
			io.write("<IMG SRC='/static/tango/16x16/devices/computer.png' width='16' height='16' alt STYLE='margin-left:"..cnt.."0px'> ".. 
				tostring(v) .. "</SPAN><BR>")
		else
			io.write("<SPAN STYLE='margin-left:"..cnt.."0px;font-wegith:strong;'> ".. 
				tostring(k) .. "</SPAN><BR>")
			recurseoutput(v,cnt)
		end
	end
end
?>

<? 
local myform = form.status.domains
if (myform) and (myform.value) then
	io.write("\t<DT")
	io.write(">" .. myform.label .. "</DT>\n")
	io.write("\t\t<DD>\n")

	for k,v in pairs(myform.value) do 
		recurseoutput(v)
	end

--[[
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
--]]

--[[
		local output = k
		io.write("<SPAN STYLE='margin-left:10px;font-weight:bold;'>".. k .. "</SPAN><BR>")
		if (#v == 0) then
		for k1,v1 in pairs(v) do 
			output = k1 .. "." .. output
			io.write("<SPAN STYLE='margin-left:20px;font-weight:normal;font-weight:bold;'>".. output .. "</SPAN><BR>")
			if (#v1 == 0) then
			for k2,v2 in pairs(v1) do 
				output = k2 .. "." .. output
				io.write("<SPAN STYLE='margin-left:30px;font-weight:normal;font-weight:bold;'>".. output .. "</SPAN><BR>")
				if (#v2 == 0) then
				for k3,v3 in pairs(v2) do 
					output = k3 .. "." .. output
					io.write("<SPAN STYLE='margin-left:40px;font-weight:normal;font-weight:bold;'>".. output .. "</SPAN><BR>")
					if (#v3 == 0) then
					for k4,v4 in pairs(v3) do 
						output = k4 .. "." .. output
						io.write("<SPAN STYLE='margin-left:50px;font-weight:normal;font-weight:bold;'>".. output .. "</SPAN><BR>")
						if (#v4 == 0) then
						for k5,v5 in pairs(v4) do 
							output = k5 .. "." .. output
							io.write("<SPAN STYLE='margin-left:60px;font-weight:normal;font-weight:bold;'>".. output .. "</SPAN><BR>")
							if (#v5 == 0) then
							for k6,v6 in pairs(v5) do 
								output = k6 .. "." .. output
								io.write("<SPAN STYLE='margin-left:70px;font-weight:normal;font-weight:bold;'>".. output .. "</SPAN><BR>")
							end
							else
								computer(output,7)
							end
						end
						else
							computer(output,6)
						end
					end
					else
						computer(output,5)
					end
				end
				else
					computer(output,5)
				end
			end
			else
				computer(output,5)
			end
		end
		else
			computer(output,4)
		end
	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>")
--]]
?>