Commit 99457fa3 authored by Ted Trask's avatar Ted Trask

Cleaned up use of config files

parent f04f17d0
......@@ -162,14 +162,7 @@ end
function listfiles(self)
return self.model.listfiles(self)
end
function createfile(self)
return controllerfunctions.handle_form(self, self.model.getnewfile, self.model.createfile, self.clientdata, "Create", "Create New Weblog File", "Weblog File Created")
end
function editfile(self)
return controllerfunctions.handle_form(self, function() return self.model.readfile(self.clientdata.filename) end, self.model.updatefile, self.clientdata, "Save", "Edit Weblog File", "Weblog File Saved" )
end
function deletefile(self)
return self:redirect_to_referrer(self.model.deletefile(self.clientdata.filename))
return controllerfunctions.handle_form(self, function() return self.model.readfile(self.clientdata.filename) end, self.model.updatefile, self.clientdata, "Save", "Edit Weblog File", "Weblog File Saved" )
end
<% local form, viewlibrary, page_info = ...
require("viewfunctions")
%>
<H1><%= html.html_escape(form.label) %></H1>
<%
form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action
form.value.passwd.type = "password"
if page_info.action == "editsource" then
form.value.sourcename.readonly = true
end
local order = {"sourcename", "enabled", "source", "method", "userid", "passwd"}
displayform(form, order)
%>
weblog-editsource-html.lsp
\ No newline at end of file
......@@ -2,41 +2,18 @@
require("viewfunctions")
%>
<% displaycommandresults({"editfile", "deletefile", "startstop"}, session) %>
<% displaycommandresults({"createfile"}, session, true) %>
<% displaycommandresults({"editfile"}, session) %>
<H1>File List</H1>
<DL>
<TABLE>
<TR style="background:#eee;font-weight:bold;">
<TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">Action</TD>
<TD style="white-space:nowrap;text-align:left;" class="header">File</TD>
</TR>
<% for i,file in ipairs(view.value) do %>
<TR>
<TD style="padding-right:20px;white-space:nowrap;">
<% if viewlibrary.check_permission("editfile") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editfile?filename="..file.."&redir="..page_info.orig_action, label="Edit "} %>
<% end %>
<% if viewlibrary.check_permission("deletefile") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletefile?filename="..file, label="Delete "} %>
<% end %>
</TD>
<TD style="white-space:nowrap;"><%= html.html_escape(file) %></TD>
</TR>
<% end %>
<TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">File</TD>
<TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">Size</TD>
<TD style="white-space:nowrap;text-align:left;" class="header">Last Modified</TD>
</TR>
<% for k,v in ipairs( view.value ) do
io.write( "<tr><td><a href=\"" .. html.html_escape(page_info.script .. page_info.prefix .. page_info.controller) .. "/editfile?filename=" .. html.html_escape(v.filename) .. "&redir=" .. html.html_escape(page_info.orig_action) .. "\">" .. html.html_escape(v.filename) .. "</a></td><td>" .. html.html_escape(v.size) .."</td><td>" .. html.html_escape(v.mtime) .."</td></tr>\n" )
end %>
</TABLE>
</DL>
<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("createfile") then
local createform = viewlibrary.dispatch_component("createfile", nil, true) %>
<H2><%= html.html_escape(createform.label) %></H2>
<%
createform.action = page_info.script .. page_info.prefix .. page_info.controller .. "/createfile"
displayform(createform)
end %>
<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("startstop") then
viewlibrary.dispatch_component("startstop")
end %>
......@@ -20,7 +20,8 @@ local configcontent = fs.read_file(configfile) or ""
local config = format.parse_ini_file(configcontent, "") or {}
local goodwordslist = "/etc/weblog/goodwords"
local badwordslist = "/etc/weblog/badwords"
local baseurl = "/etc/weblog/"
local ignorewordslist = "/etc/weblog/ignorewords"
local files = {badwordslist, goodwordslist, ignorewordslist, configfile}
local database_creation_script = {
"CREATE TABLE dbhistlog (logdatetime timestamp(3) without time zone NOT NULL, msgtext text)",
......@@ -529,7 +530,7 @@ local function parsesquidlog(line)
local ignoreme=false
--check for ignored records first
for thisline in io.lines("/etc/weblog/ignorewords") do
for thisline in io.lines(ignorewordslist) do
if not thisline then
break
end
......@@ -542,7 +543,7 @@ local function parsesquidlog(line)
if ignoreme ~= true then
--proceed with record analysis
for thisline in io.lines("/etc/weblog/badwords") do
for thisline in io.lines(badwordslist) do
if not thisline then
break
end
......@@ -572,7 +573,7 @@ local function parsesquidlog(line)
isbypass=1
end
end
for goodline in io.lines("/etc/weblog/goodwords") do
for goodline in io.lines(goodwordslist) do
if not goodline then
break
end
......@@ -641,7 +642,7 @@ local function parsesquarklog(line)
local ignoreme=false
--check for ignored records first
for thisline in io.lines("/etc/weblog/ignorewords") do
for thisline in io.lines(ignorewordslist) do
if not thisline then
break
end
......@@ -653,7 +654,7 @@ local function parsesquarklog(line)
end
if ignoreme ~= true then
for thisline in io.lines(baseurl.."badwords") do
for thisline in io.lines(badwordslist) do
if not thisline then
-- logme("This line is apparently empty...")
break
......@@ -681,7 +682,7 @@ local function parsesquarklog(line)
isbypass=1
end
end
for goodline in io.lines(baseurl.."goodwords") do
for goodline in io.lines(goodwordslist) do
if not goodline then
-- logme("This line is apparently empty...")
break
......@@ -745,7 +746,7 @@ local function parsedglog(line)
local ignoreme=false
--check for ignored records first
for thisline in io.lines("/etc/weblog/ignorewords") do
for thisline in io.lines(ignorewordslist) do
if not thisline then
break
end
......@@ -757,7 +758,7 @@ local function parsedglog(line)
end
if ignoreme ~= true then
for thisline in io.lines("/etc/weblog/badwords") do
for thisline in io.lines(badwordslist) do
if not thisline then
-- logme("This line is apparently empty...")
break
......@@ -786,7 +787,7 @@ local function parsedglog(line)
isbypass=1
end
end
for goodline in io.lines("/etc/weblog/goodwords") do
for goodline in io.lines(goodwordslist) do
if not goodline then
-- logme("This line is apparently empty...")
break
......@@ -846,7 +847,7 @@ local function parsedumplog(line)
isbad=0
isdenied=0
isbypass=0
for thisline in io.lines("/etc/weblog/badwords") do
for thisline in io.lines(badwordslist) do
if not thisline then
logme("This line is apparently empty...")
break
......@@ -872,7 +873,7 @@ local function parsedumplog(line)
isbypass=1
end
end
for goodline in io.lines("/etc/weblog/goodwords") do
for goodline in io.lines(goodwordslist) do
if not goodline then
-- logme("This line is apparently empty...")
break
......@@ -1798,40 +1799,21 @@ function create_database(database)
return database
end
function listfiles()
local retval = cfe({ type="list", value={}, label="Weblog Files" })
if not fs.is_dir(baseurl) then fs.create_directory(baseurl) end
for file in posix.files(baseurl) do
file = baseurl..file
if fs.is_file(file) then
table.insert(retval.value, file)
end
end
table.sort(retval.value)
for i,file in ipairs(files) do
local details = fs.stat(file) or {}
details.filename = file
retval.value[#retval.value + 1] = details
end
return retval
end
function getnewfile()
local filename = cfe({ label="File Name", descr="Must be in "..baseurl })
return cfe({ type="group", value={filename=filename}, label="Weblog File" })
end
function readfile(filename)
return modelfunctions.getfiledetails(filename, listfiles().value)
return modelfunctions.getfiledetails(filename, files)
end
function updatefile(filedetails)
return modelfunctions.setfiledetails(filedetails, listfiles().value)
end
function deletefile(filename)
local retval = cfe({ label="Delete Weblog File result", errtxt = "Failed to delete Weblog File - invalid filename" })
for i,file in ipairs(listfiles().value) do
if filename == file then
retval.value = "Deleted File"
retval.errtxt = nil
os.remove(filename)
break
end
end
return retval
return modelfunctions.setfiledetails(filedetails, files)
end
USER=weblog:viewauditstats,weblog:completeaudit,weblog:viewactivitylog,weblog:viewwatchlist,weblog:viewweblog,weblog:downloadweblog,weblog:viewblocklog,weblog:viewusagestats,weblog:deletewatchlistentry,weblog:createwatchlistentry,weblog:adhocquery,weblog:downloadadhocquery
EXPERT=weblog:config,weblog:viewweblog,weblog:listsources,weblog:createsource,weblog:deletesource,weblog:editsource,weblog:testsource,weblog:importlogs,weblog:status,weblog:createdatabase,weblog:listfile,weblog:editfile
EXPERT=weblog:config,weblog:viewweblog,weblog:listsources,weblog:createsource,weblog:deletesource,weblog:editsource,weblog:testsource,weblog:importlogs,weblog:status,weblog:createdatabase,weblog:listfiles,weblog:editfile
ADMIN=weblog:config,weblog:viewauditstats,weblog:completeaudit,weblog:viewactivitylog,weblog:viewwatchlist,weblog:viewweblog,weblog:viewselected,weblog:downloadweblog,weblog:downloadlogview,weblog:downloadselected,weblog:checkselected,weblog:editselected,weblog:clearselected,weblog:viewblocklog,weblog:viewusagestats,weblog:listsources,weblog:createsource,weblog:deletesource,weblog:editsource,weblog:testsource,weblog:importlogs,weblog:deletewatchlistentry,weblog:createwatchlistentry,weblog:adhocquery,weblog:downloadadhocquery,weblog:status,weblog:createdatabase,weblog:listfiles,weblog:editfile
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment