Project

General

Profile

Download (26.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-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2021 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'] = $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 = 0;
153
$interfaces = get_configured_interface_list();
154
foreach ($interfaces as $interface) {
155
	if (interface_has_gateway($interface)) {
156
		$multiwan++;
157
		if ($multiwan > 1) {
158
			break;
159
		}
160
	}
161
}
162

    
163
if ($_POST) {
164

    
165
	$changecount++;
166

    
167
	unset($input_errors);
168
	$pconfig = $_POST;
169

    
170
	/* input validation */
171
	$reqdfields = explode(" ", "hostname domain");
172
	$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
173

    
174
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
175

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

    
193
	$dnslist = $ignore_posted_dnsgw = array();
194

    
195
	$dnscounter = 0;
196
	$dnsname = "dns{$dnscounter}";
197

    
198
	while (isset($_POST[$dnsname])) {
199
		$dnsgwname = "dnsgw{$dnscounter}";
200
		$dnshostname = "dnshost{$dnscounter}";
201
		$dnslist[] = $_POST[$dnsname];
202

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

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

    
232
	$dnscounter = 0;
233
	$dnsname = "dns{$dnscounter}";
234

    
235
	$direct_networks_list = explode(" ", filter_get_direct_networks_list());
236
	while (isset($_POST[$dnsname])) {
237
		$dnsgwname = "dnsgw{$dnscounter}";
238
		if ($_POST[$dnsgwname] && ($_POST[$dnsgwname] <> "none")) {
239
			foreach ($direct_networks_list as $direct_network) {
240
				if (ip_in_subnet($_POST[$dnsname], $direct_network)) {
241
					$input_errors[] = sprintf(gettext("A gateway cannot be specified for %s because that IP address is part of a directly connected subnet %s. To use that nameserver, change its Gateway to `none`."), $_POST[$dnsname], $direct_network);
242
				}
243
			}
244
		}
245
		$dnscounter++;
246
		$dnsname = "dns{$dnscounter}";
247
	}
248

    
249
	# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
250
	$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
251
	$_POST['timeservers'] = trim($_POST['timeservers']);
252
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
253
		if (!is_domain($ts) && (!is_ipaddr($ts))) {
254
			$input_errors[] = gettext("NTP Time Server names must be valid domain names, IPv4 addresses, or IPv6 addresses");
255
		}
256
	}
257

    
258
	if ($input_errors) {
259
		// Put the user-entered list back into place so it will be redisplayed for correction.
260
		$pconfig['dnsserver'] = $dnslist;
261
	} else {
262
		// input validation passed, so we can proceed with removing static routes for dead DNS gateways
263
		if (is_array($config['system']['dnsserver'])) {
264
		  	$dns_servers_arr = $config['system']['dnsserver'];
265
	 		foreach ($dns_servers_arr as $arr_index => $this_dnsserver) {
266
	   			$i = (int)$arr_index + 1;
267
	   			$this_dnsgw = $config['system']['dns'.$i.'gw'];
268
				unset($gatewayip);
269
				unset($inet6);
270
				if ((!empty($this_dnsgw)) && ($this_dnsgw != 'none') && (!empty($this_dnsserver))) {
271
					$gatewayip = lookup_gateway_ip_by_name($this_dnsgw);
272
					$inet6 = is_ipaddrv6($gatewayip) ? '-inet6 ' : '';
273
					mwexec("/sbin/route -q delete -host {$inet6}{$this_dnsserver} " . escapeshellarg($gatewayip));
274
				}
275
			}
276
		}
277

    
278
		update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
279
		update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
280
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
281
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
282

    
283
		if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
284
			$config['system']['language'] = $_POST['language'];
285
			set_language();
286
		}
287

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

    
291
		unset($config['system']['webgui']['webguileftcolumnhyper']);
292
		$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
293

    
294
		unset($config['system']['webgui']['disablealiaspopupdetail']);
295
		$config['system']['webgui']['disablealiaspopupdetail'] = $_POST['disablealiaspopupdetail'] ? true : false;
296

    
297
		unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
298
		$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
299

    
300
		unset($config['system']['webgui']['systemlogsfilterpanel']);
301
		$config['system']['webgui']['systemlogsfilterpanel'] = $_POST['systemlogsfilterpanel'] ? true : false;
302

    
303
		unset($config['system']['webgui']['systemlogsmanagelogpanel']);
304
		$config['system']['webgui']['systemlogsmanagelogpanel'] = $_POST['systemlogsmanagelogpanel'] ? true : false;
305

    
306
		unset($config['system']['webgui']['statusmonitoringsettingspanel']);
307
		$config['system']['webgui']['statusmonitoringsettingspanel'] = $_POST['statusmonitoringsettingspanel'] ? true : false;
308

    
309
//		if ($_POST['dashboardperiod']) {
310
//			$config['widgets']['period'] = $_POST['dashboardperiod'];
311
//		}
312

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

    
319
		$config['system']['webgui']['roworderdragging'] = $_POST['roworderdragging'] ? true:false;
320

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

    
327
		$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
328

    
329
		if ($_POST['webguifixedmenu']) {
330
			$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
331
		} else {
332
			unset($config['system']['webgui']['webguifixedmenu']);
333
		}
334

    
335
		if ($_POST['webguihostnamemenu']) {
336
			$config['system']['webgui']['webguihostnamemenu'] = $_POST['webguihostnamemenu'];
337
		} else {
338
			unset($config['system']['webgui']['webguihostnamemenu']);
339
		}
340

    
341
		if ($_POST['dashboardcolumns']) {
342
			$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
343
		} else {
344
			unset($config['system']['webgui']['dashboardcolumns']);
345
		}
346

    
347
		$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
348

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

    
353
		$dnscounter = 0;
354
		$dnsname = "dns{$dnscounter}";
355

    
356
		while (isset($_POST[$dnsname])) {
357
			if ($_POST[$dnsname]) {
358
				$config['system']['dnsserver'][] = $_POST[$dnsname];
359
			}
360
			$dnscounter++;
361
			$dnsname = "dns{$dnscounter}";
362
		}
363

    
364
		// Remember the new list for display also.
365
		$pconfig['dnsserver'] = $config['system']['dnsserver'];
366

    
367
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
368

    
369
		unset($config['system']['dnsallowoverride']);
370
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
371

    
372
		if ($_POST['dnslocalhost']) {
373
			$config['system']['dnslocalhost'] = $_POST['dnslocalhost'];
374
		} else {
375
			unset($config['system']['dnslocalhost']);
376
		}
377

    
378
		/* which interface should the dns servers resolve through? */
379
		$dnscounter = 0;
380
		// The $_POST array key of the DNS IP (starts from 0)
381
		$dnsname = "dns{$dnscounter}";
382
		$outdnscounter = 0;
383
		while (isset($_POST[$dnsname])) {
384
			// The $_POST array key of the corresponding gateway (starts from 0)
385
			$dnsgwname = "dnsgw{$dnscounter}";
386
			$dnshostname = "dnshost{$dnscounter}";
387
			// The numbering of DNS GW/host entries in the config starts from 1
388
			$dnsgwconfigcounter = $dnscounter + 1;
389
			$dnshostconfigcounter = $dnscounter + 1;
390
			// So this is the array key of the DNS GW entry in $config['system']
391
			$dnsgwconfigname = "dns{$dnsgwconfigcounter}gw";
392
			$dnshostconfigname = "dns{$dnshostconfigcounter}host";
393

    
394
			$olddnsgwname = $config['system'][$dnsgwconfigname];
395
			$olddnshostname = $config['system'][$dnshostconfigname];
396

    
397
			if ($ignore_posted_dnsgw[$dnsgwname]) {
398
				$thisdnsgwname = "none";
399
			} else {
400
				$thisdnsgwname = $pconfig[$dnsgwname];
401
			}
402
			$thisdnshostname = $pconfig[$dnshostname];
403

    
404
			// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
405
			$config['system'][$dnsgwconfigname] = "none";
406
			$pconfig[$dnsgwname] = "none";
407
			$config['system'][$dnshostconfigname] = "";
408
			$pconfig[$dnshostname] = "";
409
			$pconfig[$dnsname] = "";
410

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

    
416
				// The $pconfig array key of the DNS IP (starts from 0)
417
				$outdnsname = "dns{$outdnscounter}";
418
				// The $pconfig array key of the corresponding gateway (starts from 0)
419
				$outdnsgwname = "dnsgw{$outdnscounter}";
420
				// The $pconfig array key of the corresponding hostname (starts from 0)
421
				$outdnshostname = "dnshost{$outdnscounter}";
422

    
423
				// The numbering of DNS GW/host entries in the config starts from 1
424
				$outdnsgwconfigcounter = $outdnscounter + 1;
425
				$outdnshostconfigcounter = $outdnscounter + 1;
426
				// So this is the array key of the output DNS GW entry in $config['system']
427
				$outdnsgwconfigname = "dns{$outdnsgwconfigcounter}gw";
428
				$outdnshostconfigname = "dns{$outdnshostconfigcounter}host";
429

    
430
				$pconfig[$outdnsname] = $_POST[$dnsname];
431
				if ($_POST[$dnsgwname]) {
432
					$config['system'][$outdnsgwconfigname] = $thisdnsgwname;
433
					$pconfig[$outdnsgwname] = $thisdnsgwname;
434
				} else {
435
					// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
436
					unset($config['system'][$outdnsgwconfigname]);
437
					$pconfig[$outdnsgwname] = "";
438
				}
439
				if ($_POST[$dnshostname]) {
440
					$config['system'][$outdnshostconfigname] = $thisdnshostname;
441
					$pconfig[$outdnshostname] = $thisdnshostname;
442
				} else {
443
					// Note: when no DNS hostname is chosen, unset the value.
444
					unset($config['system'][$outdnshostconfigname]);
445
					$pconfig[$outdnshostname] = "";
446
				}
447
				$outdnscounter++;
448
			}
449

    
450
			$dnscounter++;
451
			// The $_POST array key of the DNS IP (starts from 0)
452
			$dnsname = "dns{$dnscounter}";
453
		}
454

    
455
		// clean up dnsgw orphans
456
		$oldgwcounter = 1;
457
		$olddnsgwconfigname = "dns{$oldgwcounter}gw";
458
		while (isset($config['system'][$olddnsgwconfigname])) {
459
			if (empty($config['system']['dnsserver'][$oldgwcounter - 1])) {
460
				unset($config['system'][$olddnsgwconfigname]);
461
			}
462
			$oldgwcounter++;
463
			$olddnsgwconfigname = "dns{$oldgwcounter}gw";
464
		}
465
		unset($oldgwcounter);
466
		unset($olddnsgwconfigname);
467

    
468
		if ($changecount > 0) {
469
			write_config($changedesc);
470
		}
471

    
472
		$changes_applied = true;
473
		$retval = 0;
474
		$retval |= system_hostname_configure();
475
		$retval |= system_hosts_generate();
476
		$retval |= system_resolvconf_generate();
477
		if (isset($config['dnsmasq']['enable'])) {
478
			$retval |= services_dnsmasq_configure();
479
		} elseif (isset($config['unbound']['enable'])) {
480
			$retval |= services_unbound_configure();
481
		}
482
		$retval |= system_timezone_configure();
483
		$retval |= system_ntp_configure();
484

    
485
		if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
486
			$retval |= send_event("service reload dns");
487
		}
488

    
489
		// Reload the filter - plugins might need to be run.
490
		$retval |= filter_configure();
491
	}
492

    
493
	unset($ignore_posted_dnsgw);
494
}
495

    
496
$pgtitle = array(gettext("System"), gettext("General Setup"));
497
include("head.inc");
498

    
499
if ($input_errors) {
500
	print_input_errors($input_errors);
501
}
502

    
503
if ($changes_applied) {
504
	print_apply_result_box($retval);
505
}
506
?>
507
<div id="container">
508
<?php
509

    
510
$form = new Form;
511
$section = new Form_Section('System');
512
$section->addInput(new Form_Input(
513
	'hostname',
514
	'*Hostname',
515
	'text',
516
	$pconfig['hostname'],
517
	['placeholder' => 'pfSense']
518
))->setHelp('Name of the firewall host, without domain part');
519

    
520
$section->addInput(new Form_Input(
521
	'domain',
522
	'*Domain',
523
	'text',
524
	$pconfig['domain'],
525
	['placeholder' => 'example.com, home, office, private, etc.']
526
))->setHelp('Do not end the domain name with \'.local\' as the final part (Top Level Domain, TLD), ' .
527
	'The \'local\' TLD is %1$swidely used%2$s by mDNS (e.g. Avahi, Bonjour, Rendezvous, Airprint, Airplay) ' .
528
	'and some Windows systems and networked devices. ' .
529
	'These will not network correctly if the router uses \'local\' as its TLD. ' .
530
	'Alternative TLDs such as \'local.lan\' or \'mylocal\' are safe.',
531
	'<a target="_blank" href="https://www.unbound.net/pipermail/unbound-users/2011-March/001735.html">',
532
	'</a>'
533
);
534

    
535
$form->add($section);
536

    
537
$section = new Form_Section('DNS Server Settings');
538

    
539
if (!is_array($pconfig['dnsserver'])) {
540
	$pconfig['dnsserver'] = array();
541
}
542

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

    
551
// If there are no DNS servers, make an empty entry for initial display.
552
if ($dnsserver_count == 0) {
553
	$pconfig['dnsserver'][] = '';
554
}
555

    
556
foreach ($pconfig['dnsserver'] as $dnsserver) {
557

    
558
	$is_last_dnsserver = (($dnsserver_num == $dnsserver_count - 1) || $dnsserver_count == 0);
559
	$group = new Form_Group($dnsserver_num == 0 ? 'DNS Servers':'');
560
	$group->addClass('repeatable');
561

    
562
	$group->add(new Form_Input(
563
		'dns' . $dnsserver_num,
564
		'DNS Server',
565
		'text',
566
		$dnsserver
567
	))->setHelp(($is_last_dnsserver) ? $dnsserver_help:null);
568

    
569
	$group->add(new Form_Input(
570
		'dnshost' . $dnsserver_num,
571
		'DNS Hostname',
572
		'text',
573
		$pconfig['dnshost' . $dnsserver_num]
574
	))->setHelp(($is_last_dnsserver) ? $dnshost_help:null);
575

    
576
	if ($multiwan > 1) {
577
		$options = array('none' => 'none');
578

    
579
		foreach ($arr_gateways as $gwname => $gwitem) {
580
			if ((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
581
				continue;
582
			}
583

    
584
			if ((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
585
				continue;
586
			}
587

    
588
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
589
		}
590

    
591
		$group->add(new Form_Select(
592
			'dnsgw' . $dnsserver_num,
593
			'Gateway',
594
			$pconfig['dnsgw' . $dnsserver_num],
595
			$options
596
		))->setWidth(4)->setHelp(($is_last_dnsserver) ? $dnsgw_help:null);
597
	}
598

    
599
	$group->add(new Form_Button(
600
		'deleterow' . $dnsserver_num,
601
		'Delete',
602
		null,
603
		'fa-trash'
604
	))->setWidth(2)->addClass('btn-warning');
605

    
606
	$section->add($group);
607
	$dnsserver_num++;
608
}
609

    
610
$section->addInput(new Form_Button(
611
	'addrow',
612
	'Add DNS Server',
613
	null,
614
	'fa-plus'
615
))->addClass('btn-success addbtn');
616

    
617
$section->addInput(new Form_Checkbox(
618
	'dnsallowoverride',
619
	'DNS Server Override',
620
	'Allow DNS server list to be overridden by DHCP/PPP on WAN',
621
	$pconfig['dnsallowoverride']
622
))->setHelp('If this option is set, %s will use DNS servers '.
623
	'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
624
	'the DNS Forwarder/DNS Resolver). However, they will not be assigned to DHCP '.
625
	'clients.', $g['product_label']);
626

    
627
$section->addInput(new Form_Select(
628
	'dnslocalhost',
629
	'DNS Resolution Behavior',
630
	$pconfig['dnslocalhost'],
631
	array(
632
		''       => 'Use local DNS (127.0.0.1), fall back to remote DNS Servers (Default)',
633
		'local'  => 'Use local DNS (127.0.0.1), ignore remote DNS Servers',
634
		'remote' => 'Use remote DNS Servers, ignore local DNS',
635
	)
636
))->setHelp('By default the firewall will use local DNS service (127.0.0.1, DNS '.
637
	'Resolver or Forwarder) as the first DNS server when possible, and it '.
638
	'will fall back to remote DNS servers otherwise. Use this option to '.
639
	'choose alternate behaviors.');
640

    
641
$form->add($section);
642

    
643
$section = new Form_Section('Localization');
644

    
645
$section->addInput(new Form_Select(
646
	'timezone',
647
	'*Timezone',
648
	$pconfig['timezone'],
649
	array_combine($timezonelist, $timezonedesc)
650
))->setHelp('Select a geographic region name (Continent/Location) to determine the timezone for the firewall. %1$s' .
651
	'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/>');
652

    
653
$section->addInput(new Form_Input(
654
	'timeservers',
655
	'Timeservers',
656
	'text',
657
	$pconfig['timeservers']
658
))->setHelp('Use a space to separate multiple hosts (only one required). '.
659
	'Remember to set up at least one DNS server if a host name is entered here!');
660

    
661
$section->addInput(new Form_Select(
662
	'language',
663
	'*Language',
664
	$pconfig['language'],
665
	get_locale_list()
666
))->setHelp('Choose a language for the webConfigurator');
667

    
668
$form->add($section);
669

    
670
$section = new Form_Section('webConfigurator');
671

    
672
gen_webguicss_field($section, $pconfig['webguicss']);
673
gen_webguifixedmenu_field($section, $pconfig['webguifixedmenu']);
674
gen_webguihostnamemenu_field($section, $pconfig['webguihostnamemenu']);
675
gen_dashboardcolumns_field($section, $pconfig['dashboardcolumns']);
676
gen_interfacessort_field($section, $pconfig['interfacessort']);
677
gen_associatedpanels_fields(
678
	$section,
679
	$pconfig['dashboardavailablewidgetspanel'],
680
	$pconfig['systemlogsfilterpanel'],
681
	$pconfig['systemlogsmanagelogpanel'],
682
	$pconfig['statusmonitoringsettingspanel']);
683
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
684
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
685
gen_disablealiaspopupdetail_field($section, $pconfig['disablealiaspopupdetail']);
686

    
687
$section->addInput(new Form_Checkbox(
688
	'roworderdragging',
689
	'Disable dragging',
690
	'Disable dragging of firewall/NAT rules',
691
	$pconfig['roworderdragging']
692
))->setHelp('Disables dragging rows to allow selecting and copying row contents and avoid accidental changes.');
693

    
694
$section->addInput(new Form_Select(
695
	'logincss',
696
	'Login page color',
697
	$pconfig['logincss'],
698
	["1e3f75;" => gettext("Dark Blue"), "003300" => gettext("Dark green"), "770101" => gettext("Crimson red"),
699
	 "4b1263" => gettext("Purple"), "424142" => gettext("Gray"), "333333" => gettext("Dark gray"),
700
	 "000000" => gettext("Black"), "633215" => gettext("Dark brown"), "bf7703" => gettext("Brown"), 
701
	 "008000" => gettext("Green"), "007faa" => gettext("Light Blue"), "dc2a2a" => gettext("Red"),
702
	 "9b59b6" => gettext("Violet")]
703
))->setHelp('Choose a color for the login page');
704

    
705
$section->addInput(new Form_Checkbox(
706
	'loginshowhost',
707
	'Login hostname',
708
	'Show hostname on login banner',
709
	$pconfig['loginshowhost']
710
));
711
/*
712
$section->addInput(new Form_Input(
713
	'dashboardperiod',
714
	'Dashboard update period',
715
	'number',
716
	$pconfig['dashboardperiod'],
717
	['min' => '5', 'max' => '600']
718
))->setHelp('Time in seconds between dashboard widget updates. Small values cause ' .
719
			'more frequent updates but increase the load on the web server. ' .
720
			'Minimum is 5 seconds, maximum 600 seconds');
721
*/
722
$form->add($section);
723

    
724
print $form;
725

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

    
728
?>
729
</div>
730

    
731
<script type="text/javascript">
732
//<![CDATA[
733
events.push(function() {
734

    
735
	function setThemeWarning() {
736
		if ($('#webguicss').val().startsWith("pfSense")) {
737
			$('#csstxt').html("").addClass("text-default");
738
		} else {
739
			$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
740
		}
741
	}
742

    
743
	$('#webguicss').change(function() {
744
		setThemeWarning();
745
	});
746

    
747
	setThemeWarning();
748

    
749
	// Suppress "Delete row" button if there are fewer than two rows
750
	checkLastRow();
751
});
752
//]]>
753
</script>
754

    
755
<?php
756
include("foot.inc");
757
?>
(184-184/227)