1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
5 For use with Tomato Firmware only.
6 No part of this file may be used without permission.
10 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
11 <meta name='robots' content='noindex,nofollow'
>
12 <title>[<%
ident(); %>] Status: Web Usage
</title>
13 <link rel='stylesheet' type='text/css' href='tomato.css'
>
14 <link rel='stylesheet' type='text/css' href='color.css'
>
15 <script type='text/javascript' src='tomato.js'
></script>
19 <style type='text/css'
>
26 #webmon-controls .selected
{
29 text-decoration: underline
;
34 <script type='text/javascript' src='debug.js'
></script>
36 <script type='text/javascript'
>
38 // <% nvram("log_wm,log_wmdmax,log_wmsmax"); %>
46 var lastMaxCount
= -1;
54 function clearLog(clear
)
59 xob
.onCompleted = function(text
, xml
) {
61 E('clear' + clear
).innerHTML
= '» <a href="javascript:clearLog(' + clear
+ ')">Clear</a>';
62 if (!ref
.running
) ref
.once
= 1;
65 xob
.onError = function(ex
) {
69 xob
.post('webmon.cgi', 'clear=' + clear
);
70 E('clear' + clear
).innerHTML
= 'Please wait... <img src="spin.gif" style="vertical-align:top">';
75 if ((queue
.length
== 0) || (xob
)) return;
78 xob
.onCompleted = function(text
, xml
) {
80 for (var i
= 0; i
< resolve_data
.length
; ++i
) {
81 var r
= resolve_data
[i
];
82 if (r
[1] == '') r
[1] = r
[0];
85 dg
.setName(r
[0], r
[1]);
86 sg
.setName(r
[0], r
[1]);
91 xob
.onError = function(ex
) {
95 xob
.post('resolve.cgi', 'ip=' + queue
.splice(0, 20).join(','));
98 var ref
= new TomatoRefresh('update.cgi', '', 0, 'status_webmon');
100 ref
.refresh = function(text
)
121 function showSelectedOption(prev
, curr
)
125 elem
.removeClass('mc' + prev
, 'selected'); // safe if prev doesn't exist
126 if ((e
= E('mc' + curr
)) != null) {
127 elem
.addClass(e
, 'selected');
132 function showMaxCount()
134 if (maxCount
== lastMaxCount
) return;
135 showSelectedOption(lastMaxCount
, maxCount
);
136 lastMaxCount
= maxCount
;
137 ref
.postData
= 'exec=webmon&arg0=' + maxCount
;
140 function switchMaxCount(c
)
144 if (!ref
.running
) ref
.once
= 1;
146 cookie
.set('webmon-maxcount', maxCount
);
149 function WMGrid() { return this; }
150 WMGrid
.prototype = new TomatoGrid
;
152 WMGrid
.prototype.resolveAll = function()
158 for (i
= 1; i
< this.tb
.rows
.length
; ++i
) {
159 row
= this.tb
.rows
[i
];
160 ip
= row
.getRowData().ip
;
161 if (ip
.indexOf('<') == -1) {
166 row
.style
.cursor
= 'wait';
173 WMGrid
.prototype.onClick = function(cell
)
175 if ((cell
.cellIndex
|| 0) == 2 /* url */) return;
178 var ip
= row
.getRowData().ip
;
179 if (this.lastClicked
!= row
) {
180 this.lastClicked
= row
;
182 if (ip
.indexOf('<') == -1) {
184 row
.style
.cursor
= 'wait';
193 WMGrid
.prototype.setName = function(ip
, name
)
197 for (i
= this.tb
.rows
.length
- 1; i
> 0; --i
) {
198 row
= this.tb
.rows
[i
];
199 data
= row
.getRowData();
201 data
[1] = name
+ ((ip
.indexOf(':') != -1) ? '<br>' : ' ') + '<small>(' + ip
+ ')</small>';
202 row
.setRowData(data
);
203 row
.cells
[1].innerHTML
= data
[1];
204 row
.style
.cursor
= 'default';
209 WMGrid
.prototype.populateData = function(data
, url
)
216 this.lastClicked
= null;
217 this.removeAllData();
218 for (i
= 0; i
< list
.length
; ++i
) {
224 for (i
= data
.length
- 1; i
>= 0; --i
) {
235 for (i
= list
.length
- 1; i
>= 0; --i
) {
238 a
= CompressIPv6Address(e
.ip
);
239 if (a
!= null) e
.ip
= a
;
241 if (cache
[e
.ip
] != null) {
242 new_cache
[e
.ip
] = cache
[e
.ip
];
243 e
.ip
= cache
[e
.ip
] + ((e
.ip
.indexOf(':') != -1) ? '<br>' : ' ') + '<small>(' + e
.ip
+ ')</small>';
248 e
.value
= '<a href="http://' + e
.value
+ '" target="_new">' +
249 (e
.value
.length
> maxl
+ 3 ? e
.value
.substr(0, maxl
) + '...' : e
.value
) + '</a>';
252 e
.value
= e
.value
.replace(/\+/g, ' ');
253 if (e
.value
.length
> maxl
+ 3)
254 e
.value
= e
.value
.substr(0, maxl
) + '...';
256 dt
.setTime(e
.time
* 1000);
257 var row
= this.insert(-1, e
, [dt
.toDateString() + ', ' + dt
.toLocaleTimeString(),
258 e
.ip
, e
.value
], false);
259 if (cursor
) row
.style
.cursor
= cursor
;
267 WMGrid
.prototype.sortCompare = function(a
, b
)
269 var col
= this.sortColumn
;
270 var ra
= a
.getRowData();
271 var rb
= b
.getRowData();
276 r
= -cmpInt(ra
.time
, rb
.time
);
279 var aip
= fixIP(ra
.ip
);
280 var bip
= fixIP(rb
.ip
);
281 if ((aip
!= null) && (bip
!= null)) {
282 r
= aton(aip
) - aton(bip
);
287 r
= cmpText(a
.cells
[col
].innerHTML
, b
.cells
[col
].innerHTML
);
289 return this.sortAscending
? r
: -r
;
292 var dg
= new WMGrid();
294 dg
.setup = function() {
295 this.init('dom-grid', 'sort');
296 this.headerSet(['Last Access Time', 'IP Address', 'Domain Name']);
300 dg
.populate = function() {
301 this.populateData(wm_domains
, 1);
304 var sg
= new WMGrid();
306 sg
.setup = function() {
307 this.init('srh-grid', 'sort');
308 this.headerSet(['Search Time', 'IP Address', 'Search Criteria']);
312 sg
.populate = function() {
313 this.populateData(wm_searches
, 0);
320 if (!ref
.running
) ref
.once
= 1;
326 if (nvram
.log_wm
== '1' && (nvram
.log_wmdmax
!= '0' || nvram
.log_wmsmax
!= '0')) {
327 E('webmon').style
.display
= '';
328 E('wm-disabled').style
.display
= 'none';
330 maxLimit
= nvram
.log_wmdmax
* 1;
331 if (nvram
.log_wmsmax
* 1 > maxLimit
) maxLimit
= nvram
.log_wmsmax
* 1;
333 E('webmon-mc').style
.display
= 'none';
335 if (maxLimit
<= 20) E('mc20').style
.display
= 'none';
336 if (maxLimit
<= 50) E('mc50').style
.display
= 'none';
337 if (maxLimit
<= 100) E('mc100').style
.display
= 'none';
338 if (maxLimit
<= 200) E('mc200').style
.display
= 'none';
339 if (maxLimit
<= 500) E('mc500').style
.display
= 'none';
340 if (maxLimit
<= 1000) E('mc1000').style
.display
= 'none';
341 if (maxLimit
<= 2000) E('mc2000').style
.display
= 'none';
342 if (maxLimit
<= 5000) E('mc5000').style
.display
= 'none';
345 if (nvram
.log_wmdmax
== '0') E('webmon-domains').style
.display
= 'none';
346 if (nvram
.log_wmsmax
== '0') E('webmon-searches').style
.display
= 'none';
351 maxCount
= fixInt(cookie
.get('webmon-maxcount'), 0, maxLimit
, 50);
357 <body onload='init()'
>
358 <form id='_fom' action='javascript:{}'
>
359 <table id='container' cellspacing=
0>
360 <tr><td colspan=
2 id='header'
>
361 <div class='title'
>Tomato
</div>
362 <div class='version'
>Version <%
version(); %></div>
364 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
366 <div id='ident'
><%
ident(); %></div>
370 <div id='webmon' style='display:none'
>
371 <div id='webmon-domains'
>
372 <div class='section-title'
>Recently Visited Web Sites
</div>
373 <div class='section'
>
374 <table id='dom-grid' class='tomato-grid'
style=
"float:left" cellspacing=
1></table>
375 » <a href=
"webmon_recent_domains?_http_id=<% nv(http_id) %>">Download
</a
>
376 <div style
="float:right;text-align:right;margin-right:5px" id
="clear1">
377 »
; <a href
="javascript:clearLog(1)">Clear
</a
>
382 <div id
='webmon-searches'>
383 <div
class='section-title'>Recent Web Searches
</div
>
384 <div
class='section'>
385 <table id
='srh-grid' class='tomato-grid' style
="float:left" cellspacing
=1></table
>
386 »
; <a href
="webmon_recent_searches?_http_id=<% nv(http_id) %>">Download
</a
>
387 <div style
="float:right;text-align:right;margin-right:5px" id
="clear2">
388 »
; <a href
="javascript:clearLog(2)">Clear
</a
>
393 <div id
='webmon-controls'>
396 <a href
='javascript:switchMaxCount(10);' id
='mc10'>10,</a
>
397 <a href
='javascript:switchMaxCount(20);' id
='mc20'>20,</a
>
398 <a href
='javascript:switchMaxCount(50);' id
='mc50'>50,</a
>
399 <a href
='javascript:switchMaxCount(100);' id
='mc100'>100,</a
>
400 <a href
='javascript:switchMaxCount(200);' id
='mc200'>200,</a
>
401 <a href
='javascript:switchMaxCount(500);' id
='mc500'>500,</a
>
402 <a href
='javascript:switchMaxCount(1000);' id
='mc1000'>1000,</a
>
403 <a href
='javascript:switchMaxCount(2000);' id
='mc2000'>2000,</a
>
404 <a href
='javascript:switchMaxCount(5000);' id
='mc5000'>5000,</a
>
405 <a href
='javascript:switchMaxCount(0);' id
='mc0'>All
</a
> 
;
406 <small
>available entries
</small
>
408 »
; <a href
="admin-log.asp">Web Monitor Configuration
</a
>
411 <script type
='text/javascript'>genStdRefresh(1,0,'ref.toggle()');</script
>
416 <div id
='wm-disabled'>
417 <b
>Web Monitoring disabled
.</b
>
419 <a href
="admin-log.asp">Enable
»
;</a
>
423 <script type
='text/javascript'>earlyInit();</script
>
428 <tr
><td id
='footer' colspan
=2> 
;</td
></tr
>