fixes, fully translated tomato, with english dictionary and Polish translation
[tomato.git] / release / src / router / www / forward-upnp.asp
blobff861de5ab1dd140a68971a099c3dfc679437aa6
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(); %>] <% translate("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 /* REMOVE-BEGIN
41 !!TB - additional miniupnp settings
42 REMOVE-END */
43 // <% nvram("upnp_enable,upnp_mnp,upnp_clean,upnp_secure,upnp_clean_interval,upnp_clean_threshold"); %>
45 // <% upnpinfo(); %>
47 nvram.upnp_enable = fixInt(nvram.upnp_enable, 0, 3, 0);
50 function submitDelete(proto, eport)
52 form.submitHidden('upnp.cgi', {
53 remove_proto: proto,
54 remove_eport: eport,
55 _redirect: 'forward-upnp.asp' });
58 function deleteData(data)
60 if (!confirm('Delete ' + data[3] + ' ' + data[0] + ' -> ' + data[2] + ':' + data[1] + ' ?')) return;
61 submitDelete(data[3], data[0]);
64 var ug = new TomatoGrid();
66 ug.onClick = function(cell) {
67 deleteData(cell.parentNode.getRowData());
70 ug.rpDel = function(e) {
71 deleteData(PR(e).getRowData());
75 ug.setup = function() {
76 this.init('upnp-grid', 'sort delete');
77 this.headerSet(['<% translate("External"); %>', '<% translate("Internal"); %>', '<% translate("Internal Address"); %>', '<% translate("Protocol"); %>', '<% translate("Description"); %>']);
78 ug.populate();
81 ug.populate = function() {
82 var i, j, r, row, data;
84 if (nvram.upnp_enable != 0) {
85 var data = mupnp_data.split('\n');
86 for (i = 0; i < data.length; ++i) {
87 r = data[i].match(/^(UDP|TCP)\s+(\d+)\s+(.+?)\s+(\d+)\s+\[(.*)\]$/);
88 if (r == null) continue;
89 row = this.insertData(-1, [r[2], r[4], r[3], r[1], r[5]]);
91 if (!r[0]) {
92 for (j = 0; j < 5; ++j) {
93 elem.addClass(row.cells[j], '<% translate("disabled"); %>');
96 for (j = 0; j < 5; ++j) {
97 row.cells[j].title = '<% translate("Click to delete"); %>';
100 this.sort(2);
102 E('upnp-delete-all').disabled = (ug.getDataCount() == 0);
105 function deleteAll()
107 if (!confirm('<% translate("Delete all entries"); %>?')) return;
108 submitDelete('*', '0');
111 function verifyFields(focused, quiet)
113 /* REMOVE-BEGIN
114 !!TB - additional miniupnp settings
115 REMOVE-END */
116 var enable = E('_f_enable_upnp').checked || E('_f_enable_natpmp').checked;
117 var bc = E('_f_upnp_clean').checked;
119 E('_f_upnp_clean').disabled = (enable == 0);
120 E('_f_upnp_secure').disabled = (enable == 0);
121 E('_f_upnp_mnp').disabled = (E('_f_enable_upnp').checked == 0);
122 E('_upnp_clean_interval').disabled = (enable == 0) || (bc == 0);
123 E('_upnp_clean_threshold').disabled = (enable == 0) || (bc == 0);
124 elem.display(PR(E('_upnp_clean_interval')), (enable != 0) && (bc != 0));
125 elem.display(PR(E('_upnp_clean_threshold')), (enable != 0) && (bc != 0));
127 if ((enable != 0) && (bc != 0)) {
128 if (!v_range('_upnp_clean_interval', quiet, 60, 65535)) return 0;
129 if (!v_range('_upnp_clean_threshold', quiet, 0, 9999)) return 0;
131 else {
132 ferror.clear(E('_upnp_clean_interval'));
133 ferror.clear(E('_upnp_clean_threshold'));
136 return 1;
139 function save()
141 /* REMOVE-BEGIN
142 !!TB - miniupnp
143 REMOVE-END */
144 if (!verifyFields(null, 0)) return;
146 var fom = E('_fom');
147 fom.upnp_enable.value = 0;
148 if (fom.f_enable_upnp.checked) fom.upnp_enable.value = 1;
149 if (fom.f_enable_natpmp.checked) fom.upnp_enable.value |= 2;
151 /* REMOVE-BEGIN
152 !!TB - additional miniupnp settings
153 REMOVE-END */
154 fom.upnp_mnp.value = E('_f_upnp_mnp').checked ? 1 : 0;
155 fom.upnp_clean.value = E('_f_upnp_clean').checked ? 1 : 0;
156 fom.upnp_secure.value = E('_f_upnp_secure').checked ? 1 : 0;
158 form.submit(fom, 0);
161 function init()
163 ug.recolor();
166 /* REMOVE-BEGIN
167 !!TB - miniupnp
168 REMOVE-END */
169 function submit_complete()
171 reloadPage();
173 </script>
175 </head>
176 <body onload='init()'>
177 <form id='_fom' method='post' action='tomato.cgi'>
178 <table id='container' cellspacing=0>
179 <tr><td colspan=2 id='header'>
180 <div class='title'>Tomato</div>
181 <div class='version'><% translate("Version"); %> <% version(); %></div>
182 </td></tr>
183 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
184 <td id='content'>
185 <div id='ident'><% ident(); %></div>
187 <!-- / / / -->
189 <input type='hidden' name='_nextpage' value='forward-upnp.asp'>
190 <input type='hidden' name='_service' value='upnp-restart'>
192 <input type='hidden' name='upnp_enable'>
193 /* REMOVE-BEGIN
194 !!TB - additional miniupnp settings
195 REMOVE-END */
196 <input type='hidden' name='upnp_mnp'>
197 <input type='hidden' name='upnp_clean'>
198 <input type='hidden' name='upnp_secure'>
200 <div class='section-title'><% translate("Forwarded Ports"); %></div>
201 <div class='section'>
202 <table id='upnp-grid' class='tomato-grid'></table>
203 <div style='width: 100%; text-align: right'><input type='button' value='<% translate("Delete All"); %>' onclick='deleteAll()' id='upnp-delete-all'> <input type='button' value='<% translate("Refresh"); %>' onclick='javascript:reloadPage();'></div>
204 </div>
206 <div class='section-title'><% translate("Settings</div>
207 <div class='section'>
208 <script type='text/javascript'>
209 createFieldTable('', [
210 { title: '<% translate("Enable"); %> UPnP', name: 'f_enable_upnp', type: 'checkbox', value: (nvram.upnp_enable & 1) },
211 { title: '<% translate("Enable"); %> NAT-PMP', name: 'f_enable_natpmp', type: 'checkbox', value: (nvram.upnp_enable & 2) },
212 /* REMOVE-BEGIN
213 !!TB - additional miniupnp settings
214 REMOVE-END */
215 { title: '<% translate("Inactive Rules Cleaning"); %>', name: 'f_upnp_clean', type: 'checkbox', value: (nvram.upnp_clean == '1') },
216 { title: '<% translate("Cleaning Interval"); %>', indent: 2, name: 'upnp_clean_interval', type: 'text', maxlen: 5, size: 7,
217 suffix: ' <small><% translate("seconds"); %></small>', value: nvram.upnp_clean_interval },
218 { title: '<% translate("Cleaning Threshold"); %>', indent: 2, name: 'upnp_clean_threshold', type: 'text', maxlen: 4, size: 7,
219 suffix: ' <small><% translate("redirections"); %></small>', value: nvram.upnp_clean_threshold },
220 { title: '<% translate("Secure Mode"); %>', name: 'f_upnp_secure', type: 'checkbox',
221 suffix: ' <small>(<% translate("when enabled, UPnP clients are allowed to add mappings only to their IP"); %>)</small>',
222 value: (nvram.upnp_secure == '1') },
223 null,
224 { title: '<% translate("Show In My Network Places"); %>', name: 'f_upnp_mnp', type: 'checkbox', value: (nvram.upnp_mnp == '1') }
226 </script>
227 </div>
230 <!-- / / / -->
232 </td></tr>
233 <tr><td id='footer' colspan=2>
234 <span id='footer-msg'></span>
235 <input type='button' value='<% translate("Save"); %>' id='save-button' onclick='save()'>
236 <input type='button' value='<% translate("Cancel"); %>' id='cancel-button' onclick='javascript:reloadPage();'>
237 </td></tr>
238 </table>
239 </form>
240 /* REMOVE-BEGIN
241 !!TB - added verifyFields
242 REMOVE-END */
243 <script type='text/javascript'>ug.setup();verifyFields(null, 1);</script>
244 </body>
245 </html>