Tomato 1.28
[tomato/tomato-null.git] / release / src / router / www / forward-upnp.asp
blob40e67711d550ef9f749b6a7864611e6ee221d614
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(); %>] Forwarding: UPnP / NAT-PMP</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 <!-- / / / -->
21 <style type='text/css'>
22 #upnp-grid .co1, #upnp-grid .co2 {
23 width: 12%;
25 #upnp-grid .co3 {
26 width: 15%;
28 #upnp-grid .co4 {
29 width: 8%;
31 #upnp-grid .co5 {
32 width: 53%;
34 </style>
36 <script type='text/javascript' src='debug.js'></script>
38 <script type='text/javascript'>
40 // <% nvram("upnp_enable"); %>
41 // <% upnpinfo(); %>
43 nvram.upnp_enable = fixInt(nvram.upnp_enable, 0, 3, 0);
46 function submitDelete(proto, eport)
48 form.submitHidden('upnp.cgi', {
49 remove_proto: proto,
50 remove_eport: eport,
51 _redirect: 'forward-upnp.asp' });
54 function deleteData(data)
56 if (!confirm('Delete ' + data[3] + ' ' + data[0] + ' -> ' + data[2] + ':' + data[1] + ' ?')) return;
57 submitDelete(data[3], data[0]);
60 var ug = new TomatoGrid();
62 ug.onClick = function(cell) {
63 deleteData(cell.parentNode.getRowData());
66 ug.rpDel = function(e) {
67 deleteData(PR(e).getRowData());
71 ug.setup = function() {
72 this.init('upnp-grid', 'sort delete');
73 this.headerSet(['External', 'Internal', 'Internal Address', 'Protocol', 'Description']);
74 ug.populate();
77 ug.populate = function() {
78 var i, j, r, row, data;
80 if (nvram.upnp_enable != 0) {
81 var data = mupnp_data.split('\n');
82 for (i = 0; i < data.length; ++i) {
83 r = data[i].match(/^(UDP|TCP)\s+(\d+)\s+(.+?)\s+(\d+)\s+\[(.*)\]$/);
84 if (r == null) continue;
85 row = this.insertData(-1, [r[2], r[4], r[3], r[1], r[5]]);
87 if (!r[0]) {
88 for (j = 0; j < 5; ++j) {
89 elem.addClass(row.cells[j], 'disabled');
92 for (j = 0; j < 5; ++j) {
93 row.cells[j].title = 'Click to delete';
96 this.sort(2);
98 E('upnp-delete-all').disabled = (ug.getDataCount() == 0);
101 function deleteAll()
103 if (!confirm('Delete all entries?')) return;
104 submitDelete('*', '0');
107 function verifyFields(focused, quiet)
109 return 1;
112 function save()
114 var fom = E('_fom');
115 fom.upnp_enable.value = 0;
116 if (fom.f_enable_upnp.checked) fom.upnp_enable.value = 1;
117 if (fom.f_enable_natpmp.checked) fom.upnp_enable.value |= 2;
118 form.submit(fom, 0);
121 function init()
123 ug.recolor();
125 </script>
127 </head>
128 <body onload='init()'>
129 <form id='_fom' method='post' action='tomato.cgi'>
130 <table id='container' cellspacing=0>
131 <tr><td colspan=2 id='header'>
132 <div class='title'>Tomato</div>
133 <div class='version'>Version <% version(); %></div>
134 </td></tr>
135 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
136 <td id='content'>
137 <div id='ident'><% ident(); %></div>
139 <!-- / / / -->
141 <input type='hidden' name='_nextpage' value='forward-upnp.asp'>
142 <input type='hidden' name='_service' value='upnp-restart'>
144 <input type='hidden' name='upnp_enable'>
146 <div class='section-title'>Forwarded Ports</div>
147 <div class='section'>
148 <table id='upnp-grid' class='tomato-grid'></table>
149 <div style='width: 100%; text-align: right'><input type='button' value='Delete All' onclick='deleteAll()' id='upnp-delete-all'> <input type='button' value='Refresh' onclick='javascript:reloadPage();'></div>
150 </div>
152 <div class='section-title'>Settings</div>
153 <div class='section'>
154 <script type='text/javascript'>
155 createFieldTable('', [
156 { title: 'Enable UPnP', name: 'f_enable_upnp', type: 'checkbox', value: (nvram.upnp_enable & 1) },
157 { title: 'Enable NAT-PMP', name: 'f_enable_natpmp', type: 'checkbox', value: (nvram.upnp_enable & 2) }
159 </script>
160 </div>
163 <!-- / / / -->
165 </td></tr>
166 <tr><td id='footer' colspan=2>
167 <span id='footer-msg'></span>
168 <input type='button' value='Save' id='save-button' onclick='save()'>
169 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
170 </td></tr>
171 </table>
172 </form>
173 <script type='text/javascript'>ug.setup();</script>
174 </body>
175 </html>