fix proto sort
[tomato/davidwu.git] / release / src / router / www / admin-log.asp
blob97d9afa689776bfe0dc2e5e5a4f22cc1d6d58b88
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(); %>] Admin: Logging</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 <script type='text/javascript' src='debug.js'></script>
23 <script type='text/javascript'>
25 // <% nvram("log_remote,log_remoteip,log_remoteport,log_file,log_file_custom,log_file_path,log_limit,log_in,log_out,log_mark,log_events,log_wm,log_wmtype,log_wmip,log_wmdmax,log_wmsmax,log_file_size,log_file_keep"); %>
27 function verifyFields(focused, quiet)
29 var a, b, c;
31 a = E('_f_log_file').checked;
32 b = E('_f_log_remote').checked;
33 c = E('_f_log_file_custom').checked;
35 a = !(a || b);
36 E('_log_in').disabled = a;
37 E('_log_out').disabled = a;
38 E('_log_limit').disabled = a;
39 E('_log_mark').disabled = a;
40 E('_f_log_acre').disabled = a;
41 E('_f_log_crond').disabled = a;
42 E('_f_log_dhcpc').disabled = a;
43 E('_f_log_ntp').disabled = a;
44 E('_f_log_sched').disabled = a;
46 elem.display(PR('_log_remoteip'), b);
47 E('_log_remoteip').disabled = !b;
48 E('_log_remoteport').disabled = !b;
50 E('_f_log_file_custom').disabled = !E('_f_log_file').checked;
51 E('_log_file_path').disabled = !c || !E('_f_log_file').checked;
53 if (!a) {
54 if (!v_range('_log_limit', quiet, 0, 2400)) return 0;
55 if (!v_range('_log_mark', quiet, 0, 99999)) return 0;
56 if (b) {
57 c = E('_log_remoteip');
58 if (!v_ip(c, 1) && !v_domain(c, 1)) {
59 if (!quiet) ferror.show(c);
60 return 0;
62 if (!v_port('_log_remoteport', quiet)) return 0;
66 if (E('_f_log_file').checked) {
67 E('_log_file_size').disabled = 0;
68 if (!v_range('_log_file_size', quiet, 0, 99999)) return 0;
69 if (parseInt(E('_log_file_size').value) > 0) {
70 E('_log_file_keep').disabled = 0;
71 if (!v_range('_log_file_keep', quiet, 0, 99)) return 0;
72 } else {
73 E('_log_file_keep').disabled = 1;
75 } else {
76 E('_log_file_size').disabled = 1;
77 E('_log_file_keep').disabled = 1;
80 a = E('_f_log_wm').checked;
81 b = E('_log_wmtype').value != 0;
82 E('_log_wmtype').disabled = !a;
83 E('_f_log_wmip').disabled = !a;
84 E('_log_wmdmax').disabled = !a;
85 E('_log_wmsmax').disabled = !a;
86 elem.display(PR('_f_log_wmip'), b);
88 if (a) {
89 if (b) {
90 if (!_v_iptaddr('_f_log_wmip', quiet, 15, 1, 1)) return 0;
92 if (!v_range('_log_wmdmax', quiet, 0, 9999)) return 0;
93 if (!v_range('_log_wmsmax', quiet, 0, 9999)) return 0;
96 return 1;
99 function save()
101 var a, fom;
103 if (!verifyFields(null, false)) return;
105 fom = E('_fom');
106 fom.log_remote.value = E('_f_log_remote').checked ? 1 : 0;
107 fom.log_file.value = E('_f_log_file').checked ? 1 : 0;
108 fom.log_file_custom.value = E('_f_log_file_custom').checked ? 1 : 0;
110 a = [];
111 if (E('_f_log_acre').checked) a.push('acre');
112 if (E('_f_log_crond').checked) a.push('crond');
113 if (E('_f_log_dhcpc').checked) a.push('dhcpc');
114 if (E('_f_log_ntp').checked) a.push('ntp');
115 if (E('_f_log_sched').checked) a.push('sched');
116 fom.log_events.value = a.join(',');
118 fom.log_wm.value = E('_f_log_wm').checked ? 1 : 0;
119 fom.log_wmip.value = fom.f_log_wmip.value.split(/\s*,\s*/).join(',');
121 form.submit(fom, 1);
123 </script>
125 </head>
126 <body>
127 <form id='_fom' method='post' action='tomato.cgi'>
128 <table id='container' cellspacing=0>
129 <tr><td colspan=2 id='header'>
130 <div class='title'>Tomato</div>
131 <div class='version'>Version <% version(); %></div>
132 </td></tr>
133 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
134 <td id='content'>
135 <div id='ident'><% ident(); %></div>
137 <!-- / / / -->
139 <input type='hidden' name='_nextpage' value='admin-log.asp'>
140 <input type='hidden' name='_service' value='logging-restart'>
142 <input type='hidden' name='log_remote'>
143 <input type='hidden' name='log_file'>
144 <input type='hidden' name='log_file_custom'>
145 <input type='hidden' name='log_events'>
147 <input type='hidden' name='log_wm'>
148 <input type='hidden' name='log_wmip'>
150 <script type='text/javascript'>
151 </script>
153 <div class='section-title'>Syslog</div>
154 <div class='section'>
155 <script type='text/javascript'>
157 /* REMOVE-BEGIN
158 // adjust (>=1.22)
159 nvram.log_mark *= 1;
160 if (nvram.log_mark >= 120) nvram.log_mark = 120;
161 else if (nvram.log_mark >= 60) nvram.log_mark = 60;
162 else if (nvram.log_mark > 0) nvram.log_mark = 30;
163 else nvram.log_mark = 0;
164 REMOVE-END */
166 createFieldTable('', [
167 { title: 'Log Internally', name: 'f_log_file', type: 'checkbox', value: nvram.log_file == 1 },
168 { title: 'Max size before rotate', name: 'log_file_size', type: 'text', maxlen: 5, size: 6, value: nvram.log_file_size || 50, suffix: ' <small>KB</small>' },
169 { title: 'Number of rotated logs to keep', name: 'log_file_keep', type: 'text', maxlen: 2, size: 3, value: nvram.log_file_keep || 1 },
170 { title: 'Custom Log Path & Filename', multi: [
171 { name: 'f_log_file_custom', type: 'checkbox', value: nvram.log_file_custom == 1, suffix: ' ' },
172 { name: 'log_file_path', type: 'text', maxlen: 32, size: 20, value: nvram.log_file_path, suffix: ' <small>(make sure the directory exists and is writable)</small>' }
173 ] },
174 { title: 'Log To Remote System', name: 'f_log_remote', type: 'checkbox', value: nvram.log_remote == 1 },
175 { title: 'Host or IP Address / Port', indent: 2, multi: [
176 { name: 'log_remoteip', type: 'text', maxlen: 15, size: 17, value: nvram.log_remoteip, suffix: ':' },
177 { name: 'log_remoteport', type: 'text', maxlen: 5, size: 7, value: nvram.log_remoteport } ]},
178 { title: 'Generate Marker', name: 'log_mark', type: 'select', options: [[0,'Disabled'],[30,'Every 30 Minutes'],[60,'Every 1 Hour'],[120,'Every 2 Hours'],[360,'Every 6 Hours'],[720,'Every 12 Hours'],[1440,'Every 1 Day'],[10080,'Every 7 Days']], value: nvram.log_mark },
179 { title: 'Events Logged', text: '<small>(some of the changes will take effect after a restart)</small>' },
180 { title: 'Access Restriction', indent: 2, name: 'f_log_acre', type: 'checkbox', value: (nvram.log_events.indexOf('acre') != -1) },
181 { title: 'Cron', indent: 2, name: 'f_log_crond', type: 'checkbox', value: (nvram.log_events.indexOf('crond') != -1) },
182 { title: 'DHCP Client', indent: 2, name: 'f_log_dhcpc', type: 'checkbox', value: (nvram.log_events.indexOf('dhcpc') != -1) },
183 { title: 'NTP', indent: 2, name: 'f_log_ntp', type: 'checkbox', value: (nvram.log_events.indexOf('ntp') != -1) },
184 { title: 'Scheduler', indent: 2, name: 'f_log_sched', type: 'checkbox', value: (nvram.log_events.indexOf('sched') != -1) },
185 { title: 'Connection Logging' },
186 { title: 'Inbound', indent: 2, name: 'log_in', type: 'select', options: [[0,'Disabled (recommended)'],[1,'If Blocked By Firewall'],[2,'If Allowed By Firewall'],[3,'Both']], value: nvram.log_in },
187 { title: 'Outbound', indent: 2, name: 'log_out', type: 'select', options: [[0,'Disabled (recommended)'],[1,'If Blocked By Firewall'],[2,'If Allowed By Firewall'],[3,'Both']], value: nvram.log_out },
188 { title: 'Limit', indent: 2, name: 'log_limit', type: 'text', maxlen: 4, size: 5, value: nvram.log_limit, suffix: ' <small>(messages per minute / 0 for unlimited)</small>' }
190 </script>
191 </div>
193 <div class='section-title'>Web Monitor</div>
194 <div class='section'>
195 <script type='text/javascript'>
196 createFieldTable('', [
197 { title: 'Monitor Web Usage', name: 'f_log_wm', type: 'checkbox', value: nvram.log_wm == 1 },
198 { title: 'Monitor', name: 'log_wmtype', type: 'select', options: [[0,'All Computers / Devices'],[1,'The Following...'],[2,'All Except...']], value: nvram.log_wmtype },
199 { title: 'IP Address(es)', indent: 2, name: 'f_log_wmip', type: 'text', maxlen: 512, size: 64, value: nvram.log_wmip,
200 suffix: '<br><small>(ex: "1.1.1.1", "1.1.1.0/24" or "1.1.1.1 - 2.2.2.2")</small>' },
201 { title: 'Number of Entries to remember' },
202 { title: 'Domains', indent: 2, name: 'log_wmdmax', type: 'text', maxlen: 4, size: 6, value: nvram.log_wmdmax, suffix: ' <small>(0 to disable)</small>' },
203 { title: 'Searches', indent: 2, name: 'log_wmsmax', type: 'text', maxlen: 4, size: 6, value: nvram.log_wmsmax, suffix: ' <small>(0 to disable)</small>' }
205 </script>
206 </div>
208 <!-- / / / -->
210 </td></tr>
211 <tr><td id='footer' colspan=2>
212 <span id='footer-msg'></span>
213 <input type='button' value='Save' id='save-button' onclick='save()'>
214 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
215 </td></tr>
216 </table>
217 </form>
218 <script type='text/javascript'>verifyFields(null, 1);</script>
219 </body>
220 </html>