Project

General

Profile

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