Project

General

Profile

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