Project

General

Profile

Download (9.49 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php 
3
/*
4
	diag_logs_settings.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6
	
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9
	
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
	
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
	
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
	
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
require("guiconfig.inc");
33

    
34
$pconfig['reverse'] = isset($config['syslog']['reverse']);
35
$pconfig['nentries'] = $config['syslog']['nentries'];
36
$pconfig['remoteserver'] = $config['syslog']['remoteserver'];
37
$pconfig['filter'] = isset($config['syslog']['filter']);
38
$pconfig['dhcp'] = isset($config['syslog']['dhcp']);
39
$pconfig['vpn'] = isset($config['syslog']['vpn']);
40
$pconfig['system'] = isset($config['syslog']['system']);
41
$pconfig['enable'] = isset($config['syslog']['enable']);
42
$pconfig['logdefaultblock'] = !isset($config['syslog']['nologdefaultblock']);
43
$pconfig['rawfilter'] = isset($config['syslog']['rawfilter']);
44

    
45
if (!$pconfig['nentries'])
46
	$pconfig['nentries'] = 50;
47

    
48
if ($_POST) {
49

    
50
	unset($input_errors);
51
	$pconfig = $_POST;
52

    
53
	/* input validation */
54
	if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) {
55
		$input_errors[] = "A valid IP address must be specified.";
56
	}
57
	if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 1000)) {
58
		$input_errors[] = "Number of log entries to show must be between 5 and 1000.";
59
	}
60

    
61
	if (!$input_errors) {
62
		$config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
63
		$config['syslog']['nentries'] = (int)$_POST['nentries'];
64
		$config['syslog']['remoteserver'] = $_POST['remoteserver'];
65
		$config['syslog']['filter'] = $_POST['filter'] ? true : false;
66
		$config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
67
		$config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
68
		$config['syslog']['system'] = $_POST['system'] ? true : false;
69
		$config['syslog']['enable'] = $_POST['enable'] ? true : false;
70
		$oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
71
		$config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
72
		$config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
73
		
74
		write_config();
75
		
76
		$retval = 0;
77
		if (!file_exists($d_sysrebootreqd_path)) {
78
			config_lock();
79
			$retval = system_syslogd_start();
80
			if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
81
				$retval |= filter_configure();
82
			config_unlock();
83
		}
84
		$savemsg = get_std_save_message($retval);	
85
	}
86
}
87

    
88
?>
89
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
90
<html>
91
<head>
92
<title><?=gentitle("Diagnostics: System logs");?></title>
93
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
94
<link href="gui.css" rel="stylesheet" type="text/css">
95
<script language="JavaScript">
96
<!--
97
function enable_change(enable_over) {
98
	if (document.iform.enable.checked || enable_over) {
99
		document.iform.remoteserver.disabled = 0;
100
		document.iform.filter.disabled = 0;
101
		document.iform.dhcp.disabled = 0;
102
		document.iform.vpn.disabled = 0;
103
		document.iform.system.disabled = 0;
104
	} else {
105
		document.iform.remoteserver.disabled = 1;
106
		document.iform.filter.disabled = 1;
107
		document.iform.dhcp.disabled = 1;
108
		document.iform.vpn.disabled = 1;
109
		document.iform.system.disabled = 1;
110
	}
111
}
112
// -->
113
</script>
114
</head>
115

    
116
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
117
<?php include("fbegin.inc"); ?>
118
<p class="pgtitle">Diagnostics: System logs</p>
119
<form action="diag_logs_settings.php" method="post" name="iform" id="iform">
120
<?php if ($input_errors) print_input_errors($input_errors); ?>
121
<?php if ($savemsg) print_info_box($savemsg); ?>
122
<table width="100%" border="0" cellpadding="0" cellspacing="0">
123
  <tr><td>
124
  <ul id="tabnav">
125
    <li class="tabinact"><a href="diag_logs.php">System</a></li>
126
    <li class="tabinact"><a href="diag_logs_filter.php">Firewall</a></li>
127
    <li class="tabinact"><a href="diag_logs_dhcp.php">DHCP</a></li>
128
    <li class="tabinact"><a href="diag_logs_vpn.php">PPTP VPN</a></li>
129
    <li class="tabact">Settings</li>
130
  </ul>
131
  </td></tr>
132
  <tr> 
133
    <td class="tabcont">
134
	  <table width="100%" border="0" cellpadding="6" cellspacing="0">
135
                      <tr> 
136
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
137
                        <td width="78%" class="vtable"> <input name="reverse" type="checkbox" id="reverse" value="yes" <?php if ($pconfig['reverse']) echo "checked"; ?>>
138
                          <strong>Show log entries in reverse order (newest entries 
139
                          on top)</strong></td>
140
                      </tr>
141
                      <tr> 
142
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
143
                        <td width="78%" class="vtable">Number of log entries to 
144
                          show: 
145
                          <input name="nentries" id="nentries" type="text" class="formfld" size="4" value="<?=htmlspecialchars($pconfig['nentries']);?>"></td>
146
                      </tr>
147
                      <tr> 
148
                        <td valign="top" class="vtable">&nbsp;</td>
149
                        <td class="vtable"> <input name="logdefaultblock" type="checkbox" id="logdefaultblock" value="yes" <?php if ($pconfig['logdefaultblock']) echo "checked"; ?>>
150
                          <strong>Log packets blocked by the default rule</strong><br>
151
                          Hint: packets that are blocked by the 
152
                          implicit default block rule will not be logged anymore 
153
                          if you uncheck this option. Per-rule logging options are not affected.</td>
154
                      </tr>
155
                      <tr> 
156
                        <td valign="top" class="vtable">&nbsp;</td>
157
                        <td class="vtable"> <input name="rawfilter" type="checkbox" id="rawfilter" value="yes" <?php if ($pconfig['rawfilter']) echo "checked"; ?>>
158
                          <strong>Show raw filter logs</strong><br>
159
                          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>
160
                      </tr>
161
                      <tr> 
162
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
163
                        <td width="78%" class="vtable"> <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
164
                          <strong>Enable syslog'ing to remote syslog server</strong></td>
165
                      </tr>
166
                      <tr> 
167
                        <td width="22%" valign="top" class="vncell">Remote syslog 
168
                          server</td>
169
                        <td width="78%" class="vtable"> <input name="remoteserver" id="remoteserver" type="text" class="formfld" size="20" value="<?=htmlspecialchars($pconfig['remoteserver']);?>"> 
170
                          <br>
171
                          IP address of remote syslog server<br> <br> <input name="system" id="system" type="checkbox" value="yes" onclick="enable_change(false)" <?php if ($pconfig['system']) echo "checked"; ?>>
172
                          system events <br> <input name="filter" id="filter" type="checkbox" value="yes" <?php if ($pconfig['filter']) echo "checked"; ?>>
173
                          firewall events<br> <input name="dhcp" id="dhcp" type="checkbox" value="yes" <?php if ($pconfig['dhcp']) echo "checked"; ?>>
174
                          DHCP service events<br> <input name="vpn" id="vpn" type="checkbox" value="yes" <?php if ($pconfig['vpn']) echo "checked"; ?>>
175
                          PPTP VPN events</td>
176
                      </tr>
177
                      <tr> 
178
                        <td width="22%" valign="top">&nbsp;</td>
179
                        <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)"> 
180
                        </td>
181
                      </tr>
182
                      <tr> 
183
                        <td width="22%" height="53" valign="top">&nbsp;</td>
184
                        <td width="78%"><strong><span class="red">Note:</span></strong><br>
185
                          syslog sends UDP datagrams to port 514 on the specified 
186
                          remote syslog server. Be sure to set syslogd on the 
187
                          remote server to accept syslog messages from m0n0wall. 
188
                        </td>
189
                      </tr>
190
                    </table>
191
    </td>
192
  </tr>
193
</table>
194
</form>
195
<script language="JavaScript">
196
<!--
197
enable_change(false);
198
//-->
199
</script>
200
<?php include("fend.inc"); ?>
201
</body>
202
</html>
(9-9/86)