RSA Keylength to 1024
[tomato.git] / release / src / router / www / admin-iptraffic.asp
blob9cf28968477fc03aeb590b6d8d624e3b7875cb2c
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
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.
9 -->
10 <html>
11 <head>
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'>
16 <% css(); %>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
20 <style type='text/css'>
21 textarea {
22 width: 98%;
23 height: 15em;
25 </style>
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"); %>
33 function fix(name)
35 var i;
36 if (((i = name.lastIndexOf('/')) > 0) || ((i = name.lastIndexOf('\\')) > 0))
37 name = name.substring(i + 1, name.length);
38 return name;
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()
50 var name;
52 name = fix(E('backup-name').value);
53 if (name.length <= 1) {
54 alert('Invalid filename');
55 return;
57 location.href = 'ipt/' + name + '.gz?_http_id=' + nvram.http_id;
60 function restoreButton()
62 var fom;
63 var name;
64 var i;
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.');
70 return;
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();
82 function getPath()
84 var s = E('_f_loc').value;
85 return (s == '*user') ? E('_f_user').value : s;
88 function verifyFields(focused, quiet)
90 var b, v;
91 var path;
92 var eLoc, eUser, eTime, eOfs;
93 var bak;
94 var eInc, eExc, eAll, eBak, eLab;
96 eLoc = E('_f_loc');
97 eUser = E('_f_user');
98 eTime = E('_cstats_stime');
99 eOfs = E('_cstats_offset');
101 eInc = E('_cstats_include');
102 eExc = E('_cstats_exclude');
103 eAll = E('_f_all');
104 eBak = E('_f_bak');
106 eLab = E('_cstats_labels');
108 b = !E('_f_cstats_enable').checked;
109 eLoc.disabled = b;
110 eUser.disabled = b;
111 eTime.disabled = b;
112 eOfs.disabled = b;
113 eInc.disabled = b;
114 eExc.disabled = b;
115 eAll.disabled = b;
116 eBak.disabled = b;
117 eLab.disabled = b;
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;
124 ferror.clear(eLoc);
125 ferror.clear(eUser);
126 ferror.clear(eOfs);
127 if (b) return 1;
129 eInc.disabled = eAll.checked;
131 path = getPath();
132 E('newmsg').style.visibility = ((nvram.cstats_path != path) && (path != '*nvram') && (path != '')) ? 'visible' : 'hidden';
134 bak = 0;
135 v = eLoc.value;
136 b = (v == '*user');
137 elem.display(eUser, b);
138 if (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);
142 return 0;
145 else if (v == '/jffs/') {
146 if (nvram.jffs2_on != '1') {
147 ferror.set(eLoc, 'JFFS2 is not enabled.', quiet);
148 return 0;
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);
154 return 0;
157 else {
158 bak = 1;
161 E('_f_bak').disabled = bak;
163 return v_range(eOfs, quiet, 1, 31);
166 function save()
168 var fom, path, en, e, aj;
170 if (!verifyFields(null, false)) return;
172 aj = 1;
173 en = E('_f_cstats_enable').checked;
174 fom = E('_fom');
175 fom._service.value = 'cstats-restart';
176 if (en) {
177 path = getPath();
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';
190 aj = 0;
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);
209 if (en) {
210 fields.disableAll(E('backup-section'), 0);
211 fields.disableAll(E('restore-section'), 0);
215 function init()
217 backupNameChanged();
219 </script>
221 </head>
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>
227 </td></tr>
228 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
229 <td id='content'>
230 <div id='ident'><% ident(); %></div>
232 <!-- / / / -->
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) {
247 case '':
248 case '*nvram':
249 case '/jffs/':
250 case '/cifs1/':
251 case '/cifs2/':
252 loc = nvram.cstats_path;
253 break;
254 default:
255 loc = '*user';
256 break;
258 createFieldTable('', [
259 { title: 'Enable', name: 'f_cstats_enable', type: 'checkbox', value: nvram.cstats_enable == '1' },
260 { title: 'Save History Location', multi: [
261 /* REMOVE-BEGIN
262 // { name: 'f_loc', type: 'select', options: [['','RAM (Temporary)'],['*nvram','NVRAM'],['/jffs/','JFFS2'],['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],['*user','Custom Path']], value: loc },
263 REMOVE-END */
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 }
266 ] },
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: ' &nbsp; <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: '&nbsp;<small>(comma separated list)</small>' },
277 { title: 'Included IPs', name: 'cstats_include', type: 'text', value: nvram.cstats_include, maxlen: 2048, size: 50, suffix: '&nbsp;<small>(comma separated list)</small>' },
278 { title: 'Enable Auto-Discovery', name: 'f_all', type: 'checkbox', value: nvram.cstats_all == '1', suffix: '&nbsp;<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 }
281 </script>
282 </form>
283 </div>
285 <br>
287 <div class='section-title'>Backup</div>
288 <div class='section' id='backup-section'>
289 <form>
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() + "'>");
292 </script>
293 .gz &nbsp;
294 <input type='button' name='f_backup_button' id='backup-button' onclick='backupButton()' value='Backup'>
295 </form>
296 <a href='' id='backup-link'>Link</a>
297 </div>
298 <br>
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()'>
305 <br>
306 </form>
307 </div>
309 <!-- / / / -->
311 </td></tr>
312 <tr><td id='footer' colspan=2>
313 <form>
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();'>
317 </form>
318 </div>
319 </td></tr>
320 </table>
321 <script type='text/javascript'>verifyFields(null, 1);</script>
322 </body>
323 </html>