Project

General

Profile

Download (15.6 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['disablelocallogging'] = isset($config['syslog']['disablelocallogging']);
68

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

    
72
if ($_POST) {
73

    
74
	unset($input_errors);
75
	$pconfig = $_POST;
76

    
77
	/* input validation */
78
	if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) {
79
		$input_errors[] = gettext("A valid IP address must be specified for remote syslog server #1.");
80
	}
81
	if ($_POST['enable'] && $_POST['remoteserver2'] && !is_ipaddr($_POST['remoteserver2'])) {
82
		$input_errors[] = gettext("A valid IP address must be specified for remote syslog server #2.");
83
	}
84
	if ($_POST['enable'] && $_POST['remoteserver3'] && !is_ipaddr($_POST['remoteserver3'])) {
85
		$input_errors[] = gettext("A valid IP address must be specified for remote syslog server #3.");
86
	}
87
	if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) {
88
		$input_errors[] = gettext("A valid IP address must be specified.");
89
	}
90

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

    
95
	if (!$input_errors) {
96
		$config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
97
		$config['syslog']['nentries'] = (int)$_POST['nentries'];
98
		$config['syslog']['remoteserver'] = $_POST['remoteserver'];
99
		$config['syslog']['remoteserver2'] = $_POST['remoteserver2'];
100
		$config['syslog']['remoteserver3'] = $_POST['remoteserver3'];
101
		$config['syslog']['filter'] = $_POST['filter'] ? true : false;
102
		$config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
103
		$config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false;
104
		$config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
105
		$config['syslog']['apinger'] = $_POST['apinger'] ? true : false;
106
		$config['syslog']['relayd'] = $_POST['relayd'] ? true : false;
107
		$config['syslog']['hostapd'] = $_POST['hostapd'] ? true : false;
108
                $config['syslog']['logall'] = $_POST['logall'] ? true : false;
109
		$config['syslog']['system'] = $_POST['system'] ? true : false;
110
		$config['syslog']['disablelocallogging'] = $_POST['disablelocallogging'] ? true : false;
111
		$config['syslog']['enable'] = $_POST['enable'] ? true : false;
112
		$oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
113
		$config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
114
		$config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
115
		if($config['syslog']['enable'] == false) {
116
			unset($config['syslog']['remoteserver']);
117
			unset($config['syslog']['remoteserver2']);
118
			unset($config['syslog']['remoteserver3']);
119
		}
120

    
121
		write_config();
122

    
123
		$retval = 0;
124
		$retval = system_syslogd_start();
125
		if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
126
			$retval |= filter_configure();
127

    
128
		$savemsg = get_std_save_message($retval);
129
	}
130
}
131

    
132
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("Settings"));
133
include("head.inc");
134

    
135
?>
136

    
137

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

    
201
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
202
<?php include("fbegin.inc"); ?>
203
<form action="diag_logs_settings.php" method="post" name="iform" id="iform">
204
<?php if ($input_errors) print_input_errors($input_errors); ?>
205
<?php if ($savemsg) print_info_box($savemsg); ?>
206
<table width="100%" border="0" cellpadding="0" cellspacing="0">
207
  <tr><td>
208
<?php
209
	$tab_array = array();
210
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
211
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
212
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
213
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
214
	$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php");
215
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
216
	$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
217
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
218
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
219
	$tab_array[] = array(gettext("OpenNTPD"), false, "diag_logs_ntpd.php");
220
	$tab_array[] = array(gettext("Wireless"), false, "diag_logs_wireless.php");
221
	$tab_array[] = array(gettext("Settings"), true, "diag_logs_settings.php");
222
	display_top_tabs($tab_array);
223
?>
224
  </td></tr>
225
  <tr>
226
    <td>
227
	<div id="mainarea">
228
	  <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
229
                      <tr>
230
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
231
                        <td width="78%" class="vtable"> <input name="reverse" type="checkbox" id="reverse" value="yes" <?php if ($pconfig['reverse']) echo "checked"; ?>>
232
			<strong><?=gettext("Show log entries in reverse order (newest entries on top)");?></strong></td>
233
                      </tr>
234
                      <tr>
235
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
236
			<td width="78%" class="vtable"><?=gettext("Number of log entries to show:")?>
237
                          <input name="nentries" id="nentries" type="text" class="formfld unknown" size="4" value="<?=htmlspecialchars($pconfig['nentries']);?>"></td>
238
                      </tr>
239
                      <tr>
240
                        <td valign="top" class="vtable">&nbsp;</td>
241
                        <td class="vtable"> <input name="logdefaultblock" type="checkbox" id="logdefaultblock" value="yes" <?php if ($pconfig['logdefaultblock']) echo "checked"; ?>>
242
			<strong><?=gettext("Log packets blocked by the default rule");?></strong><br>
243
			  <?=gettext("Hint: packets that are blocked by the " .
244
                          "implicit default block rule will not be logged anymore " .
245
			  "if you uncheck this option. Per-rule logging options are not affected.");?></td>
246
                      </tr>
247
                      <tr>
248
                        <td valign="top" class="vtable">&nbsp;</td>
249
                        <td class="vtable"> <input name="rawfilter" type="checkbox" id="rawfilter" value="yes" <?php if ($pconfig['rawfilter']) echo "checked"; ?>>
250
			<strong><?=gettext("Show raw filter logs");?></strong><br>
251
			  <?=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.");?></td>
252
                      </tr>
253
                      <tr>
254
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
255
                        <td width="78%" class="vtable"> <input name="disablelocallogging" type="checkbox" id="disablelocallogging" value="yes" <?php if ($pconfig['disablelocallogging']) echo "checked"; ?> onClick="enable_change(false)">
256
			  <strong><?=gettext("Disable writing log files to the local RAM disk");?></strong></td>
257
                       </tr>
258
                      <tr>
259
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
260
                        <td width="78%" class="vtable"> <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
261
			  <strong><?=gettext("Enable syslog'ing to remote syslog server");?></strong></td>
262
                      </tr>
263
                      <tr>
264
			<td width="22%" valign="top" class="vncell"><?=gettext("Remote syslog servers");?></td>
265
                        <td width="78%" class="vtable"> 
266
							<table>
267
								<tr>
268
									<td>
269
										<?=gettext("Server") . " 1";?>
270
									</td>
271
									<td>
272
										<input name="remoteserver" id="remoteserver" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver']);?>">
273
									</td>
274
								</tr>
275
								<tr>
276
									<td>
277
										<?=gettext("Server") . " 2";?>
278
									</td>
279
									<td>
280
										<input name="remoteserver2" id="remoteserver2" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver2']);?>">
281
									</td>
282
								</tr>
283
								<tr>
284
									<td>
285
										<?=gettext("Server") . " 3";?>
286
									</td>
287
									<td>
288
										<input name="remoteserver3" id="remoteserver3" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver3']);?>">
289
									</td>
290
								</tr>
291
								<tr>
292
									<td>
293
										&nbsp;
294
									</td>
295
									<td>
296
										<?=gettext("IP addresses of remote syslog servers");?>
297
									</td>
298
							</table>
299
					 	  <input name="system" id="system" type="checkbox" value="yes" onclick="enable_change(false)" <?php if ($pconfig['system']) echo "checked"; ?>>
300
						  <?=gettext("System events");?><br>
301
						  <input name="filter" id="filter" type="checkbox" value="yes" <?php if ($pconfig['filter']) echo "checked"; ?>>
302
						  <?=gettext("Firewall events");?><br>
303
						  <input name="dhcp" id="dhcp" type="checkbox" value="yes" <?php if ($pconfig['dhcp']) echo "checked"; ?>>
304
						  <?=gettext("DHCP service events");?><br>
305
						  <input name="portalauth" id="portalauth" type="checkbox" value="yes" <?php if ($pconfig['portalauth']) echo "checked"; ?>>
306
						  <?=gettext("Portal Auth events");?><br>
307
						  <input name="vpn" id="vpn" type="checkbox" value="yes" <?php if ($pconfig['vpn']) echo "checked"; ?>>
308
						  <?=gettext("VPN (PPTP, IPsec, OpenVPN) events");?><br>
309
						  <input name="apinger" id="apinger" type="checkbox" value="yes" <?php if ($pconfig['apinger']) echo "checked"; ?>>
310
						  <?=gettext("Gateway Monitor events");?><br>
311
						  <input name="relayd" id="relayd" type="checkbox" value="yes" <?php if ($pconfig['relayd']) echo "checked"; ?>>
312
						  <?=gettext("Server Load Balancer events");?><br>
313
						  <input name="hostapd" id="hostapd" type="checkbox" value="yes" <?php if ($pconfig['hostapd']) echo "checked"; ?>>
314
						  <?=gettext("Wireless events");?><br>
315
                          <br> <input name="logall" id="logall" type="checkbox" value="yes" <?php if ($pconfig['logall']) echo "checked"; ?> onclick="check_everything();">
316
						  <?=gettext("Everything");?>
317
                        </td>
318
                      </tr>
319
                      <tr>
320
                        <td width="22%" valign="top">&nbsp;</td>
321
                        <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)">
322
                        </td>
323
                      </tr>
324
                      <tr>
325
                        <td width="22%" height="53" valign="top">&nbsp;</td>
326
						<td width="78%"><strong><span class="red"><?=gettext("Note:")?></span></strong><br>
327
                          <?=gettext("syslog sends UDP datagrams to port 514 on the specified " .
328
                          "remote syslog server. Be sure to set syslogd on the " .
329
						  "remote server to accept syslog messages from");?> <?=$g['product_name']?>.
330
                        </td>
331
                      </tr>
332
                    </table>
333
	</div>
334
    </td>
335
  </tr>
336
</table>
337
</form>
338
<script language="JavaScript">
339
<!--
340
enable_change(false);
341
check_everything();
342
//-->
343
</script>
344
<?php include("fend.inc"); ?>
345
</body>
346
</html>
(29-29/238)