Project

General

Profile

Download (24.4 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
// set default language if unset
83
if (!isset($config['system']['language'])) {
84
	$config['system']['language'] = $g['language'];
85
}
86

    
87
$dnsgw_counter = 1;
88

    
89
while (isset($config["system"]["dns{$dnsgw_counter}gw"])) {
90
	$pconfig_dnsgw_counter = $dnsgw_counter - 1;
91
	$pconfig["dnsgw{$pconfig_dnsgw_counter}"] = $config["system"]["dns{$dnsgw_counter}gw"];
92
	$dnsgw_counter++;
93
}
94

    
95
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
96
$pconfig['timezone'] = $config['system']['timezone'];
97
$pconfig['timeservers'] = $config['system']['timeservers'];
98
$pconfig['language'] = $config['system']['language'];
99
$pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
100
$pconfig['logincss'] = $config['system']['webgui']['logincss'];
101
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
102
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
103
$pconfig['interfacessort'] = isset($config['system']['webgui']['interfacessort']);
104
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
105
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
106
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
107
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
108
$pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
109
$pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu'];
110
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
111
$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10";
112
$pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']);
113
$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']);
114

    
115
if (!$pconfig['timezone']) {
116
	if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
117
		$pconfig['timezone'] = $g['default_timezone'];
118
	} else {
119
		$pconfig['timezone'] = "Etc/UTC";
120
	}
121
}
122

    
123
if (!$pconfig['timeservers']) {
124
	$pconfig['timeservers'] = "pool.ntp.org";
125
}
126

    
127
$changedesc = gettext("System") . ": ";
128
$changecount = 0;
129

    
130
function is_timezone($elt) {
131
	return !preg_match("/\/$/", $elt);
132
}
133

    
134
if ($pconfig['timezone'] <> $_POST['timezone']) {
135
	filter_pflog_start(true);
136
}
137

    
138
$timezonelist = system_get_timezone_list();
139
$timezonedesc = $timezonelist;
140

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

    
154
	$direction = substr($desc, 7, 1);
155

    
156
	switch ($direction) {
157
	case '-':
158
		$direction_str = gettext('AHEAD of');
159
		break;
160
	case '+':
161
		$direction_str = gettext('BEHIND');
162
		break;
163
	default:
164
		continue;
165
	}
166

    
167
	$hr_offset = substr($desc, 8);
168
	$timezonedesc[$idx] = $desc . " " .
169
	    sprintf(ngettext('(%1$s hour %2$s GMT)', '(%1$s hours %2$s GMT)', $hr_offset), $hr_offset, $direction_str);
170
}
171

    
172
$multiwan = false;
173
$interfaces = get_configured_interface_list();
174
foreach ($interfaces as $interface) {
175
	if (interface_has_gateway($interface)) {
176
		$multiwan = true;
177
	}
178
}
179

    
180
if ($_POST) {
181

    
182
	$changecount++;
183

    
184
	unset($input_errors);
185
	$pconfig = $_POST;
186

    
187
	/* input validation */
188
	$reqdfields = explode(" ", "hostname domain");
189
	$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
190

    
191
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
192

    
193
	if ($_POST['dashboardperiod']) {
194
		$config['widgets']['period'] = $_POST['dashboardperiod'];
195
	}
196

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

    
203

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

    
210
	$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
211

    
212
	if ($_POST['webguifixedmenu']) {
213
		$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
214
	} else {
215
		unset($config['system']['webgui']['webguifixedmenu']);
216
	}
217

    
218
	if ($_POST['webguihostnamemenu']) {
219
		$config['system']['webgui']['webguihostnamemenu'] = $_POST['webguihostnamemenu'];
220
	} else {
221
		unset($config['system']['webgui']['webguihostnamemenu']);
222
	}
223

    
224
	if ($_POST['dashboardcolumns']) {
225
		$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
226
	} else {
227
		unset($config['system']['webgui']['dashboardcolumns']);
228
	}
229

    
230
	$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
231

    
232
	if ($_POST['hostname']) {
233
		if (!is_hostname($_POST['hostname'])) {
234
			$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
235
		} else {
236
			if (!is_unqualified_hostname($_POST['hostname'])) {
237
				$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
238
			}
239
		}
240
	}
241
	if ($_POST['domain'] && !is_domain($_POST['domain'])) {
242
		$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
243
	}
244

    
245
	$dnslist = $ignore_posted_dnsgw = array();
246

    
247
	$dnscounter = 0;
248
	$dnsname = "dns{$dnscounter}";
249

    
250
	while (isset($_POST[$dnsname])) {
251
		$dnsgwname = "dnsgw{$dnscounter}";
252
		$dnslist[] = $_POST[$dnsname];
253

    
254
		if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
255
			$input_errors[] = sprintf(gettext("A valid IP address must be specified for DNS server %s."), $dnscounter+1);
256
		} else {
257
			if (($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
258
				// A real gateway has been selected.
259
				if (is_ipaddr($_POST[$dnsname])) {
260
					if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
261
						$input_errors[] = sprintf(gettext('The IPv6 gateway "%1$s" can not be specified for IPv4 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
262
					}
263
					if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
264
						$input_errors[] = sprintf(gettext('The IPv4 gateway "%1$s" can not be specified for IPv6 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
265
					}
266
				} else {
267
					// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
268
					$ignore_posted_dnsgw[$dnsgwname] = true;
269
				}
270
			}
271
		}
272
		$dnscounter++;
273
		$dnsname = "dns{$dnscounter}";
274
	}
275

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

    
280
	$dnscounter = 0;
281
	$dnsname = "dns{$dnscounter}";
282

    
283
	$direct_networks_list = explode(" ", filter_get_direct_networks_list());
284
	while (isset($_POST[$dnsname])) {
285
		$dnsgwname = "dnsgw{$dnscounter}";
286
		if ($_POST[$dnsgwname] && ($_POST[$dnsgwname] <> "none")) {
287
			foreach ($direct_networks_list as $direct_network) {
288
				if (ip_in_subnet($_POST[$dnsname], $direct_network)) {
289
					$input_errors[] = sprintf(gettext("A gateway can not be assigned to DNS '%s' server which is on a directly connected network."), $_POST[$dnsname]);
290
				}
291
			}
292
		}
293
		$dnscounter++;
294
		$dnsname = "dns{$dnscounter}";
295
	}
296

    
297
	# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
298
	$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
299
	$_POST['timeservers'] = trim($_POST['timeservers']);
300
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
301
		if (!is_domain($ts)) {
302
			$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
303
		}
304
	}
305

    
306
	if ($input_errors) {
307
		// Put the user-entered list back into place so it will be redisplayed for correction.
308
		$pconfig['dnsserver'] = $dnslist;
309
	} else {
310
		update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
311
		update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
312
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
313
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
314

    
315
		if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
316
			$config['system']['language'] = $_POST['language'];
317
			set_language();
318
		}
319

    
320
		unset($config['system']['webgui']['interfacessort']);
321
		$config['system']['webgui']['interfacessort'] = $_POST['interfacessort'] ? true : false;
322

    
323
		unset($config['system']['webgui']['webguileftcolumnhyper']);
324
		$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
325

    
326
		unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
327
		$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
328

    
329
		unset($config['system']['webgui']['systemlogsfilterpanel']);
330
		$config['system']['webgui']['systemlogsfilterpanel'] = $_POST['systemlogsfilterpanel'] ? true : false;
331

    
332
		unset($config['system']['webgui']['systemlogsmanagelogpanel']);
333
		$config['system']['webgui']['systemlogsmanagelogpanel'] = $_POST['systemlogsmanagelogpanel'] ? true : false;
334

    
335
		unset($config['system']['webgui']['statusmonitoringsettingspanel']);
336
		$config['system']['webgui']['statusmonitoringsettingspanel'] = $_POST['statusmonitoringsettingspanel'] ? true : false;
337

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

    
342
		$dnscounter = 0;
343
		$dnsname = "dns{$dnscounter}";
344

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

    
353
		// Remember the new list for display also.
354
		$pconfig['dnsserver'] = $config['system']['dnsserver'];
355

    
356
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
357

    
358
		unset($config['system']['dnsallowoverride']);
359
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
360

    
361
		if ($_POST['dnslocalhost'] == "yes") {
362
			$config['system']['dnslocalhost'] = true;
363
		} else {
364
			unset($config['system']['dnslocalhost']);
365
		}
366

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

    
380
			$olddnsgwname = $config['system'][$dnsgwconfigname];
381

    
382
			if ($ignore_posted_dnsgw[$dnsgwname]) {
383
				$thisdnsgwname = "none";
384
			} else {
385
				$thisdnsgwname = $pconfig[$dnsgwname];
386
			}
387

    
388
			// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
389
			$config['system'][$dnsgwconfigname] = "none";
390
			$pconfig[$dnsgwname] = "none";
391
			$pconfig[$dnsname] = "";
392

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

    
398
				// The $pconfig array key of the DNS IP (starts from 0)
399
				$outdnsname = "dns{$outdnscounter}";
400
				// The $pconfig array key of the corresponding gateway (starts from 0)
401
				$outdnsgwname = "dnsgw{$outdnscounter}";
402
				// The numbering of DNS GW entries in the config starts from 1
403
				$outdnsgwconfigcounter = $outdnscounter + 1;
404
				// So this is the array key of the output DNS GW entry in $config['system']
405
				$outdnsgwconfigname = "dns{$outdnsgwconfigcounter}gw";
406

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

    
428
			$dnscounter++;
429
			// The $_POST array key of the DNS IP (starts from 0)
430
			$dnsname = "dns{$dnscounter}";
431
		}
432

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

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

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

    
453
		// Reload the filter - plugins might need to be run.
454
		$retval |= filter_configure();
455

    
456
		$savemsg = get_std_save_message($retval);
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 ($savemsg) {
470
	print_info_box($savemsg, 'success');
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
$form->add($section);
499

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
596
$section->addInput(new Form_Select(
597
	'timezone',
598
	'*Timezone',
599
	$pconfig['timezone'],
600
	array_combine($timezonelist, $timezonedesc)
601
))->setHelp('Select the timezone or location within the timezone to be used by this system. '.
602
	'Usually choose a "Continent/City". Only choose a special or "Etc" entry if you understand why you need to use it.');
603

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

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

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

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

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

    
637
$section->addInput(new Form_Select(
638
	'logincss',
639
	'Login page color',
640
	$pconfig['logincss'],
641
	["1e3f75;" => gettext("Blue"), "003300" => gettext("Green"), "770101" => gettext("Red"),
642
	 "4b1263" => gettext("Purple"), "424142" => gettext("Gray"), "333333" => gettext("Dark gray"),
643
	 "633215" => gettext("Brown" ), "bf7703" => gettext("Orange")]
644
))->setHelp('Choose a color for the login page');
645

    
646
$section->addInput(new Form_Checkbox(
647
	'loginshowhost',
648
	'Login hostname',
649
	'Show hostname on login banner',
650
	$pconfig['loginshowhost']
651
));
652

    
653
$section->addInput(new Form_Input(
654
	'dashboardperiod',
655
	'Dashboard update period',
656
	'number',
657
	$pconfig['dashboardperiod'],
658
	['min' => '5', 'max' => '600']
659
))->setHelp('Time in seconds between dashboard widget updates. Small values cause ' .
660
			'more frequent updates but increase the load on the web server. ' .
661
			'Minimum is 5 seconds, maximum 600 seconds');
662

    
663
$form->add($section);
664

    
665
print $form;
666

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

    
669
?>
670
</div>
671

    
672
<script type="text/javascript">
673
//<![CDATA[
674
events.push(function() {
675

    
676
	function setThemeWarning() {
677
		if ($('#webguicss').val().startsWith("pfSense")) {
678
			$('#csstxt').html("").addClass("text-default");
679
		} else {
680
			$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
681
		}
682
	}
683

    
684
	$('#webguicss').change(function() {
685
		setThemeWarning();
686
	});
687

    
688
	setThemeWarning();
689

    
690
	// Suppress "Delete row" button if there are fewer than two rows
691
	checkLastRow();
692
});
693
//]]>
694
</script>
695

    
696
<?php
697
include("foot.inc");
698
?>
(184-184/225)