Project

General

Profile

Download (23.2 KB) Statistics
| Branch: | Tag: | Revision:
1 04ad7c7c Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 c5d81585 Renato Botelho
 * system.php
4 191cb31d Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 54c605d4 Stephen Beaver
 *
9 c5d81585 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
10
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
 * All rights reserved.
12 54c605d4 Stephen Beaver
 *
13 b12ea3fb Renato Botelho
 * 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 54c605d4 Stephen Beaver
 *
17 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
18 54c605d4 Stephen Beaver
 *
19 b12ea3fb Renato Botelho
 * 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 54c605d4 Stephen Beaver
 */
25 5b237745 Scott Ullrich
26 6b07c15a Matthew Grooms
##|+PRIV
27
##|*IDENT=page-system-generalsetup
28 5230f468 jim-p
##|*NAME=System: General Setup
29 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'System: General Setup' page.
30
##|*MATCH=system.php*
31
##|-PRIV
32
33 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
34 7a927e67 Scott Ullrich
require_once("functions.inc");
35
require_once("filter.inc");
36
require_once("shaper.inc");
37 60ff91f1 Renato Botelho
require_once("system.inc");
38 5b237745 Scott Ullrich
39
$pconfig['hostname'] = $config['system']['hostname'];
40
$pconfig['domain'] = $config['system']['domain'];
41 a2d23e88 Phil Davis
$pconfig['dnsserver'] = $config['system']['dnsserver'];
42 0d8a219e Scott Ullrich
43 d623f2da Seth Mos
$arr_gateways = return_gateways_array();
44
45 e6367325 Phil Davis
// set default columns to two if unset
46 8f65151c Phil Davis
if (!isset($config['system']['webgui']['dashboardcolumns'])) {
47 477db933 Jared Dillard
	$config['system']['webgui']['dashboardcolumns'] = 2;
48
}
49
50 27db3c75 Phil Davis
// set default language if unset
51
if (!isset($config['system']['language'])) {
52 41817934 jim-p
	$config['system']['language'] = $g['language'];
53 27db3c75 Phil Davis
}
54
55 a2d23e88 Phil Davis
$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 e180a6e3 Scott Ullrich
63 5b237745 Scott Ullrich
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
64
$pconfig['timezone'] = $config['system']['timezone'];
65
$pconfig['timeservers'] = $config['system']['timeservers'];
66 3e139f90 Vinicius Coque
$pconfig['language'] = $config['system']['language'];
67 a5995a8e Stephen Beaver
$pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
68 e79ff1ee Steve Beaver
$pconfig['logincss'] = $config['system']['webgui']['logincss'];
69 3d29d2eb Jared Dillard
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
70 477db933 Jared Dillard
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
71 1d3510cf Phil Davis
$pconfig['interfacessort'] = isset($config['system']['webgui']['interfacessort']);
72 24f15b3a NOYB
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
73 d9058974 Phil Davis
$pconfig['disablealiaspopupdetail'] = isset($config['system']['webgui']['disablealiaspopupdetail']);
74 c05363c8 NOYB
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
75
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
76
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
77 b1b8784a NOYB
$pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
78 e93242eb Phil Davis
$pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu'];
79 8ca95ed8 jim-p
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
80 6c1f2a1c Steve Beaver
//$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10";
81 a22947a4 Steve Beaver
$pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']);
82 88081ea2 derelict-pf
$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']);
83 8ca95ed8 jim-p
84 2ee8dea1 Phil Davis
if (!$pconfig['timezone']) {
85 ecaca752 Renato Botelho
	if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
86
		$pconfig['timezone'] = $g['default_timezone'];
87
	} else {
88
		$pconfig['timezone'] = "Etc/UTC";
89
	}
90 2ee8dea1 Phil Davis
}
91 ecaca752 Renato Botelho
92 2ee8dea1 Phil Davis
if (!$pconfig['timeservers']) {
93 5b237745 Scott Ullrich
	$pconfig['timeservers'] = "pool.ntp.org";
94 2ee8dea1 Phil Davis
}
95 04ad7c7c Scott Ullrich
96 79eaddf4 Renato Botelho
$changedesc = gettext("System") . ": ";
97 62d01225 Bill Marquette
$changecount = 0;
98 417c6042 Bill Marquette
99 5b237745 Scott Ullrich
function is_timezone($elt) {
100
	return !preg_match("/\/$/", $elt);
101
}
102
103 2ee8dea1 Phil Davis
if ($pconfig['timezone'] <> $_POST['timezone']) {
104 744306c6 jim-p
	filter_pflog_start(true);
105 aa1ab1da Scott Ullrich
}
106
107 60ff91f1 Renato Botelho
$timezonelist = system_get_timezone_list();
108 e5f4c829 Renato Botelho
$timezonedesc = $timezonelist;
109
110
/*
111
 * Etc/GMT entries work the opposite way to what people expect.
112
 * Ref: https://github.com/eggert/tz/blob/master/etcetera and Redmine issue 7089
113
 * Add explanatory text to entries like:
114
 * Etc/GMT+1 and Etc/GMT-1
115
 * but not:
116
 * Etc/GMT or Etc/GMT+0
117
 */
118
foreach ($timezonedesc as $idx => $desc) {
119
	if (substr($desc, 0, 7) != "Etc/GMT" || substr($desc, 8, 1) == "0") {
120
		continue;
121
	}
122
123
	$direction = substr($desc, 7, 1);
124
125
	switch ($direction) {
126
	case '-':
127 88de4ab0 Phil Davis
		$direction_str = gettext('AHEAD of');
128 e5f4c829 Renato Botelho
		break;
129
	case '+':
130
		$direction_str = gettext('BEHIND');
131
		break;
132
	default:
133
		continue;
134
	}
135
136
	$hr_offset = substr($desc, 8);
137 88de4ab0 Phil Davis
	$timezonedesc[$idx] = $desc . " " .
138
	    sprintf(ngettext('(%1$s hour %2$s GMT)', '(%1$s hours %2$s GMT)', $hr_offset), $hr_offset, $direction_str);
139 e5f4c829 Renato Botelho
}
140 5b237745 Scott Ullrich
141 77446beb Matthew Grooms
$multiwan = false;
142 7922db8a Seth Mos
$interfaces = get_configured_interface_list();
143 2ee8dea1 Phil Davis
foreach ($interfaces as $interface) {
144
	if (interface_has_gateway($interface)) {
145 77446beb Matthew Grooms
		$multiwan = true;
146 7922db8a Seth Mos
	}
147
}
148 77446beb Matthew Grooms
149 5b237745 Scott Ullrich
if ($_POST) {
150
151 c668c964 Scott Ullrich
	$changecount++;
152 1180e4f0 Sjon Hortensius
153 5b237745 Scott Ullrich
	unset($input_errors);
154
	$pconfig = $_POST;
155
156
	/* input validation */
157 cfbfd941 smos
	$reqdfields = explode(" ", "hostname domain");
158 2ee8dea1 Phil Davis
	$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
159 04ad7c7c Scott Ullrich
160 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
161 04ad7c7c Scott Ullrich
162 6c1f2a1c Steve Beaver
//	if ($_POST['dashboardperiod']) {
163
//		$config['widgets']['period'] = $_POST['dashboardperiod'];
164
//	}
165 512f2c10 Stephen Beaver
166 a5995a8e Stephen Beaver
	if ($_POST['webguicss']) {
167
		$config['system']['webgui']['webguicss'] = $_POST['webguicss'];
168
	} else {
169
		unset($config['system']['webgui']['webguicss']);
170
	}
171 8f65151c Phil Davis
172 e79ff1ee Steve Beaver
	if ($_POST['logincss']) {
173
		$config['system']['webgui']['logincss'] = $_POST['logincss'];
174
	} else {
175
		unset($config['system']['webgui']['logincss']);
176
	}
177
178 a22947a4 Steve Beaver
	$config['system']['webgui']['loginshowhost'] = $_POST['loginshowhost'] ? true:false;
179
180 ddb84143 Stephen Beaver
	if ($_POST['webguifixedmenu']) {
181
		$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
182
	} else {
183
		unset($config['system']['webgui']['webguifixedmenu']);
184
	}
185 477db933 Jared Dillard
186 1d129967 Christopher Fazendin
	if ($_POST['webguihostnamemenu']) {
187
		$config['system']['webgui']['webguihostnamemenu'] = $_POST['webguihostnamemenu'];
188
	} else {
189
		unset($config['system']['webgui']['webguihostnamemenu']);
190
	}
191
192 477db933 Jared Dillard
	if ($_POST['dashboardcolumns']) {
193
		$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
194
	} else {
195
		unset($config['system']['webgui']['dashboardcolumns']);
196 8f65151c Phil Davis
	}
197
198 88081ea2 derelict-pf
	$config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false;
199
200 2d86ee95 Phil Davis
	if ($_POST['hostname']) {
201
		if (!is_hostname($_POST['hostname'])) {
202
			$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
203
		} else {
204
			if (!is_unqualified_hostname($_POST['hostname'])) {
205
				$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
206
			}
207
		}
208 5b237745 Scott Ullrich
	}
209
	if ($_POST['domain'] && !is_domain($_POST['domain'])) {
210 7465d12c Carlos Eduardo Ramos
		$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
211 5b237745 Scott Ullrich
	}
212 d623f2da Seth Mos
213 58b07c57 NewEraCracker
	$dnslist = $ignore_posted_dnsgw = array();
214 df4471e2 Phil Davis
215 a2d23e88 Phil Davis
	$dnscounter = 0;
216
	$dnsname = "dns{$dnscounter}";
217
218
	while (isset($_POST[$dnsname])) {
219
		$dnsgwname = "dnsgw{$dnscounter}";
220 a936104b Stephen Beaver
		$dnslist[] = $_POST[$dnsname];
221
222 d623f2da Seth Mos
		if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
223 a2d23e88 Phil Davis
			$input_errors[] = sprintf(gettext("A valid IP address must be specified for DNS server %s."), $dnscounter+1);
224 52acb1ff Phil Davis
		} else {
225 2ee8dea1 Phil Davis
			if (($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
226 52acb1ff Phil Davis
				// A real gateway has been selected.
227
				if (is_ipaddr($_POST[$dnsname])) {
228 2ee8dea1 Phil Davis
					if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
229 1bab4a10 NOYB
						$input_errors[] = sprintf(gettext('The IPv6 gateway "%1$s" can not be specified for IPv4 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
230 52acb1ff Phil Davis
					}
231 2ee8dea1 Phil Davis
					if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
232 1bab4a10 NOYB
						$input_errors[] = sprintf(gettext('The IPv4 gateway "%1$s" can not be specified for IPv6 DNS server "%2$s".'), $_POST[$dnsgwname], $_POST[$dnsname]);
233 52acb1ff Phil Davis
					}
234
				} else {
235 df4471e2 Phil Davis
					// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
236
					$ignore_posted_dnsgw[$dnsgwname] = true;
237 52acb1ff Phil Davis
				}
238 13ea7caa smos
			}
239 d623f2da Seth Mos
		}
240 a2d23e88 Phil Davis
		$dnscounter++;
241
		$dnsname = "dns{$dnscounter}";
242 5b237745 Scott Ullrich
	}
243 d623f2da Seth Mos
244 c25e42c8 Mark Furneaux
	if (count(array_filter($dnslist)) != count(array_unique(array_filter($dnslist)))) {
245 f700dc99 Chris Buechler
		$input_errors[] = gettext('Each configured DNS server must have a unique IP address. Remove the duplicated IP.');
246
	}
247
248 a2d23e88 Phil Davis
	$dnscounter = 0;
249
	$dnsname = "dns{$dnscounter}";
250
251 985fc0fb Ermal Lu?i
	$direct_networks_list = explode(" ", filter_get_direct_networks_list());
252 a2d23e88 Phil Davis
	while (isset($_POST[$dnsname])) {
253
		$dnsgwname = "dnsgw{$dnscounter}";
254
		if ($_POST[$dnsgwname] && ($_POST[$dnsgwname] <> "none")) {
255 d8587952 Phil Davis
			foreach ($direct_networks_list as $direct_network) {
256 a2d23e88 Phil Davis
				if (ip_in_subnet($_POST[$dnsname], $direct_network)) {
257
					$input_errors[] = sprintf(gettext("A gateway can not be assigned to DNS '%s' server which is on a directly connected network."), $_POST[$dnsname]);
258 c98d28e1 Seth Mos
				}
259
			}
260
		}
261 a2d23e88 Phil Davis
		$dnscounter++;
262
		$dnsname = "dns{$dnscounter}";
263 c98d28e1 Seth Mos
	}
264
265 8adb814b David P Hilton
	# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
266
	$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
267
	$_POST['timeservers'] = trim($_POST['timeservers']);
268 5b237745 Scott Ullrich
	foreach (explode(' ', $_POST['timeservers']) as $ts) {
269
		if (!is_domain($ts)) {
270 7465d12c Carlos Eduardo Ramos
			$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
271 5b237745 Scott Ullrich
		}
272
	}
273
274 a2d23e88 Phil Davis
	if ($input_errors) {
275
		// Put the user-entered list back into place so it will be redisplayed for correction.
276
		$pconfig['dnsserver'] = $dnslist;
277
	} else {
278 f1a34790 N0YB
		update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
279
		update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
280 9eab73da Bill Marquette
		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
281
		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
282 04ad7c7c Scott Ullrich
283 2ee8dea1 Phil Davis
		if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
284 3e139f90 Vinicius Coque
			$config['system']['language'] = $_POST['language'];
285 ceecd29b Renato Botelho
			set_language();
286 3e139f90 Vinicius Coque
		}
287
288 1d3510cf Phil Davis
		unset($config['system']['webgui']['interfacessort']);
289
		$config['system']['webgui']['interfacessort'] = $_POST['interfacessort'] ? true : false;
290
291 24f15b3a NOYB
		unset($config['system']['webgui']['webguileftcolumnhyper']);
292
		$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
293
294 d9058974 Phil Davis
		unset($config['system']['webgui']['disablealiaspopupdetail']);
295
		$config['system']['webgui']['disablealiaspopupdetail'] = $_POST['disablealiaspopupdetail'] ? true : false;
296
297 c05363c8 NOYB
		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 b1b8784a NOYB
		unset($config['system']['webgui']['statusmonitoringsettingspanel']);
307
		$config['system']['webgui']['statusmonitoringsettingspanel'] = $_POST['statusmonitoringsettingspanel'] ? true : false;
308
309 4fbf63aa Bill Marquette
		/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
310 52acb1ff Phil Davis
		$olddnsservers = $config['system']['dnsserver'];
311 5b237745 Scott Ullrich
		unset($config['system']['dnsserver']);
312 a2d23e88 Phil Davis
313
		$dnscounter = 0;
314
		$dnsname = "dns{$dnscounter}";
315
316
		while (isset($_POST[$dnsname])) {
317
			if ($_POST[$dnsname]) {
318
				$config['system']['dnsserver'][] = $_POST[$dnsname];
319
			}
320
			$dnscounter++;
321
			$dnsname = "dns{$dnscounter}";
322 2ee8dea1 Phil Davis
		}
323 04ad7c7c Scott Ullrich
324 a2d23e88 Phil Davis
		// Remember the new list for display also.
325
		$pconfig['dnsserver'] = $config['system']['dnsserver'];
326
327 07bd3f83 Scott Ullrich
		$olddnsallowoverride = $config['system']['dnsallowoverride'];
328 20b90e0a Scott Ullrich
329 0d8a219e Scott Ullrich
		unset($config['system']['dnsallowoverride']);
330 5b237745 Scott Ullrich
		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
331 e180a6e3 Scott Ullrich
332 2ee8dea1 Phil Davis
		if ($_POST['dnslocalhost'] == "yes") {
333 8ca95ed8 jim-p
			$config['system']['dnslocalhost'] = true;
334 2ee8dea1 Phil Davis
		} else {
335 8ca95ed8 jim-p
			unset($config['system']['dnslocalhost']);
336 2ee8dea1 Phil Davis
		}
337 8ca95ed8 jim-p
338 e180a6e3 Scott Ullrich
		/* which interface should the dns servers resolve through? */
339 a2d23e88 Phil Davis
		$dnscounter = 0;
340
		// The $_POST array key of the DNS IP (starts from 0)
341
		$dnsname = "dns{$dnscounter}";
342 df4471e2 Phil Davis
		$outdnscounter = 0;
343 a2d23e88 Phil Davis
		while (isset($_POST[$dnsname])) {
344
			// The $_POST array key of the corresponding gateway (starts from 0)
345
			$dnsgwname = "dnsgw{$dnscounter}";
346
			// The numbering of DNS GW entries in the config starts from 1
347
			$dnsgwconfigcounter = $dnscounter + 1;
348
			// So this is the array key of the DNS GW entry in $config['system']
349
			$dnsgwconfigname = "dns{$dnsgwconfigcounter}gw";
350
351
			$olddnsgwname = $config['system'][$dnsgwconfigname];
352 df4471e2 Phil Davis
353 2ee8dea1 Phil Davis
			if ($ignore_posted_dnsgw[$dnsgwname]) {
354 df4471e2 Phil Davis
				$thisdnsgwname = "none";
355 2ee8dea1 Phil Davis
			} else {
356 df4471e2 Phil Davis
				$thisdnsgwname = $pconfig[$dnsgwname];
357 2ee8dea1 Phil Davis
			}
358 df4471e2 Phil Davis
359
			// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
360 a2d23e88 Phil Davis
			$config['system'][$dnsgwconfigname] = "none";
361 df4471e2 Phil Davis
			$pconfig[$dnsgwname] = "none";
362
			$pconfig[$dnsname] = "";
363
364
			if ($_POST[$dnsname]) {
365
				// Only the non-blank DNS servers were put into the config above.
366
				// So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
367
				// 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.
368 a2d23e88 Phil Davis
369
				// The $pconfig array key of the DNS IP (starts from 0)
370
				$outdnsname = "dns{$outdnscounter}";
371
				// The $pconfig array key of the corresponding gateway (starts from 0)
372
				$outdnsgwname = "dnsgw{$outdnscounter}";
373
				// The numbering of DNS GW entries in the config starts from 1
374
				$outdnsgwconfigcounter = $outdnscounter + 1;
375
				// So this is the array key of the output DNS GW entry in $config['system']
376
				$outdnsgwconfigname = "dns{$outdnsgwconfigcounter}gw";
377
378 df4471e2 Phil Davis
				$pconfig[$outdnsname] = $_POST[$dnsname];
379 2ee8dea1 Phil Davis
				if ($_POST[$dnsgwname]) {
380 a2d23e88 Phil Davis
					$config['system'][$outdnsgwconfigname] = $thisdnsgwname;
381 df4471e2 Phil Davis
					$pconfig[$outdnsgwname] = $thisdnsgwname;
382
				} else {
383
					// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
384 a2d23e88 Phil Davis
					unset($config['system'][$outdnsgwconfigname]);
385 df4471e2 Phil Davis
					$pconfig[$outdnsgwname] = "";
386
				}
387 a2d23e88 Phil Davis
				$outdnscounter++;
388 d623f2da Seth Mos
			}
389 a2d23e88 Phil Davis
			if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter] != $_POST[$dnsname]))) {
390 52acb1ff Phil Davis
				// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
391
				// Remove the route. Later calls will add the correct new route if needed.
392 a2d23e88 Phil Davis
				if (is_ipaddrv4($olddnsservers[$dnscounter])) {
393 52acb1ff Phil Davis
					mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
394 a2d23e88 Phil Davis
				} else if (is_ipaddrv6($olddnsservers[$dnscounter])) {
395 312c32c9 Renato Botelho
					mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
396 2ee8dea1 Phil Davis
				}
397 52acb1ff Phil Davis
			}
398 a2d23e88 Phil Davis
399
			$dnscounter++;
400
			// The $_POST array key of the DNS IP (starts from 0)
401
			$dnsname = "dns{$dnscounter}";
402 d623f2da Seth Mos
		}
403 04ad7c7c Scott Ullrich
404 2ee8dea1 Phil Davis
		if ($changecount > 0) {
405 62d01225 Bill Marquette
			write_config($changedesc);
406 2ee8dea1 Phil Davis
		}
407 04ad7c7c Scott Ullrich
408 44c42356 Phil Davis
		$changes_applied = true;
409 5b237745 Scott Ullrich
		$retval = 0;
410 44c42356 Phil Davis
		$retval |= system_hostname_configure();
411 3cfdba5f Scott Ullrich
		$retval |= system_hosts_generate();
412
		$retval |= system_resolvconf_generate();
413 2ee8dea1 Phil Davis
		if (isset($config['dnsmasq']['enable'])) {
414 1e2c8821 Warren Baker
			$retval |= services_dnsmasq_configure();
415 2ee8dea1 Phil Davis
		} elseif (isset($config['unbound']['enable'])) {
416 1e2c8821 Warren Baker
			$retval |= services_unbound_configure();
417 2ee8dea1 Phil Davis
		}
418 3cfdba5f Scott Ullrich
		$retval |= system_timezone_configure();
419
		$retval |= system_ntp_configure();
420
421 2ee8dea1 Phil Davis
		if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
422 b8292903 Ermal
			$retval |= send_event("service reload dns");
423 2ee8dea1 Phil Davis
		}
424 3cfdba5f Scott Ullrich
425 e7d967d8 Scott Ullrich
		// Reload the filter - plugins might need to be run.
426 0027de0a Ermal Lu?i
		$retval |= filter_configure();
427 5b237745 Scott Ullrich
	}
428 df4471e2 Phil Davis
429
	unset($ignore_posted_dnsgw);
430 5b237745 Scott Ullrich
}
431 4df96eff Scott Ullrich
432 2ee8dea1 Phil Davis
$pgtitle = array(gettext("System"), gettext("General Setup"));
433 4df96eff Scott Ullrich
include("head.inc");
434
435 8f65151c Phil Davis
if ($input_errors) {
436 41ea4cf3 Sjon Hortensius
	print_input_errors($input_errors);
437 8f65151c Phil Davis
}
438 ddb84143 Stephen Beaver
439 44c42356 Phil Davis
if ($changes_applied) {
440
	print_apply_result_box($retval);
441 8f65151c Phil Davis
}
442 5b237745 Scott Ullrich
?>
443 41ea4cf3 Sjon Hortensius
<div id="container">
444 b40bcb23 Sjon Hortensius
<?php
445 1180e4f0 Sjon Hortensius
446 b40bcb23 Sjon Hortensius
$form = new Form;
447 a32c0623 Sjon Hortensius
$section = new Form_Section('System');
448
$section->addInput(new Form_Input(
449 a97531c5 Sjon Hortensius
	'hostname',
450 153c3aa6 Phil Davis
	'*Hostname',
451 a32c0623 Sjon Hortensius
	'text',
452
	$pconfig['hostname'],
453
	['placeholder' => 'pfSense']
454
))->setHelp('Name of the firewall host, without domain part');
455 512f2c10 Stephen Beaver
456 a32c0623 Sjon Hortensius
$section->addInput(new Form_Input(
457 a97531c5 Sjon Hortensius
	'domain',
458 153c3aa6 Phil Davis
	'*Domain',
459 a32c0623 Sjon Hortensius
	'text',
460
	$pconfig['domain'],
461
	['placeholder' => 'mycorp.com, home, office, private, etc.']
462 ef77e40e stilez
))->setHelp('Do not use \'.local\' as the final part of the domain (TLD), The \'.local\' domain is %1$swidely used%2$s by '.
463 d751dee3 stilez
	'mDNS (including Avahi and Apple OS X\'s Bonjour/Rendezvous/Airprint/Airplay), and some Windows systems and networked devices. ' .
464 ef77e40e stilez
	'These will not network correctly if the router uses \'.local\'. Alternatives such as \'.local.lan\' or \'.mylocal\' are safe.',
465
	 '<a target="_blank" href="https://www.unbound.net/pipermail/unbound-users/2011-March/001735.html">',
466
	 '</a>'
467
);
468 512f2c10 Stephen Beaver
469 b40bcb23 Sjon Hortensius
$form->add($section);
470
471 70dc5cd6 Phil Davis
$section = new Form_Section('DNS Server Settings');
472 b40bcb23 Sjon Hortensius
473 a2d23e88 Phil Davis
if (!is_array($pconfig['dnsserver'])) {
474
	$pconfig['dnsserver'] = array();
475
}
476
477
$dnsserver_count = count($pconfig['dnsserver']);
478
$dnsserver_num = 0;
479
$dnsserver_help = gettext("Address") . '<br/>' . gettext("Enter IP addresses to be used by the system for DNS resolution.") . " " .
480
	gettext("These are also used for the DHCP service, DNS Forwarder and DNS Resolver when it has DNS Query Forwarding enabled.");
481
$dnsgw_help = gettext("Gateway") . '<br/>'. gettext("Optionally select the gateway for each DNS server.") . " " .
482
	gettext("When using multiple WAN connections there should be at least one unique DNS server per gateway.");
483
484
// If there are no DNS servers, make an empty entry for initial display.
485
if ($dnsserver_count == 0) {
486
	$pconfig['dnsserver'][] = '';
487
}
488
489
foreach ($pconfig['dnsserver'] as $dnsserver) {
490 54c605d4 Stephen Beaver
491 a2d23e88 Phil Davis
	$is_last_dnsserver = ($dnsserver_num == $dnsserver_count - 1);
492
	$group = new Form_Group($dnsserver_num == 0 ? 'DNS Servers':'');
493
	$group->addClass('repeatable');
494 54c605d4 Stephen Beaver
495
	$group->add(new Form_Input(
496 a2d23e88 Phil Davis
		'dns' . $dnsserver_num,
497 54c605d4 Stephen Beaver
		'DNS Server',
498
		'text',
499 a2d23e88 Phil Davis
		$dnsserver
500
	))->setHelp(($is_last_dnsserver) ? $dnsserver_help:null);
501 b40bcb23 Sjon Hortensius
502 54c605d4 Stephen Beaver
	if ($multiwan)	{
503 b40bcb23 Sjon Hortensius
		$options = array('none' => 'none');
504
505 8f65151c Phil Davis
		foreach ($arr_gateways as $gwname => $gwitem) {
506
			if ((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
507 b40bcb23 Sjon Hortensius
				continue;
508
			}
509 54c605d4 Stephen Beaver
510 8f65151c Phil Davis
			if ((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
511 b40bcb23 Sjon Hortensius
				continue;
512
			}
513 1180e4f0 Sjon Hortensius
514 b40bcb23 Sjon Hortensius
			$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
515
		}
516 1180e4f0 Sjon Hortensius
517 a97531c5 Sjon Hortensius
		$group->add(new Form_Select(
518 a2d23e88 Phil Davis
			'dnsgw' . $dnsserver_num,
519 e4dd8be4 NOYB
			'Gateway',
520 a2d23e88 Phil Davis
			$pconfig['dnsgw' . $dnsserver_num],
521 a97531c5 Sjon Hortensius
			$options
522 a2d23e88 Phil Davis
		))->setHelp(($is_last_dnsserver) ? $dnsgw_help:null);;
523 b40bcb23 Sjon Hortensius
	}
524 1180e4f0 Sjon Hortensius
525 a2d23e88 Phil Davis
	$group->add(new Form_Button(
526
		'deleterow' . $dnsserver_num,
527
		'Delete',
528
		null,
529
		'fa-trash'
530
	))->addClass('btn-warning');
531 54c605d4 Stephen Beaver
532 b40bcb23 Sjon Hortensius
	$section->add($group);
533 a2d23e88 Phil Davis
	$dnsserver_num++;
534 b40bcb23 Sjon Hortensius
}
535 1180e4f0 Sjon Hortensius
536 a2d23e88 Phil Davis
$section->addInput(new Form_Button(
537
	'addrow',
538
	'Add DNS Server',
539
	null,
540
	'fa-plus'
541
))->addClass('btn-success addbtn');
542
543 a005a836 Sjon Hortensius
$section->addInput(new Form_Checkbox(
544 a97531c5 Sjon Hortensius
	'dnsallowoverride',
545 70dc5cd6 Phil Davis
	'DNS Server Override',
546 b40bcb23 Sjon Hortensius
	'Allow DNS server list to be overridden by DHCP/PPP on WAN',
547
	$pconfig['dnsallowoverride']
548 314a088a Phil Davis
))->setHelp('If this option is set, %s will use DNS servers '.
549 a32c0623 Sjon Hortensius
	'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
550 a56e37ca doktornotor
	'the DNS Forwarder/DNS Resolver). However, they will not be assigned to DHCP '.
551 314a088a Phil Davis
	'clients.', $g['product_name']);
552 b40bcb23 Sjon Hortensius
553 a005a836 Sjon Hortensius
$section->addInput(new Form_Checkbox(
554 a97531c5 Sjon Hortensius
	'dnslocalhost',
555 70dc5cd6 Phil Davis
	'Disable DNS Forwarder',
556 a56e37ca doktornotor
	'Do not use the DNS Forwarder/DNS Resolver as a DNS server for the firewall',
557 b40bcb23 Sjon Hortensius
	$pconfig['dnslocalhost']
558 e4dd8be4 NOYB
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS '.
559 a32c0623 Sjon Hortensius
	'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
560 a56e37ca doktornotor
	'listen on localhost, so system can use the local DNS service to perform '.
561
	'lookups. Checking this box omits localhost from the list of DNS servers in resolv.conf.');
562 b40bcb23 Sjon Hortensius
563
$form->add($section);
564
565 a005a836 Sjon Hortensius
$section = new Form_Section('Localization');
566 512f2c10 Stephen Beaver
567 a005a836 Sjon Hortensius
$section->addInput(new Form_Select(
568 a97531c5 Sjon Hortensius
	'timezone',
569 153c3aa6 Phil Davis
	'*Timezone',
570 a32c0623 Sjon Hortensius
	$pconfig['timezone'],
571 e5f4c829 Renato Botelho
	array_combine($timezonelist, $timezonedesc)
572 781d9ce4 Phil Davis
))->setHelp('Select a geographic region name (Continent/Location) to determine the timezone for the firewall. %1$s' .
573
	'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/>');
574 512f2c10 Stephen Beaver
575 a005a836 Sjon Hortensius
$section->addInput(new Form_Input(
576 a97531c5 Sjon Hortensius
	'timeservers',
577 a32c0623 Sjon Hortensius
	'Timeservers',
578
	'text',
579
	$pconfig['timeservers']
580
))->setHelp('Use a space to separate multiple hosts (only one required). '.
581 1bab4a10 NOYB
	'Remember to set up at least one DNS server if a host name is entered here!');
582 512f2c10 Stephen Beaver
583 a005a836 Sjon Hortensius
$section->addInput(new Form_Select(
584 a97531c5 Sjon Hortensius
	'language',
585 153c3aa6 Phil Davis
	'*Language',
586 a32c0623 Sjon Hortensius
	$pconfig['language'],
587
	get_locale_list()
588
))->setHelp('Choose a language for the webConfigurator');
589 b40bcb23 Sjon Hortensius
590
$form->add($section);
591
592 1176360c k-paulius
$section = new Form_Section('webConfigurator');
593 a5995a8e Stephen Beaver
594 8bab524e Phil Davis
gen_webguicss_field($section, $pconfig['webguicss']);
595
gen_webguifixedmenu_field($section, $pconfig['webguifixedmenu']);
596
gen_webguihostnamemenu_field($section, $pconfig['webguihostnamemenu']);
597
gen_dashboardcolumns_field($section, $pconfig['dashboardcolumns']);
598 1d3510cf Phil Davis
gen_interfacessort_field($section, $pconfig['interfacessort']);
599 8bab524e Phil Davis
gen_associatedpanels_fields(
600
	$section,
601
	$pconfig['dashboardavailablewidgetspanel'],
602
	$pconfig['systemlogsfilterpanel'],
603
	$pconfig['systemlogsmanagelogpanel'],
604
	$pconfig['statusmonitoringsettingspanel']);
605 88081ea2 derelict-pf
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
606 8bab524e Phil Davis
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
607 d9058974 Phil Davis
gen_disablealiaspopupdetail_field($section, $pconfig['disablealiaspopupdetail']);
608 24f15b3a NOYB
609 e79ff1ee Steve Beaver
$section->addInput(new Form_Select(
610
	'logincss',
611 d58a7378 Steve Beaver
	'Login page color',
612 e79ff1ee Steve Beaver
	$pconfig['logincss'],
613 d58a7378 Steve Beaver
	["1e3f75;" => gettext("Blue"), "003300" => gettext("Green"), "770101" => gettext("Red"),
614 626aefbe Steve Beaver
	 "4b1263" => gettext("Purple"), "424142" => gettext("Gray"), "333333" => gettext("Dark gray"),
615 79cd920c Steve Beaver
	 "633215" => gettext("Brown" ), "bf7703" => gettext("Orange")]
616 d58a7378 Steve Beaver
))->setHelp('Choose a color for the login page');
617 e79ff1ee Steve Beaver
618 a22947a4 Steve Beaver
$section->addInput(new Form_Checkbox(
619
	'loginshowhost',
620
	'Login hostname',
621
	'Show hostname on login banner',
622
	$pconfig['loginshowhost']
623
));
624 6c1f2a1c Steve Beaver
/*
625 512f2c10 Stephen Beaver
$section->addInput(new Form_Input(
626
	'dashboardperiod',
627
	'Dashboard update period',
628
	'number',
629
	$pconfig['dashboardperiod'],
630 134ee13d Stephen Beaver
	['min' => '5', 'max' => '600']
631 512f2c10 Stephen Beaver
))->setHelp('Time in seconds between dashboard widget updates. Small values cause ' .
632
			'more frequent updates but increase the load on the web server. ' .
633
			'Minimum is 5 seconds, maximum 600 seconds');
634 6c1f2a1c Steve Beaver
*/
635 a5995a8e Stephen Beaver
$form->add($section);
636
637 b40bcb23 Sjon Hortensius
print $form;
638 7bb301eb Stephen Beaver
639
$csswarning = sprintf(gettext("%sUser-created themes are unsupported, use at your own risk."), "<br />");
640
641 8c4ef875 NOYB
?>
642
</div>
643 7bb301eb Stephen Beaver
644 46345696 Colin Fleming
<script type="text/javascript">
645 7bb301eb Stephen Beaver
//<![CDATA[
646
events.push(function() {
647
648
	function setThemeWarning() {
649
		if ($('#webguicss').val().startsWith("pfSense")) {
650
			$('#csstxt').html("").addClass("text-default");
651
		} else {
652
			$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
653
		}
654
	}
655
656
	$('#webguicss').change(function() {
657
		setThemeWarning();
658
	});
659
660
	setThemeWarning();
661 a2d23e88 Phil Davis
662
	// Suppress "Delete row" button if there are fewer than two rows
663
	checkLastRow();
664 7bb301eb Stephen Beaver
});
665
//]]>
666
</script>
667
668 8c4ef875 NOYB
<?php
669 60ff91f1 Renato Botelho
include("foot.inc");
670 8c4ef875 NOYB
?>