% local form, viewlibrary, page_info = ...
require("viewfunctions")
%>
<% if form.value.result then %>
<%= html.html_escape(form.value.result.label) %>
<% if #form.value.result.value == 0 then %>
No results, try adjusting query
<% else %>
<% names = {}
for name,val in pairs(form.value.result.value[1]) do
names[#names+1] = name %>
<% end %>
<% for i,row in ipairs(form.value.result.value) do
local a,b = math.modf((i/2))
local mark = ''
if (b == 0) then mark=' class="mark"' end %>
>
<% for j,name in ipairs(names) do %>
<%= html.html_escape(row[name]) %> |
<% end %>
<% end %>
<% end %>
<% end %>
<%= html.html_escape(form.label) %>
This form accepts a Postgresql SELECT statement and displays the results. Examples:
- This statement will return the total bytes transferred by each user for the entire weblog history
SELECT clientuserid, sum(bytes) AS total FROM pubweblog GROUP BY clientuserid ORDER BY total DESC
- This statement limits the above statement to a specific range of dates (just yesterday)
SELECT clientuserid, sum(bytes) AS total FROM pubweblog WHERE logdatetime >= 'yesterday' and logdatetime < 'today' GROUP BY clientuserid ORDER BY total DESC
- This statement will return the number of requests and blocks by hour over the course of the entire usage history
SELECT extract(hour from date) AS hour, sum(numrequest) AS numrequest, sum(numblock) AS numblock FROM usagestat GROUP BY extract(hour from date) ORDER BY hour
<% displayformstart(form, page_info) %>
<% displayformitem(form.value.query, "query") %>
<% displayformend(form) %>
The available database tables and descriptions are as follows:
PubWeblog and PubBlocklog
These tables contain the combined squid access log and dansguardian log for every access and blocked access respectively. The definition of the table is as follows:
(
sourcename character varying(40),
clientip inet NOT NULL,
clientuserid character varying(64) NOT NULL,
logdatetime timestamp(3) without time zone NOT NULL,
uri text NOT NULL,
bytes integer NOT NULL,
reason text,
score integer,
shortreason text
)
dbHistLog
This table contains the database history, including such information as which log files were loaded and how many entries they contained. The definition of the table is as follows:
(
logdatetime timestamp(3) without time zone NOT NULL,
msgtext text
)
Source
This table contains the list of log file sources. The definition of the table is as follows:
(
sourcename character varying(40) NOT NULL,
method character varying(100) NOT NULL,
userid character varying(32),
passwd character varying(255),
source character varying(255) NOT NULL,
tzislocal boolean,
enabled boolean
)
Usagestat
This table contains a historical record of pages requested and blocked by hour. The definition of the table is as follows:
(
sourcename character varying(40) NOT NULL,
date timestamp(0) without time zone NOT NULL,
numrequest integer,
numblock integer
)
Watchlist
This table contains the user watch list. The definition of the table is as follows:
(
clientuserid character varying(64) NOT NULL,
expiredatetime timestamp(0) without time zone NOT NULL
)