Project

General

Profile

Download (24.9 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 e3c0d75e Luiz Souza
 * Copyright (c) 2004-2018 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 1605d940 Steve Beaver
$pconfig['logincss'] = $config['system']['webgui']['logincss'];
101 3d29d2eb Jared Dillard
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
102 477db933 Jared Dillard
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
103 3666d731 Phil Davis
$pconfig['interfacessort'] = isset($config['system']['webgui']['interfacessort']);
104 24f15b3a NOYB
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
105 c05363c8 NOYB
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
106
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
107
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
108 b1b8784a NOYB
$pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
109 0f6e77fd Phil Davis
$pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu'];
110 8ca95ed8 jim-p
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
111 5e024279 Steve Beaver
//$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10";
112 506fe755 Steve Beaver
$pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']);
113 05a13eba derelict-pf
$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']);
114 8ca95ed8 jim-p
115 2ee8dea1 Phil Davis
if (!$pconfig['timezone']) {
116 ecaca752 Renato Botelho
	if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
117
		$pconfig['timezone'] = $g['default_timezone'];
118
	} else {
119
		$pconfig['timezone'] = "Etc/UTC";
120
	}
121 2ee8dea1 Phil Davis
}
122 ecaca752 Renato Botelho
123 2ee8dea1 Phil Davis
if (!$pconfig['timeservers']) {
124 5b237745 Scott Ullrich
	$pconfig['timeservers'] = "pool.ntp.org";
125 2ee8dea1 Phil Davis
}
126 04ad7c7c Scott Ullrich
127 79eaddf4 Renato Botelho
$changedesc = gettext("System") . ": ";
128 62d01225 Bill Marquette
$changecount = 0;
129 417c6042 Bill Marquette
130 5b237745 Scott Ullrich
function is_timezone($elt) {
131
	return !preg_match("/\/$/", $elt);
132
}
133
134 2ee8dea1 Phil Davis
if ($pconfig['timezone'] <> $_POST['timezone']) {
135 744306c6 jim-p
	filter_pflog_start(true);
136 aa1ab1da Scott Ullrich
}
137
138 60ff91f1 Renato Botelho
$timezonelist = system_get_timezone_list();
139 c9911976 Renato Botelho
$timezonedesc = $timezonelist;
140
141
/*
142
 * Etc/GMT entries work the opposite way to what people expect.
143
 * Ref: https://github.com/eggert/tz/blob/master/etcetera and Redmine issue 7089
144
 * Add explanatory text to entries like:
145
 * Etc/GMT+1 and Etc/GMT-1
146
 * but not:
147
 * Etc/GMT or Etc/GMT+0
148
 */
149
foreach ($timezonedesc as $idx => $desc) {
150
	if (substr($desc, 0, 7) != "Etc/GMT" || substr($desc, 8, 1) == "0") {
151
		continue;
152
	}
153
154
	$direction = substr($desc, 7, 1);
155
156
	switch ($direction) {
157
	case '-':
158 49683e45 Phil Davis
		$direction_str = gettext('AHEAD of');
159 c9911976 Renato Botelho
		break;
160
	case '+':
161
		$direction_str = gettext('BEHIND');
162
		break;
163
	default:
164
		continue;
165
	}
166
167
	$hr_offset = substr($desc, 8);
168 49683e45 Phil Davis
	$timezonedesc[$idx] = $desc . " " .
169
	    sprintf(ngettext('(%1$s hour %2$s GMT)', '(%1$s hours %2$s GMT)', $hr_offset), $hr_offset, $direction_str);
170 c9911976 Renato Botelho
}
171 5b237745 Scott Ullrich
172 77446beb Matthew Grooms
$multiwan = false;
173 7922db8a Seth Mos
$interfaces = get_configured_interface_list();
174 2ee8dea1 Phil Davis
foreach ($interfaces as $interface) {
175
	if (interface_has_gateway($interface)) {
176 77446beb Matthew Grooms
		$multiwan = true;
177 7922db8a Seth Mos
	}
178
}
179 77446beb Matthew Grooms
180 5b237745 Scott Ullrich
if ($_POST) {
181
182 c668c964 Scott Ullrich
	$changecount++;
183 1180e4f0 Sjon Hortensius
184 5b237745 Scott Ullrich
	unset($input_errors);
185
	$pconfig = $_POST;
186
187
	/* input validation */
188 cfbfd941 smos
	$reqdfields = explode(" ", "hostname domain");
189 2ee8dea1 Phil Davis
	$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
190 04ad7c7c Scott Ullrich
191 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
192 04ad7c7c Scott Ullrich
193 2d86ee95 Phil Davis
	if ($_POST['hostname']) {
194
		if (!is_hostname($_POST['hostname'])) {
195
			$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
196
		} else {
197
			if (!is_unqualified_hostname($_POST['hostname'])) {
198
				$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
199
			}
200
		}
201 5b237745 Scott Ullrich
	}
202
	if ($_POST['domain'] && !is_domain($_POST['domain'])) {
203 7465d12c Carlos Eduardo Ramos
		$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
204 5b237745 Scott Ullrich
	}
205 209ae186 jim-p
	validate_webguicss_field($input_errors, $_POST['webguicss']);
206
	validate_webguifixedmenu_field($input_errors, $_POST['webguifixedmenu']);
207
	validate_webguihostnamemenu_field($input_errors, $_POST['webguihostnamemenu']);
208
	validate_dashboardcolumns_field($input_errors, $_POST['dashboardcolumns']);
209 d623f2da Seth Mos
210 58b07c57 NewEraCracker
	$dnslist = $ignore_posted_dnsgw = array();
211 df4471e2 Phil Davis
212 d88f26df Phil Davis
	$dnscounter = 0;
213
	$dnsname = "dns{$dnscounter}";
214
215
	while (isset($_POST[$dnsname])) {
216
		$dnsgwname = "dnsgw{$dnscounter}";
217 a936104b Stephen Beaver
		$dnslist[] = $_POST[$dnsname];
218
219 d623f2da Seth Mos
		if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
220 d88f26df Phil Davis
			$input_errors[] = sprintf(gettext("A valid IP address must be specified for DNS server %s."), $dnscounter+1);
221 52acb1ff Phil Davis
		} else {
222 2ee8dea1 Phil Davis
			if (($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
223 52acb1ff Phil Davis
				// A real gateway has been selected.
224
				if (is_ipaddr($_POST[$dnsname])) {
225 2ee8dea1 Phil Davis
					if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
226 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]);
227 52acb1ff Phil Davis
					}
228 2ee8dea1 Phil Davis
					if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
229 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]);
230 52acb1ff Phil Davis
					}
231
				} else {
232 df4471e2 Phil Davis
					// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
233
					$ignore_posted_dnsgw[$dnsgwname] = true;
234 52acb1ff Phil Davis
				}
235 13ea7caa smos
			}
236 d623f2da Seth Mos
		}
237 d88f26df Phil Davis
		$dnscounter++;
238
		$dnsname = "dns{$dnscounter}";
239 5b237745 Scott Ullrich
	}
240 d623f2da Seth Mos
241 c25e42c8 Mark Furneaux
	if (count(array_filter($dnslist)) != count(array_unique(array_filter($dnslist)))) {
242 f700dc99 Chris Buechler
		$input_errors[] = gettext('Each configured DNS server must have a unique IP address. Remove the duplicated IP.');
243
	}
244
245 d88f26df Phil Davis
	$dnscounter = 0;
246
	$dnsname = "dns{$dnscounter}";
247
248 985fc0fb Ermal Lu?i
	$direct_networks_list = explode(" ", filter_get_direct_networks_list());
249 d88f26df Phil Davis
	while (isset($_POST[$dnsname])) {
250
		$dnsgwname = "dnsgw{$dnscounter}";
251
		if ($_POST[$dnsgwname] && ($_POST[$dnsgwname] <> "none")) {
252 29069aed Phil Davis
			foreach ($direct_networks_list as $direct_network) {
253 d88f26df Phil Davis
				if (ip_in_subnet($_POST[$dnsname], $direct_network)) {
254
					$input_errors[] = sprintf(gettext("A gateway can not be assigned to DNS '%s' server which is on a directly connected network."), $_POST[$dnsname]);
255 c98d28e1 Seth Mos
				}
256
			}
257
		}
258 d88f26df Phil Davis
		$dnscounter++;
259
		$dnsname = "dns{$dnscounter}";
260 c98d28e1 Seth Mos
	}
261
262 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.
263
	$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
264
	$_POST['timeservers'] = trim($_POST['timeservers']);
265 5b237745 Scott Ullrich
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
266
		if (!is_domain($ts)) {
267 7465d12c Carlos Eduardo Ramos
			$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
268 5b237745 Scott Ullrich
		}
269
	}
270
271 d88f26df Phil Davis
	if ($input_errors) {
272
		// Put the user-entered list back into place so it will be redisplayed for correction.
273
		$pconfig['dnsserver'] = $dnslist;
274
	} else {
275 f1a34790 N0YB
		update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
276
		update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
277 9eab73da Bill Marquette
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
278
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
279 04ad7c7c Scott Ullrich
280 2ee8dea1 Phil Davis
		if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
281 3e139f90 Vinicius Coque
			$config['system']['language'] = $_POST['language'];
282 ceecd29b Renato Botelho
			set_language();
283 3e139f90 Vinicius Coque
		}
284
285 3666d731 Phil Davis
		unset($config['system']['webgui']['interfacessort']);
286
		$config['system']['webgui']['interfacessort'] = $_POST['interfacessort'] ? true : false;
287
288 24f15b3a NOYB
		unset($config['system']['webgui']['webguileftcolumnhyper']);
289
		$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
290
291 c05363c8 NOYB
		unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
292
		$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
293
294
		unset($config['system']['webgui']['systemlogsfilterpanel']);
295
		$config['system']['webgui']['systemlogsfilterpanel'] = $_POST['systemlogsfilterpanel'] ? true : false;
296
297
		unset($config['system']['webgui']['systemlogsmanagelogpanel']);
298
		$config['system']['webgui']['systemlogsmanagelogpanel'] = $_POST['systemlogsmanagelogpanel'] ? true : false;
299
300 b1b8784a NOYB
		unset($config['system']['webgui']['statusmonitoringsettingspanel']);
301
		$config['system']['webgui']['statusmonitoringsettingspanel'] = $_POST['statusmonitoringsettingspanel'] ? true : false;
302
303 209ae186 jim-p
//		if ($_POST['dashboardperiod']) {
304
//			$config['widgets']['period'] = $_POST['dashboardperiod'];
305
//		}
306
307
		if ($_POST['webguicss']) {
308
			$config['system']['webgui']['webguicss'] = $_POST['webguicss'];
309
		} else {
310
			unset($config['system']['webgui']['webguicss']);
311
		}
312
313
		$config['system']['webgui']['roworderdragging'] = $_POST['roworderdragging'] ? true:false;
314
315
		if ($_POST['logincss']) {
316
			$config['system']['webgui']['logincss'] = $_POST['logincss'];
317
		} else {
318
			unset($config['system']['webgui']['logincss']);
319
		}
320
321
		$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
322
323
		if ($_POST['webguifixedmenu']) {
324
			$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
325
		} else {
326
			unset($config['system']['webgui']['webguifixedmenu']);
327
		}
328
329
		if ($_POST['webguihostnamemenu']) {
330
			$config['system']['webgui']['webguihostnamemenu'] = $_POST['webguihostnamemenu'];
331
		} else {
332
			unset($config['system']['webgui']['webguihostnamemenu']);
333
		}
334
335
		if ($_POST['dashboardcolumns']) {
336
			$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
337
		} else {
338
			unset($config['system']['webgui']['dashboardcolumns']);
339
		}
340
341
		$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
342
343 4fbf63aa Bill Marquette
		/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
344 52acb1ff Phil Davis
		$olddnsservers = $config['system']['dnsserver'];
345 5b237745 Scott Ullrich
		unset($config['system']['dnsserver']);
346 d88f26df Phil Davis
347
		$dnscounter = 0;
348
		$dnsname = "dns{$dnscounter}";
349
350
		while (isset($_POST[$dnsname])) {
351
			if ($_POST[$dnsname]) {
352
				$config['system']['dnsserver'][] = $_POST[$dnsname];
353
			}
354
			$dnscounter++;
355
			$dnsname = "dns{$dnscounter}";
356 2ee8dea1 Phil Davis
		}
357 04ad7c7c Scott Ullrich
358 d88f26df Phil Davis
		// Remember the new list for display also.
359
		$pconfig['dnsserver'] = $config['system']['dnsserver'];
360
361 07bd3f83 Scott Ullrich
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
362 20b90e0a Scott Ullrich
363 0d8a219e Scott Ullrich
		unset($config['system']['dnsallowoverride']);
364 5b237745 Scott Ullrich
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
365 e180a6e3 Scott Ullrich
366 2ee8dea1 Phil Davis
		if ($_POST['dnslocalhost'] == "yes") {
367 8ca95ed8 jim-p
			$config['system']['dnslocalhost'] = true;
368 2ee8dea1 Phil Davis
		} else {
369 8ca95ed8 jim-p
			unset($config['system']['dnslocalhost']);
370 2ee8dea1 Phil Davis
		}
371 8ca95ed8 jim-p
372 e180a6e3 Scott Ullrich
		/* which interface should the dns servers resolve through? */
373 d88f26df Phil Davis
		$dnscounter = 0;
374
		// The $_POST array key of the DNS IP (starts from 0)
375
		$dnsname = "dns{$dnscounter}";
376 df4471e2 Phil Davis
		$outdnscounter = 0;
377 d88f26df Phil Davis
		while (isset($_POST[$dnsname])) {
378
			// The $_POST array key of the corresponding gateway (starts from 0)
379
			$dnsgwname = "dnsgw{$dnscounter}";
380
			// The numbering of DNS GW entries in the config starts from 1
381
			$dnsgwconfigcounter = $dnscounter + 1;
382
			// So this is the array key of the DNS GW entry in $config['system']
383
			$dnsgwconfigname = "dns{$dnsgwconfigcounter}gw";
384
385
			$olddnsgwname = $config['system'][$dnsgwconfigname];
386 df4471e2 Phil Davis
387 2ee8dea1 Phil Davis
			if ($ignore_posted_dnsgw[$dnsgwname]) {
388 df4471e2 Phil Davis
				$thisdnsgwname = "none";
389 2ee8dea1 Phil Davis
			} else {
390 df4471e2 Phil Davis
				$thisdnsgwname = $pconfig[$dnsgwname];
391 2ee8dea1 Phil Davis
			}
392 df4471e2 Phil Davis
393
			// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
394 d88f26df Phil Davis
			$config['system'][$dnsgwconfigname] = "none";
395 df4471e2 Phil Davis
			$pconfig[$dnsgwname] = "none";
396
			$pconfig[$dnsname] = "";
397
398
			if ($_POST[$dnsname]) {
399
				// Only the non-blank DNS servers were put into the config above.
400
				// So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
401
				// 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.
402 d88f26df Phil Davis
403
				// The $pconfig array key of the DNS IP (starts from 0)
404
				$outdnsname = "dns{$outdnscounter}";
405
				// The $pconfig array key of the corresponding gateway (starts from 0)
406
				$outdnsgwname = "dnsgw{$outdnscounter}";
407
				// The numbering of DNS GW entries in the config starts from 1
408
				$outdnsgwconfigcounter = $outdnscounter + 1;
409
				// So this is the array key of the output DNS GW entry in $config['system']
410
				$outdnsgwconfigname = "dns{$outdnsgwconfigcounter}gw";
411
412 df4471e2 Phil Davis
				$pconfig[$outdnsname] = $_POST[$dnsname];
413 2ee8dea1 Phil Davis
				if ($_POST[$dnsgwname]) {
414 d88f26df Phil Davis
					$config['system'][$outdnsgwconfigname] = $thisdnsgwname;
415 df4471e2 Phil Davis
					$pconfig[$outdnsgwname] = $thisdnsgwname;
416
				} else {
417
					// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
418 d88f26df Phil Davis
					unset($config['system'][$outdnsgwconfigname]);
419 df4471e2 Phil Davis
					$pconfig[$outdnsgwname] = "";
420
				}
421 d88f26df Phil Davis
				$outdnscounter++;
422 d623f2da Seth Mos
			}
423 d88f26df Phil Davis
			if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter] != $_POST[$dnsname]))) {
424 52acb1ff Phil Davis
				// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
425
				// Remove the route. Later calls will add the correct new route if needed.
426 d88f26df Phil Davis
				if (is_ipaddrv4($olddnsservers[$dnscounter])) {
427 52acb1ff Phil Davis
					mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
428 d88f26df Phil Davis
				} else if (is_ipaddrv6($olddnsservers[$dnscounter])) {
429 312c32c9 Renato Botelho
					mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
430 2ee8dea1 Phil Davis
				}
431 52acb1ff Phil Davis
			}
432 d88f26df Phil Davis
433
			$dnscounter++;
434
			// The $_POST array key of the DNS IP (starts from 0)
435
			$dnsname = "dns{$dnscounter}";
436 d623f2da Seth Mos
		}
437 04ad7c7c Scott Ullrich
438 2ee8dea1 Phil Davis
		if ($changecount > 0) {
439 62d01225 Bill Marquette
			write_config($changedesc);
440 2ee8dea1 Phil Davis
		}
441 04ad7c7c Scott Ullrich
442 5b237745 Scott Ullrich
		$retval = 0;
443 3cfdba5f Scott Ullrich
		$retval = system_hostname_configure();
444
		$retval |= system_hosts_generate();
445
		$retval |= system_resolvconf_generate();
446 2ee8dea1 Phil Davis
		if (isset($config['dnsmasq']['enable'])) {
447 1e2c8821 Warren Baker
			$retval |= services_dnsmasq_configure();
448 2ee8dea1 Phil Davis
		} elseif (isset($config['unbound']['enable'])) {
449 1e2c8821 Warren Baker
			$retval |= services_unbound_configure();
450 2ee8dea1 Phil Davis
		}
451 3cfdba5f Scott Ullrich
		$retval |= system_timezone_configure();
452
		$retval |= system_ntp_configure();
453
454 2ee8dea1 Phil Davis
		if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
455 b8292903 Ermal
			$retval |= send_event("service reload dns");
456 2ee8dea1 Phil Davis
		}
457 3cfdba5f Scott Ullrich
458 e7d967d8 Scott Ullrich
		// Reload the filter - plugins might need to be run.
459 0027de0a Ermal Lu?i
		$retval |= filter_configure();
460 1180e4f0 Sjon Hortensius
461 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
462
	}
463 df4471e2 Phil Davis
464
	unset($ignore_posted_dnsgw);
465 5b237745 Scott Ullrich
}
466 4df96eff Scott Ullrich
467 2ee8dea1 Phil Davis
$pgtitle = array(gettext("System"), gettext("General Setup"));
468 4df96eff Scott Ullrich
include("head.inc");
469
470 8f65151c Phil Davis
if ($input_errors) {
471 41ea4cf3 Sjon Hortensius
	print_input_errors($input_errors);
472 8f65151c Phil Davis
}
473 ddb84143 Stephen Beaver
474 8f65151c Phil Davis
if ($savemsg) {
475 1f70d78c NewEraCracker
	print_info_box($savemsg, 'success');
476 8f65151c Phil Davis
}
477 5b237745 Scott Ullrich
?>
478 41ea4cf3 Sjon Hortensius
<div id="container">
479 b40bcb23 Sjon Hortensius
<?php
480 1180e4f0 Sjon Hortensius
481 b40bcb23 Sjon Hortensius
$form = new Form;
482 a32c0623 Sjon Hortensius
$section = new Form_Section('System');
483
$section->addInput(new Form_Input(
484 a97531c5 Sjon Hortensius
	'hostname',
485 51685157 Phil Davis
	'*Hostname',
486 a32c0623 Sjon Hortensius
	'text',
487
	$pconfig['hostname'],
488
	['placeholder' => 'pfSense']
489
))->setHelp('Name of the firewall host, without domain part');
490 c1f9ca7a Stephen Beaver
491 a32c0623 Sjon Hortensius
$section->addInput(new Form_Input(
492 a97531c5 Sjon Hortensius
	'domain',
493 51685157 Phil Davis
	'*Domain',
494 a32c0623 Sjon Hortensius
	'text',
495
	$pconfig['domain'],
496
	['placeholder' => 'mycorp.com, home, office, private, etc.']
497 83477771 stilez
))->setHelp('Do not use \'.local\' as the final part of the domain (TLD), The \'.local\' domain is %1$swidely used%2$s by '.
498 514233ee stilez
	'mDNS (including Avahi and Apple OS X\'s Bonjour/Rendezvous/Airprint/Airplay), and some Windows systems and networked devices. ' .
499 83477771 stilez
	'These will not network correctly if the router uses \'.local\'. Alternatives such as \'.local.lan\' or \'.mylocal\' are safe.',
500 640d1b64 Steve Beaver
	 ['<a target="_blank" href="https://www.unbound.net/pipermail/unbound-users/2011-March/001735.html">',
501
	 '</a>']);
502 c1f9ca7a Stephen Beaver
503 b40bcb23 Sjon Hortensius
$form->add($section);
504
505 70dc5cd6 Phil Davis
$section = new Form_Section('DNS Server Settings');
506 b40bcb23 Sjon Hortensius
507 d88f26df Phil Davis
if (!is_array($pconfig['dnsserver'])) {
508
	$pconfig['dnsserver'] = array();
509
}
510
511
$dnsserver_count = count($pconfig['dnsserver']);
512
$dnsserver_num = 0;
513
$dnsserver_help = gettext("Address") . '<br/>' . gettext("Enter IP addresses to be used by the system for DNS resolution.") . " " .
514
	gettext("These are also used for the DHCP service, DNS Forwarder and DNS Resolver when it has DNS Query Forwarding enabled.");
515
$dnsgw_help = gettext("Gateway") . '<br/>'. gettext("Optionally select the gateway for each DNS server.") . " " .
516
	gettext("When using multiple WAN connections there should be at least one unique DNS server per gateway.");
517
518
// If there are no DNS servers, make an empty entry for initial display.
519
if ($dnsserver_count == 0) {
520
	$pconfig['dnsserver'][] = '';
521
}
522
523
foreach ($pconfig['dnsserver'] as $dnsserver) {
524 54c605d4 Stephen Beaver
525 d88f26df Phil Davis
	$is_last_dnsserver = ($dnsserver_num == $dnsserver_count - 1);
526
	$group = new Form_Group($dnsserver_num == 0 ? 'DNS Servers':'');
527
	$group->addClass('repeatable');
528 54c605d4 Stephen Beaver
529
	$group->add(new Form_Input(
530 d88f26df Phil Davis
		'dns' . $dnsserver_num,
531 54c605d4 Stephen Beaver
		'DNS Server',
532
		'text',
533 d88f26df Phil Davis
		$dnsserver
534
	))->setHelp(($is_last_dnsserver) ? $dnsserver_help:null);
535 b40bcb23 Sjon Hortensius
536 54c605d4 Stephen Beaver
	if ($multiwan)	{
537 b40bcb23 Sjon Hortensius
		$options = array('none' => 'none');
538
539 8f65151c Phil Davis
		foreach ($arr_gateways as $gwname => $gwitem) {
540
			if ((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
541 b40bcb23 Sjon Hortensius
				continue;
542
			}
543 54c605d4 Stephen Beaver
544 8f65151c Phil Davis
			if ((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
545 b40bcb23 Sjon Hortensius
				continue;
546
			}
547 1180e4f0 Sjon Hortensius
548 b40bcb23 Sjon Hortensius
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
549
		}
550 1180e4f0 Sjon Hortensius
551 a97531c5 Sjon Hortensius
		$group->add(new Form_Select(
552 d88f26df Phil Davis
			'dnsgw' . $dnsserver_num,
553 e4dd8be4 NOYB
			'Gateway',
554 d88f26df Phil Davis
			$pconfig['dnsgw' . $dnsserver_num],
555 a97531c5 Sjon Hortensius
			$options
556 d88f26df Phil Davis
		))->setHelp(($is_last_dnsserver) ? $dnsgw_help:null);;
557 b40bcb23 Sjon Hortensius
	}
558 1180e4f0 Sjon Hortensius
559 d88f26df Phil Davis
	$group->add(new Form_Button(
560
		'deleterow' . $dnsserver_num,
561
		'Delete',
562
		null,
563
		'fa-trash'
564
	))->addClass('btn-warning');
565 54c605d4 Stephen Beaver
566 b40bcb23 Sjon Hortensius
	$section->add($group);
567 d88f26df Phil Davis
	$dnsserver_num++;
568 b40bcb23 Sjon Hortensius
}
569 1180e4f0 Sjon Hortensius
570 d88f26df Phil Davis
$section->addInput(new Form_Button(
571
	'addrow',
572
	'Add DNS Server',
573
	null,
574
	'fa-plus'
575
))->addClass('btn-success addbtn');
576
577 a005a836 Sjon Hortensius
$section->addInput(new Form_Checkbox(
578 a97531c5 Sjon Hortensius
	'dnsallowoverride',
579 70dc5cd6 Phil Davis
	'DNS Server Override',
580 b40bcb23 Sjon Hortensius
	'Allow DNS server list to be overridden by DHCP/PPP on WAN',
581
	$pconfig['dnsallowoverride']
582 e4dd8be4 NOYB
))->setHelp(sprintf(gettext('If this option is set, %s will use DNS servers '.
583 a32c0623 Sjon Hortensius
	'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
584 9e0fab88 doktornotor
	'the DNS Forwarder/DNS Resolver). However, they will not be assigned to DHCP '.
585
	'clients.'), $g['product_name']));
586 b40bcb23 Sjon Hortensius
587 a005a836 Sjon Hortensius
$section->addInput(new Form_Checkbox(
588 a97531c5 Sjon Hortensius
	'dnslocalhost',
589 70dc5cd6 Phil Davis
	'Disable DNS Forwarder',
590 9e0fab88 doktornotor
	'Do not use the DNS Forwarder/DNS Resolver as a DNS server for the firewall',
591 b40bcb23 Sjon Hortensius
	$pconfig['dnslocalhost']
592 e4dd8be4 NOYB
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS '.
593 a32c0623 Sjon Hortensius
	'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
594 9e0fab88 doktornotor
	'listen on localhost, so system can use the local DNS service to perform '.
595
	'lookups. Checking this box omits localhost from the list of DNS servers in resolv.conf.');
596 b40bcb23 Sjon Hortensius
597
$form->add($section);
598
599 a005a836 Sjon Hortensius
$section = new Form_Section('Localization');
600 c1f9ca7a Stephen Beaver
601 a005a836 Sjon Hortensius
$section->addInput(new Form_Select(
602 a97531c5 Sjon Hortensius
	'timezone',
603 51685157 Phil Davis
	'*Timezone',
604 a32c0623 Sjon Hortensius
	$pconfig['timezone'],
605 c9911976 Renato Botelho
	array_combine($timezonelist, $timezonedesc)
606 50af3592 Phil Davis
))->setHelp('Select the timezone or location within the timezone to be used by this system. '.
607
	'Usually choose a "Continent/City". Only choose a special or "Etc" entry if you understand why you need to use it.');
608 c1f9ca7a Stephen Beaver
609 a005a836 Sjon Hortensius
$section->addInput(new Form_Input(
610 a97531c5 Sjon Hortensius
	'timeservers',
611 a32c0623 Sjon Hortensius
	'Timeservers',
612
	'text',
613
	$pconfig['timeservers']
614
))->setHelp('Use a space to separate multiple hosts (only one required). '.
615 1bab4a10 NOYB
	'Remember to set up at least one DNS server if a host name is entered here!');
616 c1f9ca7a Stephen Beaver
617 a005a836 Sjon Hortensius
$section->addInput(new Form_Select(
618 a97531c5 Sjon Hortensius
	'language',
619 51685157 Phil Davis
	'*Language',
620 a32c0623 Sjon Hortensius
	$pconfig['language'],
621
	get_locale_list()
622
))->setHelp('Choose a language for the webConfigurator');
623 b40bcb23 Sjon Hortensius
624
$form->add($section);
625
626 1176360c k-paulius
$section = new Form_Section('webConfigurator');
627 a5995a8e Stephen Beaver
628 595b074d Phil Davis
gen_webguicss_field($section, $pconfig['webguicss']);
629
gen_webguifixedmenu_field($section, $pconfig['webguifixedmenu']);
630
gen_webguihostnamemenu_field($section, $pconfig['webguihostnamemenu']);
631
gen_dashboardcolumns_field($section, $pconfig['dashboardcolumns']);
632 3666d731 Phil Davis
gen_interfacessort_field($section, $pconfig['interfacessort']);
633 595b074d Phil Davis
gen_associatedpanels_fields(
634
	$section,
635
	$pconfig['dashboardavailablewidgetspanel'],
636
	$pconfig['systemlogsfilterpanel'],
637
	$pconfig['systemlogsmanagelogpanel'],
638
	$pconfig['statusmonitoringsettingspanel']);
639 05a13eba derelict-pf
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
640 595b074d Phil Davis
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
641 24f15b3a NOYB
642 1605d940 Steve Beaver
$section->addInput(new Form_Select(
643
	'logincss',
644
	'Login page color',
645
	$pconfig['logincss'],
646
	["1e3f75;" => gettext("Blue"), "003300" => gettext("Green"), "770101" => gettext("Red"),
647
	 "4b1263" => gettext("Purple"), "424142" => gettext("Gray"), "333333" => gettext("Dark gray"),
648
	 "633215" => gettext("Brown" ), "bf7703" => gettext("Orange")]
649
))->setHelp('Choose a color for the login page');
650
651 506fe755 Steve Beaver
$section->addInput(new Form_Checkbox(
652
	'loginshowhost',
653
	'Login hostname',
654
	'Show hostname on login banner',
655
	$pconfig['loginshowhost']
656
));
657 5e024279 Steve Beaver
/*
658 c1f9ca7a Stephen Beaver
$section->addInput(new Form_Input(
659
	'dashboardperiod',
660
	'Dashboard update period',
661
	'number',
662
	$pconfig['dashboardperiod'],
663 6d203ffc Stephen Beaver
	['min' => '5', 'max' => '600']
664 c1f9ca7a Stephen Beaver
))->setHelp('Time in seconds between dashboard widget updates. Small values cause ' .
665
			'more frequent updates but increase the load on the web server. ' .
666
			'Minimum is 5 seconds, maximum 600 seconds');
667 5e024279 Steve Beaver
*/
668 a5995a8e Stephen Beaver
$form->add($section);
669
670 b40bcb23 Sjon Hortensius
print $form;
671 ee7c0a00 Stephen Beaver
672
$csswarning = sprintf(gettext("%sUser-created themes are unsupported, use at your own risk."), "<br />");
673
674 8c4ef875 NOYB
?>
675
</div>
676 ee7c0a00 Stephen Beaver
677 e296b399 Colin Fleming
<script type="text/javascript">
678 ee7c0a00 Stephen Beaver
//<![CDATA[
679
events.push(function() {
680
681
	function setThemeWarning() {
682
		if ($('#webguicss').val().startsWith("pfSense")) {
683
			$('#csstxt').html("").addClass("text-default");
684
		} else {
685
			$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
686
		}
687
	}
688
689
	$('#webguicss').change(function() {
690
		setThemeWarning();
691
	});
692
693
	setThemeWarning();
694 d88f26df Phil Davis
695
	// Suppress "Delete row" button if there are fewer than two rows
696
	checkLastRow();
697 ee7c0a00 Stephen Beaver
});
698
//]]>
699
</script>
700
701 8c4ef875 NOYB
<?php
702 60ff91f1 Renato Botelho
include("foot.inc");
703 8c4ef875 NOYB
?>