Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / www / admin-bwm.asp
blobedd5413f0e17165f356d6a8d942efd251ab9b397
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: Bandwidth Monitoring</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <link rel='stylesheet' type='text/css' href='color.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("rstats_enable,rstats_path,rstats_stime,rstats_offset,rstats_exclude,rstats_sshut,et0macaddr,cifs1,cifs2,jffs2_on,rstats_bak"); %>
33 function backupNameChanged()
35 if (location.href.match(/^(http.+?\/.+\/)/)) {
36 E('backup-link').href = RegExp.$1 + 'bwm/' + fixFile(E('backup-name').value) + '.gz?_http_id=' + nvram.http_id;
40 function backupButton()
42 var name;
44 name = fixFile(E('backup-name').value);
45 if (name.length <= 1) {
46 alert('Invalid filename');
47 return;
49 location.href = 'bwm/' + name + '.gz?_http_id=' + nvram.http_id;
52 function restoreButton()
54 var fom;
55 var name;
56 var i;
58 name = fixFile(E('restore-name').value);
59 name = name.toLowerCase();
60 if ((name.length <= 3) || (name.substring(name.length - 3, name.length).toLowerCase() != '.gz')) {
61 alert('Incorrect filename. Expecting a ".gz" file.');
62 return;
64 if (!confirm('Restore data from ' + name + '?')) return;
66 E('restore-button').disabled = 1;
67 fields.disableAll(E('config-section'), 1);
68 fields.disableAll(E('backup-section'), 1);
69 fields.disableAll(E('footer'), 1);
71 E('restore-form').submit();
74 function getPath()
76 var s = E('_f_loc').value;
77 return (s == '*user') ? E('_f_user').value : s;
80 function verifyFields(focused, quiet)
82 var b, v;
83 var path;
84 var eLoc, eUser, eTime, eOfs;
85 var bak;
87 eLoc = E('_f_loc');
88 eUser = E('_f_user');
89 eTime = E('_rstats_stime');
90 eOfs = E('_rstats_offset');
92 b = !E('_f_rstats_enable').checked;
93 eLoc.disabled = b;
94 eUser.disabled = b;
95 eTime.disabled = b;
96 eOfs.disabled = b;
97 E('_f_new').disabled = b;
98 E('_f_sshut').disabled = b;
99 E('backup-button').disabled = b;
100 E('backup-name').disabled = b;
101 E('restore-button').disabled = b;
102 E('restore-name').disabled = b;
103 ferror.clear(eLoc);
104 ferror.clear(eUser);
105 ferror.clear(eOfs);
106 if (b) return 1;
108 path = getPath();
109 E('newmsg').style.visibility = ((nvram.rstats_path != path) && (path != '*nvram') && (path != '')) ? 'visible' : 'hidden';
111 bak = 0;
112 v = eLoc.value;
113 b = (v == '*user');
114 elem.display(eUser, b);
115 if (b) {
116 if (!v_path(eUser, quiet, 1)) return 0;
118 /* JFFS2-BEGIN */
119 else if (v == '/jffs/') {
120 if (nvram.jffs2_on != '1') {
121 ferror.set(eLoc, 'JFFS2 is not enabled.', quiet);
122 return 0;
125 /* JFFS2-END */
126 /* CIFS-BEGIN */
127 else if (v.match(/^\/cifs(1|2)\/$/)) {
128 if (nvram['cifs' + RegExp.$1].substr(0, 1) != '1') {
129 ferror.set(eLoc, 'CIFS #' + RegExp.$1 + ' is not enabled.', quiet);
130 return 0;
133 /* CIFS-END */
134 else {
135 bak = 1;
138 E('_f_bak').disabled = bak;
140 return v_range(eOfs, quiet, 1, 31);
143 function save()
145 var fom, path, en, e, aj;
147 if (!verifyFields(null, false)) return;
149 aj = 1;
150 en = E('_f_rstats_enable').checked;
151 fom = E('_fom');
152 fom._service.value = 'rstats-restart';
153 if (en) {
154 path = getPath();
155 if (((E('_rstats_stime').value * 1) <= 48) &&
156 ((path == '*nvram') || (path == '/jffs/'))) {
157 if (!confirm('Frequent saving to NVRAM or JFFS2 is not recommended. Continue anyway?')) return;
159 if ((nvram.rstats_path != path) && (fom.rstats_path.value != path) && (path != '') && (path != '*nvram') &&
160 (path.substr(path.length - 1, 1) != '/')) {
161 if (!confirm('Note: ' + path + ' will be treated as a file. If this is a directory, please use a trailing /. Continue anyway?')) return;
163 fom.rstats_path.value = path;
165 if (E('_f_new').checked) {
166 fom._service.value = 'rstatsnew-restart';
167 aj = 0;
171 fom.rstats_path.disabled = !en;
172 fom.rstats_enable.value = en ? 1 : 0;
173 fom.rstats_sshut.value = E('_f_sshut').checked ? 1 : 0;
174 fom.rstats_bak.value = E('_f_bak').checked ? 1 : 0;
176 e = E('_rstats_exclude');
177 e.value = e.value.replace(/\s+/g, ',').replace(/,+/g, ',');
179 fields.disableAll(E('backup-section'), 1);
180 fields.disableAll(E('restore-section'), 1);
181 form.submit(fom, aj);
182 if (en) {
183 fields.disableAll(E('backup-section'), 0);
184 fields.disableAll(E('restore-section'), 0);
188 function init()
190 backupNameChanged();
192 </script>
194 </head>
195 <body onload="init()">
196 <table id='container' cellspacing=0>
197 <tr><td colspan=2 id='header'>
198 <div class='title'>Tomato</div>
199 <div class='version'>Version <% version(); %></div>
200 </td></tr>
201 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
202 <td id='content'>
203 <div id='ident'><% ident(); %></div>
205 <!-- / / / -->
207 <div class='section-title'>Bandwidth Monitoring</div>
208 <div class='section' id='config-section'>
209 <form id='_fom' method='post' action='tomato.cgi'>
210 <input type='hidden' name='_nextpage' value='admin-bwm.asp'>
211 <input type='hidden' name='_service' value='rstats-restart'>
212 <input type='hidden' name='rstats_enable'>
213 <input type='hidden' name='rstats_path'>
214 <input type='hidden' name='rstats_sshut'>
215 <input type='hidden' name='rstats_bak'>
217 <script type='text/javascript'>
218 switch (nvram.rstats_path) {
219 case '':
220 case '*nvram':
221 case '/jffs/':
222 case '/cifs1/':
223 case '/cifs2/':
224 loc = nvram.rstats_path;
225 break;
226 default:
227 loc = '*user';
228 break;
230 createFieldTable('', [
231 { title: 'Enable', name: 'f_rstats_enable', type: 'checkbox', value: nvram.rstats_enable == '1' },
232 { title: 'Save History Location', multi: [
233 { name: 'f_loc', type: 'select', options: [['','RAM (Temporary)'],['*nvram','NVRAM'],
234 /* JFFS2-BEGIN */
235 ['/jffs/','JFFS2'],
236 /* JFFS2-END */
237 /* CIFS-BEGIN */
238 ['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],
239 /* CIFS-END */
240 ['*user','Custom Path']], value: loc },
241 { name: 'f_user', type: 'text', maxlen: 48, size: 50, value: nvram.rstats_path }
242 ] },
243 { title: 'Save Frequency', indent: 2, name: 'rstats_stime', type: 'select', value: nvram.rstats_stime, options: [
244 [1,'Every Hour'],[2,'Every 2 Hours'],[3,'Every 3 Hours'],[4,'Every 4 Hours'],[5,'Every 5 Hours'],[6,'Every 6 Hours'],
245 [9,'Every 9 Hours'],[12,'Every 12 Hours'],[24,'Every 24 Hours'],[48,'Every 2 Days'],[72,'Every 3 Days'],[96,'Every 4 Days'],
246 [120,'Every 5 Days'],[144,'Every 6 Days'],[168,'Every Week']] },
247 { title: 'Save On Shutdown', indent: 2, name: 'f_sshut', type: 'checkbox', value: nvram.rstats_sshut == '1' },
248 { title: 'Create New File<br><small>(Reset Data)</small>', indent: 2, name: 'f_new', type: 'checkbox', value: 0,
249 suffix: ' &nbsp; <b id="newmsg" style="visibility:hidden"><small>(note: enable if this is a new file)</small></b>' },
250 { title: 'Create Backups', indent: 2, name: 'f_bak', type: 'checkbox', value: nvram.rstats_bak == '1' },
251 { title: 'First Day Of The Month', name: 'rstats_offset', type: 'text', value: nvram.rstats_offset, maxlen: 2, size: 4 },
252 { title: 'Excluded Interfaces', name: 'rstats_exclude', type: 'text', value: nvram.rstats_exclude, maxlen: 64, size: 50, suffix: '&nbsp;<br><small>(comma separated list)</small>' }
254 </script>
255 </form>
256 </div>
258 <br>
260 <div class='section-title'>Backup</div>
261 <div class='section' id='backup-section'>
262 <form>
263 <script type='text/javascript'>
264 W("<input type='text' size='40' maxlength='64' id='backup-name' name='backup_name' onchange='backupNameChanged()' value='tomato_rstats_" + nvram.et0macaddr.replace(/:/g, '').toLowerCase() + "'>");
265 </script>
266 .gz &nbsp;
267 <input type='button' name='f_backup_button' id='backup-button' onclick='backupButton()' value='Backup'>
268 </form>
269 <a href='' id='backup-link'>Link</a>
270 </div>
271 <br>
273 <div class='section-title'>Restore</div>
274 <div class='section' id='restore-section'>
275 <form id='restore-form' method='post' action='bwm/restore.cgi?_http_id=<% nv(http_id); %>' encType='multipart/form-data'>
276 <input type='file' size='40' id='restore-name' name='restore_name'>
277 <input type='button' name='f_restore_button' id='restore-button' value='Restore' onclick='restoreButton()'>
278 <br>
279 </form>
280 </div>
282 <!-- / / / -->
284 </td></tr>
285 <tr><td id='footer' colspan=2>
286 <form>
287 <span id='footer-msg'></span>
288 <input type='button' value='Save' id='save-button' onclick='save()'>
289 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
290 </form>
291 </div>
292 </td></tr>
293 </table>
294 <script type='text/javascript'>verifyFields(null, 1);</script>
295 </body>
296 </html>