Project

General

Profile

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

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

    
439
		if ($changecount > 0) {
440
			write_config($changedesc);
441
		}
442

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

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

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

    
464
	unset($ignore_posted_dnsgw);
465
}
466

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

    
470
if ($input_errors) {
471
	print_input_errors($input_errors);
472
}
473

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

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

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

    
504
$form->add($section);
505

    
506
$section = new Form_Section('DNS Server Settings');
507

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

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

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

    
525
foreach ($pconfig['dnsserver'] as $dnsserver) {
526

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

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

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

    
545
	if ($multiwan)	{
546
		$options = array('none' => 'none');
547

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

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

    
557
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
558
		}
559

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

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

    
575
	$section->add($group);
576
	$dnsserver_num++;
577
}
578

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

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

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

    
606
$form->add($section);
607

    
608
$section = new Form_Section('Localization');
609

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

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

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

    
633
$form->add($section);
634

    
635
$section = new Form_Section('webConfigurator');
636

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

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

    
659
$section->addInput(new Form_Select(
660
	'logincss',
661
	'Login page color',
662
	$pconfig['logincss'],
663
	["1e3f75;" => gettext("Dark Blue"), "003300" => gettext("Dark green"), "770101" => gettext("Crimson red"),
664
	 "4b1263" => gettext("Purple"), "424142" => gettext("Gray"), "333333" => gettext("Dark gray"),
665
	 "000000" => gettext("Black"), "633215" => gettext("Dark brown"), "bf7703" => gettext("Brown"), 
666
	 "008000" => gettext("Green"), "007faa" => gettext("Light Blue"), "dc2a2a" => gettext("Red"),
667
	 "9b59b6" => gettext("Violet")]
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
?>
(193-193/235)