Project

General

Profile

Download (15.5 KB) Statistics
| Branch: | Tag: | Revision:
1 4d875b4f Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	diag_logs_settings.php
5 13d193c2 Scott Ullrich
	Copyright (C) 2004-2009 Scott Ullrich
6 4d875b4f Scott Ullrich
	All rights reserved.
7
8
	originially part of m0n0wall (http://m0n0.ch/wall)
9 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11 4d875b4f Scott Ullrich
12 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14 4d875b4f Scott Ullrich
15 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 4d875b4f Scott Ullrich
18 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21 4d875b4f Scott Ullrich
22 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34 e34a7abb jim-p
/*
35 13d193c2 Scott Ullrich
	pfSense_MODULE:	system
36
*/
37
38 6b07c15a Matthew Grooms
##|+PRIV
39
##|*IDENT=page-diagnostics-logs-settings
40
##|*NAME=Diagnostics: Logs: Settings page
41
##|*DESCR=Allow access to the 'Diagnostics: Logs: Settings' page.
42
##|*MATCH=diag_logs_settings.php*
43
##|-PRIV
44
45 5b237745 Scott Ullrich
require("guiconfig.inc");
46 7a927e67 Scott Ullrich
require_once("functions.inc");
47
require_once("filter.inc");
48
require_once("shaper.inc");
49 5b237745 Scott Ullrich
50
$pconfig['reverse'] = isset($config['syslog']['reverse']);
51
$pconfig['nentries'] = $config['syslog']['nentries'];
52
$pconfig['remoteserver'] = $config['syslog']['remoteserver'];
53 98301932 Scott Ullrich
$pconfig['remoteserver2'] = $config['syslog']['remoteserver2'];
54 be5d59d7 Scott Ullrich
$pconfig['remoteserver3'] = $config['syslog']['remoteserver3'];
55 5b237745 Scott Ullrich
$pconfig['filter'] = isset($config['syslog']['filter']);
56
$pconfig['dhcp'] = isset($config['syslog']['dhcp']);
57 3f2b92d2 Scott Ullrich
$pconfig['portalauth'] = isset($config['syslog']['portalauth']);
58 5b237745 Scott Ullrich
$pconfig['vpn'] = isset($config['syslog']['vpn']);
59 236524c2 jim-p
$pconfig['apinger'] = isset($config['syslog']['apinger']);
60
$pconfig['relayd'] = isset($config['syslog']['relayd']);
61
$pconfig['hostapd'] = isset($config['syslog']['hostapd']);
62 4ef2d703 Chris Buechler
$pconfig['logall'] = isset($config['syslog']['logall']);
63 5b237745 Scott Ullrich
$pconfig['system'] = isset($config['syslog']['system']);
64
$pconfig['enable'] = isset($config['syslog']['enable']);
65
$pconfig['logdefaultblock'] = !isset($config['syslog']['nologdefaultblock']);
66
$pconfig['rawfilter'] = isset($config['syslog']['rawfilter']);
67 af659dda Scott Ullrich
$pconfig['disablelocallogging'] = isset($config['syslog']['disablelocallogging']);
68 5b237745 Scott Ullrich
69
if (!$pconfig['nentries'])
70
	$pconfig['nentries'] = 50;
71
72 d3a2337a jim-p
function is_valid_syslog_server($target) {
73
	return (is_ipaddr($target)
74
		|| is_ipaddrwithport($target)
75
		|| is_hostname($target)
76
		|| is_hostnamewithport($target));
77
}
78
79 5b237745 Scott Ullrich
if ($_POST) {
80
81
	unset($input_errors);
82
	$pconfig = $_POST;
83
84
	/* input validation */
85 d3a2337a jim-p
	if ($_POST['enable'] && !is_valid_syslog_server($_POST['remoteserver'])) {
86
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #1.");
87 5b237745 Scott Ullrich
	}
88 d3a2337a jim-p
	if ($_POST['enable'] && $_POST['remoteserver2'] && !is_valid_syslog_server($_POST['remoteserver2'])) {
89
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #2.");
90 be5d59d7 Scott Ullrich
	}
91 d3a2337a jim-p
	if ($_POST['enable'] && $_POST['remoteserver3'] && !is_valid_syslog_server($_POST['remoteserver3'])) {
92
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #3.");
93 be5d59d7 Scott Ullrich
	}
94
95 102de157 Scott Ullrich
	if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 2000)) {
96 f8ec8de4 Renato Botelho
		$input_errors[] = gettext("Number of log entries to show must be between 5 and 2000.");
97 5b237745 Scott Ullrich
	}
98
99
	if (!$input_errors) {
100
		$config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
101
		$config['syslog']['nentries'] = (int)$_POST['nentries'];
102
		$config['syslog']['remoteserver'] = $_POST['remoteserver'];
103 be5d59d7 Scott Ullrich
		$config['syslog']['remoteserver2'] = $_POST['remoteserver2'];
104
		$config['syslog']['remoteserver3'] = $_POST['remoteserver3'];
105 5b237745 Scott Ullrich
		$config['syslog']['filter'] = $_POST['filter'] ? true : false;
106
		$config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
107 3f2b92d2 Scott Ullrich
		$config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false;
108 5b237745 Scott Ullrich
		$config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
109 236524c2 jim-p
		$config['syslog']['apinger'] = $_POST['apinger'] ? true : false;
110
		$config['syslog']['relayd'] = $_POST['relayd'] ? true : false;
111
		$config['syslog']['hostapd'] = $_POST['hostapd'] ? true : false;
112 e34a7abb jim-p
		$config['syslog']['logall'] = $_POST['logall'] ? true : false;
113 5b237745 Scott Ullrich
		$config['syslog']['system'] = $_POST['system'] ? true : false;
114 e1c0c35a Scott Ullrich
		$config['syslog']['disablelocallogging'] = $_POST['disablelocallogging'] ? true : false;
115 5b237745 Scott Ullrich
		$config['syslog']['enable'] = $_POST['enable'] ? true : false;
116
		$oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
117
		$config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
118
		$config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
119 be5d59d7 Scott Ullrich
		if($config['syslog']['enable'] == false) {
120 f3a5f0c5 Scott Ullrich
			unset($config['syslog']['remoteserver']);
121 be5d59d7 Scott Ullrich
			unset($config['syslog']['remoteserver2']);
122
			unset($config['syslog']['remoteserver3']);
123
		}
124 c195be3f Scott Ullrich
125 5b237745 Scott Ullrich
		write_config();
126 c195be3f Scott Ullrich
127 5b237745 Scott Ullrich
		$retval = 0;
128 fd31e9ee Scott Ullrich
		$retval = system_syslogd_start();
129
		if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
130
			$retval |= filter_configure();
131 c195be3f Scott Ullrich
132 4d875b4f Scott Ullrich
		$savemsg = get_std_save_message($retval);
133 5b237745 Scott Ullrich
	}
134
}
135
136 f8ec8de4 Renato Botelho
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("Settings"));
137 b63695db Scott Ullrich
include("head.inc");
138
139 5b237745 Scott Ullrich
?>
140 b63695db Scott Ullrich
141
142 5b237745 Scott Ullrich
<script language="JavaScript">
143
<!--
144
function enable_change(enable_over) {
145
	if (document.iform.enable.checked || enable_over) {
146
		document.iform.remoteserver.disabled = 0;
147 be5d59d7 Scott Ullrich
		document.iform.remoteserver2.disabled = 0;
148
		document.iform.remoteserver3.disabled = 0;
149 5b237745 Scott Ullrich
		document.iform.filter.disabled = 0;
150
		document.iform.dhcp.disabled = 0;
151 3f2b92d2 Scott Ullrich
		document.iform.portalauth.disabled = 0;
152 5b237745 Scott Ullrich
		document.iform.vpn.disabled = 0;
153 236524c2 jim-p
		document.iform.apinger.disabled = 0;
154
		document.iform.relayd.disabled = 0;
155
		document.iform.hostapd.disabled = 0;
156 5b237745 Scott Ullrich
		document.iform.system.disabled = 0;
157 5e08497c Chris Buechler
		document.iform.logall.disabled = 0;
158 5b237745 Scott Ullrich
	} else {
159
		document.iform.remoteserver.disabled = 1;
160 be5d59d7 Scott Ullrich
		document.iform.remoteserver2.disabled = 1;
161
		document.iform.remoteserver3.disabled = 1;
162 5b237745 Scott Ullrich
		document.iform.filter.disabled = 1;
163
		document.iform.dhcp.disabled = 1;
164 3f2b92d2 Scott Ullrich
		document.iform.portalauth.disabled = 1;
165 5b237745 Scott Ullrich
		document.iform.vpn.disabled = 1;
166 236524c2 jim-p
		document.iform.apinger.disabled = 1;
167
		document.iform.relayd.disabled = 1;
168
		document.iform.hostapd.disabled = 1;
169 5b237745 Scott Ullrich
		document.iform.system.disabled = 1;
170 5e08497c Chris Buechler
		document.iform.logall.disabled = 1;
171 5b237745 Scott Ullrich
	}
172
}
173 236524c2 jim-p
function check_everything() {
174
	if (document.iform.logall.checked) {
175
		document.iform.filter.disabled = 1;
176
		document.iform.filter.checked = false
177
		document.iform.dhcp.disabled = 1;
178
		document.iform.dhcp.checked = false
179
		document.iform.portalauth.disabled = 1;
180
		document.iform.portalauth.checked = false
181
		document.iform.vpn.disabled = 1;
182
		document.iform.vpn.checked = false
183
		document.iform.apinger.disabled = 1;
184
		document.iform.apinger.checked = false
185
		document.iform.relayd.disabled = 1;
186
		document.iform.relayd.checked = false
187
		document.iform.hostapd.disabled = 1;
188
		document.iform.hostapd.checked = false
189
		document.iform.system.disabled = 1;
190
		document.iform.system.checked = false
191
	} else {
192
		document.iform.filter.disabled = 0;
193
		document.iform.dhcp.disabled = 0;
194
		document.iform.portalauth.disabled = 0;
195
		document.iform.vpn.disabled = 0;
196
		document.iform.apinger.disabled = 0;
197
		document.iform.relayd.disabled = 0;
198
		document.iform.hostapd.disabled = 0;
199
		document.iform.system.disabled = 0;
200
	}
201
}
202 5b237745 Scott Ullrich
// -->
203
</script>
204
205
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
206
<?php include("fbegin.inc"); ?>
207
<form action="diag_logs_settings.php" method="post" name="iform" id="iform">
208
<?php if ($input_errors) print_input_errors($input_errors); ?>
209
<?php if ($savemsg) print_info_box($savemsg); ?>
210
<table width="100%" border="0" cellpadding="0" cellspacing="0">
211 e34a7abb jim-p
<tr><td>
212 b63695db Scott Ullrich
<?php
213
	$tab_array = array();
214 f8ec8de4 Renato Botelho
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
215
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
216
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
217
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
218
	$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php");
219
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
220
	$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
221
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
222
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
223
	$tab_array[] = array(gettext("OpenNTPD"), false, "diag_logs_ntpd.php");
224 689eaa4d jim-p
	$tab_array[] = array(gettext("Wireless"), false, "diag_logs_wireless.php");
225 f8ec8de4 Renato Botelho
	$tab_array[] = array(gettext("Settings"), true, "diag_logs_settings.php");
226 b63695db Scott Ullrich
	display_top_tabs($tab_array);
227
?>
228 e34a7abb jim-p
</td></tr>
229
<tr>
230
	<td>
231 0f10aee4 Bill Marquette
	<div id="mainarea">
232 e34a7abb jim-p
	<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
233
		<tr>
234
			<td colspan="2" valign="top" class="listtopic"><?=gettext("General Logging Options");?></td>
235
		</tr>
236
		<tr>
237
			<td width="22%" valign="top" class="vtable">Forward/Reverse Display</td>
238
			<td width="78%" class="vtable"> <input name="reverse" type="checkbox" id="reverse" value="yes" <?php if ($pconfig['reverse']) echo "checked"; ?>>
239 f8ec8de4 Renato Botelho
			<strong><?=gettext("Show log entries in reverse order (newest entries on top)");?></strong></td>
240 e34a7abb jim-p
		</tr>
241
		<tr>
242
			<td width="22%" valign="top" class="vtable">GUI Log Entries to Display</td>
243
			<td width="78%" class="vtable">
244
			<input name="nentries" id="nentries" type="text" class="formfld unknown" size="4" value="<?=htmlspecialchars($pconfig['nentries']);?>"><br/>
245
			<?=gettext("Hint: This is only the number of log entries displayed in the GUI. It does not affect how many entries are contained in the actual log files.") ?></td>
246
		</tr>
247
		<tr>
248
			<td valign="top" class="vtable">Log Firewall Default Blocks</td>
249
			<td class="vtable"> <input name="logdefaultblock" type="checkbox" id="logdefaultblock" value="yes" <?php if ($pconfig['logdefaultblock']) echo "checked"; ?>>
250 f8ec8de4 Renato Botelho
			<strong><?=gettext("Log packets blocked by the default rule");?></strong><br>
251 e34a7abb jim-p
				<?=gettext("Hint: packets that are blocked by the " .
252
				"implicit default block rule will not be logged " .
253
				"if you uncheck this option. Per-rule logging options are still respected.");?></td>
254
		</tr>
255
		<tr>
256
			<td valign="top" class="vtable">Raw Logs</td>
257
			<td class="vtable"> <input name="rawfilter" type="checkbox" id="rawfilter" value="yes" <?php if ($pconfig['rawfilter']) echo "checked"; ?>>
258 f8ec8de4 Renato Botelho
			<strong><?=gettext("Show raw filter logs");?></strong><br>
259 e34a7abb jim-p
			<?=gettext("Hint: If this is checked, filter logs are shown as generated by the packet filter, without any formatting. This will reveal more detailed information, but it is more difficult to read.");?></td>
260
		</tr>
261
		<tr>
262
			<td width="22%" valign="top" class="vtable">Local Logging</td>
263
			<td width="78%" class="vtable"> <input name="disablelocallogging" type="checkbox" id="disablelocallogging" value="yes" <?php if ($pconfig['disablelocallogging']) echo "checked"; ?> onClick="enable_change(false)">
264
			<?php if ($g['platform'] == "pfSense"): ?>
265
			<strong><?=gettext("Disable writing log files to the local disk");?></strong></td>
266
			<?php else: ?>
267
			<strong><?=gettext("Disable writing log files to the local RAM disk");?></strong></td>
268
			<?php endif; ?>
269
		</tr>
270
		<tr>
271
			<td colspan="2" valign="top">&nbsp;</td>
272
		</tr>
273
		<tr>
274
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Remote Logging Options");?></td>
275
		</tr>
276
		<tr>
277
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable Remote Logging");?></td>
278
			<td width="78%" class="vtable"> <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
279
				<strong><?=gettext("Send log messages to remote syslog server");?></strong></td>
280
		</tr>
281
		<tr>
282
			<td width="22%" valign="top" class="vncell"><?=gettext("Remote Syslog Servers");?></td>
283
			<td width="78%" class="vtable">
284
				<table>
285
					<tr>
286
						<td><?=gettext("Server") . " 1";?></td>
287
						<td><input name="remoteserver" id="remoteserver" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver']);?>"></td>
288
					</tr>
289
					<tr>
290
						<td><?=gettext("Server") . " 2";?></td>
291
						<td><input name="remoteserver2" id="remoteserver2" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver2']);?>"></td>
292
					</tr>
293
					<tr>
294
						<td><?=gettext("Server") . " 3";?></td>
295
						<td><input name="remoteserver3" id="remoteserver3" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver3']);?>"></td>
296
					</tr>
297
					<tr>
298
						<td>&nbsp;</td>
299
						<td><?=gettext("IP addresses of remote syslog servers, or an IP:port.");?></td>
300
				</table>
301
			</td>
302
		</tr>
303
		<tr>
304
			<td width="22%" valign="top" class="vncell"><?=gettext("Remote Syslog Contents");?></td>
305
			<td width="78%" class="vtable">
306
				<input name="logall" id="logall" type="checkbox" value="yes" <?php if ($pconfig['logall']) echo "checked"; ?> onclick="check_everything();">
307
				<?=gettext("Everything");?><br/><br/>
308
				<input name="system" id="system" type="checkbox" value="yes" onclick="enable_change(false)" <?php if ($pconfig['system']) echo "checked"; ?>>
309
				<?=gettext("System events");?><br/>
310
				<input name="filter" id="filter" type="checkbox" value="yes" <?php if ($pconfig['filter']) echo "checked"; ?>>
311
				<?=gettext("Firewall events");?><br/>
312
				<input name="dhcp" id="dhcp" type="checkbox" value="yes" <?php if ($pconfig['dhcp']) echo "checked"; ?>>
313
				<?=gettext("DHCP service events");?><br/>
314
				<input name="portalauth" id="portalauth" type="checkbox" value="yes" <?php if ($pconfig['portalauth']) echo "checked"; ?>>
315
				<?=gettext("Portal Auth events");?><br/>
316
				<input name="vpn" id="vpn" type="checkbox" value="yes" <?php if ($pconfig['vpn']) echo "checked"; ?>>
317
				<?=gettext("VPN (PPTP, IPsec, OpenVPN) events");?><br/>
318
				<input name="apinger" id="apinger" type="checkbox" value="yes" <?php if ($pconfig['apinger']) echo "checked"; ?>>
319
				<?=gettext("Gateway Monitor events");?><br/>
320
				<input name="relayd" id="relayd" type="checkbox" value="yes" <?php if ($pconfig['relayd']) echo "checked"; ?>>
321
				<?=gettext("Server Load Balancer events");?><br/>
322
				<input name="hostapd" id="hostapd" type="checkbox" value="yes" <?php if ($pconfig['hostapd']) echo "checked"; ?>>
323
				<?=gettext("Wireless events");?><br/>
324
			</td>
325
		</tr>
326
		<tr>
327
			<td width="22%" valign="top">&nbsp;</td>
328
			<td width="78%"> <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)">
329
			</td>
330
		</tr>
331
		<tr>
332
			<td width="22%" height="53" valign="top">&nbsp;</td>
333
			<td width="78%"><strong><span class="red"><?=gettext("Note:")?></span></strong><br>
334
			<?=gettext("syslog sends UDP datagrams to port 514 on the specified " .
335
			"remote syslog server, unless another port is specified. Be sure to set syslogd on the " .
336
			"remote server to accept syslog messages from");?> <?=$g['product_name']?>.
337
			</td>
338
		</tr>
339
	</table>
340 0f10aee4 Bill Marquette
	</div>
341 e34a7abb jim-p
</td></tr>
342 5b237745 Scott Ullrich
</table>
343
</form>
344
<script language="JavaScript">
345
<!--
346
enable_change(false);
347 236524c2 jim-p
check_everything();
348 5b237745 Scott Ullrich
//-->
349
</script>
350
<?php include("fend.inc"); ?>
351
</body>
352
</html>