summaryrefslogtreecommitdiffstats
path: root/weblog-viewblocklog-html.lsp
blob: 0c10e0af13d42e26fc073a077e02523dc653b025 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<% local data, viewlibrary, page_info, session = ... %>

<% if data.value.focus.value ~= "" then %>
<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript">
	$(function(){
	   	if ($("#focus").length) {
			var top = $("#focus").offset().top;
			$("html,body").scrollTop(top);
		}
	});
</script>
<% end %>

<H1>Search Parameters</H1>
<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action) %>" method="POST">
<DL>
<DT>Start Time</DT>
<DD><%= html.html_escape(data.value.starttime.value) %>
<input class="text" type="text" name="starttime" value="<%= html.html_escape(data.value.starttime.value) %>" >
</DD>
<DT>User ID</DT>
<DD><%= html.html_escape(data.value.clientuserid.value) %>
<input class="text" type="text"  name="clientuserid"  value="<%= html.html_escape(data.value.clientuserid.value) %>" >
</DD>
<DT>Client IP</DT>
<DD><%= html.html_escape(data.value.clientip.value) %>
<input class="text" type="text"  name="clientip"  value="<%= html.html_escape(data.value.clientip.value) %>" >
</DD>
<DT>End Time</DT>
<DD><%= html.html_escape(data.value.endtime.value) %>
<input class="text" type="text"  name="endtime"  value="<%= html.html_escape(data.value.endtime.value) %>" >
</DD>
<DT></DT><DD><input class="submit" type="submit" name="Update" value="Update"></DD>
</DL>
</FORM>

<%
local clientinfo = ""
if data.value.clientuserid.value ~= "" then
	clientinfo = clientinfo .. "clientuserid="..data.value.clientuserid.value.."&"
end
if data.value.clientip.value ~= "" then
	clientinfo = clientinfo .. "clientip="..data.value.clientip.value.."&"
end
%>

<H1><%= html.html_escape(data.label) %></H1>
<TABLE>
	<TR style="background:#eee;font-weight:bold;">
		<TD style="padding-right:20px;white-space:nowrap;" class="header" colspan=2>Timestamp</TD>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">Client IP</TD>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">User ID</TD>
		<TD style="white-space:nowrap;" WIDTH="90%" class="header">Size</TD>
	</TR>

<% for i,watch in ipairs(data.value.log.value) do %>
	<% local time = {}
	time.year, time.month, time.day, time.hour, time.min, time.sec = 
		string.match(watch.logdatetime, "(%d+)%-(%d+)-(%d+)%s+(%d+):(%d+):(%d+)")
	time = os.time(time) %>
	<% if data.value.focus and data.value.focus.value == watch.logdatetime then %>
	<TR style="background:#ff0" id="focus">
	<% else %>
	<TR style="background:#eee">
	<% end %>
		<TD colspan=2><%= html.link{value = "viewweblog?"..clientinfo..
			"starttime="..os.date("%Y-%m-%d %H:%M:%S", time - 60*(tonumber(data.value.window.value)))..
			"&endtime="..os.date("%Y-%m-%d %H:%M:%S", time + 60*(tonumber(data.value.window.value)))..
			"&focus="..watch.logdatetime,
			label=watch.logdatetime} %></TD>
		<TD><%= html.html_escape(watch.clientip) %></TD>
		<TD><%= html.html_escape(watch.clientuserid) %></TD>
		<TD><%= html.html_escape(watch.bytes) %></TD>
	</TR>
	<TR><TD></TD><TD <% if string.find(watch.uri, "GBYPASS=") then %> style="background:#ee1" <% end %> colspan=4><%= html.link{value = watch.uri, label=watch.uri} %></TD></TR>
	<% if watch.reason and watch.reason ~= "" then %>
	<TR><TD></TD><TD style="background:#f33; color:#fff" colspan=4><%= html.html_escape(watch.reason) %></TD></TR>
	<% end %>
<% end %>
</TABLE>

<% if data.errtxt then %>
<p class="error"><%= html.html_escape(data.errtxt) %></p>
<% end %>
<% if #data.value.log.value == 0 then %>
<p>No results, try adjusting search parameters</p>
<% end %>

<% if page_info.action == "viewweblog" then %>
<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/downloadweblog") %>" method="POST">
<input type="hidden" name="starttime" value="<%= html.html_escape(data.value.starttime.value) %>" >
<input type="hidden"  name="clientuserid"  value="<%= html.html_escape(data.value.clientuserid.value) %>" >
<input type="hidden"  name="clientip"  value="<%= html.html_escape(data.value.clientip.value) %>" >
<input type="hidden"  name="endtime"  value="<%= html.html_escape(data.value.endtime.value) %>" >
<DL>
<DT>Download log</DT><DD><input class="submit" type="submit" name="Download" value="Download"></DD>
</DL>
</FORM>
<% end %>