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: 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>
20 <style type='text/css'
>
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()
44 name
= fixFile(E('backup-name').value
);
45 if (name
.length
<= 1) {
46 alert('Invalid filename');
49 location
.href
= 'bwm/' + name
+ '.gz?_http_id=' + nvram
.http_id
;
52 function restoreButton()
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.');
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();
76 var s
= E('_f_loc').value
;
77 return (s
== '*user') ? E('_f_user').value
: s
;
80 function verifyFields(focused
, quiet
)
84 var eLoc
, eUser
, eTime
, eOfs
;
89 eTime
= E('_rstats_stime');
90 eOfs
= E('_rstats_offset');
92 b
= !E('_f_rstats_enable').checked
;
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
;
109 E('newmsg').style
.visibility
= ((nvram
.rstats_path
!= path
) && (path
!= '*nvram') && (path
!= '')) ? 'visible' : 'hidden';
114 elem
.display(eUser
, b
);
116 if (!v_path(eUser
, quiet
, 1)) return 0;
119 else if (v
== '/jffs/') {
120 if (nvram
.jffs2_on
!= '1') {
121 ferror
.set(eLoc
, 'JFFS2 is not enabled.', quiet
);
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
);
138 E('_f_bak').disabled
= bak
;
140 return v_range(eOfs
, quiet
, 1, 31);
145 var fom
, path
, en
, e
, aj
;
147 if (!verifyFields(null, false)) return;
150 en
= E('_f_rstats_enable').checked
;
152 fom
._service
.value
= 'rstats-restart';
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';
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
);
183 fields
.disableAll(E('backup-section'), 0);
184 fields
.disableAll(E('restore-section'), 0);
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>
201 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
203 <div id='ident'
><%
ident(); %></div>
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
) {
224 loc
= nvram
.rstats_path
;
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'],
238 ['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],
240 ['*user','Custom Path']], value
: loc
},
241 { name
: 'f_user', type
: 'text', maxlen
: 48, size
: 50, value
: nvram
.rstats_path
}
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
: ' <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
: ' <small>(comma separated list)</small>' }
260 <div class='section-title'
>Backup
</div>
261 <div class='section' id='backup-section'
>
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() + "'>");
267 <input type='button' name='f_backup_button' id='backup-button' onclick='backupButton()' value='Backup'
>
269 <a href='' id='backup-link'
>Link
</a>
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()'
>
285 <tr><td id='footer' colspan=
2>
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();'
>
294 <script type='text/javascript'
>verifyFields(null, 1);</script>