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(); %>] <% translate(
"Admin"); %
>: <% translate(
"Access"); %
></title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'
>
16 <link rel='stylesheet' type='text/css' href='color.css' id='guicss'
>
17 <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("http_enable,https_enable,http_lanport,https_lanport,remote_management,remote_mgt_https,web_wl_filter,web_css,sshd_eas,sshd_pass,sshd_remote,telnetd_eas,http_wanport,sshd_authkeys,sshd_port,sshd_rport,sshd_forwarding,telnetd_port,rmgt_sip,https_crt_cn,https_crt_save,lan_ipaddr,ne_shlimit,web_lang"); %>
35 tdup
= parseInt('<% psup("telnetd"); %>');
36 sdup
= parseInt('<% psup("dropbear"); %>');
38 shlimit
= nvram
.ne_shlimit
.split(',');
39 if (shlimit
.length
!= 3) shlimit
= [0,3,60];
41 var xmenus
= [['<% translate("Status"); %>', 'status'], ['<% translate("Bandwidth"); %>', 'bwm'], ['<% translate("Tools"); %>', 'tools'], ['<% translate("Basic"); %>', 'basic'],
42 ['<% translate("Advanced"); %>', 'advanced'], ['<% translate("Port Forwarding"); %>', 'forward'], ['QoS', 'qos'],['<% translate("RAF Features"); %>', 'new'],
44 ['<% translate("USB and NAS"); %>', 'nas'],
47 ['<% translate("VPN Tunneling"); %>', 'vpn'],
49 ['<% translate("Administration"); %>', 'admin']];
51 function toggle(service
, isup
)
54 if (!confirm("<% translate("Unsaved changes will be lost
. Continue anyway
"); %>?")) return;
56 E('_' + service
+ '_button').disabled
= true;
57 form
.submitHidden('service.cgi', {
58 _redirect
: 'admin-access.asp',
59 _sleep
: ((service
== 'sshd') && (!isup
)) ? '7' : '3',
60 _service
: service
+ (isup
? '-stop' : '-start')
64 function verifyFields(focused
, quiet
)
71 a
= E('_web_css').value
;
72 if (a
!= nvram
.web_css
) {
73 E('guicss').href
= a
+ '.css';
80 a
= E('_f_http_local');
81 b
= E('_f_http_remote').value
;
82 if ((a
.value
!= 3) && (b
!= 0) && (a
.value
!= b
)) {
83 ferror
.set(a
, '<% translate("The local http/https must also be enabled when using remote access"); %>.', quiet
|| !ok
);
90 elem
.display(PR('_http_lanport'), (a
.value
== 1) || (a
.value
== 3));
92 c
= (a
.value
== 2) || (a
.value
== 3);
93 elem
.display(PR('_https_lanport'), 'row_sslcert', PR('_https_crt_cn'), PR('_f_https_crt_save'), PR('_f_https_crt_gen'), c
);
96 a
= E('_https_crt_cn');
97 a
.value
= a
.value
.replace(/(,+|\s+)/g, ' ').trim();
98 if (a
.value
!= nvram
.https_crt_cn
) E('_f_https_crt_gen').checked
= 1;
101 if ((!v_port('_http_lanport', quiet
|| !ok
)) || (!v_port('_https_lanport', quiet
|| !ok
))) ok
= 0;
104 a
= E('_http_wanport');
105 elem
.display(PR(a
), b
);
106 if ((b
) && (!v_port(a
, quiet
|| !ok
))) ok
= 0;
108 if (!v_port('_telnetd_port', quiet
|| !ok
)) ok
= 0;
110 a
= E('_f_sshd_remote').checked
;
111 b
= E('_sshd_rport');
112 elem
.display(PR(b
), a
);
113 if ((a
) && (!v_port(b
, quiet
|| !ok
))) ok
= 0;
115 a
= E('_sshd_authkeys');
116 if (!v_length(a
, quiet
|| !ok
, 0, 4096)) {
119 else if (a
.value
!= '') {
120 if (a
.value
.search(/^\s*ssh-(dss|rsa)/) == -1) {
121 ferror
.set(a
, '<% translate("Invalid SSH key"); %>.', quiet
|| !ok
);
126 a
= E('_f_rmgt_sip');
127 if ((a
.value
.length
) && (!_v_iptaddr(a
, quiet
|| !ok
, 15, 1, 1))) return 0;
130 if (!v_range('_f_limit_hit', quiet
|| !ok
, 1, 100)) return 0;
131 if (!v_range('_f_limit_sec', quiet
|| !ok
, 3, 3600)) return 0;
133 a
= E('_set_password_1');
134 b
= E('_set_password_2');
135 a
.value
= a
.value
.trim();
136 b
.value
= b
.value
.trim();
137 if (a
.value
!= b
.value
) {
138 ferror
.set(b
, '<% translate("Both passwords must match"); %>.', quiet
|| !ok
);
141 else if (a
.value
== '') {
142 ferror
.set(a
, '<% translate("Password must not be empty"); %>.', quiet
|| !ok
);
158 if (!verifyFields(null, false)) return;
161 a
= E('_f_http_local').value
* 1;
163 if (!confirm('<% translate("Warning: Web Admin is about to be disabled. If you decide to re-enable Web Admin at a later time, it must be done manually via Telnet, SSH or by performing a hardware reset. Are you sure you want to do this"); %>?')) return;
164 fom
._nextpage
.value
= 'about:blank';
166 fom
.http_enable
.value
= (a
& 1) ? 1 : 0;
167 fom
.https_enable
.value
= (a
& 2) ? 1 : 0;
169 nvram
.lan_ipaddr
= location
.hostname
;
170 if ((a
!= 0) && (location
.hostname
== nvram
.lan_ipaddr
)) {
171 if (location
.protocol
== 'https:') {
173 if ((a
& 2) == 0) b
= '';
177 if ((a
& 1) == 0) b
= 's';
180 a
= 'http' + b
+ '://' + location
.hostname
;
182 if (fom
.https_lanport
.value
!= 443) a
+= ':' + fom
.https_lanport
.value
;
185 if (fom
.http_lanport
.value
!= 80) a
+= ':' + fom
.http_lanport
.value
;
187 fom
._nextpage
.value
= a
+ '/admin-access.asp';
190 a
= E('_f_http_remote').value
;
191 fom
.remote_management
.value
= (a
!= 0) ? 1 : 0;
192 fom
.remote_mgt_https
.value
= (a
== 2) ? 1 : 0;
194 if ((a != 0) && (location.hostname != nvram.lan_ipaddr)) {
195 if (location.protocol == 'https:') {
196 if (a != 2) fom._nextpage.value = 'http://' + location.hostname + ':' + fom.http_wanport.value + '/admin-access.asp';
199 if (a == 2) fom._nextpage.value = 'https://' + location.hostname + ':' + fom.http_wanport.value + '/admin-access.asp';
203 fom
.https_crt_gen
.value
= E('_f_https_crt_gen').checked
? 1 : 0;
204 fom
.https_crt_save
.value
= E('_f_https_crt_save').checked
? 1 : 0;
206 fom
.web_wl_filter
.value
= E('_f_http_wireless').checked
? 0 : 1;
208 fom
.telnetd_eas
.value
= E('_f_telnetd_eas').checked
? 1 : 0;
210 fom
.sshd_eas
.value
= E('_f_sshd_eas').checked
? 1 : 0;
211 fom
.sshd_pass
.value
= E('_f_sshd_pass').checked
? 1 : 0;
212 fom
.sshd_remote
.value
= E('_f_sshd_remote').checked
? 1 : 0;
213 fom
.sshd_forwarding
.value
= E('_f_sshd_forwarding').checked
? 1 : 0;
215 fom
.rmgt_sip
.value
= fom
.f_rmgt_sip
.value
.split(/\s*,\s*/).join(',');
217 fom
.ne_shlimit
.value
= ((E('_f_limit_ssh').checked
? 1 : 0) | (E('_f_limit_telnet').checked
? 2 : 0)) +
218 ',' + E('_f_limit_hit').value
+ ',' + E('_f_limit_sec').value
;
221 for (var i
= 0; i
< xmenus
.length
; ++i
) {
223 if (E('_f_mx_' + b
).checked
) a
.push(b
);
225 fom
.web_mx
.value
= a
.join(',');
236 <body onload=
"init()">
237 <form id='_fom' method='post' action='tomato.cgi'
>
238 <table id='container' cellspacing=
0>
239 <tr><td colspan=
2 id='header'
>
240 <div class='title'
>Tomato
</div>
241 <div class='version'
><%
translate("Version"); %> <% version(); %
></div>
243 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
245 <div id='ident'
><%
ident(); %></div>
249 <input type='hidden' name='_nextpage' value='admin-access.asp'
>
250 <input type='hidden' name='_nextwait' value='
10'
>
251 <input type='hidden' name='_service' value='admin-restart'
>
253 <input type='hidden' name='http_enable'
>
254 <input type='hidden' name='https_enable'
>
255 <input type='hidden' name='https_crt_save'
>
256 <input type='hidden' name='https_crt_gen'
>
257 <input type='hidden' name='remote_management'
>
258 <input type='hidden' name='remote_mgt_https'
>
259 <input type='hidden' name='web_wl_filter'
>
260 <input type='hidden' name='telnetd_eas'
>
261 <input type='hidden' name='sshd_eas'
>
262 <input type='hidden' name='sshd_pass'
>
263 <input type='hidden' name='sshd_remote'
>
264 <input type='hidden' name='ne_shlimit'
>
265 <input type='hidden' name='rmgt_sip'
>
266 <input type='hidden' name='sshd_forwarding'
>
267 <input type='hidden' name='web_mx'
>
269 <div class='section-title'
><%
translate("Web Admin"); %></div>
270 <div class='section'
>
271 <script type='text/javascript'
>
273 { title
: '<% translate("Local Access"); %>', name
: 'f_http_local', type
: 'select', options
: [[0,'<% translate("Disabled"); %>'],[1,'HTTP'],[2,'HTTPS'],[3,'HTTP & HTTPS']],
274 value
: ((nvram
.https_enable
!= 0) ? 2 : 0) | ((nvram
.http_enable
!= 0) ? 1 : 0) },
275 { title
: '<% translate("HTTP Port"); %>', indent
: 2, name
: 'http_lanport', type
: 'text', maxlen
: 5, size
: 7, value
: fixPort(nvram
.http_lanport
, 80) },
276 { title
: '<% translate("HTTPS Port"); %>', indent
: 2, name
: 'https_lanport', type
: 'text', maxlen
: 5, size
: 7, value
: fixPort(nvram
.https_lanport
, 443) },
277 { title
: '<% translate("SSL Certificate"); %>', rid
: 'row_sslcert' },
278 { title
: '<% translate("Common Name"); %> (CN)', indent
: 2, name
: 'https_crt_cn', type
: 'text', maxlen
: 64, size
: 64, value
: nvram
.https_crt_cn
,
279 suffix
: ' <small>(<% translate("optional"); %>; <% translate("space separated"); %>)</small>' },
280 { title
: '<% translate("Regenerate"); %>', indent
: 2, name
: 'f_https_crt_gen', type
: 'checkbox', value
: 0 },
281 { title
: '<% translate("Save In NVRAM"); %>', indent
: 2, name
: 'f_https_crt_save', type
: 'checkbox', value
: nvram
.https_crt_save
== 1 },
282 { title
: '<% translate("Remote Access"); %>', name
: 'f_http_remote', type
: 'select', options
: [[0,'<% translate("Disabled"); %>'],[1,'HTTP'],[2,'HTTPS']],
283 value
: (nvram
.remote_management
== 1) ? ((nvram
.remote_mgt_https
== 1) ? 2 : 1) : 0 },
284 { title
: '<% translate("Port"); %>', indent
: 2, name
: 'http_wanport', type
: 'text', maxlen
: 5, size
: 7, value
: fixPort(nvram
.http_wanport
, 8080) },
285 { title
: '<% translate("Allow Wireless Access"); %>', name
: 'f_http_wireless', type
: 'checkbox', value
: nvram
.web_wl_filter
== 0 },
287 { title
: '<% translate("Language"); %>', name
: 'web_lang', type
: 'select',
288 options
: [['en_EN','English'],['pl_PL','Polski']], value
: nvram
.web_lang
},
290 { title
: '<% translate("Color Scheme"); %>', name
: 'web_css', type
: 'select',
291 options
: [['red','Tomato'],['black','Black'],['blue','Blue'],['bluegreen','Blue & Green (Lighter)'],['bluegreen2','Blue & Green (Darker)'],['brown','Brown'],['cyan','Cyan'],['olive','Olive'],['pumpkin','Pumpkin'],['asus','Asus RT-N16'],['usbred','USB Red'],['usbblue','USB Blue'],['ext/custom','<% translate("Custom"); %> (ext/custom.css)']], value
: nvram
.web_css
},
292 { title
: '<% translate("Open Menus"); %>' }
295 var webmx
= get_config('web_mx', '').toLowerCase();
296 for (var i
= 0; i
< xmenus
.length
; ++i
) {
297 m
.push({ title
: xmenus
[i
][0], indent
: 2, name
: 'f_mx_' + xmenus
[i
][1],
298 type
: 'checkbox', value
: (webmx
.indexOf(xmenus
[i
][1]) != -1) });
301 createFieldTable('', m
);
305 <div class='section-title'
><%
translate("SSH Daemon"); %></div>
306 <div class='section'
>
307 <script type='text/javascript'
>
308 createFieldTable('', [
309 { title
: '<% translate("Enable at Startup"); %>', name
: 'f_sshd_eas', type
: 'checkbox', value
: nvram
.sshd_eas
== 1 },
310 { title
: '<% translate("Remote Access"); %>', name
: 'f_sshd_remote', type
: 'checkbox', value
: nvram
.sshd_remote
== 1 },
311 { title
: '<% translate("Remote Port"); %>', indent
: 2, name
: 'sshd_rport', type
: 'text', maxlen
: 5, size
: 7, value
: nvram
.sshd_rport
},
312 { title
: '<% translate("Remote Forwarding"); %>', name
: 'f_sshd_forwarding', type
: 'checkbox', value
: nvram
.sshd_forwarding
== 1 },
313 { title
: '<% translate("Port"); %>', name
: 'sshd_port', type
: 'text', maxlen
: 5, size
: 7, value
: nvram
.sshd_port
},
314 { title
: '<% translate("Allow Password Login"); %>', name
: 'f_sshd_pass', type
: 'checkbox', value
: nvram
.sshd_pass
== 1 },
315 { title
: '<% translate("Authorized Keys"); %>', name
: 'sshd_authkeys', type
: 'textarea', value
: nvram
.sshd_authkeys
}
317 W('<input type="button" value="' + (sdup
? '<% translate("Stop"); %>' : '<% translate("Start"); %>') + ' <% translate("Now"); %>" onclick="toggle(\'sshd\', sdup)" id="_sshd_button">');
321 <div class='section-title'
><%
translate("Telnet Daemon"); %></div>
322 <div class='section'
>
323 <script type='text/javascript'
>
324 createFieldTable('', [
325 { title
: '<% translate("Enable at Startup"); %>', name
: 'f_telnetd_eas', type
: 'checkbox', value
: nvram
.telnetd_eas
== 1 },
326 { title
: '<% translate("Port"); %>', name
: 'telnetd_port', type
: 'text', maxlen
: 5, size
: 7, value
: nvram
.telnetd_port
}
328 W('<input type="button" value="' + (tdup
? '<% translate("Stop"); %>' : '<% translate("Start"); %>') + ' <% translate("Now"); %>" onclick="toggle(\'telnetd\', tdup)" id="_telnetd_button">');
332 <div class='section-title'
><%
translate("Admin Restrictions"); %></div>
333 <div class='section'
>
334 <script type='text/javascript'
>
335 createFieldTable('', [
336 { title
: '<% translate("Allowed Remote"); %><br><% translate("IP Address"); %>', name
: 'f_rmgt_sip', type
: 'text', maxlen
: 512, size
: 64, value
: nvram
.rmgt_sip
,
337 suffix
: '<br><small>(<% translate("optional"); %>; <% translate("ex"); %>: "1.1.1.1", "1.1.1.0/24", "1.1.1.1 - 2.2.2.2" or "me.example.com")</small>' },
338 { title
: '<% translate("Limit Connection Attempts"); %>', multi
: [
339 { suffix
: ' SSH / ', name
: 'f_limit_ssh', type
: 'checkbox', value
: (shlimit
[0] & 1) != 0 },
340 { suffix
: ' Telnet ', name
: 'f_limit_telnet', type
: 'checkbox', value
: (shlimit
[0] & 2) != 0 }
342 { title
: '', indent
: 2, multi
: [
343 { name
: 'f_limit_hit', type
: 'text', maxlen
: 4, size
: 6, suffix
: ' <% translate("every"); %> ', value
: shlimit
[1] },
344 { name
: 'f_limit_sec', type
: 'text', maxlen
: 4, size
: 6, suffix
: ' <% translate("seconds"); %>', value
: shlimit
[2] }
350 <div class='section-title'
><%
translate("Password"); %></div>
351 <div class='section'
>
352 <script type='text/javascript'
>
353 createFieldTable('', [
354 { title
: '<% translate("Password"); %>', name
: 'set_password_1', type
: 'password', value
: '**********' },
355 { title
: '<i>(<% translate("re-enter to confirm"); %>)</i>', indent
: 2, name
: 'set_password_2', type
: 'password', value
: '**********' }
363 <tr><td id='footer' colspan=
2>
364 <span id='footer-msg'
></span>
365 <input type='button' value='<%
translate("Save"); %>' id='save-button' onclick='save()'
>
366 <input type='button' value='<%
translate("Cancel"); %>' id='cancel-button' onclick='javascript:reloadPage();'
>
370 <script type='text/javascript'
>verifyFields(null, 1);</script>