Project

General

Profile

Download (16.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	diag_logs_settings.php
5
	Copyright (C) 2004-2009 Scott Ullrich
6
	All rights reserved.
7

    
8
	originially part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	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

    
22
	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
/*
35
	pfSense_MODULE:	system
36
*/
37

    
38
##|+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
require("guiconfig.inc");
46
require_once("functions.inc");
47
require_once("filter.inc");
48
require_once("shaper.inc");
49

    
50
$pconfig['reverse'] = isset($config['syslog']['reverse']);
51
$pconfig['nentries'] = $config['syslog']['nentries'];
52
$pconfig['remoteserver'] = $config['syslog']['remoteserver'];
53
$pconfig['remoteserver2'] = $config['syslog']['remoteserver2'];
54
$pconfig['remoteserver3'] = $config['syslog']['remoteserver3'];
55
$pconfig['filter'] = isset($config['syslog']['filter']);
56
$pconfig['dhcp'] = isset($config['syslog']['dhcp']);
57
$pconfig['portalauth'] = isset($config['syslog']['portalauth']);
58
$pconfig['vpn'] = isset($config['syslog']['vpn']);
59
$pconfig['apinger'] = isset($config['syslog']['apinger']);
60
$pconfig['relayd'] = isset($config['syslog']['relayd']);
61
$pconfig['hostapd'] = isset($config['syslog']['hostapd']);
62
$pconfig['logall'] = isset($config['syslog']['logall']);
63
$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
$pconfig['filterdescriptions'] = $config['syslog']['filterdescriptions'];
68
$pconfig['disablelocallogging'] = isset($config['syslog']['disablelocallogging']);
69

    
70
if (!$pconfig['nentries'])
71
	$pconfig['nentries'] = 50;
72

    
73
function is_valid_syslog_server($target) {
74
	return (is_ipaddr($target)
75
		|| is_ipaddrwithport($target)
76
		|| is_hostname($target)
77
		|| is_hostnamewithport($target));
78
}
79

    
80
if ($_POST) {
81

    
82
	unset($input_errors);
83
	$pconfig = $_POST;
84

    
85
	/* input validation */
86
	if ($_POST['enable'] && !is_valid_syslog_server($_POST['remoteserver'])) {
87
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #1.");
88
	}
89
	if ($_POST['enable'] && $_POST['remoteserver2'] && !is_valid_syslog_server($_POST['remoteserver2'])) {
90
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #2.");
91
	}
92
	if ($_POST['enable'] && $_POST['remoteserver3'] && !is_valid_syslog_server($_POST['remoteserver3'])) {
93
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #3.");
94
	}
95

    
96
	if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 2000)) {
97
		$input_errors[] = gettext("Number of log entries to show must be between 5 and 2000.");
98
	}
99

    
100
	if (!$input_errors) {
101
		$config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
102
		$config['syslog']['nentries'] = (int)$_POST['nentries'];
103
		$config['syslog']['remoteserver'] = $_POST['remoteserver'];
104
		$config['syslog']['remoteserver2'] = $_POST['remoteserver2'];
105
		$config['syslog']['remoteserver3'] = $_POST['remoteserver3'];
106
		$config['syslog']['filter'] = $_POST['filter'] ? true : false;
107
		$config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
108
		$config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false;
109
		$config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
110
		$config['syslog']['apinger'] = $_POST['apinger'] ? true : false;
111
		$config['syslog']['relayd'] = $_POST['relayd'] ? true : false;
112
		$config['syslog']['hostapd'] = $_POST['hostapd'] ? true : false;
113
		$config['syslog']['logall'] = $_POST['logall'] ? true : false;
114
		$config['syslog']['system'] = $_POST['system'] ? true : false;
115
		$config['syslog']['disablelocallogging'] = $_POST['disablelocallogging'] ? true : false;
116
		$config['syslog']['enable'] = $_POST['enable'] ? true : false;
117
		$oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
118
		$config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
119
		$config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
120
		if (is_numeric($_POST['filterdescriptions']) && $_POST['filterdescriptions'] > 0)
121
			$config['syslog']['filterdescriptions'] = $_POST['filterdescriptions'];
122
		else
123
			unset($config['syslog']['filterdescriptions']);
124
		if($config['syslog']['enable'] == false) {
125
			unset($config['syslog']['remoteserver']);
126
			unset($config['syslog']['remoteserver2']);
127
			unset($config['syslog']['remoteserver3']);
128
		}
129

    
130
		write_config();
131

    
132
		$retval = 0;
133
		$retval = system_syslogd_start();
134
		if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
135
			$retval |= filter_configure();
136

    
137
		filter_pflog_start(true);
138

    
139
		$savemsg = get_std_save_message($retval);
140
	}
141
}
142

    
143
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("Settings"));
144
include("head.inc");
145

    
146
?>
147

    
148

    
149
<script language="JavaScript">
150
<!--
151
function enable_change(enable_over) {
152
	if (document.iform.enable.checked || enable_over) {
153
		document.iform.remoteserver.disabled = 0;
154
		document.iform.remoteserver2.disabled = 0;
155
		document.iform.remoteserver3.disabled = 0;
156
		document.iform.filter.disabled = 0;
157
		document.iform.dhcp.disabled = 0;
158
		document.iform.portalauth.disabled = 0;
159
		document.iform.vpn.disabled = 0;
160
		document.iform.apinger.disabled = 0;
161
		document.iform.relayd.disabled = 0;
162
		document.iform.hostapd.disabled = 0;
163
		document.iform.system.disabled = 0;
164
		document.iform.logall.disabled = 0;
165
		check_everything();
166
	} else {
167
		document.iform.remoteserver.disabled = 1;
168
		document.iform.remoteserver2.disabled = 1;
169
		document.iform.remoteserver3.disabled = 1;
170
		document.iform.filter.disabled = 1;
171
		document.iform.dhcp.disabled = 1;
172
		document.iform.portalauth.disabled = 1;
173
		document.iform.vpn.disabled = 1;
174
		document.iform.apinger.disabled = 1;
175
		document.iform.relayd.disabled = 1;
176
		document.iform.hostapd.disabled = 1;
177
		document.iform.system.disabled = 1;
178
		document.iform.logall.disabled = 1;
179
	}
180
}
181
function check_everything() {
182
	if (document.iform.logall.checked) {
183
		document.iform.filter.disabled = 1;
184
		document.iform.filter.checked = false;
185
		document.iform.dhcp.disabled = 1;
186
		document.iform.dhcp.checked = false;
187
		document.iform.portalauth.disabled = 1;
188
		document.iform.portalauth.checked = false;
189
		document.iform.vpn.disabled = 1;
190
		document.iform.vpn.checked = false;
191
		document.iform.apinger.disabled = 1;
192
		document.iform.apinger.checked = false;
193
		document.iform.relayd.disabled = 1;
194
		document.iform.relayd.checked = false;
195
		document.iform.hostapd.disabled = 1;
196
		document.iform.hostapd.checked = false;
197
		document.iform.system.disabled = 1;
198
		document.iform.system.checked = false;
199
	} else {
200
		document.iform.filter.disabled = 0;
201
		document.iform.dhcp.disabled = 0;
202
		document.iform.portalauth.disabled = 0;
203
		document.iform.vpn.disabled = 0;
204
		document.iform.apinger.disabled = 0;
205
		document.iform.relayd.disabled = 0;
206
		document.iform.hostapd.disabled = 0;
207
		document.iform.system.disabled = 0;
208
	}
209
}
210
// -->
211
</script>
212

    
213
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
214
<?php include("fbegin.inc"); ?>
215
<form action="diag_logs_settings.php" method="post" name="iform" id="iform">
216
<?php if ($input_errors) print_input_errors($input_errors); ?>
217
<?php if ($savemsg) print_info_box($savemsg); ?>
218
<table width="100%" border="0" cellpadding="0" cellspacing="0">
219
<tr><td>
220
<?php
221
	$tab_array = array();
222
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
223
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
224
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
225
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
226
	$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php");
227
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
228
	$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
229
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
230
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
231
	$tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php");
232
	$tab_array[] = array(gettext("Settings"), true, "diag_logs_settings.php");
233
	display_top_tabs($tab_array);
234
?>
235
</td></tr>
236
<tr>
237
	<td>
238
	<div id="mainarea">
239
	<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
240
		<tr>
241
			<td colspan="2" valign="top" class="listtopic"><?=gettext("General Logging Options");?></td>
242
		</tr>
243
		<tr>
244
			<td width="22%" valign="top" class="vtable">Forward/Reverse Display</td>
245
			<td width="78%" class="vtable"> <input name="reverse" type="checkbox" id="reverse" value="yes" <?php if ($pconfig['reverse']) echo "checked"; ?>>
246
			<strong><?=gettext("Show log entries in reverse order (newest entries on top)");?></strong></td>
247
		</tr>
248
		<tr>
249
			<td width="22%" valign="top" class="vtable">GUI Log Entries to Display</td>
250
			<td width="78%" class="vtable">
251
			<input name="nentries" id="nentries" type="text" class="formfld unknown" size="4" value="<?=htmlspecialchars($pconfig['nentries']);?>"><br/>
252
			<?=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>
253
		</tr>
254
		<tr>
255
			<td valign="top" class="vtable">Log Firewall Default Blocks</td>
256
			<td class="vtable"> <input name="logdefaultblock" type="checkbox" id="logdefaultblock" value="yes" <?php if ($pconfig['logdefaultblock']) echo "checked"; ?>>
257
			<strong><?=gettext("Log packets blocked by the default rule");?></strong><br>
258
				<?=gettext("Hint: packets that are blocked by the " .
259
				"implicit default block rule will not be logged " .
260
				"if you uncheck this option. Per-rule logging options are still respected.");?></td>
261
		</tr>
262
		<tr>
263
			<td valign="top" class="vtable">Raw Logs</td>
264
			<td class="vtable"> <input name="rawfilter" type="checkbox" id="rawfilter" value="yes" <?php if ($pconfig['rawfilter']) echo "checked"; ?>>
265
			<strong><?=gettext("Show raw filter logs");?></strong><br>
266
			<?=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>
267
		</tr>
268
		<tr>
269
			<td valign="top" class="vtable">Filter descriptions</td>
270
			<td class="vtable">
271
				<select name="filterdescriptions" id="filterdescriptions" >
272
				  <option value="0"<?=!isset($pconfig['filterdescriptions'])?" selected":""?>>Dont load descriptions</option>
273
				  <option value="1"<?=($pconfig['filterdescriptions'])==="1"?" selected":""?>>Display as column</option>
274
				  <option value="2"<?=($pconfig['filterdescriptions'])==="2"?" selected":""?>>Display as second row</option>
275
				</select>
276
				<strong><?=gettext("Show the applied rule description below or in the firewall log rows.");?></strong>
277
				<br/>
278
				<?=gettext("Displaying rule descriptions for all lines in the log might affect performance with large rulessets.");?></td>
279
			</td>
280
		</tr>
281
		<tr>
282
			<td width="22%" valign="top" class="vtable">Local Logging</td>
283
			<td width="78%" class="vtable"> <input name="disablelocallogging" type="checkbox" id="disablelocallogging" value="yes" <?php if ($pconfig['disablelocallogging']) echo "checked"; ?> onClick="enable_change(false)">
284
			<?php if ($g['platform'] == "pfSense"): ?>
285
			<strong><?=gettext("Disable writing log files to the local disk");?></strong></td>
286
			<?php else: ?>
287
			<strong><?=gettext("Disable writing log files to the local RAM disk");?></strong></td>
288
			<?php endif; ?>
289
		</tr>
290
		<tr>
291
			<td colspan="2" valign="top">&nbsp;</td>
292
		</tr>
293
		<tr>
294
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Remote Logging Options");?></td>
295
		</tr>
296
		<tr>
297
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable Remote Logging");?></td>
298
			<td width="78%" class="vtable"> <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
299
				<strong><?=gettext("Send log messages to remote syslog server");?></strong></td>
300
		</tr>
301
		<tr>
302
			<td width="22%" valign="top" class="vncell"><?=gettext("Remote Syslog Servers");?></td>
303
			<td width="78%" class="vtable">
304
				<table>
305
					<tr>
306
						<td><?=gettext("Server") . " 1";?></td>
307
						<td><input name="remoteserver" id="remoteserver" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver']);?>"></td>
308
					</tr>
309
					<tr>
310
						<td><?=gettext("Server") . " 2";?></td>
311
						<td><input name="remoteserver2" id="remoteserver2" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver2']);?>"></td>
312
					</tr>
313
					<tr>
314
						<td><?=gettext("Server") . " 3";?></td>
315
						<td><input name="remoteserver3" id="remoteserver3" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver3']);?>"></td>
316
					</tr>
317
					<tr>
318
						<td>&nbsp;</td>
319
						<td><?=gettext("IP addresses of remote syslog servers, or an IP:port.");?></td>
320
				</table>
321
			</td>
322
		</tr>
323
		<tr>
324
			<td width="22%" valign="top" class="vncell"><?=gettext("Remote Syslog Contents");?></td>
325
			<td width="78%" class="vtable">
326
				<input name="logall" id="logall" type="checkbox" value="yes" <?php if ($pconfig['logall']) echo "checked"; ?> onclick="check_everything();">
327
				<?=gettext("Everything");?><br/><br/>
328
				<input name="system" id="system" type="checkbox" value="yes" onclick="enable_change(false)" <?php if ($pconfig['system']) echo "checked"; ?>>
329
				<?=gettext("System events");?><br/>
330
				<input name="filter" id="filter" type="checkbox" value="yes" <?php if ($pconfig['filter']) echo "checked"; ?>>
331
				<?=gettext("Firewall events");?><br/>
332
				<input name="dhcp" id="dhcp" type="checkbox" value="yes" <?php if ($pconfig['dhcp']) echo "checked"; ?>>
333
				<?=gettext("DHCP service events");?><br/>
334
				<input name="portalauth" id="portalauth" type="checkbox" value="yes" <?php if ($pconfig['portalauth']) echo "checked"; ?>>
335
				<?=gettext("Portal Auth events");?><br/>
336
				<input name="vpn" id="vpn" type="checkbox" value="yes" <?php if ($pconfig['vpn']) echo "checked"; ?>>
337
				<?=gettext("VPN (PPTP, IPsec, OpenVPN) events");?><br/>
338
				<input name="apinger" id="apinger" type="checkbox" value="yes" <?php if ($pconfig['apinger']) echo "checked"; ?>>
339
				<?=gettext("Gateway Monitor events");?><br/>
340
				<input name="relayd" id="relayd" type="checkbox" value="yes" <?php if ($pconfig['relayd']) echo "checked"; ?>>
341
				<?=gettext("Server Load Balancer events");?><br/>
342
				<input name="hostapd" id="hostapd" type="checkbox" value="yes" <?php if ($pconfig['hostapd']) echo "checked"; ?>>
343
				<?=gettext("Wireless events");?><br/>
344
			</td>
345
		</tr>
346
		<tr>
347
			<td width="22%" valign="top">&nbsp;</td>
348
			<td width="78%"> <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)">
349
			</td>
350
		</tr>
351
		<tr>
352
			<td width="22%" height="53" valign="top">&nbsp;</td>
353
			<td width="78%"><strong><span class="red"><?=gettext("Note:")?></span></strong><br>
354
			<?=gettext("syslog sends UDP datagrams to port 514 on the specified " .
355
			"remote syslog server, unless another port is specified. Be sure to set syslogd on the " .
356
			"remote server to accept syslog messages from");?> <?=$g['product_name']?>.
357
			</td>
358
		</tr>
359
	</table>
360
	</div>
361
</td></tr>
362
</table>
363
</form>
364
<script language="JavaScript">
365
<!--
366
enable_change(false);
367
//-->
368
</script>
369
<?php include("fend.inc"); ?>
370
</body>
371
</html>
(32-32/249)