1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
12 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
13 <meta name='robots' content='noindex,nofollow'
>
14 <title>[<%
ident(); %>] Admin: IP Traffic Monitoring
</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'
>
17 <script type='text/javascript' src='tomato.js'
></script>
20 <style type='text/css'
>
27 <script type='text/javascript' src='debug.js'
></script>
29 <script type='text/javascript'
>
31 // <% nvram("cstats_enable,cstats_path,cstats_stime,cstats_offset,cstats_exclude,cstats_include,cstats_sshut,et0macaddr,cifs1,cifs2,jffs2_on,cstats_bak,cstats_all,cstats_labels"); %>
36 if (((i
= name
.lastIndexOf('/')) > 0) || ((i
= name
.lastIndexOf('\\')) > 0))
37 name
= name
.substring(i
+ 1, name
.length
);
41 function backupNameChanged()
43 if (location
.href
.match(/^(http.+?\/.+\/)/)) {
44 E('backup-link').href
= RegExp
.$1 + 'ipt/' + fix(E('backup-name').value
) + '.gz?_http_id=' + nvram
.http_id
;
48 function backupButton()
52 name
= fix(E('backup-name').value
);
53 if (name
.length
<= 1) {
54 alert('Invalid filename');
57 location
.href
= 'ipt/' + name
+ '.gz?_http_id=' + nvram
.http_id
;
60 function restoreButton()
66 name
= fix(E('restore-name').value
);
67 name
= name
.toLowerCase();
68 if ((name
.length
<= 3) || (name
.substring(name
.length
- 3, name
.length
).toLowerCase() != '.gz')) {
69 alert('Incorrect filename. Expecting a ".gz" file.');
72 if (!confirm('Restore data from ' + name
+ '?')) return;
74 E('restore-button').disabled
= 1;
75 fields
.disableAll(E('config-section'), 1);
76 fields
.disableAll(E('backup-section'), 1);
77 fields
.disableAll(E('footer'), 1);
79 E('restore-form').submit();
84 var s
= E('_f_loc').value
;
85 return (s
== '*user') ? E('_f_user').value
: s
;
88 function verifyFields(focused
, quiet
)
92 var eLoc
, eUser
, eTime
, eOfs
;
94 var eInc
, eExc
, eAll
, eBak
, eLab
;
98 eTime
= E('_cstats_stime');
99 eOfs
= E('_cstats_offset');
101 eInc
= E('_cstats_include');
102 eExc
= E('_cstats_exclude');
106 eLab
= E('_cstats_labels');
108 b
= !E('_f_cstats_enable').checked
;
118 E('_f_new').disabled
= b
;
119 E('_f_sshut').disabled
= b
;
120 E('backup-button').disabled
= b
;
121 E('backup-name').disabled
= b
;
122 E('restore-button').disabled
= b
;
123 E('restore-name').disabled
= b
;
129 eInc
.disabled
= eAll
.checked
;
132 E('newmsg').style
.visibility
= ((nvram
.cstats_path
!= path
) && (path
!= '*nvram') && (path
!= '')) ? 'visible' : 'hidden';
137 elem
.display(eUser
, b
);
139 if (!v_length(eUser
, quiet
, 2)) return 0;
140 if (path
.substr(0, 1) != '/') {
141 ferror
.set(eUser
, 'Please start at the / root directory.', quiet
);
145 else if (v
== '/jffs/') {
146 if (nvram
.jffs2_on
!= '1') {
147 ferror
.set(eLoc
, 'JFFS2 is not enabled.', quiet
);
151 else if (v
.match(/^\/cifs(1|2)\/$/)) {
152 if (nvram
['cifs' + RegExp
.$1].substr(0, 1) != '1') {
153 ferror
.set(eLoc
, 'CIFS #' + RegExp
.$1 + ' is not enabled.', quiet
);
161 E('_f_bak').disabled
= bak
;
163 return v_range(eOfs
, quiet
, 1, 31);
168 var fom
, path
, en
, e
, aj
;
170 if (!verifyFields(null, false)) return;
173 en
= E('_f_cstats_enable').checked
;
175 fom
._service
.value
= 'cstats-restart';
178 if (((E('_cstats_stime').value
* 1) <= 48) &&
179 ((path
== '*nvram') || (path
== '/jffs/'))) {
180 if (!confirm('Frequent saving to NVRAM or JFFS2 is not recommended. Continue anyway?')) return;
182 if ((nvram
.cstats_path
!= path
) && (fom
.cstats_path
.value
!= path
) && (path
!= '') && (path
!= '*nvram') &&
183 (path
.substr(path
.length
- 1, 1) != '/')) {
184 if (!confirm('Note: ' + path
+ ' will be treated as a file. If this is a directory, please use a trailing /. Continue anyway?')) return;
186 fom
.cstats_path
.value
= path
;
188 if (E('_f_new').checked
) {
189 fom
._service
.value
= 'cstatsnew-restart';
194 fom
.cstats_path
.disabled
= !en
;
195 fom
.cstats_enable
.value
= en
? 1 : 0;
196 fom
.cstats_sshut
.value
= E('_f_sshut').checked
? 1 : 0;
197 fom
.cstats_bak
.value
= E('_f_bak').checked
? 1 : 0;
198 fom
.cstats_all
.value
= E('_f_all').checked
? 1 : 0;
200 e
= E('_cstats_exclude');
201 e
.value
= e
.value
.replace(/\s+/g, ',').replace(/,+/g, ',');
203 e
= E('_cstats_include');
204 e
.value
= e
.value
.replace(/\s+/g, ',').replace(/,+/g, ',');
206 fields
.disableAll(E('backup-section'), 1);
207 fields
.disableAll(E('restore-section'), 1);
208 form
.submit(fom
, aj
);
210 fields
.disableAll(E('backup-section'), 0);
211 fields
.disableAll(E('restore-section'), 0);
222 <body onload=
"init()">
223 <table id='container' cellspacing=
0>
224 <tr><td colspan=
2 id='header'
>
225 <div class='title'
>Tomato
</div>
226 <div class='version'
>Version <%
version(); %></div>
228 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
230 <div id='ident'
><%
ident(); %></div>
234 <div class='section-title'
>IP Traffic Monitoring
</div>
235 <div class='section' id='config-section'
>
236 <form id='_fom' method='post' action='tomato.cgi'
>
237 <input type='hidden' name='_nextpage' value='admin-iptraffic.asp'
>
238 <input type='hidden' name='_service' value='cstats-restart'
>
239 <input type='hidden' name='cstats_enable'
>
240 <input type='hidden' name='cstats_path'
>
241 <input type='hidden' name='cstats_sshut'
>
242 <input type='hidden' name='cstats_bak'
>
243 <input type='hidden' name='cstats_all'
>
245 <script type='text/javascript'
>
246 switch (nvram
.cstats_path
) {
252 loc
= nvram
.cstats_path
;
258 createFieldTable('', [
259 { title
: 'Enable', name
: 'f_cstats_enable', type
: 'checkbox', value
: nvram
.cstats_enable
== '1' },
260 { title
: 'Save History Location', multi
: [
262 // { name: 'f_loc', type: 'select', options: [['','RAM (Temporary)'],['*nvram','NVRAM'],['/jffs/','JFFS2'],['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],['*user','Custom Path']], value: loc },
264 { name
: 'f_loc', type
: 'select', options
: [['','RAM (Temporary)'],['/jffs/','JFFS2'],['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],['*user','Custom Path']], value
: loc
},
265 { name
: 'f_user', type
: 'text', maxlen
: 48, size
: 50, value
: nvram
.cstats_path
}
267 { title
: 'Save Frequency', indent
: 2, name
: 'cstats_stime', type
: 'select', value
: nvram
.cstats_stime
, options
: [
268 [1,'Every Hour'],[2,'Every 2 Hours'],[3,'Every 3 Hours'],[4,'Every 4 Hours'],[5,'Every 5 Hours'],[6,'Every 6 Hours'],
269 [9,'Every 9 Hours'],[12,'Every 12 Hours'],[24,'Every 24 Hours'],[48,'Every 2 Days'],[72,'Every 3 Days'],[96,'Every 4 Days'],
270 [120,'Every 5 Days'],[144,'Every 6 Days'],[168,'Every Week']] },
271 { title
: 'Save On Shutdown', indent
: 2, name
: 'f_sshut', type
: 'checkbox', value
: nvram
.cstats_sshut
== '1' },
272 { title
: 'Create New File<br><small>(Reset Data)</small>', indent
: 2, name
: 'f_new', type
: 'checkbox', value
: 0,
273 suffix
: ' <b id="newmsg" style="visibility:hidden"><small>(note: enable if this is a new file)</small></b>' },
274 { title
: 'Create Backups', indent
: 2, name
: 'f_bak', type
: 'checkbox', value
: nvram
.cstats_bak
== '1' },
275 { title
: 'First Day Of The Month', name
: 'cstats_offset', type
: 'text', value
: nvram
.cstats_offset
, maxlen
: 2, size
: 4 },
276 { title
: 'Excluded IPs', name
: 'cstats_exclude', type
: 'text', value
: nvram
.cstats_exclude
, maxlen
: 512, size
: 50, suffix
: ' <small>(comma separated list)</small>' },
277 { title
: 'Included IPs', name
: 'cstats_include', type
: 'text', value
: nvram
.cstats_include
, maxlen
: 2048, size
: 50, suffix
: ' <small>(comma separated list)</small>' },
278 { title
: 'Enable Auto-Discovery', name
: 'f_all', type
: 'checkbox', value
: nvram
.cstats_all
== '1', suffix
: ' <small>(automatically include new IPs in monitoring as soon as any traffic is detected)</small>' },
279 { title
: 'Labels on graphics', name
: 'cstats_labels', type
: 'select', value
: nvram
.cstats_stime
, options
: [[0,'Show known hostnames and IPs'],[1,'Prefer to show only known hostnames, otherwise show IPs'],[2,'Show only IPs']], value
: nvram
.cstats_labels
}
287 <div class='section-title'
>Backup
</div>
288 <div class='section' id='backup-section'
>
290 <script type='text/javascript'
>
291 W("<input type='text' size='40' maxlength='64' id='backup-name' name='backup_name' onchange='backupNameChanged()' value='tomato_cstats_" + nvram
.et0macaddr
.replace(/:/g
, '').toLowerCase() + "'>");
294 <input type='button' name='f_backup_button' id='backup-button' onclick='backupButton()' value='Backup'
>
296 <a href='' id='backup-link'
>Link
</a>
300 <div class='section-title'
>Restore
</div>
301 <div class='section' id='restore-section'
>
302 <form id='restore-form' method='post' action='ipt/restore.cgi?_http_id=<%
nv(http_id
); %>' encType='multipart/form-data'
>
303 <input type='file' size='
40' id='restore-name' name='restore_name'
>
304 <input type='button' name='f_restore_button' id='restore-button' value='Restore' onclick='restoreButton()'
>
312 <tr><td id='footer' colspan=
2>
314 <span id='footer-msg'
></span>
315 <input type='button' value='Save' id='save-button' onclick='save()'
>
316 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'
>
321 <script type='text/javascript'
>verifyFields(null, 1);</script>