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 <meta name=
"viewport" content=
"width=device-width">
15 <title>[<%
ident(); %>] Admin: Bandwidth Monitoring
</title>
16 <link rel='stylesheet' type='text/css' href='tomato.css'
>
17 <link rel='stylesheet' type='text/css' href='color.css'
>
18 <script type='text/javascript' src='tomato.js'
></script>
21 <style type='text/css'
>
28 <script type='text/javascript' src='debug.js'
></script>
30 <script type='text/javascript'
>
32 // <% nvram("rstats_enable,rstats_path,rstats_stime,rstats_offset,rstats_exclude,rstats_sshut,et0macaddr,cifs1,cifs2,jffs2_on,rstats_bak"); %>
34 function backupNameChanged()
36 if (location
.href
.match(/^(http.+?\/.+\/)/)) {
37 E('backup-link').href
= RegExp
.$1 + 'bwm/' + fixFile(E('backup-name').value
) + '.gz?_http_id=' + nvram
.http_id
;
41 function backupButton()
45 name
= fixFile(E('backup-name').value
);
46 if (name
.length
<= 1) {
47 alert('Invalid filename');
50 location
.href
= 'bwm/' + name
+ '.gz?_http_id=' + nvram
.http_id
;
53 function restoreButton()
59 name
= fixFile(E('restore-name').value
);
60 name
= name
.toLowerCase();
61 if ((name
.length
<= 3) || (name
.substring(name
.length
- 3, name
.length
).toLowerCase() != '.gz')) {
62 alert('Incorrect filename. Expecting a ".gz" file.');
65 if (!confirm('Restore data from ' + name
+ '?')) return;
67 E('restore-button').disabled
= 1;
68 fields
.disableAll(E('config-section'), 1);
69 fields
.disableAll(E('backup-section'), 1);
70 fields
.disableAll(E('footer'), 1);
72 E('restore-form').submit();
77 var s
= E('_f_loc').value
;
78 return (s
== '*user') ? E('_f_user').value
: s
;
81 function verifyFields(focused
, quiet
)
85 var eLoc
, eUser
, eTime
, eOfs
;
90 eTime
= E('_rstats_stime');
91 eOfs
= E('_rstats_offset');
93 b
= !E('_f_rstats_enable').checked
;
98 E('_f_new').disabled
= b
;
99 E('_f_sshut').disabled
= b
;
100 E('backup-button').disabled
= b
;
101 E('backup-name').disabled
= b
;
102 E('restore-button').disabled
= b
;
103 E('restore-name').disabled
= b
;
110 E('newmsg').style
.visibility
= ((nvram
.rstats_path
!= path
) && (path
!= '*nvram') && (path
!= '')) ? 'visible' : 'hidden';
115 elem
.display(eUser
, b
);
117 if (!v_path(eUser
, quiet
, 1)) return 0;
120 else if (v
== '/jffs/') {
121 if (nvram
.jffs2_on
!= '1') {
122 ferror
.set(eLoc
, 'JFFS2 is not enabled.', quiet
);
128 else if (v
.match(/^\/cifs(1|2)\/$/)) {
129 if (nvram
['cifs' + RegExp
.$1].substr(0, 1) != '1') {
130 ferror
.set(eLoc
, 'CIFS #' + RegExp
.$1 + ' is not enabled.', quiet
);
139 E('_f_bak').disabled
= bak
;
141 return v_range(eOfs
, quiet
, 1, 31);
146 var fom
, path
, en
, e
, aj
;
148 if (!verifyFields(null, false)) return;
151 en
= E('_f_rstats_enable').checked
;
153 fom
._service
.value
= 'rstats-restart';
156 if (((E('_rstats_stime').value
* 1) <= 48) &&
157 ((path
== '*nvram') || (path
== '/jffs/'))) {
158 if (!confirm('Frequent saving to NVRAM or JFFS2 is not recommended. Continue anyway?')) return;
160 if ((nvram
.rstats_path
!= path
) && (fom
.rstats_path
.value
!= path
) && (path
!= '') && (path
!= '*nvram') &&
161 (path
.substr(path
.length
- 1, 1) != '/')) {
162 if (!confirm('Note: ' + path
+ ' will be treated as a file. If this is a directory, please use a trailing /. Continue anyway?')) return;
164 fom
.rstats_path
.value
= path
;
166 if (E('_f_new').checked
) {
167 fom
._service
.value
= 'rstatsnew-restart';
172 fom
.rstats_path
.disabled
= !en
;
173 fom
.rstats_enable
.value
= en
? 1 : 0;
174 fom
.rstats_sshut
.value
= E('_f_sshut').checked
? 1 : 0;
175 fom
.rstats_bak
.value
= E('_f_bak').checked
? 1 : 0;
177 e
= E('_rstats_exclude');
178 e
.value
= e
.value
.replace(/\s+/g, ',').replace(/,+/g, ',');
180 fields
.disableAll(E('backup-section'), 1);
181 fields
.disableAll(E('restore-section'), 1);
182 form
.submit(fom
, aj
);
184 fields
.disableAll(E('backup-section'), 0);
185 fields
.disableAll(E('restore-section'), 0);
196 <body onload=
"init()">
197 <table id='container' cellspacing=
0>
198 <tr><td colspan=
2 id='header'
>
199 <div class='title'
>Tomato
</div>
200 <div class='version'
>Version <%
version(); %></div>
202 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
204 <div id='ident'
><%
ident(); %></div>
208 <div class='section-title'
>Bandwidth Monitoring
</div>
209 <div class='section' id='config-section'
>
210 <form id='_fom' method='post' action='tomato.cgi'
>
211 <input type='hidden' name='_nextpage' value='admin-bwm.asp'
>
212 <input type='hidden' name='_service' value='rstats-restart'
>
213 <input type='hidden' name='rstats_enable'
>
214 <input type='hidden' name='rstats_path'
>
215 <input type='hidden' name='rstats_sshut'
>
216 <input type='hidden' name='rstats_bak'
>
218 <script type='text/javascript'
>
219 switch (nvram
.rstats_path
) {
225 loc
= nvram
.rstats_path
;
231 createFieldTable('', [
232 { title
: 'Enable', name
: 'f_rstats_enable', type
: 'checkbox', value
: nvram
.rstats_enable
== '1' },
233 { title
: 'Save History Location', multi
: [
234 { name
: 'f_loc', type
: 'select', options
: [['','RAM (Temporary)'],['*nvram','NVRAM'],
239 ['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],
241 ['*user','Custom Path']], value
: loc
},
242 { name
: 'f_user', type
: 'text', maxlen
: 48, size
: 50, value
: nvram
.rstats_path
}
244 { title
: 'Save Frequency', indent
: 2, name
: 'rstats_stime', type
: 'select', value
: nvram
.rstats_stime
, options
: [
245 [1,'Every Hour'],[2,'Every 2 Hours'],[3,'Every 3 Hours'],[4,'Every 4 Hours'],[5,'Every 5 Hours'],[6,'Every 6 Hours'],
246 [9,'Every 9 Hours'],[12,'Every 12 Hours'],[24,'Every 24 Hours'],[48,'Every 2 Days'],[72,'Every 3 Days'],[96,'Every 4 Days'],
247 [120,'Every 5 Days'],[144,'Every 6 Days'],[168,'Every Week']] },
248 { title
: 'Save On Shutdown', indent
: 2, name
: 'f_sshut', type
: 'checkbox', value
: nvram
.rstats_sshut
== '1' },
249 { title
: 'Create New File<br><small>(Reset Data)</small>', indent
: 2, name
: 'f_new', type
: 'checkbox', value
: 0,
250 suffix
: ' <b id="newmsg" style="visibility:hidden"><small>(note: enable if this is a new file)</small></b>' },
251 { title
: 'Create Backups', indent
: 2, name
: 'f_bak', type
: 'checkbox', value
: nvram
.rstats_bak
== '1' },
252 { title
: 'First Day Of The Month', name
: 'rstats_offset', type
: 'text', value
: nvram
.rstats_offset
, maxlen
: 2, size
: 4 },
253 { title
: 'Excluded Interfaces', name
: 'rstats_exclude', type
: 'text', value
: nvram
.rstats_exclude
, maxlen
: 64, size
: 50, suffix
: ' <small>(comma separated list)</small>' }
261 <div class='section-title'
>Backup
</div>
262 <div class='section' id='backup-section'
>
264 <script type='text/javascript'
>
265 W("<input type='text' size='40' maxlength='64' id='backup-name' name='backup_name' onchange='backupNameChanged()' value='tomato_rstats_" + nvram
.et0macaddr
.replace(/:/g
, '').toLowerCase() + "'>");
268 <input type='button' name='f_backup_button' id='backup-button' onclick='backupButton()' value='Backup'
>
269 <a href='' id='backup-link'
>Direct Download Link
</a>
274 <div class='section-title'
>Restore
</div>
275 <div class='section' id='restore-section'
>
276 <form id='restore-form' method='post' action='bwm/restore.cgi?_http_id=<%
nv(http_id
); %>' encType='multipart/form-data'
>
277 <input type='file' size='
40' id='restore-name' name='restore_name'
>
278 <input type='button' name='f_restore_button' id='restore-button' value='Restore' onclick='restoreButton()'
>
286 <tr><td id='footer' colspan=
2>
288 <span id='footer-msg'
></span>
289 <input type='button' value='Save' id='save-button' onclick='save()'
>
290 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'
>
295 <script type='text/javascript'
>verifyFields(null, 1);</script>