summaryrefslogtreecommitdiffstats
path: root/weblog-viewblocklog-html.lsp
blob: f91025ba57e9e2fd27e407c8cf1ed09c3b0a175e (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<% local data, viewlibrary, page_info, session = ... %>

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

<style type="text/css">
  #content table { border-collapse: collapse; width: 100%; }
  #content table td { border-bottom: none; white-space: nowrap; padding-right:20px; }
  #content table tr.mark { background: #E9E9E9; }
  #content table tr.markfocus { background: #E9E966; }
  #content table tr.focus { background: #E9E900; }
  #content table tr.bypass { background: #eaa; }
  #content table td.reason { color: #000; padding-left: 20px; border-bottom:1px solid #999; }
</style>

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

<%
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>
<DL><TABLE>
	<TR class="header">
		<TD class="header">Timestamp</TD>
		<TD class="header">Client IP</TD>
		<TD class="header">User ID</TD>
		<TD class="header">Size</TD>
		<TD WIDTH="90%" class="header">URL</TD>
	</TR>

<% for i,watch in ipairs(data.value.log.value) do %>
	<% local a,b = math.modf((i/2))
	local mark = ''
	if (b == 0) then mark=mark..'class="mark"' end
	if string.find(watch.uri, "GBYPASS=") then mark='class="bypass"' end
	%>
	
	<% 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) %>
	<TR <%= mark %>>
		<TD <% if data.value.focus.value == watch.logdatetime then %> style="font-weight:bold;" id="focus" <% end %> ><%= 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 <% if data.value.clientip.value == watch.clientip then %> style="font-weight:bold;" <% end %> ><%= html.html_escape(watch.clientip) %></TD>
		<TD <% if data.value.clientuserid.value == watch.clientuserid then %> style="font-weight:bold;" <% end %> ><%= html.html_escape(watch.clientuserid) %></TD>
		<TD><%= html.html_escape(watch.bytes) %></TD>
		<TD title="<%= html.html_escape(watch.uri) %>" >
		<%= html.link{value = watch.uri, label=watch.shorturi or watch.uri} %></TD>
	</TR>
	<TR <%= mark %>>
	<TD class='reason' <% if (watch.shortreason and watch.shortreason ~= "") or (watch.reason and watch.reason ~= "") then %>
		title="<%= html.html_escape(watch.reason) %>"<% end %> colspan=5>
		<% if watch.score and watch.score ~= "0" then %><%= html.html_escape(watch.score) %> - <% end %>
		<% if (watch.shortreason and watch.shortreason ~= "") then %>
			<%= html.html_escape(watch.shortreason) %>
		<% elseif (watch.reason and watch.reason ~= "") then %>
			<%= html.html_escape(string.gsub(watch.reason, "%(.*", "")) %>
		<% end %>
	</TD></TR>
<% 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) %>" >
<DT>Download log</DT><DD><input class="submit" type="submit" name="Download" value="Download"></DD>
</FORM>
<% end %>

</DL>