Project

General

Profile

Download (25.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * system.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2019 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14
 *
15
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18
 *
19
 * http://www.apache.org/licenses/LICENSE-2.0
20
 *
21
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26
 */
27

    
28
##|+PRIV
29
##|*IDENT=page-system-generalsetup
30
##|*NAME=System: General Setup
31
##|*DESCR=Allow access to the 'System: General Setup' page.
32
##|*MATCH=system.php*
33
##|-PRIV
34

    
35
require_once("guiconfig.inc");
36
require_once("functions.inc");
37
require_once("filter.inc");
38
require_once("shaper.inc");
39
require_once("system.inc");
40

    
41
$pconfig['hostname'] = $config['system']['hostname'];
42
$pconfig['domain'] = $config['system']['domain'];
43
$pconfig['dnsserver'] = $config['system']['dnsserver'];
44

    
45
$arr_gateways = return_gateways_array();
46

    
47
// set default columns to two if unset
48
if (!isset($config['system']['webgui']['dashboardcolumns'])) {
49
	$config['system']['webgui']['dashboardcolumns'] = 2;
50
}
51

    
52
// set default language if unset
53
if (!isset($config['system']['language'])) {
54
	$config['system']['language'] = $g['language'];
55
}
56

    
57
$dnshost_counter = 1;
58

    
59
while (isset($config["system"]["dns{$dnshost_counter}host"])) {
60
	$pconfig_dnshost_counter = $dnshost_counter - 1;
61
	$pconfig["dnshost{$pconfig_dnshost_counter}"] = $config["system"]["dns{$dnshost_counter}host"];
62
	$dnshost_counter++;
63
}
64

    
65
$dnsgw_counter = 1;
66

    
67
while (isset($config["system"]["dns{$dnsgw_counter}gw"])) {
68
	$pconfig_dnsgw_counter = $dnsgw_counter - 1;
69
	$pconfig["dnsgw{$pconfig_dnsgw_counter}"] = $config["system"]["dns{$dnsgw_counter}gw"];
70
	$dnsgw_counter++;
71
}
72

    
73
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
74
$pconfig['timezone'] = $config['system']['timezone'];
75
$pconfig['timeservers'] = $config['system']['timeservers'];
76
$pconfig['language'] = $config['system']['language'];
77
$pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
78
$pconfig['logincss'] = $config['system']['webgui']['logincss'];
79
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
80
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
81
$pconfig['interfacessort'] = isset($config['system']['webgui']['interfacessort']);
82
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
83
$pconfig['disablealiaspopupdetail'] = isset($config['system']['webgui']['disablealiaspopupdetail']);
84
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
85
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
86
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
87
$pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
88
$pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu'];
89
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
90
//$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10";
91
$pconfig['roworderdragging'] = isset($config['system']['webgui']['roworderdragging']);
92
$pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']);
93
$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']);
94

    
95
if (!$pconfig['timezone']) {
96
	if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
97
		$pconfig['timezone'] = $g['default_timezone'];
98
	} else {
99
		$pconfig['timezone'] = "Etc/UTC";
100
	}
101
}
102

    
103
if (!$pconfig['timeservers']) {
104
	$pconfig['timeservers'] = "pool.ntp.org";
105
}
106

    
107
$changedesc = gettext("System") . ": ";
108
$changecount = 0;
109

    
110
function is_timezone($elt) {
111
	return !preg_match("/\/$/", $elt);
112
}
113

    
114
if ($pconfig['timezone'] <> $_POST['timezone']) {
115
	filter_pflog_start(true);
116
}
117

    
118
$timezonelist = system_get_timezone_list();
119
$timezonedesc = $timezonelist;
120

    
121
/*
122
 * Etc/GMT entries work the opposite way to what people expect.
123
 * Ref: https://github.com/eggert/tz/blob/master/etcetera and Redmine issue 7089
124
 * Add explanatory text to entries like:
125
 * Etc/GMT+1 and Etc/GMT-1
126
 * but not:
127
 * Etc/GMT or Etc/GMT+0
128
 */
129
foreach ($timezonedesc as $idx => $desc) {
130
	if (substr($desc, 0, 7) != "Etc/GMT" || substr($desc, 8, 1) == "0") {
131
		continue;
132
	}
133

    
134
	$direction = substr($desc, 7, 1);
135

    
136
	switch ($direction) {
137
	case '-':
138
		$direction_str = gettext('AHEAD of');
139
		break;
140
	case '+':
141
		$direction_str = gettext('BEHIND');
142
		break;
143
	default:
144
		continue 2;
145
	}
146

    
147
	$hr_offset = substr($desc, 8);
148
	$timezonedesc[$idx] = $desc . " " .
149
	    sprintf(ngettext('(%1$s hour %2$s GMT)', '(%1$s hours %2$s GMT)', intval($hr_offset)), $hr_offset, $direction_str);
150
}
151

    
152
$multiwan = false;
153
$interfaces = get_configured_interface_list();
154
foreach ($interfaces as $interface) {
155
	if (interface_has_gateway($interface)) {
156
		$multiwan = true;
157
	}
158
}
159

    
160
if ($_POST) {
161

    
162
	$changecount++;
163

    
164
	unset($input_errors);
165
	$pconfig = $_POST;
166

    
167
	/* input validation */
168
	$reqdfields = explode(" ", "hostname domain");
169
	$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
170

    
171
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
172

    
173
	if ($_POST['hostname']) {
174
		if (!is_hostname($_POST['hostname'])) {
175
			$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
176
		} else {
177
			if (!is_unqualified_hostname($_POST['hostname'])) {
178
				$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
179
			}
180
		}
181
	}
182
	if ($_POST['domain'] && !is_domain($_POST['domain'])) {
183
		$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
184
	}
185
	validate_webguicss_field($input_errors, $_POST['webguicss']);
186
	validate_webguifixedmenu_field($input_errors, $_POST['webguifixedmenu']);
187
	validate_webguihostnamemenu_field($input_errors, $_POST['webguihostnamemenu']);
188
	validate_dashboardcolumns_field($input_errors, $_POST['dashboardcolumns']);
189

    
190
	$dnslist = $ignore_posted_dnsgw = array();
191

    
192
	$dnscounter = 0;
193
	$dnsname = "dns{$dnscounter}";
194

    
195
	while (isset($_POST[$dnsname])) {
196
		$dnsgwname = "dnsgw{$dnscounter}";
197
		$dnshostname = "dnshost{$dnscounter}";
198
		$dnslist[] = $_POST[$dnsname];
199

    
200
		if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
201
			$input_errors[] = sprintf(gettext("A valid IP address must be specified for DNS server %s."), $dnscounter+1);
202
		} else {
203
			if (!empty($_POST[$dnshostname]) && !is_hostname($_POST[$dnshostname])) {
204
				$input_errors[] = sprintf(gettext('The hostname provided for DNS server "%1$s" is not valid.'), $_POST[$dnsname]);
205
			}
206
			if (($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
207
				// A real gateway has been selected.
208
				if (is_ipaddr($_POST[$dnsname])) {
209
					if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
210
						$input_errors[] = sprintf(gettext('The IPv6 gateway "%1$s" can not be specified for IPv4 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
211
					}
212
					if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
213
						$input_errors[] = sprintf(gettext('The IPv4 gateway "%1$s" can not be specified for IPv6 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
214
					}
215
				} else {
216
					// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
217
					$ignore_posted_dnsgw[$dnsgwname] = true;
218
				}
219
			}
220
		}
221
		$dnscounter++;
222
		$dnsname = "dns{$dnscounter}";
223
	}
224

    
225
	if (count(array_filter($dnslist)) != count(array_unique(array_filter($dnslist)))) {
226
		$input_errors[] = gettext('Each configured DNS server must have a unique IP address. Remove the duplicated IP.');
227
	}
228

    
229
	$dnscounter = 0;
230
	$dnsname = "dns{$dnscounter}";
231

    
232
	$direct_networks_list = explode(" ", filter_get_direct_networks_list());
233
	while (isset($_POST[$dnsname])) {
234
		$dnsgwname = "dnsgw{$dnscounter}";
235
		if ($_POST[$dnsgwname] && ($_POST[$dnsgwname] <> "none")) {
236
			foreach ($direct_networks_list as $direct_network) {
237
				if (ip_in_subnet($_POST[$dnsname], $direct_network)) {
238
					$input_errors[] = sprintf(gettext("A gateway can not be assigned to DNS '%s' server which is on a directly connected network."), $_POST[$dnsname]);
239
				}
240
			}
241
		}
242
		$dnscounter++;
243
		$dnsname = "dns{$dnscounter}";
244
	}
245

    
246
	# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
247
	$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
248
	$_POST['timeservers'] = trim($_POST['timeservers']);
249
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
250
		if (!is_domain($ts)) {
251
			$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
252
		}
253
	}
254

    
255
	if ($input_errors) {
256
		// Put the user-entered list back into place so it will be redisplayed for correction.
257
		$pconfig['dnsserver'] = $dnslist;
258
	} else {
259
		update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
260
		update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
261
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
262
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
263

    
264
		if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
265
			$config['system']['language'] = $_POST['language'];
266
			set_language();
267
		}
268

    
269
		unset($config['system']['webgui']['interfacessort']);
270
		$config['system']['webgui']['interfacessort'] = $_POST['interfacessort'] ? true : false;
271

    
272
		unset($config['system']['webgui']['webguileftcolumnhyper']);
273
		$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
274

    
275
		unset($config['system']['webgui']['disablealiaspopupdetail']);
276
		$config['system']['webgui']['disablealiaspopupdetail'] = $_POST['disablealiaspopupdetail'] ? true : false;
277

    
278
		unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
279
		$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
280

    
281
		unset($config['system']['webgui']['systemlogsfilterpanel']);
282
		$config['system']['webgui']['systemlogsfilterpanel'] = $_POST['systemlogsfilterpanel'] ? true : false;
283

    
284
		unset($config['system']['webgui']['systemlogsmanagelogpanel']);
285
		$config['system']['webgui']['systemlogsmanagelogpanel'] = $_POST['systemlogsmanagelogpanel'] ? true : false;
286

    
287
		unset($config['system']['webgui']['statusmonitoringsettingspanel']);
288
		$config['system']['webgui']['statusmonitoringsettingspanel'] = $_POST['statusmonitoringsettingspanel'] ? true : false;
289

    
290
//		if ($_POST['dashboardperiod']) {
291
//			$config['widgets']['period'] = $_POST['dashboardperiod'];
292
//		}
293

    
294
		if ($_POST['webguicss']) {
295
			$config['system']['webgui']['webguicss'] = $_POST['webguicss'];
296
		} else {
297
			unset($config['system']['webgui']['webguicss']);
298
		}
299

    
300
		$config['system']['webgui']['roworderdragging'] = $_POST['roworderdragging'] ? true:false;
301

    
302
		if ($_POST['logincss']) {
303
			$config['system']['webgui']['logincss'] = $_POST['logincss'];
304
		} else {
305
			unset($config['system']['webgui']['logincss']);
306
		}
307

    
308
		$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
309

    
310
		if ($_POST['webguifixedmenu']) {
311
			$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
312
		} else {
313
			unset($config['system']['webgui']['webguifixedmenu']);
314
		}
315

    
316
		if ($_POST['webguihostnamemenu']) {
317
			$config['system']['webgui']['webguihostnamemenu'] = $_POST['webguihostnamemenu'];
318
		} else {
319
			unset($config['system']['webgui']['webguihostnamemenu']);
320
		}
321

    
322
		if ($_POST['dashboardcolumns']) {
323
			$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
324
		} else {
325
			unset($config['system']['webgui']['dashboardcolumns']);
326
		}
327

    
328
		$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
329

    
330
		/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
331
		$olddnsservers = $config['system']['dnsserver'];
332
		unset($config['system']['dnsserver']);
333

    
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
		}
344

    
345
		// Remember the new list for display also.
346
		$pconfig['dnsserver'] = $config['system']['dnsserver'];
347

    
348
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
349

    
350
		unset($config['system']['dnsallowoverride']);
351
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
352

    
353
		if ($_POST['dnslocalhost'] == "yes") {
354
			$config['system']['dnslocalhost'] = true;
355
		} else {
356
			unset($config['system']['dnslocalhost']);
357
		}
358

    
359
		/* which interface should the dns servers resolve through? */
360
		$dnscounter = 0;
361
		// The $_POST array key of the DNS IP (starts from 0)
362
		$dnsname = "dns{$dnscounter}";
363
		$outdnscounter = 0;
364
		while (isset($_POST[$dnsname])) {
365
			// The $_POST array key of the corresponding gateway (starts from 0)
366
			$dnsgwname = "dnsgw{$dnscounter}";
367
			$dnshostname = "dnshost{$dnscounter}";
368
			// The numbering of DNS GW/host entries in the config starts from 1
369
			$dnsgwconfigcounter = $dnscounter + 1;
370
			$dnshostconfigcounter = $dnscounter + 1;
371
			// So this is the array key of the DNS GW entry in $config['system']
372
			$dnsgwconfigname = "dns{$dnsgwconfigcounter}gw";
373
			$dnshostconfigname = "dns{$dnshostconfigcounter}host";
374

    
375
			$olddnsgwname = $config['system'][$dnsgwconfigname];
376
			$olddnshostname = $config['system'][$dnshostconfigname];
377

    
378
			if ($ignore_posted_dnsgw[$dnsgwname]) {
379
				$thisdnsgwname = "none";
380
			} else {
381
				$thisdnsgwname = $pconfig[$dnsgwname];
382
			}
383
			$thisdnshostname = $pconfig[$dnshostname];
384

    
385
			// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
386
			$config['system'][$dnsgwconfigname] = "none";
387
			$pconfig[$dnsgwname] = "none";
388
			$config['system'][$dnshostconfigname] = "";
389
			$pconfig[$dnshostname] = "";
390
			$pconfig[$dnsname] = "";
391

    
392
			if ($_POST[$dnsname]) {
393
				// Only the non-blank DNS servers were put into the config above.
394
				// So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
395
				// 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.
396

    
397
				// The $pconfig array key of the DNS IP (starts from 0)
398
				$outdnsname = "dns{$outdnscounter}";
399
				// The $pconfig array key of the corresponding gateway (starts from 0)
400
				$outdnsgwname = "dnsgw{$outdnscounter}";
401
				// The $pconfig array key of the corresponding hostname (starts from 0)
402
				$outdnshostname = "dnshost{$outdnscounter}";
403

    
404
				// The numbering of DNS GW/host entries in the config starts from 1
405
				$outdnsgwconfigcounter = $outdnscounter + 1;
406
				$outdnshostconfigcounter = $outdnscounter + 1;
407
				// So this is the array key of the output DNS GW entry in $config['system']
408
				$outdnsgwconfigname = "dns{$outdnsgwconfigcounter}gw";
409
				$outdnshostconfigname = "dns{$outdnshostconfigcounter}host";
410

    
411
				$pconfig[$outdnsname] = $_POST[$dnsname];
412
				if ($_POST[$dnsgwname]) {
413
					$config['system'][$outdnsgwconfigname] = $thisdnsgwname;
414
					$pconfig[$outdnsgwname] = $thisdnsgwname;
415
					$config['system'][$outdnshostconfigname] = $thisdnshostname;
416
					$pconfig[$outdnshostname] = $thisdnshostname;
417
				} else {
418
					// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
419
					unset($config['system'][$outdnsgwconfigname]);
420
					$pconfig[$outdnsgwname] = "";
421
					unset($config['system'][$outdnshostconfigname]);
422
					$pconfig[$outdnshostname] = "";
423
				}
424
				$outdnscounter++;
425
			}
426
			if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter] != $_POST[$dnsname]))) {
427
				// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
428
				// Remove the route. Later calls will add the correct new route if needed.
429
				if (is_ipaddrv4($olddnsservers[$dnscounter])) {
430
					mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
431
				} else if (is_ipaddrv6($olddnsservers[$dnscounter])) {
432
					mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
433
				}
434
			}
435

    
436
			$dnscounter++;
437
			// The $_POST array key of the DNS IP (starts from 0)
438
			$dnsname = "dns{$dnscounter}";
439
		}
440

    
441
		if ($changecount > 0) {
442
			write_config($changedesc);
443
		}
444

    
445
		$changes_applied = true;
446
		$retval = 0;
447
		$retval |= system_hostname_configure();
448
		$retval |= system_hosts_generate();
449
		$retval |= system_resolvconf_generate();
450
		if (isset($config['dnsmasq']['enable'])) {
451
			$retval |= services_dnsmasq_configure();
452
		} elseif (isset($config['unbound']['enable'])) {
453
			$retval |= services_unbound_configure();
454
		}
455
		$retval |= system_timezone_configure();
456
		$retval |= system_ntp_configure();
457

    
458
		if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
459
			$retval |= send_event("service reload dns");
460
		}
461

    
462
		// Reload the filter - plugins might need to be run.
463
		$retval |= filter_configure();
464
	}
465

    
466
	unset($ignore_posted_dnsgw);
467
}
468

    
469
$pgtitle = array(gettext("System"), gettext("General Setup"));
470
include("head.inc");
471

    
472
if ($input_errors) {
473
	print_input_errors($input_errors);
474
}
475

    
476
if ($changes_applied) {
477
	print_apply_result_box($retval);
478
}
479
?>
480
<div id="container">
481
<?php
482

    
483
$form = new Form;
484
$section = new Form_Section('System');
485
$section->addInput(new Form_Input(
486
	'hostname',
487
	'*Hostname',
488
	'text',
489
	$pconfig['hostname'],
490
	['placeholder' => 'pfSense']
491
))->setHelp('Name of the firewall host, without domain part');
492

    
493
$section->addInput(new Form_Input(
494
	'domain',
495
	'*Domain',
496
	'text',
497
	$pconfig['domain'],
498
	['placeholder' => 'mycorp.com, home, office, private, etc.']
499
))->setHelp('Do not use \'.local\' as the final part of the domain (TLD), The \'.local\' domain is %1$swidely used%2$s by '.
500
	'mDNS (including Avahi and Apple OS X\'s Bonjour/Rendezvous/Airprint/Airplay), and some Windows systems and networked devices. ' .
501
	'These will not network correctly if the router uses \'.local\'. Alternatives such as \'.local.lan\' or \'.mylocal\' are safe.',
502
	 '<a target="_blank" href="https://www.unbound.net/pipermail/unbound-users/2011-March/001735.html">',
503
	 '</a>'
504
);
505

    
506
$form->add($section);
507

    
508
$section = new Form_Section('DNS Server Settings');
509

    
510
if (!is_array($pconfig['dnsserver'])) {
511
	$pconfig['dnsserver'] = array();
512
}
513

    
514
$dnsserver_count = count($pconfig['dnsserver']);
515
$dnsserver_num = 0;
516
$dnsserver_help = gettext("Address") . '<br/>' . gettext("Enter IP addresses to be used by the system for DNS resolution.") . " " .
517
	gettext("These are also used for the DHCP service, DNS Forwarder and DNS Resolver when it has DNS Query Forwarding enabled.");
518
$dnshost_help = gettext("Hostname") . '<br/>' . gettext("Enter the DNS Server Hostname for TLS Verification in the DNS Resolver (optional).");
519
$dnsgw_help = gettext("Gateway") . '<br/>'. gettext("Optionally select the gateway for each DNS server.") . " " .
520
	gettext("When using multiple WAN connections there should be at least one unique DNS server per gateway.");
521

    
522
// If there are no DNS servers, make an empty entry for initial display.
523
if ($dnsserver_count == 0) {
524
	$pconfig['dnsserver'][] = '';
525
}
526

    
527
foreach ($pconfig['dnsserver'] as $dnsserver) {
528

    
529
	$is_last_dnsserver = ($dnsserver_num == $dnsserver_count - 1);
530
	$group = new Form_Group($dnsserver_num == 0 ? 'DNS Servers':'');
531
	$group->addClass('repeatable');
532

    
533
	$group->add(new Form_Input(
534
		'dns' . $dnsserver_num,
535
		'DNS Server',
536
		'text',
537
		$dnsserver
538
	))->setHelp(($is_last_dnsserver) ? $dnsserver_help:null);
539

    
540
	$group->add(new Form_Input(
541
		'dnshost' . $dnsserver_num,
542
		'DNS Hostname',
543
		'text',
544
		$pconfig['dnshost' . $dnsserver_num]
545
	))->setHelp(($is_last_dnsserver) ? $dnshost_help:null);
546

    
547
	if ($multiwan)	{
548
		$options = array('none' => 'none');
549

    
550
		foreach ($arr_gateways as $gwname => $gwitem) {
551
			if ((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
552
				continue;
553
			}
554

    
555
			if ((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
556
				continue;
557
			}
558

    
559
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
560
		}
561

    
562
		$group->add(new Form_Select(
563
			'dnsgw' . $dnsserver_num,
564
			'Gateway',
565
			$pconfig['dnsgw' . $dnsserver_num],
566
			$options
567
		))->setHelp(($is_last_dnsserver) ? $dnsgw_help:null);;
568
	}
569

    
570
	$group->add(new Form_Button(
571
		'deleterow' . $dnsserver_num,
572
		'Delete',
573
		null,
574
		'fa-trash'
575
	))->addClass('btn-warning');
576

    
577
	$section->add($group);
578
	$dnsserver_num++;
579
}
580

    
581
$section->addInput(new Form_Button(
582
	'addrow',
583
	'Add DNS Server',
584
	null,
585
	'fa-plus'
586
))->addClass('btn-success addbtn');
587

    
588
$section->addInput(new Form_Checkbox(
589
	'dnsallowoverride',
590
	'DNS Server Override',
591
	'Allow DNS server list to be overridden by DHCP/PPP on WAN',
592
	$pconfig['dnsallowoverride']
593
))->setHelp('If this option is set, %s will use DNS servers '.
594
	'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
595
	'the DNS Forwarder/DNS Resolver). However, they will not be assigned to DHCP '.
596
	'clients.', $g['product_name']);
597

    
598
$section->addInput(new Form_Checkbox(
599
	'dnslocalhost',
600
	'Disable DNS Forwarder',
601
	'Do not use the DNS Forwarder/DNS Resolver as a DNS server for the firewall',
602
	$pconfig['dnslocalhost']
603
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS '.
604
	'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
605
	'listen on localhost, so system can use the local DNS service to perform '.
606
	'lookups. Checking this box omits localhost from the list of DNS servers in resolv.conf.');
607

    
608
$form->add($section);
609

    
610
$section = new Form_Section('Localization');
611

    
612
$section->addInput(new Form_Select(
613
	'timezone',
614
	'*Timezone',
615
	$pconfig['timezone'],
616
	array_combine($timezonelist, $timezonedesc)
617
))->setHelp('Select a geographic region name (Continent/Location) to determine the timezone for the firewall. %1$s' .
618
	'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/>');
619

    
620
$section->addInput(new Form_Input(
621
	'timeservers',
622
	'Timeservers',
623
	'text',
624
	$pconfig['timeservers']
625
))->setHelp('Use a space to separate multiple hosts (only one required). '.
626
	'Remember to set up at least one DNS server if a host name is entered here!');
627

    
628
$section->addInput(new Form_Select(
629
	'language',
630
	'*Language',
631
	$pconfig['language'],
632
	get_locale_list()
633
))->setHelp('Choose a language for the webConfigurator');
634

    
635
$form->add($section);
636

    
637
$section = new Form_Section('webConfigurator');
638

    
639
gen_webguicss_field($section, $pconfig['webguicss']);
640
gen_webguifixedmenu_field($section, $pconfig['webguifixedmenu']);
641
gen_webguihostnamemenu_field($section, $pconfig['webguihostnamemenu']);
642
gen_dashboardcolumns_field($section, $pconfig['dashboardcolumns']);
643
gen_interfacessort_field($section, $pconfig['interfacessort']);
644
gen_associatedpanels_fields(
645
	$section,
646
	$pconfig['dashboardavailablewidgetspanel'],
647
	$pconfig['systemlogsfilterpanel'],
648
	$pconfig['systemlogsmanagelogpanel'],
649
	$pconfig['statusmonitoringsettingspanel']);
650
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
651
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
652
gen_disablealiaspopupdetail_field($section, $pconfig['disablealiaspopupdetail']);
653

    
654
$section->addInput(new Form_Checkbox(
655
	'roworderdragging',
656
	'Disable dragging',
657
	'Disable dragging of firewall/nat rules.',
658
	$pconfig['roworderdragging']
659
))->setHelp('Disables dragging rows to allow selecting and copying row contents and avoid accidental changes.');
660

    
661
$section->addInput(new Form_Select(
662
	'logincss',
663
	'Login page color',
664
	$pconfig['logincss'],
665
	["1e3f75;" => gettext("Blue"), "003300" => gettext("Green"), "770101" => gettext("Red"),
666
	 "4b1263" => gettext("Purple"), "424142" => gettext("Gray"), "333333" => gettext("Dark gray"),
667
	 "633215" => gettext("Brown" ), "bf7703" => gettext("Orange")]
668
))->setHelp('Choose a color for the login page');
669

    
670
$section->addInput(new Form_Checkbox(
671
	'loginshowhost',
672
	'Login hostname',
673
	'Show hostname on login banner',
674
	$pconfig['loginshowhost']
675
));
676
/*
677
$section->addInput(new Form_Input(
678
	'dashboardperiod',
679
	'Dashboard update period',
680
	'number',
681
	$pconfig['dashboardperiod'],
682
	['min' => '5', 'max' => '600']
683
))->setHelp('Time in seconds between dashboard widget updates. Small values cause ' .
684
			'more frequent updates but increase the load on the web server. ' .
685
			'Minimum is 5 seconds, maximum 600 seconds');
686
*/
687
$form->add($section);
688

    
689
print $form;
690

    
691
$csswarning = sprintf(gettext("%sUser-created themes are unsupported, use at your own risk."), "<br />");
692

    
693
?>
694
</div>
695

    
696
<script type="text/javascript">
697
//<![CDATA[
698
events.push(function() {
699

    
700
	function setThemeWarning() {
701
		if ($('#webguicss').val().startsWith("pfSense")) {
702
			$('#csstxt').html("").addClass("text-default");
703
		} else {
704
			$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
705
		}
706
	}
707

    
708
	$('#webguicss').change(function() {
709
		setThemeWarning();
710
	});
711

    
712
	setThemeWarning();
713

    
714
	// Suppress "Delete row" button if there are fewer than two rows
715
	checkLastRow();
716
});
717
//]]>
718
</script>
719

    
720
<?php
721
include("foot.inc");
722
?>
(183-183/225)