File: admin_stat_audit.vsp

package info (click to toggle)
virtuoso-opensource 6.1.6+dfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 260,992 kB
  • ctags: 125,220
  • sloc: ansic: 652,748; sql: 458,419; xml: 282,834; java: 61,031; sh: 40,031; cpp: 36,890; cs: 25,240; php: 12,692; yacc: 9,523; lex: 7,018; makefile: 6,157; jsp: 4,484; awk: 1,643; perl: 1,013; ruby: 1,003; python: 326
file content (235 lines) | stat: -rw-r--r-- 7,808 bytes parent folder | download | duplicates (2)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?vsp 
--
--  $Id$
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2012 OpenLink Software
--  
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--  
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--  
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--  
--  

 adm_pre_page(lines);

  if (not adm_check_auth (lines))
    {
      adm_tell_unauth (lines);
      return (0);
    }

declare ft, stmt, err_sqlstate, err_msg, _ord, _where, _filter_c, _order, _order_n varchar;
declare _maxres, inx, jnx, n_cols, res_len integer;
declare m_dta, m_dta_col, result, col_names, res_row, res_cols any;

ft := get_keyword('ft',params, 'yes');
_maxres := atoi(get_keyword('maxres',params, '10'));
_where := '';
_filter_c := get_keyword('filter_c', params, '');
_order_n := get_keyword('order', params, 'Ascending');

if (_order_n = 'Ascending') {_order := 'Desc'; _order_n := 'Ascending';}
else {_order := 'Asc'; _order_n := 'Descending';}

_ord := concat(get_keyword('ord', params, 'EVTTIME'), ' ', _order);

if ('' <> _filter_c)
  _where := sprintf('WHERE CLIENT = \'%s\'', get_keyword('filter_c', params, ''));

?>
<HTML>
  <HEAD>
    <LINK REL="stylesheet" TYPE="text/css" HREF="<?=adm_what_css()?>">
    <TITLE>Web Server Auditing</TITLE>
    <META NAME="AUTHOR" CONTENT="OpenLink Software">
    <META NAME="DESCRIPTION" CONTENT="Virtuoso Auditing">
  </HEAD>
<?vsp adm_page_header('Web Server Audit Trail', NULL); ?>
<?include adm_js_check.vsp ?>

	<FORM METHOD="get">
<TABLE BORDER="0" CELLPADDING="10">
<TR><TD VALIGN="top">
	<INPUT TYPE="hidden" NAME="ft" VALUE="no">
	<INPUT TYPE="hidden" NAME="filter_c" VALUE="<?=_filter_c?>">
</TD><TD VALIGN="top">
  <table cellpadding="0" cellspacing="2" border="0"  CLASS="genlist">
    <tr><td CLASS="genhead" colspan="2">Web Server Log Viewer</td></tr>
    <THEAD>
      <tr>
        <th CLASS="genhead">Display Columns</th>
        <th CLASS="genhead">Show hits from</th>
      </tr>
    </THEAD>
    <TBODY>
      <tr><td>
	  <table cellpadding="0" cellspacing="2" border="0">
	    <tr>
      	      <td CLASS="genlisthead"> Event Time</td>
      	      <td align="left"><input type="checkbox" name="time" CHECKED onClick="javascript:this.form.submit()"></td>
            </tr>
	    <tr>
	      <td CLASS="genlisthead"> Referrer</td>
	      <td align="left"><input type="checkbox" name="referer"  onClick="javascript:this.form.submit()"></td>
	    </tr>
	    <tr>
	      <td CLASS="genlisthead"> URI</td>
	      <td align="left"><input type="checkbox" name="uri"  CHECKED onClick="javascript:this.form.submit()"></td>
	    </tr>
	    <tr>
	      <td CLASS="genlisthead"> Host</td>
	      <td align="left"><input type="checkbox" name="host"  onClick="javascript:this.form.submit()"></td>
	    </tr>
	    <tr>
	      <td CLASS="genlisthead"> Client IP</td>
	      <td align="left"><input type="checkbox" name="client"  CHECKED onClick="javascript:this.form.submit()"></td>
	    </tr>
	    <tr>
	      <td CLASS="genlisthead"> Authentication</td>
	      <td align="left"><input type="checkbox" name="auth"  CHECKED onClick="javascript:this.form.submit()"></td>
	    </tr>
	    <tr>
	      <td CLASS="genlisthead"> Command</td>
	      <td align="left"><input type="checkbox" name="cmd"  onClick="javascript:this.form.submit()"></td>
	    </tr>
	    <tr>
	      <td CLASS="genlisthead"> User Agent</td>
	      <td align="left"><input type="checkbox" name="ua"  onClick="javascript:this.form.submit()"></td>
	    </tr>
	  </table>
	</td><td valign="top" align="center">
	  <table border="0" cellpadding="2" cellspacing="0">
	    <tr>
	      <th CLASS="statlistheadt">Client IP</th>
	      <th CLASS="statlistheadt">Hit Count</th>
	      <th CLASS="statlistheadt">&nbsp;</th>
	    </tr>
	    <tr>
	      <td CLASS="statdata">127.0.0.1</td>
	      <td CLASS="statdata" align="center">563</td>
	      <td CLASS="statdata" align="left"><input type="checkbox"
		  NAME="Filter" Value="127.0.0.1"
		  onClick="javascript:this.form.filter_c.value='127.0.0.1';
		  this.form.submit();"></td>
    	    </tr>
	  </table>
      </td></tr>
      <tr>
	<td CLASS="genlisthead">Row Limit</td>
	<td CLASS="geninput"><INPUT SIZE="5" TYPE="text" NAME="maxres"
	    VALUE="10">&nbsp;(0 implies no limit)</td>
    </tr>
    <tr>
      <td CLASS="geninput" COLSPAN="2" align="center">
	  <INPUT TYPE="submit" NAME="refresh" VALUE="Refresh">
	  <INPUT TYPE="submit" NAME="clearlog" HIDEFOCUS VALUE="Clear">
      </td>
    </tr>
  </TBODY>
</table>
</TD><TD VALIGN="top">
</TD></TR></TABLE>
	</FORM>
<?vsp

stmt:= 'SELECT ';
if ('' <> get_keyword('time', params, '') or ft='yes') stmt := concat(stmt, 'EVTTIME, ');
if ('' <> get_keyword('referer', params, '')) stmt := concat(stmt, 'REFERER, ');
if ('' <> get_keyword('uri', params, '') or ft='yes') stmt := concat(stmt, 'URI, ');
if ('' <> get_keyword('host', params, '')) stmt := concat(stmt, 'HOST, ');
if ('' <> get_keyword('client', params, '') or ft='yes') stmt := concat(stmt, 'CLIENT, ');
if ('' <> get_keyword('auth', params, '') or ft='yes') stmt := concat(stmt, 'sprintf(\'[%s]:%s/%s\', coalesce(AUTHALGORITHM, \'\'), coalesce(REALM, \'\'), coalesce(USERNAME, \'\')) AS AUTH, ');
if ('' <> get_keyword('cmd', params, '')) stmt := concat(stmt, 'COMMAND, ');
if ('' <> get_keyword('ua', params, '')) stmt := concat(stmt, 'USERAGENT, ');

stmt := concat(stmt, '1 FROM WS.WS.AUDIT_LOG ', _where ,' ORDER BY ', _ord);

	declare err_sqlstate1, err_msg1 varchar;
	  err_sqlstate := '00000';
	  err_msg := 'none';

exec (stmt, err_sqlstate, err_msg, vector(), _maxres, m_dta, result);

-- headers
  if (0 = m_dta)
  {
    http('<P>No data found.</P>');
  }
  else
  {
    n_cols := length (aref (m_dta,0)) -1 ; -- that dummy 1 col

?>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="2" CLASS="statlist">
<TR><TD CLASS="stathead" COLSPAN="<?=n_cols?>">Web Server Admin Log</TD></TR>
<TR><TD CLASS="AdmBorders" COLSPAN="<?=n_cols?>"><IMG SRC="../images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR>
<TR>

<?vsp

    while (inx < n_cols)
    {
      m_dta_col := aref (aref (m_dta, 0), inx);

      http ('<TD CLASS="statlistheadt" NOWRAP>');
      col_names := aref (m_dta_col, 0);

      if (adm_unqualify(col_names) = 'EVTTIME') http('Event Time');
      if (adm_unqualify(col_names) = 'REFERER') http('Referer');
      if (adm_unqualify(col_names) = 'URI') http('URI');
      if (adm_unqualify(col_names) = 'HOST') http('Host');
      if (adm_unqualify(col_names) = 'CLIENT') http('Client');
      if (adm_unqualify(col_names) = 'AUTH') http('Authentication');
      if (adm_unqualify(col_names) = 'COMMAND') http('Command');
      if (adm_unqualify(col_names) = 'USERAGENT') http('User Agent');

      http ('</TD>');

      inx := inx + 1;
    }
    http('</TR>\n');

-- data

    res_len := length (result);
    inx := 0;

    while (inx < res_len)
    {
      http ('<TR>');

      res_row := aref (result, inx);

      jnx := 0;

      while (jnx < n_cols)
	{
	  http ('<TD CLASS="statdata">');
	  http_value (coalesce (aref (res_row, jnx), '<DB NULL>'));
	  http ('</TD>');
	  jnx := jnx + 1;
	}

      http ('</TR>\n');
      inx := inx + 1;
    }

    http ('</TABLE>');

  }
?>
<?vsp adm_page_footer(); ?>
</HTML>