summaryrefslogtreecommitdiffstats
path: root/snort-expert-html.lsp
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-03-03 14:55:02 +0000
committerMika Havela <mika.havela@gmail.com>2008-03-03 14:55:02 +0000
commitf14ce45bcdcbbe99cb5693966019d0deb39371e5 (patch)
tree72d6db9d18f64c9f938c43000481595316e79389 /snort-expert-html.lsp
parent1c331f9c3a09d3f50c98a129db3a5dd77abc348e (diff)
downloadacf-snort-f14ce45bcdcbbe99cb5693966019d0deb39371e5.tar.bz2
acf-snort-f14ce45bcdcbbe99cb5693966019d0deb39371e5.tar.xz
Some changes to get 'save' button to work in expert-tab
git-svn-id: svn://svn.alpinelinux.org/acf/snort/trunk@785 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'snort-expert-html.lsp')
-rw-r--r--snort-expert-html.lsp120
1 files changed, 71 insertions, 49 deletions
diff --git a/snort-expert-html.lsp b/snort-expert-html.lsp
index ab2ee56..2217089 100644
--- a/snort-expert-html.lsp
+++ b/snort-expert-html.lsp
@@ -6,69 +6,91 @@ io.write(html.cfe_unpack(view))
io.write("</span>")
--]]
?>
-<h1>SYSTEM INFO</h1>
-
-<dl>
-<dt>Program status
-<dd><? if (view.status.enabled) then io.write('Enabled') else io.write('Disabled') end ?></dd>
-</dl>
+<?
+function displayinfo(myform,tags,viewonly)
+ 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
+end
+?>
-<dl>
-<dt>Program version</dt>
-<dd><?= view.status.version ?></dd>
-</dl>
+<H1>SYSTEM INFO</H1>
+<DL>
+<?
+local myform = view.status
+local tags = { "status", "version", }
+displayinfo(myform,tags,"viewonly")
+?>
+</DL>
+<form name="myform" action="" method="POST">
<h1>CONFIGURATION</h1>
-
<H2>Expert config</H2>
-
<h3>File details</h3>
-
<DL>
-<dt>File name</dt>
-<dd><?= view.file.details.path ?></dd>
+<?
+local myform = view.file
+local tags = { "filename", "filesize", "mtime", "sumerrors", }
+displayinfo(myform,tags,"viewonly")
+?>
</DL>
-<DL>
-<dt>File size</dt>
-<dd><?= view.file.details.size ?></dd>
-</DL>
+<H3>FILE CONTENT</H3>
+<?
+local myform = view.file
+io.write(html.form[myform.filecontent.type](myform.filecontent))
+?>
+<H2>SAVE AND APPLY ABOVE SETTINGS</H2>
<DL>
-<dt>Last modified</dt>
-<dd><?= view.file.details.mtime ?></dd>
+<?
+local tags = { "cmdsave", }
+displayinfo(myform,tags)
+?>
</DL>
-<h3>File content</h3>
-
-<form name="myform" action="" method="POST">
-<input name="name" type=hidden value="">
-<textarea name="modifications"><?= view.file.content ?></textarea>
-
-<H2>Save and apply above settings</H2>
-<DL>
-<DT>Apply settings</DT>
-<DD><input class="submit" type="submit" value="Apply"/></DD>
-</DL>
</form>
-<H1>MANAGEMENT</H1>
-
-<dl>
-<dt>Program controll-panel</dt>
-<dd><form name="cmd" action="" method="POST">
-<input type=submit class="submit" name="cmd" value="start">
-<input type=submit class="submit" name="cmd" value="stop">
-<input type=submit class="submit" name="cmd" value="restart">
-</form></dd>
-</dl>
-
-<? if (view.startstop) then ?>
-<dl>
-<dt>Previous action result</dt>
-<dd><pre><?= view.startstop?></pre></dd>
-</dl>
-<? end ?>
+<? -- MANAGEMENT BUTTONS
+local cmdform = view.management
+local cmdresult = view.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