Commit 13b0dd0c authored by Ted Trask's avatar Ted Trask

Whitespace cleanup

parent 893f78c2
......@@ -61,7 +61,6 @@ function downloadweblog(self)
for i,log in ipairs(retval.value.log.value) do
content[#content+1] = string.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,",
log.clientuserid, log.clientip, log.logdatetime, log.uri, log.bytes, log.reason, log.score or "0", log.reason, log.badyesno, log.deniedyesno, log.bypassyesno )
end
file.value = table.concat(content, "\n")
return file
......@@ -84,14 +83,14 @@ end
function downloadselected(self)
thisdate=os.date()
self.conf.viewtype = "stream"
local retval = viewselected(self)
local retval = viewselected(self)
local file = cfe({ type="longtext", value="", label="Weblog-resnet-selected-"..thisdate..".tab" })
local content = {"clientuserid\tclientip\tlogdatetime\turi\tbytes\treason\tscore\treason\tbadyesno\tdeniedyesno\tbypassyesno"}
for i,log in ipairs(retval.value.log.value) do
content[#content+1] = string.format("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t",
log.clientuserid, log.clientip, log.logdatetime, log.uri, log.bytes, log.reason, log.score or "0", log.reason, log.badyesno, log.deniedyesno, log.bypassyesno )
end
file.value = table.concat(content, "\n")
end
file.value = table.concat(content, "\n")
return file
end
......@@ -100,7 +99,8 @@ function checkselected(self)
self.conf.viewtype = "silent"
return self.model.editselected(self.clientdata.chkdata)
--return file
end
end
function clearselected(self)
return self:redirect_to_referrer(self.model.clearselected())
end
......@@ -131,7 +131,7 @@ function downloadadhocquery(self)
local retval = self.model.getnewadhocquery()
controllerfunctions.handle_clientdata(retval, self.clientdata)
retval = self.model.adhocquery(retval)
local file = cfe({ type="longtext", value="", label="query" })
if retval.value.result and #retval.value.result.value > 0 then
local columns = {}
......@@ -148,7 +148,7 @@ function downloadadhocquery(self)
end
file.value = table.concat(content, "\n")
end
return file
end
......
......@@ -253,7 +253,6 @@ local updateusagestats = function()
"date_trunc('hour', weblog.logdatetime) as date, " ..
"count(*), SUM(deniedyesno) from weblog group by sourcename,date"
local res = assert (con:execute(sql))
end
-- Move weblog into pubweblog, and truncate weblog
......@@ -295,7 +294,7 @@ end
local groompublogs = function()
local purgedays = config.purgedays or 30
--local watchdays = config.watchdays or 14
local now = os.time()
local temp = os.date("%Y-%m-%d %H:%M:%S", now - purgedays*86400)
......@@ -305,7 +304,7 @@ local groompublogs = function()
sql = "Insert into pubweblog_history select * from pubweblog where logdatetime < '" .. temp .."' and (badyesno > 0 or deniedyesno > 0 or bypassyesno > 0 or selected = 'true')"
res = assert (con:execute(sql))
logme("Moved " .. res .. " old records to history")
sql = "Delete from pubweblog where logdatetime < '" .. temp .."'"
res = assert (con:execute(sql))
logme("Deleted " .. res .. " old records to from pubweblog")
......@@ -365,18 +364,17 @@ local generatewhereclause = function(clientuserid, starttime, endtime, clientip,
if score and score ~= "" then
where[#where+1] = "score >= '"..escape(score).."'"
end
if urisearch and urisearch ~= "" then
if urisearch and urisearch ~= "" then
where[#where+1] = "lower(uri) LIKE '%"..escape(urisearch).."%'"
end
if selected and selected == "true" then
where[#where+1] = "selected = 'true'"
end
if #where > 0 then
sql = " WHERE " .. table.concat(where, " AND ")
end
return sql
end
......@@ -533,7 +531,7 @@ local function checkwords(logentry)
if not thisline then
break
end
_,instcnt = string.lower(logentry.URL):gsub(thisline, " ")
if instcnt ~= 0 then
-- logme("instcnt = "..instcnt)
......@@ -542,29 +540,29 @@ local function checkwords(logentry)
badwordloc[#badwordloc+1] = thisline
end
end
--check for DansGuardian actions
if (logentry.reason and logentry.reason ~= "") then
if string.find(logentry.reason,"DENIED") then
-- logme("*Denied*")
logentry.deniedyesno=1
elseif string.find(logentry.URL,"GBYPASS") then
-- logme("GBYPASS")
logentry.bypassyesno=1
elseif string.find(logentry.reason,"OVERRIDE") then
-- logme("*OVERRIDE*")
logentry.bypassyesno=1
end
if string.find(logentry.reason,"DENIED") then
-- logme("*Denied*")
logentry.deniedyesno=1
elseif string.find(logentry.URL,"GBYPASS") then
-- logme("GBYPASS")
logentry.bypassyesno=1
elseif string.find(logentry.reason,"OVERRIDE") then
-- logme("*OVERRIDE*")
logentry.bypassyesno=1
end
end
--check for Squark actions
if (logentry.squarkaction and logentry.squarkaction ~= "") then
--logme("squarkaction="..logentry.squarkaction)
if string.find(logentry.squarkaction, "blocked") then
logentry.deniedyesno=1
elseif string.find(logentry.squarkaction,"overridden") then
logentry.bypassyesno=1
end
--logme("squarkaction="..logentry.squarkaction)
if string.find(logentry.squarkaction, "blocked") then
logentry.deniedyesno=1
elseif string.find(logentry.squarkaction,"overridden") then
logentry.bypassyesno=1
end
end
for i,goodline in ipairs(goodwords) do
......@@ -616,7 +614,7 @@ local function parsesquidlog(line)
peerhost=string.match(words[9] or "", "[^/]*$"),
squarkcategory=string.match(words[11] or "", "^[^,]*"),
squarkaction=string.match(words[11] or "", "[^,]*$")}
checkwords(logentry)
-- Don't care about local requests (from DG) (this check also removes blank lines)
......@@ -843,7 +841,6 @@ function createsource(sourcedata)
if not res and err then
sourcedata.errtxt = sourcedata.errtxt .. "\n" .. err
end
else
end
return sourcedata
......@@ -981,7 +978,7 @@ function importlogs()
-- Determine sources
local sources = listsourceentries(sourcename)
for i,source in ipairs(sources) do
if source.enabled then
logme("Getting logs from source " .. source.sourcename)
......@@ -1204,7 +1201,7 @@ function getselected(csvdata)
databaseconnect(DatabaseUser)
local entries = {}
-- retrieve a cursor
local sql = "SELECT * FROM pubweblog where selected = true and logdatetime >= '" .. starttime .. "' and logdatetime <= '" .. endtime .. "'"
local sql = "SELECT * FROM pubweblog where selected = true and logdatetime >= '" .. starttime .. "' and logdatetime <= '" .. endtime .. "'"
local idcnt = 0
sql = sql .. " ORDER BY logdatetime;"
cur = assert (con:execute(sql))
......@@ -1215,11 +1212,11 @@ function getselected(csvdata)
end
-- close everything
cur:close()
result.log.value = entries or {}
result.log.value = entries or {}
--result.log.value = sql
databasedisconnect()
end)
return cfe({ type="group", value=result, errtxt=err, label="Weblog Selected" })
return cfe({ type="group", value=result, errtxt=err, label="Weblog Selected" })
end
function editselected(chkdata)
......@@ -1229,9 +1226,9 @@ function editselected(chkdata)
idarray = format.string_to_table(chkdata, "|")
for key,x in pairs(idarray) do
keycnt = keycnt + 1
if keycnt == 1 then
if keycnt == 1 then
sql = sql..x.." WHERE id = "
else
else
sql = sql..x
end
end
......@@ -1247,32 +1244,30 @@ function clearselected()
databasedisconnect()
retval.value = "Cleared"
retval.errtxt = nil
return retval
return retval
end
function getweblog(activelog, clientuserid, starttime, endtime, clientip, badyesno, deniedyesno, bypassyesno, score, urisearch, sortby, selected, focus )
if (not activelog or activelog=="") then
activelog = "pubweblog"
end
if (not starttime or starttime=="") and (not endtime or endtime=="") and config.auditstart~="" and config.auditend~="" then
starttime = config.auditstart
endtime = config.auditend
starttime = config.auditstart
endtime = config.auditend
if config.badyesno=="true" then
badyesno = '1'
badyesno = '1'
end
end
if (not score or score=="") and config.minimumscore~="" then
score = config.minimumscore
score = config.minimumscore
end
if (not sortby or sortby=="") and config.sortby~="" then
sortby = config.sortby
sortby = config.sortby
end
local result = handleparameters(activelog, clientuserid, starttime, endtime, clientip, badyesno, deniedyesno, bypassyesno, score, urisearch, sortby, selected, focus)
result.log = cfe({ type="list", value={}, label="Weblog Access Log" })
local success = validateparameters(result)
......@@ -1286,7 +1281,6 @@ function getweblog(activelog, clientuserid, starttime, endtime, clientip, badyes
err = "Invalid search parameters"
end
return cfe({ type="group", value=result, errtxt=err, label="Weblog Access Log" })
end
function getusagestats()
......@@ -1402,7 +1396,7 @@ function updateconfig(newconfig)
configcontent = format.update_ini_file(configcontent, "", "badyesno", tostring(newconfig.value.badyesno.value))
configcontent = format.update_ini_file(configcontent, "", "minimumscore", tostring(newconfig.value.minimumscore.value))
configcontent = format.update_ini_file(configcontent, "", "sortby", tostring(newconfig.value.sortby.value))
fs.write_file(configfile, configcontent)
config = format.parse_ini_file(configcontent, "") or {}
else
......@@ -1553,7 +1547,7 @@ end
function readfile(filename)
return modelfunctions.getfiledetails(filename, files)
end
function updatefile(filedetails)
return modelfunctions.setfiledetails(filedetails, files)
end
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