Project

General

Profile

Download (23.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * system.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 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
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions are met:
15
 *
16
 * 1. Redistributions of source code must retain the above copyright notice,
17
 *    this list of conditions and the following disclaimer.
18
 *
19
 * 2. Redistributions in binary form must reproduce the above copyright
20
 *    notice, this list of conditions and the following disclaimer in
21
 *    the documentation and/or other materials provided with the
22
 *    distribution.
23
 *
24
 * 3. All advertising materials mentioning features or use of this software
25
 *    must display the following acknowledgment:
26
 *    "This product includes software developed by the pfSense Project
27
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
28
 *
29
 * 4. The names "pfSense" and "pfSense Project" must not be used to
30
 *    endorse or promote products derived from this software without
31
 *    prior written permission. For written permission, please contact
32
 *    coreteam@pfsense.org.
33
 *
34
 * 5. Products derived from this software may not be called "pfSense"
35
 *    nor may "pfSense" appear in their names without prior written
36
 *    permission of the Electric Sheep Fencing, LLC.
37
 *
38
 * 6. Redistributions of any form whatsoever must retain the following
39
 *    acknowledgment:
40
 *
41
 * "This product includes software developed by the pfSense Project
42
 * for use in the pfSense software distribution (http://www.pfsense.org/).
43
 *
44
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
45
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
48
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55
 * OF THE POSSIBILITY OF SUCH DAMAGE.
56
 */
57

    
58
##|+PRIV
59
##|*IDENT=page-system-generalsetup
60
##|*NAME=System: General Setup
61
##|*DESCR=Allow access to the 'System: General Setup' page.
62
##|*MATCH=system.php*
63
##|-PRIV
64

    
65
require_once("guiconfig.inc");
66
require_once("functions.inc");
67
require_once("filter.inc");
68
require_once("shaper.inc");
69
require_once("system.inc");
70

    
71
$pconfig['hostname'] = $config['system']['hostname'];
72
$pconfig['domain'] = $config['system']['domain'];
73
$pconfig['dnsserver'] = $config['system']['dnsserver'];
74

    
75
$arr_gateways = return_gateways_array();
76

    
77
// set default columns to two if unset
78
if (!isset($config['system']['webgui']['dashboardcolumns'])) {
79
	$config['system']['webgui']['dashboardcolumns'] = 2;
80
}
81

    
82
$dnsgw_counter = 1;
83

    
84
while (isset($config["system"]["dns{$dnsgw_counter}gw"])) {
85
	$pconfig_dnsgw_counter = $dnsgw_counter - 1;
86
	$pconfig["dnsgw{$pconfig_dnsgw_counter}"] = $config["system"]["dns{$dnsgw_counter}gw"];
87
	$dnsgw_counter++;
88
}
89

    
90
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
91
$pconfig['timezone'] = $config['system']['timezone'];
92
$pconfig['timeservers'] = $config['system']['timeservers'];
93
$pconfig['language'] = $config['system']['language'];
94
$pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
95
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
96
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
97
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
98
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
99
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
100
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
101
$pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
102
$pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu'];
103
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
104
$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10";
105
$pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']);
106
$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']);
107

    
108
if (!$pconfig['timezone']) {
109
	if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
110
		$pconfig['timezone'] = $g['default_timezone'];
111
	} else {
112
		$pconfig['timezone'] = "Etc/UTC";
113
	}
114
}
115

    
116
if (!$pconfig['timeservers']) {
117
	$pconfig['timeservers'] = "pool.ntp.org";
118
}
119

    
120
$changedesc = gettext("System") . ": ";
121
$changecount = 0;
122

    
123
function is_timezone($elt) {
124
	return !preg_match("/\/$/", $elt);
125
}
126

    
127
if ($pconfig['timezone'] <> $_POST['timezone']) {
128
	filter_pflog_start(true);
129
}
130

    
131
$timezonelist = system_get_timezone_list();
132
$timezonedesc = $timezonelist;
133

    
134
/*
135
 * Etc/GMT entries work the opposite way to what people expect.
136
 * Ref: https://github.com/eggert/tz/blob/master/etcetera and Redmine issue 7089
137
 * Add explanatory text to entries like:
138
 * Etc/GMT+1 and Etc/GMT-1
139
 * but not:
140
 * Etc/GMT or Etc/GMT+0
141
 */
142
foreach ($timezonedesc as $idx => $desc) {
143
	if (substr($desc, 0, 7) != "Etc/GMT" || substr($desc, 8, 1) == "0") {
144
		continue;
145
	}
146

    
147
	$direction = substr($desc, 7, 1);
148

    
149
	switch ($direction) {
150
	case '-':
151
		$direction_str = gettext('AHEAD of');
152
		break;
153
	case '+':
154
		$direction_str = gettext('BEHIND');
155
		break;
156
	default:
157
		continue;
158
	}
159

    
160
	$hr_offset = substr($desc, 8);
161
	$timezonedesc[$idx] = $desc . " " .
162
	    sprintf(ngettext('(%1$s hour %2$s GMT)', '(%1$s hours %2$s GMT)', $hr_offset), $hr_offset, $direction_str);
163
}
164

    
165
$multiwan = false;
166
$interfaces = get_configured_interface_list();
167
foreach ($interfaces as $interface) {
168
	if (interface_has_gateway($interface)) {
169
		$multiwan = true;
170
	}
171
}
172

    
173
if ($_POST) {
174

    
175
	$changecount++;
176

    
177
	unset($input_errors);
178
	$pconfig = $_POST;
179

    
180
	/* input validation */
181
	$reqdfields = explode(" ", "hostname domain");
182
	$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
183

    
184
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
185

    
186
	if ($_POST['dashboardperiod']) {
187
		$config['widgets']['period'] = $_POST['dashboardperiod'];
188
	}
189

    
190
	if ($_POST['webguicss']) {
191
		$config['system']['webgui']['webguicss'] = $_POST['webguicss'];
192
	} else {
193
		unset($config['system']['webgui']['webguicss']);
194
	}
195

    
196
	$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
197

    
198
	if ($_POST['webguifixedmenu']) {
199
		$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
200
	} else {
201
		unset($config['system']['webgui']['webguifixedmenu']);
202
	}
203

    
204
	if ($_POST['webguihostnamemenu']) {
205
		$config['system']['webgui']['webguihostnamemenu'] = $_POST['webguihostnamemenu'];
206
	} else {
207
		unset($config['system']['webgui']['webguihostnamemenu']);
208
	}
209

    
210
	if ($_POST['dashboardcolumns']) {
211
		$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
212
	} else {
213
		unset($config['system']['webgui']['dashboardcolumns']);
214
	}
215

    
216
	$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
217

    
218
	if ($_POST['hostname']) {
219
		if (!is_hostname($_POST['hostname'])) {
220
			$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
221
		} else {
222
			if (!is_unqualified_hostname($_POST['hostname'])) {
223
				$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
224
			}
225
		}
226
	}
227
	if ($_POST['domain'] && !is_domain($_POST['domain'])) {
228
		$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
229
	}
230

    
231
	$dnslist = $ignore_posted_dnsgw = array();
232

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

    
236
	while (isset($_POST[$dnsname])) {
237
		$dnsgwname = "dnsgw{$dnscounter}";
238
		$dnslist[] = $_POST[$dnsname];
239

    
240
		if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
241
			$input_errors[] = sprintf(gettext("A valid IP address must be specified for DNS server %s."), $dnscounter+1);
242
		} else {
243
			if (($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
244
				// A real gateway has been selected.
245
				if (is_ipaddr($_POST[$dnsname])) {
246
					if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
247
						$input_errors[] = sprintf(gettext('The IPv6 gateway "%1$s" can not be specified for IPv4 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
248
					}
249
					if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
250
						$input_errors[] = sprintf(gettext('The IPv4 gateway "%1$s" can not be specified for IPv6 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
251
					}
252
				} else {
253
					// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
254
					$ignore_posted_dnsgw[$dnsgwname] = true;
255
				}
256
			}
257
		}
258
		$dnscounter++;
259
		$dnsname = "dns{$dnscounter}";
260
	}
261

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

    
266
	$dnscounter = 0;
267
	$dnsname = "dns{$dnscounter}";
268

    
269
	$direct_networks_list = explode(" ", filter_get_direct_networks_list());
270
	while (isset($_POST[$dnsname])) {
271
		$dnsgwname = "dnsgw{$dnscounter}";
272
		if ($_POST[$dnsgwname] && ($_POST[$dnsgwname] <> "none")) {
273
			foreach ($direct_networks_list as $direct_network) {
274
				if (ip_in_subnet($_POST[$dnsname], $direct_network)) {
275
					$input_errors[] = sprintf(gettext("A gateway can not be assigned to DNS '%s' server which is on a directly connected network."), $_POST[$dnsname]);
276
				}
277
			}
278
		}
279
		$dnscounter++;
280
		$dnsname = "dns{$dnscounter}";
281
	}
282

    
283
	# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
284
	$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
285
	$_POST['timeservers'] = trim($_POST['timeservers']);
286
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
287
		if (!is_domain($ts)) {
288
			$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
289
		}
290
	}
291

    
292
	if ($input_errors) {
293
		// Put the user-entered list back into place so it will be redisplayed for correction.
294
		$pconfig['dnsserver'] = $dnslist;
295
	} else {
296
		update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
297
		update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
298
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
299
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
300

    
301
		if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
302
			$config['system']['language'] = $_POST['language'];
303
			set_language();
304
		}
305

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

    
309
		unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
310
		$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
311

    
312
		unset($config['system']['webgui']['systemlogsfilterpanel']);
313
		$config['system']['webgui']['systemlogsfilterpanel'] = $_POST['systemlogsfilterpanel'] ? true : false;
314

    
315
		unset($config['system']['webgui']['systemlogsmanagelogpanel']);
316
		$config['system']['webgui']['systemlogsmanagelogpanel'] = $_POST['systemlogsmanagelogpanel'] ? true : false;
317

    
318
		unset($config['system']['webgui']['statusmonitoringsettingspanel']);
319
		$config['system']['webgui']['statusmonitoringsettingspanel'] = $_POST['statusmonitoringsettingspanel'] ? true : false;
320

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

    
325
		$dnscounter = 0;
326
		$dnsname = "dns{$dnscounter}";
327

    
328
		while (isset($_POST[$dnsname])) {
329
			if ($_POST[$dnsname]) {
330
				$config['system']['dnsserver'][] = $_POST[$dnsname];
331
			}
332
			$dnscounter++;
333
			$dnsname = "dns{$dnscounter}";
334
		}
335

    
336
		// Remember the new list for display also.
337
		$pconfig['dnsserver'] = $config['system']['dnsserver'];
338

    
339
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
340

    
341
		unset($config['system']['dnsallowoverride']);
342
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
343

    
344
		if ($_POST['dnslocalhost'] == "yes") {
345
			$config['system']['dnslocalhost'] = true;
346
		} else {
347
			unset($config['system']['dnslocalhost']);
348
		}
349

    
350
		/* which interface should the dns servers resolve through? */
351
		$dnscounter = 0;
352
		// The $_POST array key of the DNS IP (starts from 0)
353
		$dnsname = "dns{$dnscounter}";
354
		$outdnscounter = 0;
355
		while (isset($_POST[$dnsname])) {
356
			// The $_POST array key of the corresponding gateway (starts from 0)
357
			$dnsgwname = "dnsgw{$dnscounter}";
358
			// The numbering of DNS GW entries in the config starts from 1
359
			$dnsgwconfigcounter = $dnscounter + 1;
360
			// So this is the array key of the DNS GW entry in $config['system']
361
			$dnsgwconfigname = "dns{$dnsgwconfigcounter}gw";
362

    
363
			$olddnsgwname = $config['system'][$dnsgwconfigname];
364

    
365
			if ($ignore_posted_dnsgw[$dnsgwname]) {
366
				$thisdnsgwname = "none";
367
			} else {
368
				$thisdnsgwname = $pconfig[$dnsgwname];
369
			}
370

    
371
			// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
372
			$config['system'][$dnsgwconfigname] = "none";
373
			$pconfig[$dnsgwname] = "none";
374
			$pconfig[$dnsname] = "";
375

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

    
381
				// The $pconfig array key of the DNS IP (starts from 0)
382
				$outdnsname = "dns{$outdnscounter}";
383
				// The $pconfig array key of the corresponding gateway (starts from 0)
384
				$outdnsgwname = "dnsgw{$outdnscounter}";
385
				// The numbering of DNS GW entries in the config starts from 1
386
				$outdnsgwconfigcounter = $outdnscounter + 1;
387
				// So this is the array key of the output DNS GW entry in $config['system']
388
				$outdnsgwconfigname = "dns{$outdnsgwconfigcounter}gw";
389

    
390
				$pconfig[$outdnsname] = $_POST[$dnsname];
391
				if ($_POST[$dnsgwname]) {
392
					$config['system'][$outdnsgwconfigname] = $thisdnsgwname;
393
					$pconfig[$outdnsgwname] = $thisdnsgwname;
394
				} else {
395
					// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
396
					unset($config['system'][$outdnsgwconfigname]);
397
					$pconfig[$outdnsgwname] = "";
398
				}
399
				$outdnscounter++;
400
			}
401
			if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter] != $_POST[$dnsname]))) {
402
				// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
403
				// Remove the route. Later calls will add the correct new route if needed.
404
				if (is_ipaddrv4($olddnsservers[$dnscounter])) {
405
					mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
406
				} else if (is_ipaddrv6($olddnsservers[$dnscounter])) {
407
					mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
408
				}
409
			}
410

    
411
			$dnscounter++;
412
			// The $_POST array key of the DNS IP (starts from 0)
413
			$dnsname = "dns{$dnscounter}";
414
		}
415

    
416
		if ($changecount > 0) {
417
			write_config($changedesc);
418
		}
419

    
420
		$retval = 0;
421
		$retval = system_hostname_configure();
422
		$retval |= system_hosts_generate();
423
		$retval |= system_resolvconf_generate();
424
		if (isset($config['dnsmasq']['enable'])) {
425
			$retval |= services_dnsmasq_configure();
426
		} elseif (isset($config['unbound']['enable'])) {
427
			$retval |= services_unbound_configure();
428
		}
429
		$retval |= system_timezone_configure();
430
		$retval |= system_ntp_configure();
431

    
432
		if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
433
			$retval |= send_event("service reload dns");
434
		}
435

    
436
		// Reload the filter - plugins might need to be run.
437
		$retval |= filter_configure();
438

    
439
		$savemsg = get_std_save_message($retval);
440
	}
441

    
442
	unset($ignore_posted_dnsgw);
443
}
444

    
445
$pgtitle = array(gettext("System"), gettext("General Setup"));
446
include("head.inc");
447

    
448
if ($input_errors) {
449
	print_input_errors($input_errors);
450
}
451

    
452
if ($savemsg) {
453
	print_info_box($savemsg, 'success');
454
}
455
?>
456
<div id="container">
457
<?php
458

    
459
$form = new Form;
460
$section = new Form_Section('System');
461
$section->addInput(new Form_Input(
462
	'hostname',
463
	'*Hostname',
464
	'text',
465
	$pconfig['hostname'],
466
	['placeholder' => 'pfSense']
467
))->setHelp('Name of the firewall host, without domain part');
468

    
469
$section->addInput(new Form_Input(
470
	'domain',
471
	'*Domain',
472
	'text',
473
	$pconfig['domain'],
474
	['placeholder' => 'mycorp.com, home, office, private, etc.']
475
))->setHelp('Do not use \'local\' as a domain name. It will cause local '.
476
	'hosts running mDNS (avahi, bonjour, etc.) to be unable to resolve '.
477
	'local hosts not running mDNS.');
478

    
479
$form->add($section);
480

    
481
$section = new Form_Section('DNS Server Settings');
482

    
483
if (!is_array($pconfig['dnsserver'])) {
484
	$pconfig['dnsserver'] = array();
485
}
486

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

    
494
// If there are no DNS servers, make an empty entry for initial display.
495
if ($dnsserver_count == 0) {
496
	$pconfig['dnsserver'][] = '';
497
}
498

    
499
foreach ($pconfig['dnsserver'] as $dnsserver) {
500

    
501
	$is_last_dnsserver = ($dnsserver_num == $dnsserver_count - 1);
502
	$group = new Form_Group($dnsserver_num == 0 ? 'DNS Servers':'');
503
	$group->addClass('repeatable');
504

    
505
	$group->add(new Form_Input(
506
		'dns' . $dnsserver_num,
507
		'DNS Server',
508
		'text',
509
		$dnsserver
510
	))->setHelp(($is_last_dnsserver) ? $dnsserver_help:null);
511

    
512
	if ($multiwan)	{
513
		$options = array('none' => 'none');
514

    
515
		foreach ($arr_gateways as $gwname => $gwitem) {
516
			if ((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
517
				continue;
518
			}
519

    
520
			if ((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
521
				continue;
522
			}
523

    
524
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
525
		}
526

    
527
		$group->add(new Form_Select(
528
			'dnsgw' . $dnsserver_num,
529
			'Gateway',
530
			$pconfig['dnsgw' . $dnsserver_num],
531
			$options
532
		))->setHelp(($is_last_dnsserver) ? $dnsgw_help:null);;
533
	}
534

    
535
	$group->add(new Form_Button(
536
		'deleterow' . $dnsserver_num,
537
		'Delete',
538
		null,
539
		'fa-trash'
540
	))->addClass('btn-warning');
541

    
542
	$section->add($group);
543
	$dnsserver_num++;
544
}
545

    
546
$section->addInput(new Form_Button(
547
	'addrow',
548
	'Add DNS Server',
549
	null,
550
	'fa-plus'
551
))->addClass('btn-success addbtn');
552

    
553
$section->addInput(new Form_Checkbox(
554
	'dnsallowoverride',
555
	'DNS Server Override',
556
	'Allow DNS server list to be overridden by DHCP/PPP on WAN',
557
	$pconfig['dnsallowoverride']
558
))->setHelp(sprintf(gettext('If this option is set, %s will use DNS servers '.
559
	'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
560
	'the DNS Forwarder/DNS Resolver). However, they will not be assigned to DHCP '.
561
	'clients.'), $g['product_name']));
562

    
563
$section->addInput(new Form_Checkbox(
564
	'dnslocalhost',
565
	'Disable DNS Forwarder',
566
	'Do not use the DNS Forwarder/DNS Resolver as a DNS server for the firewall',
567
	$pconfig['dnslocalhost']
568
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS '.
569
	'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
570
	'listen on localhost, so system can use the local DNS service to perform '.
571
	'lookups. Checking this box omits localhost from the list of DNS servers in resolv.conf.');
572

    
573
$form->add($section);
574

    
575
$section = new Form_Section('Localization');
576

    
577
$section->addInput(new Form_Select(
578
	'timezone',
579
	'*Timezone',
580
	$pconfig['timezone'],
581
	array_combine($timezonelist, $timezonedesc)
582
))->setHelp('Select the timezone or location within the timezone to be used by this system. '.
583
	'Usually choose a "Continent/City". Only choose a special or "Etc" entry if you understand why you need to use it.');
584

    
585
$section->addInput(new Form_Input(
586
	'timeservers',
587
	'Timeservers',
588
	'text',
589
	$pconfig['timeservers']
590
))->setHelp('Use a space to separate multiple hosts (only one required). '.
591
	'Remember to set up at least one DNS server if a host name is entered here!');
592

    
593
$section->addInput(new Form_Select(
594
	'language',
595
	'*Language',
596
	$pconfig['language'],
597
	get_locale_list()
598
))->setHelp('Choose a language for the webConfigurator');
599

    
600
$form->add($section);
601

    
602
$section = new Form_Section('webConfigurator');
603

    
604
gen_webguicss_field($section, $pconfig['webguicss']);
605
gen_webguifixedmenu_field($section, $pconfig['webguifixedmenu']);
606
gen_webguihostnamemenu_field($section, $pconfig['webguihostnamemenu']);
607
gen_dashboardcolumns_field($section, $pconfig['dashboardcolumns']);
608
gen_associatedpanels_fields(
609
	$section,
610
	$pconfig['dashboardavailablewidgetspanel'],
611
	$pconfig['systemlogsfilterpanel'],
612
	$pconfig['systemlogsmanagelogpanel'],
613
	$pconfig['statusmonitoringsettingspanel']);
614
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
615
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
616

    
617
$section->addInput(new Form_Checkbox(
618
	'loginshowhost',
619
	'Login hostname',
620
	'Show hostname on login banner',
621
	$pconfig['loginshowhost']
622
));
623

    
624
$section->addInput(new Form_Input(
625
	'dashboardperiod',
626
	'Dashboard update period',
627
	'number',
628
	$pconfig['dashboardperiod'],
629
	['min' => '5', 'max' => '600']
630
))->setHelp('Time in seconds between dashboard widget updates. Small values cause ' .
631
			'more frequent updates but increase the load on the web server. ' .
632
			'Minimum is 5 seconds, maximum 600 seconds');
633

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

    
636
print $form;
637

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

    
640
?>
641
</div>
642

    
643
<script type="text/javascript">
644
//<![CDATA[
645
events.push(function() {
646

    
647
	function setThemeWarning() {
648
		if ($('#webguicss').val().startsWith("pfSense")) {
649
			$('#csstxt').html("").addClass("text-default");
650
		} else {
651
			$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
652
		}
653
	}
654

    
655
	$('#webguicss').change(function() {
656
		setThemeWarning();
657
	});
658

    
659
	setThemeWarning();
660

    
661
	// Suppress "Delete row" button if there are fewer than two rows
662
	checkLastRow();
663
});
664
//]]>
665
</script>
666

    
667
<?php
668
include("foot.inc");
669
?>
(184-184/225)