Project

General

Profile

Download (25.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * system.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2019 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * originally based on m0n0wall (http://m0n0.ch/wall)
10
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
 * All rights reserved.
12
 *
13
 * 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
 *
17
 * http://www.apache.org/licenses/LICENSE-2.0
18
 *
19
 * 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
 */
25

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

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

    
39
$pconfig['hostname'] = $config['system']['hostname'];
40
$pconfig['domain'] = $config['system']['domain'];
41
$pconfig['dnsserver'] = $config['system']['dnsserver'];
42

    
43
$arr_gateways = return_gateways_array();
44

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

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

    
55
$dnshost_counter = 1;
56

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

    
63
$dnsgw_counter = 1;
64

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

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

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

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

    
105
$changedesc = gettext("System") . ": ";
106
$changecount = 0;
107

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

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

    
116
$timezonelist = system_get_timezone_list();
117
$timezonedesc = $timezonelist;
118

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

    
132
	$direction = substr($desc, 7, 1);
133

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

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

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

    
158
if ($_POST) {
159

    
160
	$changecount++;
161

    
162
	unset($input_errors);
163
	$pconfig = $_POST;
164

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

    
169
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
170

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

    
188
	$dnslist = $ignore_posted_dnsgw = array();
189

    
190
	$dnscounter = 0;
191
	$dnsname = "dns{$dnscounter}";
192

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

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

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

    
227
	$dnscounter = 0;
228
	$dnsname = "dns{$dnscounter}";
229

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

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

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

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

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

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

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

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

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

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

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

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

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

    
298
		$config['system']['webgui']['roworderdragging'] = $_POST['roworderdragging'] ? true:false;
299

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

    
306
		$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
307

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

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

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

    
326
		$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
327

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

    
332
		$dnscounter = 0;
333
		$dnsname = "dns{$dnscounter}";
334

    
335
		while (isset($_POST[$dnsname])) {
336
			if ($_POST[$dnsname]) {
337
				$config['system']['dnsserver'][] = $_POST[$dnsname];
338
			}
339
			$dnscounter++;
340
			$dnsname = "dns{$dnscounter}";
341
		}
342

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

    
346
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
347

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

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

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

    
373
			$olddnsgwname = $config['system'][$dnsgwconfigname];
374
			$olddnshostname = $config['system'][$dnshostconfigname];
375

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

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

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

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

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

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

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

    
443
		if ($changecount > 0) {
444
			write_config($changedesc);
445
		}
446

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

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

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

    
468
	unset($ignore_posted_dnsgw);
469
}
470

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

    
474
if ($input_errors) {
475
	print_input_errors($input_errors);
476
}
477

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

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

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

    
508
$form->add($section);
509

    
510
$section = new Form_Section('DNS Server Settings');
511

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

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

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

    
529
foreach ($pconfig['dnsserver'] as $dnsserver) {
530

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

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

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

    
549
	if ($multiwan)	{
550
		$options = array('none' => 'none');
551

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

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

    
561
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
562
		}
563

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

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

    
579
	$section->add($group);
580
	$dnsserver_num++;
581
}
582

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

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

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

    
610
$form->add($section);
611

    
612
$section = new Form_Section('Localization');
613

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

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

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

    
637
$form->add($section);
638

    
639
$section = new Form_Section('webConfigurator');
640

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

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

    
663
$section->addInput(new Form_Select(
664
	'logincss',
665
	'Login page color',
666
	$pconfig['logincss'],
667
	["1e3f75;" => gettext("Dark Blue"), "003300" => gettext("Dark green"), "770101" => gettext("Crimson red"),
668
	 "4b1263" => gettext("Purple"), "424142" => gettext("Gray"), "333333" => gettext("Dark gray"),
669
	 "000000" => gettext("Black"), "633215" => gettext("Dark brown"), "bf7703" => gettext("Brown"), 
670
	 "008000" => gettext("Green"), "007faa" => gettext("Light Blue"), "dc2a2a" => gettext("Red"),
671
	 "9b59b6" => gettext("Violet")]
672
))->setHelp('Choose a color for the login page');
673

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

    
693
print $form;
694

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

    
697
?>
698
</div>
699

    
700
<script type="text/javascript">
701
//<![CDATA[
702
events.push(function() {
703

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

    
712
	$('#webguicss').change(function() {
713
		setThemeWarning();
714
	});
715

    
716
	setThemeWarning();
717

    
718
	// Suppress "Delete row" button if there are fewer than two rows
719
	checkLastRow();
720
});
721
//]]>
722
</script>
723

    
724
<?php
725
include("foot.inc");
726
?>
(193-193/235)