Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / www / nas-usb.asp
blobb11fd03d6288eb58958f5f4600da7a4f39d91f34
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 USB Support - !!TB
6 For use with Tomato Firmware only.
7 No part of this file may be used without permission.
8 -->
9 <html>
10 <head>
11 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
12 <meta name='robots' content='noindex,nofollow'>
13 <title>[<% ident(); %>] NAS: USB Support</title>
14 <link rel='stylesheet' type='text/css' href='tomato.css'>
15 <link rel='stylesheet' type='text/css' href='color.css'>
16 <script type='text/javascript' src='tomato.js'></script>
18 <!-- / / / -->
20 <style type='text/css'>
21 textarea {
22 width: 98%;
23 height: 5em;
25 </style>
27 <style type='text/css'>
28 #dev-grid .co1 {
29 width: 10%;
31 #dev-grid .co2 {
32 width: 9%;
34 #dev-grid .co3 {
35 width: 65%;
37 #dev-grid .co4 {
38 width: 16%;
39 text-align: center;
41 #dev-grid .header {
42 text-align: left;
44 </style>
46 <script type='text/javascript' src='debug.js'></script>
48 <script type='text/javascript'>
50 // <% nvram("usb_enable,usb_uhci,usb_ohci,usb_usb2,usb_mmc,usb_storage,usb_printer,usb_printer_bidirect,usb_automount,usb_fs_ext3,usb_fs_fat,usb_fs_ntfs,usb_fs_hfs,script_usbmount,script_usbumount,script_usbhotplug,idle_enable,usb_3g"); %>
51 // <% usbdevices(); %>
53 list = [];
55 var xob = null;
57 function _umountHost(host)
59 form.submitHidden('usbcmd.cgi', { remove: host });
62 function _mountHost(host)
64 form.submitHidden('usbcmd.cgi', { mount: host });
67 function _forceRefresh()
69 if (!ref.running) ref.once = 1;
70 ref.start();
73 function umountHost(a, host)
75 if (xob) return;
77 if ((xob = new XmlHttp()) == null) {
78 _umountHost(host);
79 return;
82 a = E(a);
83 a.innerHTML = 'Please wait...';
85 xob.onCompleted = function(text, xml) {
86 eval(text);
87 if (usb.length == 1) {
88 if (usb[0] != 0)
89 ferror.set(a, 'The device is busy. Please make sure no applications are using it, and try again.', 0);
91 xob = null;
92 _forceRefresh();
95 xob.onError = function() {
96 xob = null;
97 _forceRefresh();
100 xob.post('usbcmd.cgi', 'remove=' + host);
103 function mountHost(a, host)
105 if (xob) return;
107 if ((xob = new XmlHttp()) == null) {
108 _mountHost(host);
109 return;
112 a = E(a);
113 a.innerHTML = 'Please wait...';
115 xob.onCompleted = function(text, xml) {
116 eval(text);
117 if (usb.length == 1) {
118 if (usb[0] == 0)
119 ferror.set(a, 'Failed to mount. Verify the device is plugged in, and try again.', 0);
121 xob = null;
122 _forceRefresh();
125 xob.onError = function() {
126 xob = null;
127 _forceRefresh();
130 xob.post('usbcmd.cgi', 'mount=' + host);
133 var ref = new TomatoRefresh('update.cgi', 'exec=usbdevices', 0, 'nas_usb_refresh');
135 ref.refresh = function(text)
137 try {
138 eval(text);
140 catch (ex) {
141 return;
143 dg.removeAllData();
144 dg.populate();
145 dg.resort();
148 var dg = new TomatoGrid();
150 dg.sortCompare = function(a, b) {
151 var col = this.sortColumn;
152 var ra = a.getRowData();
153 var rb = b.getRowData();
154 var r;
156 switch (col) {
157 case 1:
158 if (ra.type == 'Storage' && ra.type == rb.type)
159 r = cmpInt(ra.host, rb.host);
160 else
161 r = cmpText(ra.host, rb.host);
162 break;
163 default:
164 r = cmpText(a.cells[col].innerHTML, b.cells[col].innerHTML);
166 return this.sortAscending ? r : -r;
169 dg.populate = function()
171 var i, j, k, a, b, c, e, s, desc, d, parts, p;
173 list = [];
175 for (i = 0; i < list.length; ++i) {
176 list[i].type = '';
177 list[i].host = '';
178 list[i].vendor = '';
179 list[i].product = '';
180 list[i].serial = '';
181 list[i].discs = [];
182 list[i].is_mounted = 0;
185 for (i = usbdev.length - 1; i >= 0; --i) {
186 a = usbdev[i];
187 e = {
188 type: a[0],
189 host: a[1],
190 vendor: a[2],
191 product: a[3],
192 serial: a[4],
193 discs: a[5],
194 is_mounted: a[6]
196 list.push(e);
199 for (i = list.length - 1; i >= 0; --i) {
200 e = list[i];
202 if (e.type != 'Storage')
203 s = '&nbsp<br><small>&nbsp</small>';
204 else {
205 if (xob)
206 s = ((e.is_mounted == 0) ? 'No' : 'Yes') + '<br><small>Please wait...</small>';
207 else if (e.is_mounted == 0)
208 s = 'No<br><small><a href="javascript:mountHost(\'L' + i + '\',\'' + e.host + '\')" title="Mount all Partitions of Storage Device" id="L' + i + '">[ Mount ]</a></small>';
209 else
210 s = 'Yes<br><small><a href="javascript:umountHost(\'L' + i + '\',\'' + e.host + '\')" title="Safely Remove Storage Device" id="L' + i + '">[ Unmount ]</a></small>';
212 desc = (e.vendor + ' ' + e.product).trim() + '<small>'; // + (e.serial == '' ? '' : '<br>Serial No: ' + e.serial);
213 if (e.discs) {
214 for (j = 0; j <= e.discs.length - 1; ++j) {
215 d = e.discs[j];
216 parts = d[1];
217 for (k = 0; k <= parts.length - 1; ++k) {
218 p = parts[k];
219 if (p) {
220 desc = desc + '<br>Partition \'' + p[0] + '\'' + (p[3] != '' ? ' ' + p[3] : '') +
221 ((p[5] != 0) ? ' (' + doScaleSize(p[5], 0) +
222 ((p[1] == 1) ? ' / ' + doScaleSize(p[6], 0) + ' free' : '') +
223 ')' : '') + ' is ' +
224 ((p[1] != 0) ? '' : 'not ') + ((p[3] == 'swap') ? 'active' : 'mounted') +
225 ((p[2] != '') ? ' on ' + p[2] : '');
230 desc = desc + '</small>';
231 this.insert(-1, e, [e.type, e.host, desc, s], false);
234 list = [];
237 dg.setup = function()
239 this.init('dev-grid', 'sort');
240 this.headerSet(['Type', 'Host', 'Description', 'Mounted?']);
241 this.populate();
242 this.sort(1);
245 function earlyInit()
247 dg.setup();
250 function init()
252 dg.recolor();
253 ref.initPage();
256 function verifyFields(focused, quiet)
258 var b = !E('_f_usb').checked;
259 var a = !E('_f_storage').checked;
261 E('_f_uhci').disabled = b || nvram.usb_uhci == -1;
262 E('_f_ohci').disabled = b || nvram.usb_ohci == -1;
263 E('_f_usb2').disabled = b;
264 E('_f_print').disabled = b;
265 E('_f_storage').disabled = b;
267 /* LINUX26-BEGIN */
268 /* MICROSD-BEGIN */
269 E('_f_mmc').disabled = a || b || nvram.usb_mmc == -1;
270 elem.display(PR('_f_mmc'), nvram.usb_mmc != -1);
271 /* MICROSD-END */
272 /* LINUX26-END */
274 E('_f_ext3').disabled = b || a;
275 E('_f_fat').disabled = b || a;
276 /* LINUX26-BEGIN */
277 E('_f_idle_enable').disabled = b || a;
278 E('_f_usb_3g').disabled = b;
279 /* LINUX26-END */
280 /* NTFS-BEGIN */
281 E('_f_ntfs').disabled = b || a;
282 /* NTFS-END */
283 /* HFS-BEGIN */
284 E('_f_hfs').disabled = b || a; //!Victek
285 /* HFS-END */
286 E('_f_automount').disabled = b || a;
287 E('_f_bprint').disabled = b || !E('_f_print').checked;
289 elem.display(PR('_f_automount'), !b && !a);
290 elem.display(PR('_script_usbmount'), PR('_script_usbumount'), !b && !a && E('_f_automount').checked);
291 elem.display(PR('_script_usbhotplug'), !b && (!a || E('_f_print').checked));
293 if (!v_length('_script_usbmount', quiet, 0, 2048)) return 0;
294 if (!v_length('_script_usbumount', quiet, 0, 2048)) return 0;
295 if (!v_length('_script_usbhotplug', quiet, 0, 2048)) return 0;
297 return 1;
300 function save()
302 var fom;
304 if (!verifyFields(null, 0)) return;
306 fom = E('_fom');
307 fom.usb_enable.value = E('_f_usb').checked ? 1 : 0;
308 fom.usb_uhci.value = nvram.usb_uhci == -1 ? -1 : (E('_f_uhci').checked ? 1 : 0);
309 fom.usb_ohci.value = nvram.usb_ohci == -1 ? -1 : (E('_f_ohci').checked ? 1 : 0);
310 fom.usb_usb2.value = E('_f_usb2').checked ? 1 : 0;
311 fom.usb_storage.value = E('_f_storage').checked ? 1 : 0;
312 fom.usb_printer.value = E('_f_print').checked ? 1 : 0;
313 fom.usb_printer_bidirect.value = E('_f_bprint').checked ? 1 : 0;
315 /* LINUX26-BEGIN */
316 /* MICROSD-BEGIN */
317 fom.usb_mmc.value = nvram.usb_mmc == -1 ? -1 : (E('_f_mmc').checked ? 1 : 0);
318 /* MICROSD-END */
319 /* LINUX26-END */
321 fom.usb_fs_ext3.value = E('_f_ext3').checked ? 1 : 0;
322 fom.usb_fs_fat.value = E('_f_fat').checked ? 1 : 0;
323 /* NTFS-BEGIN */
324 fom.usb_fs_ntfs.value = E('_f_ntfs').checked ? 1 : 0;
325 /* NTFS-END */
326 /* HFS-BEGIN */
327 fom.usb_fs_hfs.value = E('_f_hfs').checked ? 1 : 0; //!Victek
328 /* HFS-END */
329 fom.usb_automount.value = E('_f_automount').checked ? 1 : 0;
330 /* LINUX26-BEGIN */
331 fom.idle_enable.value = E('_f_idle_enable').checked ? 1 : 0;
332 fom.usb_3g.value = E('_f_usb_3g').checked ? 1 : 0;
333 /* LINUX26-END */
335 form.submit(fom, 1);
338 function submit_complete()
340 reloadPage();
342 </script>
344 </head>
345 <body onload='init()'>
346 <form id='_fom' method='post' action='tomato.cgi'>
347 <table id='container' cellspacing=0>
348 <tr><td colspan=2 id='header'>
349 <div class='title'>Tomato</div>
350 <div class='version'>Version <% version(); %></div>
351 </td></tr>
352 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
353 <td id='content'>
354 <div id='ident'><% ident(); %></div>
356 <!-- / / / -->
358 <input type='hidden' name='_nextpage' value='nas-usb.asp'>
359 <input type='hidden' name='_service' value='usb-restart'>
361 <input type='hidden' name='usb_enable'>
362 <input type='hidden' name='usb_uhci'>
363 <input type='hidden' name='usb_ohci'>
364 <input type='hidden' name='usb_usb2'>
365 <input type='hidden' name='usb_mmc'>
366 <input type='hidden' name='usb_storage'>
367 <input type='hidden' name='usb_printer'>
368 <input type='hidden' name='usb_printer_bidirect'>
369 <input type='hidden' name='usb_fs_ext3'>
370 <input type='hidden' name='usb_fs_fat'>
371 <!-- NTFS-BEGIN
372 <input type='hidden' name='usb_fs_ntfs'>
373 NTFS-END -->
374 <!-- HFS-BEGIN
375 <input type='hidden' name='usb_fs_hfs'>
376 HFS-END -->
377 <input type='hidden' name='usb_automount'>
378 /* LINUX26-BEGIN */
379 <input type='hidden' name='idle_enable'>
380 <input type='hidden' name='usb_3g'>
381 /* LINUX26-END */
383 <div class='section-title'>USB Support</div>
384 <div class='section'>
385 <script type='text/javascript'>
387 createFieldTable('', [
388 { title: 'Core USB Support', name: 'f_usb', type: 'checkbox', value: nvram.usb_enable == 1 },
389 { title: 'USB 2.0 Support', indent: 2, name: 'f_usb2', type: 'checkbox', value: nvram.usb_usb2 == 1 },
390 { title: 'USB 1.1 Support', indent: 2, multi: [
391 { suffix: '&nbsp; OHCI &nbsp;&nbsp;&nbsp;', name: 'f_ohci', type: 'checkbox', value: nvram.usb_ohci == 1 },
392 { suffix: '&nbsp; UHCI &nbsp;', name: 'f_uhci', type: 'checkbox', value: nvram.usb_uhci == 1 }
393 ] },
394 null,
395 { title: 'USB Printer Support', name: 'f_print', type: 'checkbox', value: nvram.usb_printer == 1 },
396 { title: 'Bidirectional copying', indent: 2, name: 'f_bprint', type: 'checkbox', value: nvram.usb_printer_bidirect == 1 },
397 null,
398 { title: 'USB Storage Support', name: 'f_storage', type: 'checkbox', value: nvram.usb_storage == 1 },
399 { title: 'File Systems Support', indent: 2, multi: [
400 { suffix: '&nbsp; Ext2 / Ext3 &nbsp;&nbsp;&nbsp;', name: 'f_ext3', type: 'checkbox', value: nvram.usb_fs_ext3 == 1 },
401 /* NTFS-BEGIN */
402 { suffix: '&nbsp; NTFS &nbsp;&nbsp;&nbsp;', name: 'f_ntfs', type: 'checkbox', value: nvram.usb_fs_ntfs == 1 },
403 /* NTFS-END */
404 { suffix: '&nbsp; FAT &nbsp;', name: 'f_fat', type: 'checkbox', value: nvram.usb_fs_fat == 1 }
405 /* HFS-BEGIN */
406 ,{ suffix: '&nbsp; HFS / HFS+ &nbsp;', name: 'f_hfs', type: 'checkbox', value: nvram.usb_fs_hfs == 1 }
407 /* HFS-END */
408 ] },
409 /* LINUX26-BEGIN */
410 /* MICROSD-BEGIN */
411 { title: 'SD/MMC Card Support', indent: 2, name: 'f_mmc', type: 'checkbox', value: nvram.usb_mmc == 1 },
412 /* MICROSD-END */
413 /* LINUX26-END */
414 { title: 'Automount', indent: 2, name: 'f_automount', type: 'checkbox',
415 suffix: ' <small>Automatically mount all partitions to sub-directories in <i>/mnt</i>.</small>', value: nvram.usb_automount == 1 },
416 { title: 'Run after mounting', indent: 2, name: 'script_usbmount', type: 'textarea', value: nvram.script_usbmount },
417 { title: 'Run before unmounting', indent: 2, name: 'script_usbumount', type: 'textarea', value: nvram.script_usbumount },
418 null,
419 /* LINUX26-BEGIN */
420 { title: 'HDD Spindown', name: 'f_idle_enable', type: 'checkbox',
421 suffix: ' <small>Spin down each HDD when idle. No need to use with flashdrive.</small>', value: nvram.idle_enable == 1 },
422 null,
423 { title: 'USB 3G Modem support', name: 'f_usb_3g', type: 'checkbox',
424 suffix: ' <small>Before disconnecting 3G Modem from USB port, remember to uncheck box. If modem used usbserial module, you have to reboot router before unplug modem.</small>', value: nvram.usb_3g == 1 },
425 null,
426 /* LINUX26-END */
427 { title: 'Hotplug script<br><small>(called when any USB device is attached or removed)</small>', name: 'script_usbhotplug', type: 'textarea', value: nvram.script_usbhotplug },
428 null,
429 { text: '<small>Some of the changes will take effect only after a restart.</small>' }
431 </script>
432 </div>
434 <!-- / / / -->
436 <div class='section-title'>Attached Devices</div>
437 <div class='section'>
438 <table id='dev-grid' class='tomato-grid' cellspacing=0></table>
439 <div id='usb-controls'>
440 <script type='text/javascript'>genStdRefresh(1,0,'ref.toggle()');</script>
441 </div>
442 <script type='text/javascript'></script>
443 </div>
445 <!-- / / / -->
447 </td></tr>
448 <tr><td id='footer' colspan=2>
449 <span id='footer-msg'></span>
450 <input type='button' value='Save' id='save-button' onclick='save()'>
451 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
452 </td></tr>
453 </table>
454 </form>
455 <script type='text/javascript'>earlyInit();verifyFields(null, 1);</script>
456 </body>
457 </html>