diff options
author | Ted Trask <ttrask01@yahoo.com> | 2011-09-07 15:27:34 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2011-09-07 15:27:34 +0000 |
commit | 13b0dd0cb952d316b27f911f06d0a9c60a60ffd8 (patch) | |
tree | 99fd6a75c7502a46cb62f088882d830ff5dc0716 /weblog-model.lua | |
parent | 893f78c2213c87ef27339f19d5db3ad91959e6d9 (diff) | |
download | acf-weblog-13b0dd0cb952d316b27f911f06d0a9c60a60ffd8.tar.bz2 acf-weblog-13b0dd0cb952d316b27f911f06d0a9c60a60ffd8.tar.xz |
Whitespace cleanup
Diffstat (limited to 'weblog-model.lua')
-rw-r--r-- | weblog-model.lua | 90 |
1 files changed, 42 insertions, 48 deletions
diff --git a/weblog-model.lua b/weblog-model.lua index cbf200a..6f440d3 100644 --- a/weblog-model.lua +++ b/weblog-model.lua @@ -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 |