Project

General

Profile

Download (14.7 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php 
3
/*
4
	system_advanced.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['filteringbridge_enable'] = isset($config['bridge']['filteringbridge']);
35
$pconfig['ipv6nat_enable'] = isset($config['diag']['ipv6nat']['enable']);
36
$pconfig['ipv6nat_ipaddr'] = $config['diag']['ipv6nat']['ipaddr'];
37
$pconfig['cert'] = base64_decode($config['system']['webgui']['certificate']);
38
$pconfig['key'] = base64_decode($config['system']['webgui']['private-key']);
39
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
40
$pconfig['disablefirmwarecheck'] = isset($config['system']['disablefirmwarecheck']);
41
$pconfig['expanddiags'] = isset($config['system']['webgui']['expanddiags']);
42
if ($g['platform'] == "generic-pc")
43
	$pconfig['harddiskstandby'] = $config['system']['harddiskstandby'];
44
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
45
$pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout'];
46

    
47
if ($_POST) {
48

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

    
52
	/* input validation */
53
	if ($_POST['ipv6nat_enable'] && !is_ipaddr($_POST['ipv6nat_ipaddr'])) {
54
		$input_errors[] = "You must specify an IP address to NAT IPv6 packets.";
55
	}
56
	if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) {
57
		$input_errors[] = "The TCP idle timeout must be an integer.";
58
	}
59
	if (($_POST['cert'] && !$_POST['key']) || ($_POST['key'] && !$_POST['cert'])) {
60
		$input_errors[] = "Certificate and key must always be specified together.";
61
	} else if ($_POST['cert'] && $_POST['key']) {
62
		if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
63
			$input_errors[] = "This certificate does not appear to be valid.";
64
		if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
65
			$input_errors[] = "This key does not appear to be valid.";
66
	}
67

    
68
	if (!$input_errors) {
69
		$config['bridge']['filteringbridge'] = $_POST['filteringbridge_enable'] ? true : false;
70
		$config['diag']['ipv6nat']['enable'] = $_POST['ipv6nat_enable'] ? true : false;
71
		$config['diag']['ipv6nat']['ipaddr'] = $_POST['ipv6nat_ipaddr'];
72
		$oldcert = $config['system']['webgui']['certificate'];
73
		$oldkey = $config['system']['webgui']['private-key'];
74
		$config['system']['webgui']['certificate'] = base64_encode($_POST['cert']);
75
		$config['system']['webgui']['private-key'] = base64_encode($_POST['key']);
76
		$config['system']['disableconsolemenu'] = $_POST['disableconsolemenu'] ? true : false;
77
		$config['system']['disablefirmwarecheck'] = $_POST['disablefirmwarecheck'] ? true : false;
78
		$config['system']['webgui']['expanddiags'] = $_POST['expanddiags'] ? true : false;
79
		if ($g['platform'] == "generic-pc") {
80
			$oldharddiskstandby = $config['system']['harddiskstandby'];
81
			$config['system']['harddiskstandby'] = $_POST['harddiskstandby'];
82
		}
83
		$config['system']['webgui']['noantilockout'] = $_POST['noantilockout'] ? true : false;
84
		$config['filter']['tcpidletimeout'] = $_POST['tcpidletimeout'];
85
			
86
		write_config();
87
		
88
		if (($config['system']['webgui']['certificate'] != $oldcert)
89
				|| ($config['system']['webgui']['private-key'] != $oldkey)) {
90
			touch($d_sysrebootreqd_path);
91
		} else if (($g['platform'] == "generic-pc") && ($config['system']['harddiskstandby'] != $oldharddiskstandby)) {
92
			if (!$config['system']['harddiskstandby']) {
93
				// Reboot needed to deactivate standby due to a stupid ATA-protocol
94
				touch($d_sysrebootreqd_path);
95
				unset($config['system']['harddiskstandby']);
96
			} else {
97
				// No need to set the standby-time if a reboot is needed anyway
98
				system_set_harddisk_standby();
99
			}
100
		}
101
		
102
		$retval = 0;
103
		if (!file_exists($d_sysrebootreqd_path)) {
104
			config_lock();
105
			$retval = filter_configure();
106
			$retval |= interfaces_optional_configure();
107
			config_unlock();
108
		}
109
		$savemsg = get_std_save_message($retval);
110
	}
111
}
112
?>
113
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
114
<html>
115
<head>
116
<title><?=gentitle("System: Advanced functions");?></title>
117
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
118
<link href="gui.css" rel="stylesheet" type="text/css">
119
<script language="JavaScript">
120
<!--
121
function enable_change(enable_over) {
122
	if (document.iform.ipv6nat_enable.checked || enable_over) {
123
		document.iform.ipv6nat_ipaddr.disabled = 0;
124
	} else {
125
		document.iform.ipv6nat_ipaddr.disabled = 1;
126
	}
127
}
128
// -->
129
</script>
130
</head>
131

    
132
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
133
<?php include("fbegin.inc"); ?>
134
      <p class="pgtitle">System: Advanced functions</p>
135
            <?php if ($input_errors) print_input_errors($input_errors); ?>
136
            <?php if ($savemsg) print_info_box($savemsg); ?>
137
            <p><span class="vexpl"><span class="red"><strong>Note: </strong></span>the 
138
              options on this page are intended for use by advanced users only, 
139
              and there's <strong>NO</strong> support for them.</span></p>
140
            <form action="system_advanced.php" method="post" name="iform" id="iform">
141
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
142
                <tr> 
143
                  <td colspan="2" valign="top" class="listtopic">IPv6 tunneling</td>
144
                </tr>
145
                <tr> 
146
                  <td width="22%" valign="top" class="vncell">&nbsp;</td>
147
                  <td width="78%" class="vtable"> 
148
                    <input name="ipv6nat_enable" type="checkbox" id="ipv6nat_enable" value="yes" <?php if ($pconfig['ipv6nat_enable']) echo "checked"; ?> onclick="enable_change(false)"> 
149
                    <strong>NAT encapsulated IPv6 packets (IP protocol 41/RFC2893) 
150
                    to:</strong><br> <br> <input name="ipv6nat_ipaddr" type="text" class="formfld" id="ipv6nat_ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipv6nat_ipaddr']);?>"> 
151
                    &nbsp;(IP address)<span class="vexpl"><br>
152
                    Don't forget to add a firewall rule to permit IPv6 packets!</span></td>
153
                </tr>
154
                <tr> 
155
                  <td width="22%" valign="top">&nbsp;</td>
156
                  <td width="78%"> 
157
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)"> 
158
                  </td>
159
                </tr>
160
                <tr> 
161
                  <td colspan="2" class="list" height="12"></td>
162
                </tr>
163
				<tr> 
164
                  <td colspan="2" valign="top" class="listtopic">Filtering bridge</td>
165
                </tr>
166
                <tr> 
167
                  <td width="22%" valign="top" class="vncell">&nbsp;</td>
168
                  <td width="78%" class="vtable"> 
169
                    <input name="filteringbridge_enable" type="checkbox" id="filteringbridge_enable" value="yes" <?php if ($pconfig['filteringbridge_enable']) echo "checked"; ?>>
170
                    <strong>Enable filtering bridge</strong><span class="vexpl"><br>
171
                    This will cause bridged packets to pass through the packet 
172
                    filter in the same way as routed packets do (by default bridged 
173
                    packets are always passed). If you enable this option, you'll 
174
                    have to add filter rules to selectively permit traffic from 
175
                    bridged interfaces.</span></td>
176
                </tr>
177
                <tr> 
178
                  <td width="22%" valign="top">&nbsp;</td>
179
                  <td width="78%"> 
180
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)"> 
181
                  </td>
182
                </tr>
183
                <tr> 
184
                  <td colspan="2" class="list" height="12"></td>
185
                </tr>
186
                <tr> 
187
                  <td colspan="2" valign="top" class="listtopic">webGUI SSL certificate/key</td>
188
                </tr>
189
                <tr> 
190
                  <td width="22%" valign="top" class="vncell">Certificate</td>
191
                  <td width="78%" class="vtable"> 
192
                    <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
193
                    <br> 
194
                    Paste a signed certificate in X.509 PEM format here.</td>
195
                </tr>
196
                <tr> 
197
                  <td width="22%" valign="top" class="vncell">Key</td>
198
                  <td width="78%" class="vtable"> 
199
                    <textarea name="key" cols="65" rows="7" id="key" class="formpre"><?=htmlspecialchars($pconfig['key']);?></textarea>
200
                    <br> 
201
                    Paste an RSA private key in PEM format here.</td>
202
                </tr>
203
                <tr> 
204
                  <td width="22%" valign="top">&nbsp;</td>
205
                  <td width="78%"> 
206
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)"> 
207
                  </td>
208
                </tr>
209
                <tr> 
210
                  <td colspan="2" class="list" height="12"></td>
211
                </tr>
212
                <tr> 
213
                  <td colspan="2" valign="top" class="listtopic">Miscellaneous</td>
214
                </tr>
215
				<tr> 
216
                  <td width="22%" valign="top" class="vncell">Console menu </td>
217
                  <td width="78%" class="vtable"> 
218
                    <input name="disableconsolemenu" type="checkbox" id="disableconsolemenu" value="yes" <?php if ($pconfig['disableconsolemenu']) echo "checked"; ?>>
219
                    <strong>Disable console menu</strong><span class="vexpl"><br>
220
                    Changes to this option will take effect after a reboot.</span></td>
221
                </tr>
222
				<tr>
223
                  <td valign="top" class="vncell">Firmware version check </td>
224
                  <td class="vtable">
225
                    <input name="disablefirmwarecheck" type="checkbox" id="disablefirmwarecheck" value="yes" <?php if ($pconfig['disablefirmwarecheck']) echo "checked"; ?>>
226
                    <strong>Disable firmware version check</strong><span class="vexpl"><br>
227
    This will cause m0n0wall not to check for newer firmware versions when the <a href="system_firmware.php">System: Firmware</a> page is viewed.</span></td>
228
			    </tr>
229
				<tr>
230
                  <td valign="top" class="vncell">TCP idle timeout </td>
231
                  <td class="vtable">                    <span class="vexpl">
232
                    <input name="tcpidletimeout" type="text" class="formfld" id="tcpidletimeout" size="8" value="<?=htmlspecialchars($pconfig['tcpidletimeout']);?>">
233
                    seconds<br>
234
    Idle TCP connections will be removed from the state table after no packets have been received for the specified number of seconds. Don't set this too high or your state table could become full of connections that have been improperly shut down. The default is 2.5 hours.</span></td>
235
			    </tr>
236
<?php if ($g['platform'] == "generic-pc"): ?>
237
				<tr> 
238
                  <td width="22%" valign="top" class="vncell">Hard disk standby time </td>
239
                  <td width="78%" class="vtable"> 
240
                    <select name="harddiskstandby" class="formfld">
241
					<?php
242
                        /* Values from ATA-2
243
                           http://www.t13.org/project/d0948r3-ATA-2.pdf
244
                           Page 66 */
245
						$sbvals = explode(" ", "0.5,6 1,12 2,24 3,36 4,48 5,60 7.5,90 10,120 15,180 20,240 30,241 60,242");
246
					?>
247
                      <option value="" <?php if(!$pconfig['harddiskstandby']) echo('selected');?>>Always on</option>
248
					<?php
249
					foreach ($sbvals as $sbval):
250
						list($min,$val) = explode(",", $sbval); ?>
251
                      <option value="<?=$val;?>" <?php if($pconfig['harddiskstandby'] == $val) echo('selected');?>><?=$min;?> minutes</option>
252
					<?php endforeach; ?>
253
                    </select>
254
                    <br>
255
                    Puts the hard disk into standby mode when the selected amount of time after the last
256
                    access has elapsed. <em>Do not set this for CF cards.</em></td>
257
				</tr>
258
<?php endif; ?>
259
				<tr> 
260
                  <td width="22%" valign="top" class="vncell">Navigation</td>
261
                  <td width="78%" class="vtable"> 
262
                    <input name="expanddiags" type="checkbox" id="expanddiags" value="yes" <?php if ($pconfig['expanddiags']) echo "checked"; ?>>
263
                    <strong>Keep diagnostics in navigation expanded </strong></td>
264
                </tr>
265
				<tr> 
266
                  <td width="22%" valign="top" class="vncell">webGUI anti-lockout</td>
267
                  <td width="78%" class="vtable"> 
268
                    <input name="noantilockout" type="checkbox" id="noantilockout" value="yes" <?php if ($pconfig['noantilockout']) echo "checked"; ?>>
269
                    <strong>Disable webGUI anti-lockout rule</strong><br>
270
					By default, access to the webGUI on the LAN interface is always permitted, regardless of the user-defined filter rule set. Enable this feature to control webGUI access (make sure to have a filter rule in place that allows you in, or you will lock yourself out!).<br>
271
					Hint: 
272
					the &quot;set LAN IP address&quot; option in the console menu  resets this setting as well.</td>
273
                </tr>
274
                <tr> 
275
                  <td width="22%" valign="top">&nbsp;</td>
276
                  <td width="78%"> 
277
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)"> 
278
                  </td>
279
                </tr>
280
              </table>
281
</form>
282
            <script language="JavaScript">
283
<!--
284
enable_change(false);
285
//-->
286
</script>
287
<?php include("fend.inc"); ?>
288
</body>
289
</html>
(72-72/86)