Project

General

Profile

Download (23.5 KB) Statistics
| Branch: | Tag: | Revision:
1 04ad7c7c Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 aaec5634 Renato Botelho
 * system.php
4 191cb31d Stephen Beaver
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 2a2396a6 Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 aaec5634 Renato Botelho
 * All rights reserved.
8 54c605d4 Stephen Beaver
 *
9 aaec5634 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
10
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
 * All rights reserved.
12 54c605d4 Stephen Beaver
 *
13 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions are met:
15 54c605d4 Stephen Beaver
 *
16 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
17
 *    this list of conditions and the following disclaimer.
18 54c605d4 Stephen Beaver
 *
19 aaec5634 Renato Botelho
 * 2. Redistributions in binary form must reproduce the above copyright
20
 *    notice, this list of conditions and the following disclaimer in
21
 *    the documentation and/or other materials provided with the
22
 *    distribution.
23 54c605d4 Stephen Beaver
 *
24 aaec5634 Renato Botelho
 * 3. All advertising materials mentioning features or use of this software
25
 *    must display the following acknowledgment:
26
 *    "This product includes software developed by the pfSense Project
27
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
28 54c605d4 Stephen Beaver
 *
29 aaec5634 Renato Botelho
 * 4. The names "pfSense" and "pfSense Project" must not be used to
30
 *    endorse or promote products derived from this software without
31
 *    prior written permission. For written permission, please contact
32
 *    coreteam@pfsense.org.
33 54c605d4 Stephen Beaver
 *
34 aaec5634 Renato Botelho
 * 5. Products derived from this software may not be called "pfSense"
35
 *    nor may "pfSense" appear in their names without prior written
36
 *    permission of the Electric Sheep Fencing, LLC.
37 54c605d4 Stephen Beaver
 *
38 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
39
 *    acknowledgment:
40 54c605d4 Stephen Beaver
 *
41 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
42
 * for use in the pfSense software distribution (http://www.pfsense.org/).
43 54c605d4 Stephen Beaver
 *
44 aaec5634 Renato Botelho
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
45
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
48
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55
 * OF THE POSSIBILITY OF SUCH DAMAGE.
56 54c605d4 Stephen Beaver
 */
57 5b237745 Scott Ullrich
58 6b07c15a Matthew Grooms
##|+PRIV
59
##|*IDENT=page-system-generalsetup
60 5230f468 jim-p
##|*NAME=System: General Setup
61 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'System: General Setup' page.
62
##|*MATCH=system.php*
63
##|-PRIV
64
65 aceaf18c Phil Davis
require_once("guiconfig.inc");
66 7a927e67 Scott Ullrich
require_once("functions.inc");
67
require_once("filter.inc");
68
require_once("shaper.inc");
69 60ff91f1 Renato Botelho
require_once("system.inc");
70 5b237745 Scott Ullrich
71
$pconfig['hostname'] = $config['system']['hostname'];
72
$pconfig['domain'] = $config['system']['domain'];
73 d88f26df Phil Davis
$pconfig['dnsserver'] = $config['system']['dnsserver'];
74 0d8a219e Scott Ullrich
75 d623f2da Seth Mos
$arr_gateways = return_gateways_array();
76
77 c72c71f9 Phil Davis
// set default columns to two if unset
78 8f65151c Phil Davis
if (!isset($config['system']['webgui']['dashboardcolumns'])) {
79 477db933 Jared Dillard
	$config['system']['webgui']['dashboardcolumns'] = 2;
80
}
81
82 7b492a56 Phil Davis
// set default language if unset
83
if (!isset($config['system']['language'])) {
84 d258e30d jim-p
	$config['system']['language'] = $g['language'];
85 7b492a56 Phil Davis
}
86
87 d88f26df Phil Davis
$dnsgw_counter = 1;
88
89
while (isset($config["system"]["dns{$dnsgw_counter}gw"])) {
90
	$pconfig_dnsgw_counter = $dnsgw_counter - 1;
91
	$pconfig["dnsgw{$pconfig_dnsgw_counter}"] = $config["system"]["dns{$dnsgw_counter}gw"];
92
	$dnsgw_counter++;
93
}
94 e180a6e3 Scott Ullrich
95 5b237745 Scott Ullrich
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
96
$pconfig['timezone'] = $config['system']['timezone'];
97
$pconfig['timeservers'] = $config['system']['timeservers'];
98 3e139f90 Vinicius Coque
$pconfig['language'] = $config['system']['language'];
99 a5995a8e Stephen Beaver
$pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
100 3d29d2eb Jared Dillard
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
101 477db933 Jared Dillard
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
102 3666d731 Phil Davis
$pconfig['interfacessort'] = isset($config['system']['webgui']['interfacessort']);
103 24f15b3a NOYB
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
104 c05363c8 NOYB
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
105
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
106
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
107 b1b8784a NOYB
$pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
108 0f6e77fd Phil Davis
$pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu'];
109 8ca95ed8 jim-p
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
110 c1f9ca7a Stephen Beaver
$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10";
111 506fe755 Steve Beaver
$pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']);
112 05a13eba derelict-pf
$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']);
113 8ca95ed8 jim-p
114 2ee8dea1 Phil Davis
if (!$pconfig['timezone']) {
115 ecaca752 Renato Botelho
	if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
116
		$pconfig['timezone'] = $g['default_timezone'];
117
	} else {
118
		$pconfig['timezone'] = "Etc/UTC";
119
	}
120 2ee8dea1 Phil Davis
}
121 ecaca752 Renato Botelho
122 2ee8dea1 Phil Davis
if (!$pconfig['timeservers']) {
123 5b237745 Scott Ullrich
	$pconfig['timeservers'] = "pool.ntp.org";
124 2ee8dea1 Phil Davis
}
125 04ad7c7c Scott Ullrich
126 79eaddf4 Renato Botelho
$changedesc = gettext("System") . ": ";
127 62d01225 Bill Marquette
$changecount = 0;
128 417c6042 Bill Marquette
129 5b237745 Scott Ullrich
function is_timezone($elt) {
130
	return !preg_match("/\/$/", $elt);
131
}
132
133 2ee8dea1 Phil Davis
if ($pconfig['timezone'] <> $_POST['timezone']) {
134 744306c6 jim-p
	filter_pflog_start(true);
135 aa1ab1da Scott Ullrich
}
136
137 60ff91f1 Renato Botelho
$timezonelist = system_get_timezone_list();
138 c9911976 Renato Botelho
$timezonedesc = $timezonelist;
139
140
/*
141
 * Etc/GMT entries work the opposite way to what people expect.
142
 * Ref: https://github.com/eggert/tz/blob/master/etcetera and Redmine issue 7089
143
 * Add explanatory text to entries like:
144
 * Etc/GMT+1 and Etc/GMT-1
145
 * but not:
146
 * Etc/GMT or Etc/GMT+0
147
 */
148
foreach ($timezonedesc as $idx => $desc) {
149
	if (substr($desc, 0, 7) != "Etc/GMT" || substr($desc, 8, 1) == "0") {
150
		continue;
151
	}
152
153
	$direction = substr($desc, 7, 1);
154
155
	switch ($direction) {
156
	case '-':
157 49683e45 Phil Davis
		$direction_str = gettext('AHEAD of');
158 c9911976 Renato Botelho
		break;
159
	case '+':
160
		$direction_str = gettext('BEHIND');
161
		break;
162
	default:
163
		continue;
164
	}
165
166
	$hr_offset = substr($desc, 8);
167 49683e45 Phil Davis
	$timezonedesc[$idx] = $desc . " " .
168
	    sprintf(ngettext('(%1$s hour %2$s GMT)', '(%1$s hours %2$s GMT)', $hr_offset), $hr_offset, $direction_str);
169 c9911976 Renato Botelho
}
170 5b237745 Scott Ullrich
171 77446beb Matthew Grooms
$multiwan = false;
172 7922db8a Seth Mos
$interfaces = get_configured_interface_list();
173 2ee8dea1 Phil Davis
foreach ($interfaces as $interface) {
174
	if (interface_has_gateway($interface)) {
175 77446beb Matthew Grooms
		$multiwan = true;
176 7922db8a Seth Mos
	}
177
}
178 77446beb Matthew Grooms
179 5b237745 Scott Ullrich
if ($_POST) {
180
181 c668c964 Scott Ullrich
	$changecount++;
182 1180e4f0 Sjon Hortensius
183 5b237745 Scott Ullrich
	unset($input_errors);
184
	$pconfig = $_POST;
185
186
	/* input validation */
187 cfbfd941 smos
	$reqdfields = explode(" ", "hostname domain");
188 2ee8dea1 Phil Davis
	$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
189 04ad7c7c Scott Ullrich
190 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
191 04ad7c7c Scott Ullrich
192 c1f9ca7a Stephen Beaver
	if ($_POST['dashboardperiod']) {
193
		$config['widgets']['period'] = $_POST['dashboardperiod'];
194
	}
195
196 a5995a8e Stephen Beaver
	if ($_POST['webguicss']) {
197
		$config['system']['webgui']['webguicss'] = $_POST['webguicss'];
198
	} else {
199
		unset($config['system']['webgui']['webguicss']);
200
	}
201 8f65151c Phil Davis
202 506fe755 Steve Beaver
	$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
203
204 ddb84143 Stephen Beaver
	if ($_POST['webguifixedmenu']) {
205
		$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
206
	} else {
207
		unset($config['system']['webgui']['webguifixedmenu']);
208
	}
209 477db933 Jared Dillard
210 cb0222b0 Christopher Fazendin
	if ($_POST['webguihostnamemenu']) {
211
		$config['system']['webgui']['webguihostnamemenu'] = $_POST['webguihostnamemenu'];
212
	} else {
213
		unset($config['system']['webgui']['webguihostnamemenu']);
214
	}
215
216 477db933 Jared Dillard
	if ($_POST['dashboardcolumns']) {
217
		$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
218
	} else {
219
		unset($config['system']['webgui']['dashboardcolumns']);
220 8f65151c Phil Davis
	}
221
222 05a13eba derelict-pf
	$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
223
224 2d86ee95 Phil Davis
	if ($_POST['hostname']) {
225
		if (!is_hostname($_POST['hostname'])) {
226
			$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
227
		} else {
228
			if (!is_unqualified_hostname($_POST['hostname'])) {
229
				$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
230
			}
231
		}
232 5b237745 Scott Ullrich
	}
233
	if ($_POST['domain'] && !is_domain($_POST['domain'])) {
234 7465d12c Carlos Eduardo Ramos
		$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
235 5b237745 Scott Ullrich
	}
236 d623f2da Seth Mos
237 58b07c57 NewEraCracker
	$dnslist = $ignore_posted_dnsgw = array();
238 df4471e2 Phil Davis
239 d88f26df Phil Davis
	$dnscounter = 0;
240
	$dnsname = "dns{$dnscounter}";
241
242
	while (isset($_POST[$dnsname])) {
243
		$dnsgwname = "dnsgw{$dnscounter}";
244 a936104b Stephen Beaver
		$dnslist[] = $_POST[$dnsname];
245
246 d623f2da Seth Mos
		if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
247 d88f26df Phil Davis
			$input_errors[] = sprintf(gettext("A valid IP address must be specified for DNS server %s."), $dnscounter+1);
248 52acb1ff Phil Davis
		} else {
249 2ee8dea1 Phil Davis
			if (($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
250 52acb1ff Phil Davis
				// A real gateway has been selected.
251
				if (is_ipaddr($_POST[$dnsname])) {
252 2ee8dea1 Phil Davis
					if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
253 1bab4a10 NOYB
						$input_errors[] = sprintf(gettext('The IPv6 gateway "%1$s" can not be specified for IPv4 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
254 52acb1ff Phil Davis
					}
255 2ee8dea1 Phil Davis
					if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
256 1bab4a10 NOYB
						$input_errors[] = sprintf(gettext('The IPv4 gateway "%1$s" can not be specified for IPv6 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
257 52acb1ff Phil Davis
					}
258
				} else {
259 df4471e2 Phil Davis
					// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
260
					$ignore_posted_dnsgw[$dnsgwname] = true;
261 52acb1ff Phil Davis
				}
262 13ea7caa smos
			}
263 d623f2da Seth Mos
		}
264 d88f26df Phil Davis
		$dnscounter++;
265
		$dnsname = "dns{$dnscounter}";
266 5b237745 Scott Ullrich
	}
267 d623f2da Seth Mos
268 c25e42c8 Mark Furneaux
	if (count(array_filter($dnslist)) != count(array_unique(array_filter($dnslist)))) {
269 f700dc99 Chris Buechler
		$input_errors[] = gettext('Each configured DNS server must have a unique IP address. Remove the duplicated IP.');
270
	}
271
272 d88f26df Phil Davis
	$dnscounter = 0;
273
	$dnsname = "dns{$dnscounter}";
274
275 985fc0fb Ermal Lu?i
	$direct_networks_list = explode(" ", filter_get_direct_networks_list());
276 d88f26df Phil Davis
	while (isset($_POST[$dnsname])) {
277
		$dnsgwname = "dnsgw{$dnscounter}";
278
		if ($_POST[$dnsgwname] && ($_POST[$dnsgwname] <> "none")) {
279 29069aed Phil Davis
			foreach ($direct_networks_list as $direct_network) {
280 d88f26df Phil Davis
				if (ip_in_subnet($_POST[$dnsname], $direct_network)) {
281
					$input_errors[] = sprintf(gettext("A gateway can not be assigned to DNS '%s' server which is on a directly connected network."), $_POST[$dnsname]);
282 c98d28e1 Seth Mos
				}
283
			}
284
		}
285 d88f26df Phil Davis
		$dnscounter++;
286
		$dnsname = "dns{$dnscounter}";
287 c98d28e1 Seth Mos
	}
288
289 8adb814b David P Hilton
	# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
290
	$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
291
	$_POST['timeservers'] = trim($_POST['timeservers']);
292 5b237745 Scott Ullrich
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
293
		if (!is_domain($ts)) {
294 7465d12c Carlos Eduardo Ramos
			$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
295 5b237745 Scott Ullrich
		}
296
	}
297
298 d88f26df Phil Davis
	if ($input_errors) {
299
		// Put the user-entered list back into place so it will be redisplayed for correction.
300
		$pconfig['dnsserver'] = $dnslist;
301
	} else {
302 f1a34790 N0YB
		update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
303
		update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
304 9eab73da Bill Marquette
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
305
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
306 04ad7c7c Scott Ullrich
307 2ee8dea1 Phil Davis
		if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
308 3e139f90 Vinicius Coque
			$config['system']['language'] = $_POST['language'];
309 ceecd29b Renato Botelho
			set_language();
310 3e139f90 Vinicius Coque
		}
311
312 3666d731 Phil Davis
		unset($config['system']['webgui']['interfacessort']);
313
		$config['system']['webgui']['interfacessort'] = $_POST['interfacessort'] ? true : false;
314
315 24f15b3a NOYB
		unset($config['system']['webgui']['webguileftcolumnhyper']);
316
		$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
317
318 c05363c8 NOYB
		unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
319
		$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
320
321
		unset($config['system']['webgui']['systemlogsfilterpanel']);
322
		$config['system']['webgui']['systemlogsfilterpanel'] = $_POST['systemlogsfilterpanel'] ? true : false;
323
324
		unset($config['system']['webgui']['systemlogsmanagelogpanel']);
325
		$config['system']['webgui']['systemlogsmanagelogpanel'] = $_POST['systemlogsmanagelogpanel'] ? true : false;
326
327 b1b8784a NOYB
		unset($config['system']['webgui']['statusmonitoringsettingspanel']);
328
		$config['system']['webgui']['statusmonitoringsettingspanel'] = $_POST['statusmonitoringsettingspanel'] ? true : false;
329
330 4fbf63aa Bill Marquette
		/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
331 52acb1ff Phil Davis
		$olddnsservers = $config['system']['dnsserver'];
332 5b237745 Scott Ullrich
		unset($config['system']['dnsserver']);
333 d88f26df Phil Davis
334
		$dnscounter = 0;
335
		$dnsname = "dns{$dnscounter}";
336
337
		while (isset($_POST[$dnsname])) {
338
			if ($_POST[$dnsname]) {
339
				$config['system']['dnsserver'][] = $_POST[$dnsname];
340
			}
341
			$dnscounter++;
342
			$dnsname = "dns{$dnscounter}";
343 2ee8dea1 Phil Davis
		}
344 04ad7c7c Scott Ullrich
345 d88f26df Phil Davis
		// Remember the new list for display also.
346
		$pconfig['dnsserver'] = $config['system']['dnsserver'];
347
348 07bd3f83 Scott Ullrich
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
349 20b90e0a Scott Ullrich
350 0d8a219e Scott Ullrich
		unset($config['system']['dnsallowoverride']);
351 5b237745 Scott Ullrich
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
352 e180a6e3 Scott Ullrich
353 2ee8dea1 Phil Davis
		if ($_POST['dnslocalhost'] == "yes") {
354 8ca95ed8 jim-p
			$config['system']['dnslocalhost'] = true;
355 2ee8dea1 Phil Davis
		} else {
356 8ca95ed8 jim-p
			unset($config['system']['dnslocalhost']);
357 2ee8dea1 Phil Davis
		}
358 8ca95ed8 jim-p
359 e180a6e3 Scott Ullrich
		/* which interface should the dns servers resolve through? */
360 d88f26df Phil Davis
		$dnscounter = 0;
361
		// The $_POST array key of the DNS IP (starts from 0)
362
		$dnsname = "dns{$dnscounter}";
363 df4471e2 Phil Davis
		$outdnscounter = 0;
364 d88f26df Phil Davis
		while (isset($_POST[$dnsname])) {
365
			// The $_POST array key of the corresponding gateway (starts from 0)
366
			$dnsgwname = "dnsgw{$dnscounter}";
367
			// The numbering of DNS GW entries in the config starts from 1
368
			$dnsgwconfigcounter = $dnscounter + 1;
369
			// So this is the array key of the DNS GW entry in $config['system']
370
			$dnsgwconfigname = "dns{$dnsgwconfigcounter}gw";
371
372
			$olddnsgwname = $config['system'][$dnsgwconfigname];
373 df4471e2 Phil Davis
374 2ee8dea1 Phil Davis
			if ($ignore_posted_dnsgw[$dnsgwname]) {
375 df4471e2 Phil Davis
				$thisdnsgwname = "none";
376 2ee8dea1 Phil Davis
			} else {
377 df4471e2 Phil Davis
				$thisdnsgwname = $pconfig[$dnsgwname];
378 2ee8dea1 Phil Davis
			}
379 df4471e2 Phil Davis
380
			// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
381 d88f26df Phil Davis
			$config['system'][$dnsgwconfigname] = "none";
382 df4471e2 Phil Davis
			$pconfig[$dnsgwname] = "none";
383
			$pconfig[$dnsname] = "";
384
385
			if ($_POST[$dnsname]) {
386
				// Only the non-blank DNS servers were put into the config above.
387
				// So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
388
				// This keeps the DNS server IP and corresponding gateway "lined up" when the user blanks out a DNS server IP in the middle of the list.
389 d88f26df Phil Davis
390
				// The $pconfig array key of the DNS IP (starts from 0)
391
				$outdnsname = "dns{$outdnscounter}";
392
				// The $pconfig array key of the corresponding gateway (starts from 0)
393
				$outdnsgwname = "dnsgw{$outdnscounter}";
394
				// The numbering of DNS GW entries in the config starts from 1
395
				$outdnsgwconfigcounter = $outdnscounter + 1;
396
				// So this is the array key of the output DNS GW entry in $config['system']
397
				$outdnsgwconfigname = "dns{$outdnsgwconfigcounter}gw";
398
399 df4471e2 Phil Davis
				$pconfig[$outdnsname] = $_POST[$dnsname];
400 2ee8dea1 Phil Davis
				if ($_POST[$dnsgwname]) {
401 d88f26df Phil Davis
					$config['system'][$outdnsgwconfigname] = $thisdnsgwname;
402 df4471e2 Phil Davis
					$pconfig[$outdnsgwname] = $thisdnsgwname;
403
				} else {
404
					// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
405 d88f26df Phil Davis
					unset($config['system'][$outdnsgwconfigname]);
406 df4471e2 Phil Davis
					$pconfig[$outdnsgwname] = "";
407
				}
408 d88f26df Phil Davis
				$outdnscounter++;
409 d623f2da Seth Mos
			}
410 d88f26df Phil Davis
			if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter] != $_POST[$dnsname]))) {
411 52acb1ff Phil Davis
				// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
412
				// Remove the route. Later calls will add the correct new route if needed.
413 d88f26df Phil Davis
				if (is_ipaddrv4($olddnsservers[$dnscounter])) {
414 52acb1ff Phil Davis
					mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
415 d88f26df Phil Davis
				} else if (is_ipaddrv6($olddnsservers[$dnscounter])) {
416 312c32c9 Renato Botelho
					mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
417 2ee8dea1 Phil Davis
				}
418 52acb1ff Phil Davis
			}
419 d88f26df Phil Davis
420
			$dnscounter++;
421
			// The $_POST array key of the DNS IP (starts from 0)
422
			$dnsname = "dns{$dnscounter}";
423 d623f2da Seth Mos
		}
424 04ad7c7c Scott Ullrich
425 2ee8dea1 Phil Davis
		if ($changecount > 0) {
426 62d01225 Bill Marquette
			write_config($changedesc);
427 2ee8dea1 Phil Davis
		}
428 04ad7c7c Scott Ullrich
429 5b237745 Scott Ullrich
		$retval = 0;
430 3cfdba5f Scott Ullrich
		$retval = system_hostname_configure();
431
		$retval |= system_hosts_generate();
432
		$retval |= system_resolvconf_generate();
433 2ee8dea1 Phil Davis
		if (isset($config['dnsmasq']['enable'])) {
434 1e2c8821 Warren Baker
			$retval |= services_dnsmasq_configure();
435 2ee8dea1 Phil Davis
		} elseif (isset($config['unbound']['enable'])) {
436 1e2c8821 Warren Baker
			$retval |= services_unbound_configure();
437 2ee8dea1 Phil Davis
		}
438 3cfdba5f Scott Ullrich
		$retval |= system_timezone_configure();
439
		$retval |= system_ntp_configure();
440
441 2ee8dea1 Phil Davis
		if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
442 b8292903 Ermal
			$retval |= send_event("service reload dns");
443 2ee8dea1 Phil Davis
		}
444 3cfdba5f Scott Ullrich
445 e7d967d8 Scott Ullrich
		// Reload the filter - plugins might need to be run.
446 0027de0a Ermal Lu?i
		$retval |= filter_configure();
447 1180e4f0 Sjon Hortensius
448 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
449
	}
450 df4471e2 Phil Davis
451
	unset($ignore_posted_dnsgw);
452 5b237745 Scott Ullrich
}
453 4df96eff Scott Ullrich
454 2ee8dea1 Phil Davis
$pgtitle = array(gettext("System"), gettext("General Setup"));
455 4df96eff Scott Ullrich
include("head.inc");
456
457 8f65151c Phil Davis
if ($input_errors) {
458 41ea4cf3 Sjon Hortensius
	print_input_errors($input_errors);
459 8f65151c Phil Davis
}
460 ddb84143 Stephen Beaver
461 8f65151c Phil Davis
if ($savemsg) {
462 1f70d78c NewEraCracker
	print_info_box($savemsg, 'success');
463 8f65151c Phil Davis
}
464 5b237745 Scott Ullrich
?>
465 41ea4cf3 Sjon Hortensius
<div id="container">
466 b40bcb23 Sjon Hortensius
<?php
467 1180e4f0 Sjon Hortensius
468 b40bcb23 Sjon Hortensius
$form = new Form;
469 a32c0623 Sjon Hortensius
$section = new Form_Section('System');
470
$section->addInput(new Form_Input(
471 a97531c5 Sjon Hortensius
	'hostname',
472 51685157 Phil Davis
	'*Hostname',
473 a32c0623 Sjon Hortensius
	'text',
474
	$pconfig['hostname'],
475
	['placeholder' => 'pfSense']
476
))->setHelp('Name of the firewall host, without domain part');
477 c1f9ca7a Stephen Beaver
478 a32c0623 Sjon Hortensius
$section->addInput(new Form_Input(
479 a97531c5 Sjon Hortensius
	'domain',
480 51685157 Phil Davis
	'*Domain',
481 a32c0623 Sjon Hortensius
	'text',
482
	$pconfig['domain'],
483
	['placeholder' => 'mycorp.com, home, office, private, etc.']
484
))->setHelp('Do not use \'local\' as a domain name. It will cause local '.
485
	'hosts running mDNS (avahi, bonjour, etc.) to be unable to resolve '.
486
	'local hosts not running mDNS.');
487 c1f9ca7a Stephen Beaver
488 b40bcb23 Sjon Hortensius
$form->add($section);
489
490 70dc5cd6 Phil Davis
$section = new Form_Section('DNS Server Settings');
491 b40bcb23 Sjon Hortensius
492 d88f26df Phil Davis
if (!is_array($pconfig['dnsserver'])) {
493
	$pconfig['dnsserver'] = array();
494
}
495
496
$dnsserver_count = count($pconfig['dnsserver']);
497
$dnsserver_num = 0;
498
$dnsserver_help = gettext("Address") . '<br/>' . gettext("Enter IP addresses to be used by the system for DNS resolution.") . " " .
499
	gettext("These are also used for the DHCP service, DNS Forwarder and DNS Resolver when it has DNS Query Forwarding enabled.");
500
$dnsgw_help = gettext("Gateway") . '<br/>'. gettext("Optionally select the gateway for each DNS server.") . " " .
501
	gettext("When using multiple WAN connections there should be at least one unique DNS server per gateway.");
502
503
// If there are no DNS servers, make an empty entry for initial display.
504
if ($dnsserver_count == 0) {
505
	$pconfig['dnsserver'][] = '';
506
}
507
508
foreach ($pconfig['dnsserver'] as $dnsserver) {
509 54c605d4 Stephen Beaver
510 d88f26df Phil Davis
	$is_last_dnsserver = ($dnsserver_num == $dnsserver_count - 1);
511
	$group = new Form_Group($dnsserver_num == 0 ? 'DNS Servers':'');
512
	$group->addClass('repeatable');
513 54c605d4 Stephen Beaver
514
	$group->add(new Form_Input(
515 d88f26df Phil Davis
		'dns' . $dnsserver_num,
516 54c605d4 Stephen Beaver
		'DNS Server',
517
		'text',
518 d88f26df Phil Davis
		$dnsserver
519
	))->setHelp(($is_last_dnsserver) ? $dnsserver_help:null);
520 b40bcb23 Sjon Hortensius
521 54c605d4 Stephen Beaver
	if ($multiwan)	{
522 b40bcb23 Sjon Hortensius
		$options = array('none' => 'none');
523
524 8f65151c Phil Davis
		foreach ($arr_gateways as $gwname => $gwitem) {
525
			if ((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
526 b40bcb23 Sjon Hortensius
				continue;
527
			}
528 54c605d4 Stephen Beaver
529 8f65151c Phil Davis
			if ((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
530 b40bcb23 Sjon Hortensius
				continue;
531
			}
532 1180e4f0 Sjon Hortensius
533 b40bcb23 Sjon Hortensius
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
534
		}
535 1180e4f0 Sjon Hortensius
536 a97531c5 Sjon Hortensius
		$group->add(new Form_Select(
537 d88f26df Phil Davis
			'dnsgw' . $dnsserver_num,
538 e4dd8be4 NOYB
			'Gateway',
539 d88f26df Phil Davis
			$pconfig['dnsgw' . $dnsserver_num],
540 a97531c5 Sjon Hortensius
			$options
541 d88f26df Phil Davis
		))->setHelp(($is_last_dnsserver) ? $dnsgw_help:null);;
542 b40bcb23 Sjon Hortensius
	}
543 1180e4f0 Sjon Hortensius
544 d88f26df Phil Davis
	$group->add(new Form_Button(
545
		'deleterow' . $dnsserver_num,
546
		'Delete',
547
		null,
548
		'fa-trash'
549
	))->addClass('btn-warning');
550 54c605d4 Stephen Beaver
551 b40bcb23 Sjon Hortensius
	$section->add($group);
552 d88f26df Phil Davis
	$dnsserver_num++;
553 b40bcb23 Sjon Hortensius
}
554 1180e4f0 Sjon Hortensius
555 d88f26df Phil Davis
$section->addInput(new Form_Button(
556
	'addrow',
557
	'Add DNS Server',
558
	null,
559
	'fa-plus'
560
))->addClass('btn-success addbtn');
561
562 a005a836 Sjon Hortensius
$section->addInput(new Form_Checkbox(
563 a97531c5 Sjon Hortensius
	'dnsallowoverride',
564 70dc5cd6 Phil Davis
	'DNS Server Override',
565 b40bcb23 Sjon Hortensius
	'Allow DNS server list to be overridden by DHCP/PPP on WAN',
566
	$pconfig['dnsallowoverride']
567 e4dd8be4 NOYB
))->setHelp(sprintf(gettext('If this option is set, %s will use DNS servers '.
568 a32c0623 Sjon Hortensius
	'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
569 9e0fab88 doktornotor
	'the DNS Forwarder/DNS Resolver). However, they will not be assigned to DHCP '.
570
	'clients.'), $g['product_name']));
571 b40bcb23 Sjon Hortensius
572 a005a836 Sjon Hortensius
$section->addInput(new Form_Checkbox(
573 a97531c5 Sjon Hortensius
	'dnslocalhost',
574 70dc5cd6 Phil Davis
	'Disable DNS Forwarder',
575 9e0fab88 doktornotor
	'Do not use the DNS Forwarder/DNS Resolver as a DNS server for the firewall',
576 b40bcb23 Sjon Hortensius
	$pconfig['dnslocalhost']
577 e4dd8be4 NOYB
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS '.
578 a32c0623 Sjon Hortensius
	'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
579 9e0fab88 doktornotor
	'listen on localhost, so system can use the local DNS service to perform '.
580
	'lookups. Checking this box omits localhost from the list of DNS servers in resolv.conf.');
581 b40bcb23 Sjon Hortensius
582
$form->add($section);
583
584 a005a836 Sjon Hortensius
$section = new Form_Section('Localization');
585 c1f9ca7a Stephen Beaver
586 a005a836 Sjon Hortensius
$section->addInput(new Form_Select(
587 a97531c5 Sjon Hortensius
	'timezone',
588 51685157 Phil Davis
	'*Timezone',
589 a32c0623 Sjon Hortensius
	$pconfig['timezone'],
590 c9911976 Renato Botelho
	array_combine($timezonelist, $timezonedesc)
591 50af3592 Phil Davis
))->setHelp('Select the timezone or location within the timezone to be used by this system. '.
592
	'Usually choose a "Continent/City". Only choose a special or "Etc" entry if you understand why you need to use it.');
593 c1f9ca7a Stephen Beaver
594 a005a836 Sjon Hortensius
$section->addInput(new Form_Input(
595 a97531c5 Sjon Hortensius
	'timeservers',
596 a32c0623 Sjon Hortensius
	'Timeservers',
597
	'text',
598
	$pconfig['timeservers']
599
))->setHelp('Use a space to separate multiple hosts (only one required). '.
600 1bab4a10 NOYB
	'Remember to set up at least one DNS server if a host name is entered here!');
601 c1f9ca7a Stephen Beaver
602 a005a836 Sjon Hortensius
$section->addInput(new Form_Select(
603 a97531c5 Sjon Hortensius
	'language',
604 51685157 Phil Davis
	'*Language',
605 a32c0623 Sjon Hortensius
	$pconfig['language'],
606
	get_locale_list()
607
))->setHelp('Choose a language for the webConfigurator');
608 b40bcb23 Sjon Hortensius
609
$form->add($section);
610
611 1176360c k-paulius
$section = new Form_Section('webConfigurator');
612 a5995a8e Stephen Beaver
613 595b074d Phil Davis
gen_webguicss_field($section, $pconfig['webguicss']);
614
gen_webguifixedmenu_field($section, $pconfig['webguifixedmenu']);
615
gen_webguihostnamemenu_field($section, $pconfig['webguihostnamemenu']);
616
gen_dashboardcolumns_field($section, $pconfig['dashboardcolumns']);
617 3666d731 Phil Davis
gen_interfacessort_field($section, $pconfig['interfacessort']);
618 595b074d Phil Davis
gen_associatedpanels_fields(
619
	$section,
620
	$pconfig['dashboardavailablewidgetspanel'],
621
	$pconfig['systemlogsfilterpanel'],
622
	$pconfig['systemlogsmanagelogpanel'],
623
	$pconfig['statusmonitoringsettingspanel']);
624 05a13eba derelict-pf
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
625 595b074d Phil Davis
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
626 24f15b3a NOYB
627 506fe755 Steve Beaver
$section->addInput(new Form_Checkbox(
628
	'loginshowhost',
629
	'Login hostname',
630
	'Show hostname on login banner',
631
	$pconfig['loginshowhost']
632
));
633
634 c1f9ca7a Stephen Beaver
$section->addInput(new Form_Input(
635
	'dashboardperiod',
636
	'Dashboard update period',
637
	'number',
638
	$pconfig['dashboardperiod'],
639 6d203ffc Stephen Beaver
	['min' => '5', 'max' => '600']
640 c1f9ca7a Stephen Beaver
))->setHelp('Time in seconds between dashboard widget updates. Small values cause ' .
641
			'more frequent updates but increase the load on the web server. ' .
642
			'Minimum is 5 seconds, maximum 600 seconds');
643
644 a5995a8e Stephen Beaver
$form->add($section);
645
646 b40bcb23 Sjon Hortensius
print $form;
647 ee7c0a00 Stephen Beaver
648
$csswarning = sprintf(gettext("%sUser-created themes are unsupported, use at your own risk."), "<br />");
649
650 8c4ef875 NOYB
?>
651
</div>
652 ee7c0a00 Stephen Beaver
653 e296b399 Colin Fleming
<script type="text/javascript">
654 ee7c0a00 Stephen Beaver
//<![CDATA[
655
events.push(function() {
656
657
	function setThemeWarning() {
658
		if ($('#webguicss').val().startsWith("pfSense")) {
659
			$('#csstxt').html("").addClass("text-default");
660
		} else {
661
			$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
662
		}
663
	}
664
665
	$('#webguicss').change(function() {
666
		setThemeWarning();
667
	});
668
669
	setThemeWarning();
670 d88f26df Phil Davis
671
	// Suppress "Delete row" button if there are fewer than two rows
672
	checkLastRow();
673 ee7c0a00 Stephen Beaver
});
674
//]]>
675
</script>
676
677 8c4ef875 NOYB
<?php
678 60ff91f1 Renato Botelho
include("foot.inc");
679 8c4ef875 NOYB
?>