Project

General

Profile

Download (24.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * system.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2018 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
$dnsgw_counter = 1;
56

    
57
while (isset($config["system"]["dns{$dnsgw_counter}gw"])) {
58
	$pconfig_dnsgw_counter = $dnsgw_counter - 1;
59
	$pconfig["dnsgw{$pconfig_dnsgw_counter}"] = $config["system"]["dns{$dnsgw_counter}gw"];
60
	$dnsgw_counter++;
61
}
62

    
63
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
64
$pconfig['timezone'] = $config['system']['timezone'];
65
$pconfig['timeservers'] = $config['system']['timeservers'];
66
$pconfig['language'] = $config['system']['language'];
67
$pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
68
$pconfig['logincss'] = $config['system']['webgui']['logincss'];
69
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
70
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
71
$pconfig['interfacessort'] = isset($config['system']['webgui']['interfacessort']);
72
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
73
$pconfig['disablealiaspopupdetail'] = isset($config['system']['webgui']['disablealiaspopupdetail']);
74
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
75
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
76
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
77
$pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
78
$pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu'];
79
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
80
//$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10";
81
$pconfig['roworderdragging'] = isset($config['system']['webgui']['roworderdragging']);
82
$pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']);
83
$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']);
84

    
85
if (!$pconfig['timezone']) {
86
	if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
87
		$pconfig['timezone'] = $g['default_timezone'];
88
	} else {
89
		$pconfig['timezone'] = "Etc/UTC";
90
	}
91
}
92

    
93
if (!$pconfig['timeservers']) {
94
	$pconfig['timeservers'] = "pool.ntp.org";
95
}
96

    
97
$changedesc = gettext("System") . ": ";
98
$changecount = 0;
99

    
100
function is_timezone($elt) {
101
	return !preg_match("/\/$/", $elt);
102
}
103

    
104
if ($pconfig['timezone'] <> $_POST['timezone']) {
105
	filter_pflog_start(true);
106
}
107

    
108
$timezonelist = system_get_timezone_list();
109
$timezonedesc = $timezonelist;
110

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

    
124
	$direction = substr($desc, 7, 1);
125

    
126
	switch ($direction) {
127
	case '-':
128
		$direction_str = gettext('AHEAD of');
129
		break;
130
	case '+':
131
		$direction_str = gettext('BEHIND');
132
		break;
133
	default:
134
		continue;
135
	}
136

    
137
	$hr_offset = substr($desc, 8);
138
	$timezonedesc[$idx] = $desc . " " .
139
	    sprintf(ngettext('(%1$s hour %2$s GMT)', '(%1$s hours %2$s GMT)', intval($hr_offset)), $hr_offset, $direction_str);
140
}
141

    
142
$multiwan = 0;
143
$interfaces = get_configured_interface_list();
144
foreach ($interfaces as $interface) {
145
	if (interface_has_gateway($interface)) {
146
		$multiwan++;
147
		if ($multiwan > 1) {
148
			break;
149
		}
150
	}
151
}
152

    
153
if ($_POST) {
154

    
155
	$changecount++;
156

    
157
	unset($input_errors);
158
	$pconfig = $_POST;
159

    
160
	/* input validation */
161
	$reqdfields = explode(" ", "hostname domain");
162
	$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
163

    
164
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
165

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

    
183
	$dnslist = $ignore_posted_dnsgw = array();
184

    
185
	$dnscounter = 0;
186
	$dnsname = "dns{$dnscounter}";
187

    
188
	while (isset($_POST[$dnsname])) {
189
		$dnsgwname = "dnsgw{$dnscounter}";
190
		$dnslist[] = $_POST[$dnsname];
191

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

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

    
218
	$dnscounter = 0;
219
	$dnsname = "dns{$dnscounter}";
220

    
221
	$direct_networks_list = explode(" ", filter_get_direct_networks_list());
222
	while (isset($_POST[$dnsname])) {
223
		$dnsgwname = "dnsgw{$dnscounter}";
224
		if ($_POST[$dnsgwname] && ($_POST[$dnsgwname] <> "none")) {
225
			foreach ($direct_networks_list as $direct_network) {
226
				if (ip_in_subnet($_POST[$dnsname], $direct_network)) {
227
					$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);
228
				}
229
			}
230
		}
231
		$dnscounter++;
232
		$dnsname = "dns{$dnscounter}";
233
	}
234

    
235
	# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
236
	$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
237
	$_POST['timeservers'] = trim($_POST['timeservers']);
238
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
239
		if (!is_domain($ts)) {
240
			$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
241
		}
242
	}
243

    
244
	if ($input_errors) {
245
		// Put the user-entered list back into place so it will be redisplayed for correction.
246
		$pconfig['dnsserver'] = $dnslist;
247
	} else {
248
		// input validation passed, so we can proceed with removing static routes for dead DNS gateways
249
		if (is_array($config['system']['dnsserver'])) {
250
		  	$dns_servers_arr = $config['system']['dnsserver'];
251
	 		foreach ($dns_servers_arr as $arr_index => $this_dnsserver) {
252
	   			$i = (int)$arr_index + 1;
253
	   			$this_dnsgw = $config['system']['dns'.$i.'gw'];
254
				unset($gatewayip);
255
				unset($inet6);
256
				if ((!empty($this_dnsgw)) && ($this_dnsgw != 'none') && (!empty($this_dnsserver))) {
257
					$gatewayip = lookup_gateway_ip_by_name($this_dnsgw);
258
					$inet6 = is_ipaddrv6($gatewayip) ? '-inet6 ' : '';
259
					mwexec("/sbin/route -q delete -host {$inet6}{$this_dnsserver}");
260
				}
261
			}
262
		}
263

    
264
		update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
265
		update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
266
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
267
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
268

    
269
		if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
270
			$config['system']['language'] = $_POST['language'];
271
			set_language();
272
		}
273

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

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

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

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

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

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

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

    
295
//		if ($_POST['dashboardperiod']) {
296
//			$config['widgets']['period'] = $_POST['dashboardperiod'];
297
//		}
298

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

    
305
		$config['system']['webgui']['roworderdragging'] = $_POST['roworderdragging'] ? true:false;
306

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

    
313
		$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
314

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

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

    
327
		if ($_POST['dashboardcolumns']) {
328
			$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
329
		} else {
330
			unset($config['system']['webgui']['dashboardcolumns']);
331
		}
332

    
333
		$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
334

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

    
339
		$dnscounter = 0;
340
		$dnsname = "dns{$dnscounter}";
341

    
342
		while (isset($_POST[$dnsname])) {
343
			if ($_POST[$dnsname]) {
344
				$config['system']['dnsserver'][] = $_POST[$dnsname];
345
			}
346
			$dnscounter++;
347
			$dnsname = "dns{$dnscounter}";
348
		}
349

    
350
		// Remember the new list for display also.
351
		$pconfig['dnsserver'] = $config['system']['dnsserver'];
352

    
353
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
354

    
355
		unset($config['system']['dnsallowoverride']);
356
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
357

    
358
		if ($_POST['dnslocalhost'] == "yes") {
359
			$config['system']['dnslocalhost'] = true;
360
		} else {
361
			unset($config['system']['dnslocalhost']);
362
		}
363

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

    
377
			$olddnsgwname = $config['system'][$dnsgwconfigname];
378

    
379
			if ($ignore_posted_dnsgw[$dnsgwname]) {
380
				$thisdnsgwname = "none";
381
			} else {
382
				$thisdnsgwname = $pconfig[$dnsgwname];
383
			}
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
			$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 numbering of DNS GW entries in the config starts from 1
400
				$outdnsgwconfigcounter = $outdnscounter + 1;
401
				// So this is the array key of the output DNS GW entry in $config['system']
402
				$outdnsgwconfigname = "dns{$outdnsgwconfigcounter}gw";
403

    
404
				$pconfig[$outdnsname] = $_POST[$dnsname];
405
				if ($_POST[$dnsgwname]) {
406
					$config['system'][$outdnsgwconfigname] = $thisdnsgwname;
407
					$pconfig[$outdnsgwname] = $thisdnsgwname;
408
				} else {
409
					// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
410
					unset($config['system'][$outdnsgwconfigname]);
411
					$pconfig[$outdnsgwname] = "";
412
				}
413
				$outdnscounter++;
414
			}
415

    
416
			$dnscounter++;
417
			// The $_POST array key of the DNS IP (starts from 0)
418
			$dnsname = "dns{$dnscounter}";
419
		}
420

    
421
		// clean up dnsgw orphans
422
		$oldgwcounter = 1;
423
		$olddnsgwconfigname = "dns{$oldgwcounter}gw";
424
		while (isset($config['system'][$olddnsgwconfigname])) {
425
			if (empty($config['system']['dnsserver'][$oldgwcounter - 1])) {
426
				unset($config['system'][$olddnsgwconfigname]);
427
			}
428
			$oldgwcounter++;
429
			$olddnsgwconfigname = "dns{$oldgwcounter}gw";
430
		}
431
		unset($oldgwcounter);
432
		unset($olddnsgwconfigname);
433

    
434
		if ($changecount > 0) {
435
			write_config($changedesc);
436
		}
437

    
438
		$changes_applied = true;
439
		$retval = 0;
440
		$retval |= system_hostname_configure();
441
		$retval |= system_hosts_generate();
442
		$retval |= system_resolvconf_generate();
443
		if (isset($config['dnsmasq']['enable'])) {
444
			$retval |= services_dnsmasq_configure();
445
		} elseif (isset($config['unbound']['enable'])) {
446
			$retval |= services_unbound_configure();
447
		}
448
		$retval |= system_timezone_configure();
449
		$retval |= system_ntp_configure();
450

    
451
		if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
452
			$retval |= send_event("service reload dns");
453
		}
454

    
455
		// Reload the filter - plugins might need to be run.
456
		$retval |= filter_configure();
457
	}
458

    
459
	unset($ignore_posted_dnsgw);
460
}
461

    
462
$pgtitle = array(gettext("System"), gettext("General Setup"));
463
include("head.inc");
464

    
465
if ($input_errors) {
466
	print_input_errors($input_errors);
467
}
468

    
469
if ($changes_applied) {
470
	print_apply_result_box($retval);
471
}
472
?>
473
<div id="container">
474
<?php
475

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

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

    
499
$form->add($section);
500

    
501
$section = new Form_Section('DNS Server Settings');
502

    
503
if (!is_array($pconfig['dnsserver'])) {
504
	$pconfig['dnsserver'] = array();
505
}
506

    
507
$dnsserver_count = count($pconfig['dnsserver']);
508
$dnsserver_num = 0;
509
$dnsserver_help = gettext("Address") . '<br/>' . gettext("Enter IP addresses to be used by the system for DNS resolution.") . " " .
510
	gettext("These are also used for the DHCP service, DNS Forwarder and DNS Resolver when it has DNS Query Forwarding enabled.");
511
$dnsgw_help = gettext("Gateway") . '<br/>'. gettext("Optionally select the gateway for each DNS server.") . " " .
512
	gettext("When using multiple WAN connections there should be at least one unique DNS server per gateway.");
513

    
514
// If there are no DNS servers, make an empty entry for initial display.
515
if ($dnsserver_count == 0) {
516
	$pconfig['dnsserver'][] = '';
517
}
518

    
519
foreach ($pconfig['dnsserver'] as $dnsserver) {
520

    
521
	$is_last_dnsserver = ($dnsserver_num == $dnsserver_count - 1);
522
	$group = new Form_Group($dnsserver_num == 0 ? 'DNS Servers':'');
523
	$group->addClass('repeatable');
524

    
525
	$group->add(new Form_Input(
526
		'dns' . $dnsserver_num,
527
		'DNS Server',
528
		'text',
529
		$dnsserver
530
	))->setHelp(($is_last_dnsserver) ? $dnsserver_help:null);
531

    
532
	if ($multiwan > 1) {
533
		$options = array('none' => 'none');
534

    
535
		foreach ($arr_gateways as $gwname => $gwitem) {
536
			if ((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
537
				continue;
538
			}
539

    
540
			if ((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
541
				continue;
542
			}
543

    
544
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
545
		}
546

    
547
		$group->add(new Form_Select(
548
			'dnsgw' . $dnsserver_num,
549
			'Gateway',
550
			$pconfig['dnsgw' . $dnsserver_num],
551
			$options
552
		))->setWidth(4)->setHelp(($is_last_dnsserver) ? $dnsgw_help:null);
553
	}
554

    
555
	$group->add(new Form_Button(
556
		'deleterow' . $dnsserver_num,
557
		'Delete',
558
		null,
559
		'fa-trash'
560
	))->setWidth(2)->addClass('btn-warning');
561

    
562
	$section->add($group);
563
	$dnsserver_num++;
564
}
565

    
566
$section->addInput(new Form_Button(
567
	'addrow',
568
	'Add DNS Server',
569
	null,
570
	'fa-plus'
571
))->addClass('btn-success addbtn');
572

    
573
$section->addInput(new Form_Checkbox(
574
	'dnsallowoverride',
575
	'DNS Server Override',
576
	'Allow DNS server list to be overridden by DHCP/PPP on WAN',
577
	$pconfig['dnsallowoverride']
578
))->setHelp('If this option is set, %s will use DNS servers '.
579
	'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
580
	'the DNS Forwarder/DNS Resolver). However, they will not be assigned to DHCP '.
581
	'clients.', $g['product_name']);
582

    
583
$section->addInput(new Form_Checkbox(
584
	'dnslocalhost',
585
	'Disable DNS Forwarder',
586
	'Do not use the DNS Forwarder/DNS Resolver as a DNS server for the firewall',
587
	$pconfig['dnslocalhost']
588
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS '.
589
	'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
590
	'listen on localhost, so system can use the local DNS service to perform '.
591
	'lookups. Checking this box omits localhost from the list of DNS servers in resolv.conf.');
592

    
593
$form->add($section);
594

    
595
$section = new Form_Section('Localization');
596

    
597
$section->addInput(new Form_Select(
598
	'timezone',
599
	'*Timezone',
600
	$pconfig['timezone'],
601
	array_combine($timezonelist, $timezonedesc)
602
))->setHelp('Select a geographic region name (Continent/Location) to determine the timezone for the firewall. %1$s' .
603
	'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/>');
604

    
605
$section->addInput(new Form_Input(
606
	'timeservers',
607
	'Timeservers',
608
	'text',
609
	$pconfig['timeservers']
610
))->setHelp('Use a space to separate multiple hosts (only one required). '.
611
	'Remember to set up at least one DNS server if a host name is entered here!');
612

    
613
$section->addInput(new Form_Select(
614
	'language',
615
	'*Language',
616
	$pconfig['language'],
617
	get_locale_list()
618
))->setHelp('Choose a language for the webConfigurator');
619

    
620
$form->add($section);
621

    
622
$section = new Form_Section('webConfigurator');
623

    
624
gen_webguicss_field($section, $pconfig['webguicss']);
625
gen_webguifixedmenu_field($section, $pconfig['webguifixedmenu']);
626
gen_webguihostnamemenu_field($section, $pconfig['webguihostnamemenu']);
627
gen_dashboardcolumns_field($section, $pconfig['dashboardcolumns']);
628
gen_interfacessort_field($section, $pconfig['interfacessort']);
629
gen_associatedpanels_fields(
630
	$section,
631
	$pconfig['dashboardavailablewidgetspanel'],
632
	$pconfig['systemlogsfilterpanel'],
633
	$pconfig['systemlogsmanagelogpanel'],
634
	$pconfig['statusmonitoringsettingspanel']);
635
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
636
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
637
gen_disablealiaspopupdetail_field($section, $pconfig['disablealiaspopupdetail']);
638

    
639
$section->addInput(new Form_Checkbox(
640
	'roworderdragging',
641
	'Disable dragging',
642
	'Disable dragging of firewall/NAT rules',
643
	$pconfig['roworderdragging']
644
))->setHelp('Disables dragging rows to allow selecting and copying row contents and avoid accidental changes.');
645

    
646
$section->addInput(new Form_Select(
647
	'logincss',
648
	'Login page color',
649
	$pconfig['logincss'],
650
	["1e3f75;" => gettext("Blue"), "003300" => gettext("Green"), "770101" => gettext("Red"),
651
	 "4b1263" => gettext("Purple"), "424142" => gettext("Gray"), "333333" => gettext("Dark gray"),
652
	 "633215" => gettext("Brown" ), "bf7703" => gettext("Orange")]
653
))->setHelp('Choose a color for the login page');
654

    
655
$section->addInput(new Form_Checkbox(
656
	'loginshowhost',
657
	'Login hostname',
658
	'Show hostname on login banner',
659
	$pconfig['loginshowhost']
660
));
661
/*
662
$section->addInput(new Form_Input(
663
	'dashboardperiod',
664
	'Dashboard update period',
665
	'number',
666
	$pconfig['dashboardperiod'],
667
	['min' => '5', 'max' => '600']
668
))->setHelp('Time in seconds between dashboard widget updates. Small values cause ' .
669
			'more frequent updates but increase the load on the web server. ' .
670
			'Minimum is 5 seconds, maximum 600 seconds');
671
*/
672
$form->add($section);
673

    
674
print $form;
675

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

    
678
?>
679
</div>
680

    
681
<script type="text/javascript">
682
//<![CDATA[
683
events.push(function() {
684

    
685
	function setThemeWarning() {
686
		if ($('#webguicss').val().startsWith("pfSense")) {
687
			$('#csstxt').html("").addClass("text-default");
688
		} else {
689
			$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
690
		}
691
	}
692

    
693
	$('#webguicss').change(function() {
694
		setThemeWarning();
695
	});
696

    
697
	setThemeWarning();
698

    
699
	// Suppress "Delete row" button if there are fewer than two rows
700
	checkLastRow();
701
});
702
//]]>
703
</script>
704

    
705
<?php
706
include("foot.inc");
707
?>
(192-192/234)