Project

General

Profile

Download (14 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system.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
##|+PRIV
33
##|*IDENT=page-system-generalsetup
34
##|*NAME=System: General Setup page
35
##|*DESCR=Allow access to the 'System: General Setup' page.
36
##|*MATCH=system.php*
37
##|-PRIV
38

    
39

    
40
require("guiconfig.inc");
41

    
42
$pconfig['hostname'] = $config['system']['hostname'];
43
$pconfig['domain'] = $config['system']['domain'];
44
list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $config['system']['dnsserver'];
45

    
46
$pconfig['dns1gwint'] = $config['system']['dns1gwint'];
47
$pconfig['dns2gwint'] = $config['system']['dns2gwint'];
48
$pconfig['dns3gwint'] = $config['system']['dns3gwint'];
49
$pconfig['dns4gwint'] = $config['system']['dns4gwint'];
50

    
51
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
52
$pconfig['timezone'] = $config['system']['timezone'];
53
$pconfig['timeupdateinterval'] = $config['system']['time-update-interval'];
54
$pconfig['timeservers'] = $config['system']['timeservers'];
55
$pconfig['theme'] = $config['system']['theme'];
56

    
57
if (!isset($pconfig['timeupdateinterval']))
58
	$pconfig['timeupdateinterval'] = 300;
59
if (!$pconfig['timezone'])
60
	$pconfig['timezone'] = "Etc/UTC";
61
if (!$pconfig['timeservers'])
62
	$pconfig['timeservers'] = "pool.ntp.org";
63

    
64
$changedesc = "System: ";
65
$changecount = 0;
66

    
67
function is_timezone($elt) {
68
	return !preg_match("/\/$/", $elt);
69
}
70

    
71
if($pconfig['timezone'] <> $_POST['timezone']) {
72
	/* restart firewall log dumper helper */
73
	require_once("functions.inc");
74
	$pid = `ps awwwux | grep -v "grep" | grep "tcpdump -v -l -n -e -ttt -i pflog0"  | awk '{ print $2 }'`;
75
	if($pid) {
76
		mwexec("kill $pid");
77
		usleep(1000);
78
	}		
79
	filter_pflog_start();
80
}
81

    
82
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
83
$timezonelist = array_filter($timezonelist, 'is_timezone');
84
sort($timezonelist);
85

    
86
if ($_POST) {
87

    
88
	$changecount++;
89
	
90
	unset($input_errors);
91
	$pconfig = $_POST;
92

    
93
	/* input validation */
94
	$reqdfields = split(" ", "hostname domain");
95
	$reqdfieldsn = split(",", "Hostname,Domain");
96

    
97
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
98

    
99
	if ($_POST['hostname'] && !is_hostname($_POST['hostname'])) {
100
		$input_errors[] = "The hostname may only contain the characters a-z, 0-9 and '-'.";
101
	}
102
	if ($_POST['domain'] && !is_domain($_POST['domain'])) {
103
		$input_errors[] = "The domain may only contain the characters a-z, 0-9, '-' and '.'.";
104
	}
105
	if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) {
106
		$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS server.";
107
	}
108
	if (($_POST['dns3'] && !is_ipaddr($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddr($_POST['dns4']))) {
109
		$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS server.";
110
	}	
111
	if ($_POST['webguiport'] && (!is_numericint($_POST['webguiport']) ||
112
			($_POST['webguiport'] < 1) || ($_POST['webguiport'] > 65535))) {
113
		$input_errors[] = "A valid TCP/IP port must be specified for the webConfigurator port.";
114
	}
115

    
116
	$t = (int)$_POST['timeupdateinterval'];
117
	if (($t < 0) || (($t > 0) && ($t < 6)) || ($t > 1440)) {
118
		$input_errors[] = "The time update interval must be either 0 (disabled) or between 6 and 1440.";
119
	}
120
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
121
		if (!is_domain($ts)) {
122
			$input_errors[] = "A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.";
123
		}
124
	}
125

    
126
	if (!$input_errors) {
127
		update_if_changed("hostname", $config['system']['hostname'], strtolower($_POST['hostname']));
128
		update_if_changed("domain", $config['system']['domain'], strtolower($_POST['domain']));
129

    
130
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
131
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
132
		update_if_changed("NTP update interval", $config['system']['time-update-interval'], $_POST['timeupdateinterval']);
133

    
134
		/* pfSense themes */
135
		update_if_changed("System Theme", $config['theme'], $_POST['theme']);
136

    
137
		/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
138
		unset($config['system']['dnsserver']);
139
		if ($_POST['dns1'])
140
			$config['system']['dnsserver'][] = $_POST['dns1'];
141
		if ($_POST['dns2'])
142
			$config['system']['dnsserver'][] = $_POST['dns2'];
143
		if ($_POST['dns3'])
144
			$config['system']['dnsserver'][] = $_POST['dns3'];
145
		if ($_POST['dns4'])
146
			$config['system']['dnsserver'][] = $_POST['dns4'];
147

    
148
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
149

    
150
		unset($config['system']['dnsallowoverride']);
151
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
152

    
153
		/* which interface should the dns servers resolve through? */
154
		if($_POST['dns1gwint']) 
155
			$config['system']['dns1gwint'] = $pconfig['dns1gwint'];
156
		else 
157
			unset($config['system']['dns1gwint']);
158
		if($_POST['dns2gwint']) 
159
			$config['system']['dns2gwint'] = $pconfig['dns2gwint'];
160
		else
161
			unset($config['system']['dns2gwint']);
162
		if($_POST['dns3gwint']) 
163
			$config['system']['dns1gwint'] = $pconfig['dns3gwint'];
164
		else 
165
			unset($config['system']['dns3gwint']);
166
		if($_POST['dns4gwint']) 
167
			$config['system']['dns4gwint'] = $pconfig['dns4gwint'];
168
		else
169
			unset($config['system']['dns4gwint']);
170

    
171
		if ($changecount > 0)
172
			write_config($changedesc);
173

    
174
		$retval = 0;
175
		config_lock();
176
		$retval = system_hostname_configure();
177
		$retval |= system_hosts_generate();
178
		$retval |= system_resolvconf_generate();
179
		$retval |= services_dnsmasq_configure();
180
		$retval |= system_timezone_configure();
181
		$retval |= system_ntp_configure();
182

    
183
		/* XXX: ermal -- What is this supposed to do?! */
184
		if ($olddnsallowoverride != $config['system']['dnsallowoverride'])
185
			$retval |= interface_configure();
186

    
187
		config_unlock();
188

    
189
		$savemsg = get_std_save_message($retval);
190
	}
191
}
192

    
193
$pgtitle = array("System","General Setup");
194
include("head.inc");
195

    
196
?>
197

    
198
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
199
<?php include("fbegin.inc"); ?>
200
<?php if ($input_errors) print_input_errors($input_errors); ?>
201
<?php if ($savemsg) print_info_box($savemsg); ?>
202
<form action="system.php" method="post">
203
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
204
				<tr>
205
					<td colspan="2" valign="top" class="listtopic">System</td>
206
				</tr>
207
                <tr>
208
                  <td width="22%" valign="top" class="vncellreq">Hostname</td>
209
                  <td width="78%" class="vtable"> <input name="hostname" type="text" class="formfld unknown" id="hostname" size="40" value="<?=htmlspecialchars($pconfig['hostname']);?>">
210
                    <br> <span class="vexpl">name of the firewall host, without
211
                    domain part<br>
212
                    e.g. <em>firewall</em></span></td>
213
                </tr>
214
                <tr>
215
                  <td width="22%" valign="top" class="vncellreq">Domain</td>
216
                  <td width="78%" class="vtable"> <input name="domain" type="text" class="formfld unknown" id="domain" size="40" value="<?=htmlspecialchars($pconfig['domain']);?>">
217
                    <br> <span class="vexpl">e.g. <em>mycorp.com</em> </span></td>
218
                </tr>
219
                <tr>
220
                  <td width="22%" valign="top" class="vncell">DNS servers</td>
221
                  <td width="78%" class="vtable"> <p>
222
                  <table>
223
                  	  <tr><td><b>DNS Server</td>
224
                      <?php
225
                      	$multiwan = false;
226
                      	foreach($config['interfaces'] as $int) 
227
                      		if($int['gateway']) 
228
                      			$multiwan = true;
229
                      	$ints = get_interface_list();
230
                      	if($multiwan) 
231
                      		echo "<td><b>Use gateway</td>";
232
                      ?>
233
                      </tr>
234
<?php for($dnscounter=1; $dnscounter<5; $dnscounter++): ?>
235
                      <tr>
236
                      <td>
237
                      <input name="dns<?php echo $dnscounter;?>" type="text" class="formfld unknown" id="dns<?php echo $dnscounter;?>" size="20" value="<?php echo $pconfig['dns'.$dnscounter];?>">
238
                      </td>
239
                      <?php
240
                      	if($multiwan) {
241
                      		echo "<td><select name='dns{$dnscounter}gwint'>\n";
242
                      		echo "<option value=''>wan</option>";
243
                      		foreach($ints as $int) {
244
	                      		$friendly = $int['friendly'];
245
                      			if($config['interfaces'][$friendly]['gateway']) {
246
	                   				$selected = "";
247
	                   				if($pconfig['dns{$dnscounter}gwint'] == $int) 
248
	                   					$selected = " SELECTED";
249
	                   				echo "<option value='{$friendly}'{$selected}>{$friendly}</option>";
250
                      			}
251
                      		}
252
                      		echo "</select>";
253
                      	}
254
                      ?>
255
                      </td>
256
                      </tr>
257
<?php endfor; ?>
258
                      </table>
259
                      <br>
260
                      <span class="vexpl">IP addresses; these are also used for
261
                      the DHCP service, DNS forwarder and for PPTP VPN clients.
262
                      <br>
263
                      <?php
264
                      	if($multiwan) 
265
                      		echo "<br/>In addition, select the gateway for each DNS server.  You should have a unique DNS server per gateway.<br/>";
266
                      ?>
267
                      <br>
268
                      <input name="dnsallowoverride" type="checkbox" id="dnsallowoverride" value="yes" <?php if ($pconfig['dnsallowoverride']) echo "checked"; ?>>
269
                      <strong>Allow DNS server list to be overridden by DHCP/PPP
270
                      on WAN</strong><br>
271
                      If this option is set, <?php echo $g['product_name']; ?> will use DNS servers assigned
272
                      by a DHCP/PPP server on WAN for its own purposes (including
273
                      the DNS forwarder). They will not be assigned to DHCP and
274
                      PPTP VPN clients, though.</span></p></td>
275
                </tr>
276
                <tr>
277
                  <td width="22%" valign="top" class="vncell">Time zone</td>
278
                  <td width="78%" class="vtable"> <select name="timezone" id="timezone">
279
                      <?php foreach ($timezonelist as $value): ?>
280
                      <option value="<?=htmlspecialchars($value);?>" <?php if ($value == $pconfig['timezone']) echo "selected"; ?>>
281
                      <?=htmlspecialchars($value);?>
282
                      </option>
283
                      <?php endforeach; ?>
284
                    </select> <br> <span class="vexpl">Select the location closest
285
                    to you</span></td>
286
                </tr>
287
                <!--
288
                <tr>
289
                  <td width="22%" valign="top" class="vncell">Time update interval</td>
290
                  <td width="78%" class="vtable"> <input name="timeupdateinterval" type="text" class="formfld unknown" id="timeupdateinterval" size="4" value="<?=htmlspecialchars($pconfig['timeupdateinterval']);?>">
291
                    <br> <span class="vexpl">Minutes between network time sync.;
292
                    300 recommended, or 0 to disable </span></td>
293
                </tr>
294
                -->
295
                <tr>
296
                  <td width="22%" valign="top" class="vncell">NTP time server</td>
297
                  <td width="78%" class="vtable"> <input name="timeservers" type="text" class="formfld unknown" id="timeservers" size="40" value="<?=htmlspecialchars($pconfig['timeservers']);?>">
298
                    <br> <span class="vexpl">Use a space to separate multiple
299
                    hosts (only one required). Remember to set up at least one
300
                    DNS server if you enter a host name here!</span></td>
301
                </tr>
302
				<tr>
303
					<td colspan="2" class="list" height="12">&nbsp;</td>
304
				</tr>
305
				<tr>
306
					<td colspan="2" valign="top" class="listtopic">Theme</td>
307
				</tr>
308
				<tr>
309
				<td width="22%" valign="top" class="vncell">&nbsp;</td>
310
				<td width="78%" class="vtable">
311
				    <select name="theme">
312
<?php
313
				$files = return_dir_as_array("/usr/local/www/themes/");
314
				foreach($files as $f) {
315
					if ( (substr($f, 0, 1) == "_") && !isset($config['system']['developer']) ) continue;
316
					if($f == "CVS") continue;
317
					$selected = "";
318
					if($f == $config['theme'])
319
						$selected = " SELECTED";
320
					if($config['theme'] == "" and $f == "pfsense")
321
						$selceted = " SELECTED";
322
					echo "\t\t\t\t\t"."<option{$selected}>{$f}</option>\n";
323
				}
324
?>
325
					</select>
326
					<strong>This will change the look and feel of <?php echo $g['product_name']; ?>.</strong>
327
				</td>
328
				</tr>
329
				<tr>
330
                  <td width="22%" valign="top">&nbsp;</td>
331
                  <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save">
332
                  </td>
333
                </tr>
334
              </table>
335
</form>
336
<?php include("fend.inc"); ?>
337
</body>
338
</html>
(163-163/210)