1 |
04ad7c7c
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
|
|
system.php
|
4 |
|
|
*/
|
5 |
54c605d4
|
Stephen Beaver
|
/* ====================================================================
|
6 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
191cb31d
|
Stephen Beaver
|
*
|
8 |
cb41dd63
|
Renato Botelho
|
* Some or all of this file is based on the m0n0wall project which is
|
9 |
|
|
* Copyright (c) 2004 Manuel Kasper (BSD 2 clause)
|
10 |
54c605d4
|
Stephen Beaver
|
*
|
11 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
12 |
|
|
* are permitted provided that the following conditions are met:
|
13 |
|
|
*
|
14 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
* this list of conditions and the following disclaimer.
|
16 |
|
|
*
|
17 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
* notice, this list of conditions and the following disclaimer in
|
19 |
|
|
* the documentation and/or other materials provided with the
|
20 |
|
|
* distribution.
|
21 |
|
|
*
|
22 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
23 |
|
|
* must display the following acknowledgment:
|
24 |
|
|
* "This product includes software developed by the pfSense Project
|
25 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
26 |
|
|
*
|
27 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
28 |
|
|
* endorse or promote products derived from this software without
|
29 |
|
|
* prior written permission. For written permission, please contact
|
30 |
|
|
* coreteam@pfsense.org.
|
31 |
|
|
*
|
32 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
33 |
|
|
* nor may "pfSense" appear in their names without prior written
|
34 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
35 |
|
|
*
|
36 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
37 |
|
|
* acknowledgment:
|
38 |
|
|
*
|
39 |
|
|
* "This product includes software developed by the pfSense Project
|
40 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
41 |
|
|
*
|
42 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
43 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
44 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
45 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
46 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
47 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
48 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
49 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
50 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
51 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
52 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
53 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
54 |
|
|
*
|
55 |
|
|
* ====================================================================
|
56 |
|
|
*
|
57 |
|
|
*/
|
58 |
1d333258
|
Scott Ullrich
|
/*
|
59 |
|
|
pfSense_BUILDER_BINARIES: /bin/kill /usr/bin/tar
|
60 |
64c3b4cd
|
sbeaver
|
pfSense_MODULE: system
|
61 |
1d333258
|
Scott Ullrich
|
*/
|
62 |
5b237745
|
Scott Ullrich
|
|
63 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
64 |
|
|
##|*IDENT=page-system-generalsetup
|
65 |
5230f468
|
jim-p
|
##|*NAME=System: General Setup
|
66 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'System: General Setup' page.
|
67 |
|
|
##|*MATCH=system.php*
|
68 |
|
|
##|-PRIV
|
69 |
|
|
|
70 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
71 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
72 |
|
|
require_once("filter.inc");
|
73 |
|
|
require_once("shaper.inc");
|
74 |
60ff91f1
|
Renato Botelho
|
require_once("system.inc");
|
75 |
5b237745
|
Scott Ullrich
|
|
76 |
|
|
$pconfig['hostname'] = $config['system']['hostname'];
|
77 |
|
|
$pconfig['domain'] = $config['system']['domain'];
|
78 |
2ee8dea1
|
Phil Davis
|
list($pconfig['dns1'], $pconfig['dns2'], $pconfig['dns3'], $pconfig['dns4']) = $config['system']['dnsserver'];
|
79 |
0d8a219e
|
Scott Ullrich
|
|
80 |
d623f2da
|
Seth Mos
|
$arr_gateways = return_gateways_array();
|
81 |
|
|
|
82 |
477db933
|
Jared Dillard
|
// set default colmns to two if unset
|
83 |
|
|
if(!isset($config['system']['webgui']['dashboardcolumns'])) {
|
84 |
|
|
$config['system']['webgui']['dashboardcolumns'] = 2;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
d623f2da
|
Seth Mos
|
$pconfig['dns1gw'] = $config['system']['dns1gw'];
|
88 |
|
|
$pconfig['dns2gw'] = $config['system']['dns2gw'];
|
89 |
|
|
$pconfig['dns3gw'] = $config['system']['dns3gw'];
|
90 |
|
|
$pconfig['dns4gw'] = $config['system']['dns4gw'];
|
91 |
e180a6e3
|
Scott Ullrich
|
|
92 |
5b237745
|
Scott Ullrich
|
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
|
93 |
|
|
$pconfig['timezone'] = $config['system']['timezone'];
|
94 |
|
|
$pconfig['timeservers'] = $config['system']['timeservers'];
|
95 |
3e139f90
|
Vinicius Coque
|
$pconfig['language'] = $config['system']['language'];
|
96 |
a5995a8e
|
Stephen Beaver
|
$pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
|
97 |
3d29d2eb
|
Jared Dillard
|
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
|
98 |
477db933
|
Jared Dillard
|
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
|
99 |
8ca95ed8
|
jim-p
|
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
|
100 |
|
|
|
101 |
2ee8dea1
|
Phil Davis
|
if (!$pconfig['timezone']) {
|
102 |
ecaca752
|
Renato Botelho
|
if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
|
103 |
|
|
$pconfig['timezone'] = $g['default_timezone'];
|
104 |
|
|
} else {
|
105 |
|
|
$pconfig['timezone'] = "Etc/UTC";
|
106 |
|
|
}
|
107 |
2ee8dea1
|
Phil Davis
|
}
|
108 |
ecaca752
|
Renato Botelho
|
|
109 |
2ee8dea1
|
Phil Davis
|
if (!$pconfig['timeservers']) {
|
110 |
5b237745
|
Scott Ullrich
|
$pconfig['timeservers'] = "pool.ntp.org";
|
111 |
2ee8dea1
|
Phil Davis
|
}
|
112 |
04ad7c7c
|
Scott Ullrich
|
|
113 |
79eaddf4
|
Renato Botelho
|
$changedesc = gettext("System") . ": ";
|
114 |
62d01225
|
Bill Marquette
|
$changecount = 0;
|
115 |
417c6042
|
Bill Marquette
|
|
116 |
5b237745
|
Scott Ullrich
|
function is_timezone($elt) {
|
117 |
|
|
return !preg_match("/\/$/", $elt);
|
118 |
|
|
}
|
119 |
|
|
|
120 |
2ee8dea1
|
Phil Davis
|
if ($pconfig['timezone'] <> $_POST['timezone']) {
|
121 |
744306c6
|
jim-p
|
filter_pflog_start(true);
|
122 |
aa1ab1da
|
Scott Ullrich
|
}
|
123 |
|
|
|
124 |
60ff91f1
|
Renato Botelho
|
$timezonelist = system_get_timezone_list();
|
125 |
5b237745
|
Scott Ullrich
|
|
126 |
77446beb
|
Matthew Grooms
|
$multiwan = false;
|
127 |
7922db8a
|
Seth Mos
|
$interfaces = get_configured_interface_list();
|
128 |
2ee8dea1
|
Phil Davis
|
foreach ($interfaces as $interface) {
|
129 |
|
|
if (interface_has_gateway($interface)) {
|
130 |
77446beb
|
Matthew Grooms
|
$multiwan = true;
|
131 |
7922db8a
|
Seth Mos
|
}
|
132 |
|
|
}
|
133 |
77446beb
|
Matthew Grooms
|
|
134 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
135 |
|
|
|
136 |
c668c964
|
Scott Ullrich
|
$changecount++;
|
137 |
1180e4f0
|
Sjon Hortensius
|
|
138 |
5b237745
|
Scott Ullrich
|
unset($input_errors);
|
139 |
|
|
$pconfig = $_POST;
|
140 |
|
|
|
141 |
|
|
/* input validation */
|
142 |
cfbfd941
|
smos
|
$reqdfields = explode(" ", "hostname domain");
|
143 |
2ee8dea1
|
Phil Davis
|
$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
|
144 |
04ad7c7c
|
Scott Ullrich
|
|
145 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
146 |
04ad7c7c
|
Scott Ullrich
|
|
147 |
a5995a8e
|
Stephen Beaver
|
if ($_POST['webguicss']) {
|
148 |
|
|
$config['system']['webgui']['webguicss'] = $_POST['webguicss'];
|
149 |
|
|
} else {
|
150 |
|
|
unset($config['system']['webgui']['webguicss']);
|
151 |
|
|
}
|
152 |
3d29d2eb
|
Jared Dillard
|
|
153 |
ddb84143
|
Stephen Beaver
|
if ($_POST['webguifixedmenu']) {
|
154 |
|
|
$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
|
155 |
|
|
} else {
|
156 |
|
|
unset($config['system']['webgui']['webguifixedmenu']);
|
157 |
|
|
}
|
158 |
477db933
|
Jared Dillard
|
|
159 |
|
|
if ($_POST['dashboardcolumns']) {
|
160 |
|
|
$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
|
161 |
|
|
} else {
|
162 |
|
|
unset($config['system']['webgui']['dashboardcolumns']);
|
163 |
|
|
}
|
164 |
3d29d2eb
|
Jared Dillard
|
|
165 |
2d86ee95
|
Phil Davis
|
if ($_POST['hostname']) {
|
166 |
|
|
if (!is_hostname($_POST['hostname'])) {
|
167 |
|
|
$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
|
168 |
|
|
} else {
|
169 |
|
|
if (!is_unqualified_hostname($_POST['hostname'])) {
|
170 |
|
|
$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
5b237745
|
Scott Ullrich
|
}
|
174 |
|
|
if ($_POST['domain'] && !is_domain($_POST['domain'])) {
|
175 |
7465d12c
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
|
176 |
5b237745
|
Scott Ullrich
|
}
|
177 |
d623f2da
|
Seth Mos
|
|
178 |
df4471e2
|
Phil Davis
|
$ignore_posted_dnsgw = array();
|
179 |
|
|
|
180 |
2ee8dea1
|
Phil Davis
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
|
181 |
d623f2da
|
Seth Mos
|
$dnsname="dns{$dnscounter}";
|
182 |
|
|
$dnsgwname="dns{$dnscounter}gw";
|
183 |
|
|
if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
|
184 |
52acb1ff
|
Phil Davis
|
$input_errors[] = gettext("A valid IP address must be specified for DNS server $dnscounter.");
|
185 |
|
|
} else {
|
186 |
2ee8dea1
|
Phil Davis
|
if (($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
|
187 |
52acb1ff
|
Phil Davis
|
// A real gateway has been selected.
|
188 |
|
|
if (is_ipaddr($_POST[$dnsname])) {
|
189 |
2ee8dea1
|
Phil Davis
|
if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
|
190 |
52acb1ff
|
Phil Davis
|
$input_errors[] = gettext("You can not specify IPv6 gateway '{$_POST[$dnsgwname]}' for IPv4 DNS server '{$_POST[$dnsname]}'");
|
191 |
|
|
}
|
192 |
2ee8dea1
|
Phil Davis
|
if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
|
193 |
52acb1ff
|
Phil Davis
|
$input_errors[] = gettext("You can not specify IPv4 gateway '{$_POST[$dnsgwname]}' for IPv6 DNS server '{$_POST[$dnsname]}'");
|
194 |
|
|
}
|
195 |
|
|
} else {
|
196 |
df4471e2
|
Phil Davis
|
// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
|
197 |
|
|
$ignore_posted_dnsgw[$dnsgwname] = true;
|
198 |
52acb1ff
|
Phil Davis
|
}
|
199 |
13ea7caa
|
smos
|
}
|
200 |
d623f2da
|
Seth Mos
|
}
|
201 |
5b237745
|
Scott Ullrich
|
}
|
202 |
d623f2da
|
Seth Mos
|
|
203 |
985fc0fb
|
Ermal Lu?i
|
$direct_networks_list = explode(" ", filter_get_direct_networks_list());
|
204 |
c98d28e1
|
Seth Mos
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
|
205 |
|
|
$dnsitem = "dns{$dnscounter}";
|
206 |
d623f2da
|
Seth Mos
|
$dnsgwitem = "dns{$dnscounter}gw";
|
207 |
c98d28e1
|
Seth Mos
|
if ($_POST[$dnsgwitem]) {
|
208 |
2ee8dea1
|
Phil Davis
|
if (interface_has_gateway($_POST[$dnsgwitem])) {
|
209 |
|
|
foreach ($direct_networks_list as $direct_network) {
|
210 |
|
|
if (ip_in_subnet($_POST[$dnsitem], $direct_network)) {
|
211 |
|
|
$input_errors[] = sprintf(gettext("You can not assign a gateway to DNS '%s' server which is on a directly connected network."), $_POST[$dnsitem]);
|
212 |
c98d28e1
|
Seth Mos
|
}
|
213 |
|
|
}
|
214 |
|
|
}
|
215 |
|
|
}
|
216 |
|
|
}
|
217 |
|
|
|
218 |
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.
|
219 |
|
|
$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
|
220 |
|
|
$_POST['timeservers'] = trim($_POST['timeservers']);
|
221 |
5b237745
|
Scott Ullrich
|
foreach (explode(' ', $_POST['timeservers']) as $ts) {
|
222 |
|
|
if (!is_domain($ts)) {
|
223 |
7465d12c
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
|
224 |
5b237745
|
Scott Ullrich
|
}
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
if (!$input_errors) {
|
228 |
f1a34790
|
N0YB
|
update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
|
229 |
|
|
update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
|
230 |
9eab73da
|
Bill Marquette
|
update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
|
231 |
|
|
update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
|
232 |
04ad7c7c
|
Scott Ullrich
|
|
233 |
2ee8dea1
|
Phil Davis
|
if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
|
234 |
3e139f90
|
Vinicius Coque
|
$config['system']['language'] = $_POST['language'];
|
235 |
|
|
set_language($config['system']['language']);
|
236 |
|
|
}
|
237 |
|
|
|
238 |
4fbf63aa
|
Bill Marquette
|
/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
|
239 |
52acb1ff
|
Phil Davis
|
$olddnsservers = $config['system']['dnsserver'];
|
240 |
5b237745
|
Scott Ullrich
|
unset($config['system']['dnsserver']);
|
241 |
2ee8dea1
|
Phil Davis
|
if ($_POST['dns1']) {
|
242 |
5b237745
|
Scott Ullrich
|
$config['system']['dnsserver'][] = $_POST['dns1'];
|
243 |
2ee8dea1
|
Phil Davis
|
}
|
244 |
|
|
if ($_POST['dns2']) {
|
245 |
5b237745
|
Scott Ullrich
|
$config['system']['dnsserver'][] = $_POST['dns2'];
|
246 |
2ee8dea1
|
Phil Davis
|
}
|
247 |
|
|
if ($_POST['dns3']) {
|
248 |
93e0800d
|
Scott Ullrich
|
$config['system']['dnsserver'][] = $_POST['dns3'];
|
249 |
2ee8dea1
|
Phil Davis
|
}
|
250 |
|
|
if ($_POST['dns4']) {
|
251 |
93e0800d
|
Scott Ullrich
|
$config['system']['dnsserver'][] = $_POST['dns4'];
|
252 |
2ee8dea1
|
Phil Davis
|
}
|
253 |
04ad7c7c
|
Scott Ullrich
|
|
254 |
07bd3f83
|
Scott Ullrich
|
$olddnsallowoverride = $config['system']['dnsallowoverride'];
|
255 |
20b90e0a
|
Scott Ullrich
|
|
256 |
0d8a219e
|
Scott Ullrich
|
unset($config['system']['dnsallowoverride']);
|
257 |
5b237745
|
Scott Ullrich
|
$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
|
258 |
e180a6e3
|
Scott Ullrich
|
|
259 |
2ee8dea1
|
Phil Davis
|
if ($_POST['dnslocalhost'] == "yes") {
|
260 |
8ca95ed8
|
jim-p
|
$config['system']['dnslocalhost'] = true;
|
261 |
2ee8dea1
|
Phil Davis
|
} else {
|
262 |
8ca95ed8
|
jim-p
|
unset($config['system']['dnslocalhost']);
|
263 |
2ee8dea1
|
Phil Davis
|
}
|
264 |
8ca95ed8
|
jim-p
|
|
265 |
e180a6e3
|
Scott Ullrich
|
/* which interface should the dns servers resolve through? */
|
266 |
df4471e2
|
Phil Davis
|
$outdnscounter = 0;
|
267 |
d623f2da
|
Seth Mos
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
|
268 |
|
|
$dnsname="dns{$dnscounter}";
|
269 |
|
|
$dnsgwname="dns{$dnscounter}gw";
|
270 |
52acb1ff
|
Phil Davis
|
$olddnsgwname = $config['system'][$dnsgwname];
|
271 |
df4471e2
|
Phil Davis
|
|
272 |
2ee8dea1
|
Phil Davis
|
if ($ignore_posted_dnsgw[$dnsgwname]) {
|
273 |
df4471e2
|
Phil Davis
|
$thisdnsgwname = "none";
|
274 |
2ee8dea1
|
Phil Davis
|
} else {
|
275 |
df4471e2
|
Phil Davis
|
$thisdnsgwname = $pconfig[$dnsgwname];
|
276 |
2ee8dea1
|
Phil Davis
|
}
|
277 |
df4471e2
|
Phil Davis
|
|
278 |
|
|
// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
|
279 |
|
|
$config['system'][$dnsgwname] = "none";
|
280 |
|
|
$pconfig[$dnsgwname] = "none";
|
281 |
|
|
$pconfig[$dnsname] = "";
|
282 |
|
|
|
283 |
|
|
if ($_POST[$dnsname]) {
|
284 |
|
|
// Only the non-blank DNS servers were put into the config above.
|
285 |
|
|
// So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
|
286 |
|
|
// 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.
|
287 |
|
|
$outdnscounter++;
|
288 |
|
|
$outdnsname="dns{$outdnscounter}";
|
289 |
|
|
$outdnsgwname="dns{$outdnscounter}gw";
|
290 |
|
|
$pconfig[$outdnsname] = $_POST[$dnsname];
|
291 |
2ee8dea1
|
Phil Davis
|
if ($_POST[$dnsgwname]) {
|
292 |
df4471e2
|
Phil Davis
|
$config['system'][$outdnsgwname] = $thisdnsgwname;
|
293 |
|
|
$pconfig[$outdnsgwname] = $thisdnsgwname;
|
294 |
|
|
} else {
|
295 |
|
|
// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
|
296 |
|
|
unset($config['system'][$outdnsgwname]);
|
297 |
|
|
$pconfig[$outdnsgwname] = "";
|
298 |
|
|
}
|
299 |
d623f2da
|
Seth Mos
|
}
|
300 |
df4471e2
|
Phil Davis
|
if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter-1] != $_POST[$dnsname]))) {
|
301 |
52acb1ff
|
Phil Davis
|
// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
|
302 |
|
|
// Remove the route. Later calls will add the correct new route if needed.
|
303 |
2ee8dea1
|
Phil Davis
|
if (is_ipaddrv4($olddnsservers[$dnscounter-1])) {
|
304 |
52acb1ff
|
Phil Davis
|
mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
|
305 |
312c32c9
|
Renato Botelho
|
} else if (is_ipaddrv6($olddnsservers[$dnscounter-1])) {
|
306 |
|
|
mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
|
307 |
2ee8dea1
|
Phil Davis
|
}
|
308 |
52acb1ff
|
Phil Davis
|
}
|
309 |
d623f2da
|
Seth Mos
|
}
|
310 |
04ad7c7c
|
Scott Ullrich
|
|
311 |
2ee8dea1
|
Phil Davis
|
if ($changecount > 0) {
|
312 |
62d01225
|
Bill Marquette
|
write_config($changedesc);
|
313 |
2ee8dea1
|
Phil Davis
|
}
|
314 |
04ad7c7c
|
Scott Ullrich
|
|
315 |
5b237745
|
Scott Ullrich
|
$retval = 0;
|
316 |
3cfdba5f
|
Scott Ullrich
|
$retval = system_hostname_configure();
|
317 |
|
|
$retval |= system_hosts_generate();
|
318 |
|
|
$retval |= system_resolvconf_generate();
|
319 |
2ee8dea1
|
Phil Davis
|
if (isset($config['dnsmasq']['enable'])) {
|
320 |
1e2c8821
|
Warren Baker
|
$retval |= services_dnsmasq_configure();
|
321 |
2ee8dea1
|
Phil Davis
|
} elseif (isset($config['unbound']['enable'])) {
|
322 |
1e2c8821
|
Warren Baker
|
$retval |= services_unbound_configure();
|
323 |
2ee8dea1
|
Phil Davis
|
}
|
324 |
3cfdba5f
|
Scott Ullrich
|
$retval |= system_timezone_configure();
|
325 |
|
|
$retval |= system_ntp_configure();
|
326 |
|
|
|
327 |
2ee8dea1
|
Phil Davis
|
if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
|
328 |
b8292903
|
Ermal
|
$retval |= send_event("service reload dns");
|
329 |
2ee8dea1
|
Phil Davis
|
}
|
330 |
3cfdba5f
|
Scott Ullrich
|
|
331 |
e7d967d8
|
Scott Ullrich
|
// Reload the filter - plugins might need to be run.
|
332 |
0027de0a
|
Ermal Lu?i
|
$retval |= filter_configure();
|
333 |
1180e4f0
|
Sjon Hortensius
|
|
334 |
5b237745
|
Scott Ullrich
|
$savemsg = get_std_save_message($retval);
|
335 |
|
|
}
|
336 |
df4471e2
|
Phil Davis
|
|
337 |
|
|
unset($ignore_posted_dnsgw);
|
338 |
5b237745
|
Scott Ullrich
|
}
|
339 |
4df96eff
|
Scott Ullrich
|
|
340 |
2ee8dea1
|
Phil Davis
|
$pgtitle = array(gettext("System"), gettext("General Setup"));
|
341 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
342 |
|
|
|
343 |
41ea4cf3
|
Sjon Hortensius
|
if ($input_errors)
|
344 |
|
|
print_input_errors($input_errors);
|
345 |
ddb84143
|
Stephen Beaver
|
|
346 |
41ea4cf3
|
Sjon Hortensius
|
if ($savemsg)
|
347 |
ddb84143
|
Stephen Beaver
|
print_info_box($savemsg, success);
|
348 |
5b237745
|
Scott Ullrich
|
?>
|
349 |
41ea4cf3
|
Sjon Hortensius
|
<div id="container">
|
350 |
b40bcb23
|
Sjon Hortensius
|
<?php
|
351 |
1180e4f0
|
Sjon Hortensius
|
|
352 |
b40bcb23
|
Sjon Hortensius
|
$form = new Form;
|
353 |
a32c0623
|
Sjon Hortensius
|
$section = new Form_Section('System');
|
354 |
|
|
$section->addInput(new Form_Input(
|
355 |
a97531c5
|
Sjon Hortensius
|
'hostname',
|
356 |
a32c0623
|
Sjon Hortensius
|
'Hostname',
|
357 |
|
|
'text',
|
358 |
|
|
$pconfig['hostname'],
|
359 |
|
|
['placeholder' => 'pfSense']
|
360 |
|
|
))->setHelp('Name of the firewall host, without domain part');
|
361 |
|
|
$section->addInput(new Form_Input(
|
362 |
a97531c5
|
Sjon Hortensius
|
'domain',
|
363 |
a32c0623
|
Sjon Hortensius
|
'Domain',
|
364 |
|
|
'text',
|
365 |
|
|
$pconfig['domain'],
|
366 |
|
|
['placeholder' => 'mycorp.com, home, office, private, etc.']
|
367 |
|
|
))->setHelp('Do not use \'local\' as a domain name. It will cause local '.
|
368 |
|
|
'hosts running mDNS (avahi, bonjour, etc.) to be unable to resolve '.
|
369 |
|
|
'local hosts not running mDNS.');
|
370 |
b40bcb23
|
Sjon Hortensius
|
$form->add($section);
|
371 |
|
|
|
372 |
a005a836
|
Sjon Hortensius
|
$section = new Form_Section('DNS server settings');
|
373 |
b40bcb23
|
Sjon Hortensius
|
|
374 |
|
|
for ($i=1; $i<5; $i++)
|
375 |
|
|
{
|
376 |
54c605d4
|
Stephen Beaver
|
// if (!isset($pconfig['dns'.$i]))
|
377 |
|
|
// continue;
|
378 |
|
|
|
379 |
|
|
$group = new Form_Group('DNS Server ' . $i);
|
380 |
|
|
|
381 |
|
|
$group->add(new Form_Input(
|
382 |
c52e1c1f
|
Stephen Beaver
|
'dns' . $i,
|
383 |
54c605d4
|
Stephen Beaver
|
'DNS Server',
|
384 |
|
|
'text',
|
385 |
c52e1c1f
|
Stephen Beaver
|
$pconfig['dns'. $i]
|
386 |
54c605d4
|
Stephen Beaver
|
))->setHelp(($i == 4) ? 'Address':null);
|
387 |
b40bcb23
|
Sjon Hortensius
|
|
388 |
|
|
$help = "Enter IP addresses to be used by the system for DNS resolution. " .
|
389 |
|
|
"These are also used for the DHCP service, DNS forwarder and for PPTP VPN clients.";
|
390 |
|
|
|
391 |
54c605d4
|
Stephen Beaver
|
if ($multiwan) {
|
392 |
b40bcb23
|
Sjon Hortensius
|
$options = array('none' => 'none');
|
393 |
|
|
|
394 |
54c605d4
|
Stephen Beaver
|
foreach($arr_gateways as $gwname => $gwitem) {
|
395 |
b40bcb23
|
Sjon Hortensius
|
if((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
|
396 |
|
|
continue;
|
397 |
|
|
}
|
398 |
54c605d4
|
Stephen Beaver
|
|
399 |
b40bcb23
|
Sjon Hortensius
|
if((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
|
400 |
|
|
continue;
|
401 |
|
|
}
|
402 |
1180e4f0
|
Sjon Hortensius
|
|
403 |
b40bcb23
|
Sjon Hortensius
|
$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
|
404 |
|
|
}
|
405 |
1180e4f0
|
Sjon Hortensius
|
|
406 |
a97531c5
|
Sjon Hortensius
|
$group->add(new Form_Select(
|
407 |
c52e1c1f
|
Stephen Beaver
|
'dns' . $i . 'gw',
|
408 |
a97531c5
|
Sjon Hortensius
|
'Gateway',
|
409 |
c52e1c1f
|
Stephen Beaver
|
$pconfig['dns' . $i . 'gw'],
|
410 |
a97531c5
|
Sjon Hortensius
|
$options
|
411 |
54c605d4
|
Stephen Beaver
|
))->setHelp(($i == 4) ? 'Gateway':null);;
|
412 |
1180e4f0
|
Sjon Hortensius
|
|
413 |
b40bcb23
|
Sjon Hortensius
|
$help .= '<br/>'. "In addition, optionally select the gateway for each DNS server. " .
|
414 |
|
|
"When using multiple WAN connections there should be at least one unique DNS server per gateway.";
|
415 |
|
|
}
|
416 |
1180e4f0
|
Sjon Hortensius
|
|
417 |
54c605d4
|
Stephen Beaver
|
if($i == 4)
|
418 |
|
|
$group->setHelp($help);
|
419 |
|
|
|
420 |
b40bcb23
|
Sjon Hortensius
|
$section->add($group);
|
421 |
|
|
}
|
422 |
1180e4f0
|
Sjon Hortensius
|
|
423 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Checkbox(
|
424 |
a97531c5
|
Sjon Hortensius
|
'dnsallowoverride',
|
425 |
b40bcb23
|
Sjon Hortensius
|
'DNS server override',
|
426 |
|
|
'Allow DNS server list to be overridden by DHCP/PPP on WAN',
|
427 |
|
|
$pconfig['dnsallowoverride']
|
428 |
a32c0623
|
Sjon Hortensius
|
))->setHelp(sprintf(gettext('If this option is set, %s will use DNS servers'.
|
429 |
|
|
'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
|
430 |
|
|
'the DNS forwarder). However, they will not be assigned to DHCP and PPTP '.
|
431 |
|
|
'VPN clients.'), $g['product_name']));
|
432 |
b40bcb23
|
Sjon Hortensius
|
|
433 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Checkbox(
|
434 |
a97531c5
|
Sjon Hortensius
|
'dnslocalhost',
|
435 |
b40bcb23
|
Sjon Hortensius
|
'Disable DNS forwarder',
|
436 |
|
|
'Do not use the DNS Forwarder as a DNS server for the firewall',
|
437 |
|
|
$pconfig['dnslocalhost']
|
438 |
a32c0623
|
Sjon Hortensius
|
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS'.
|
439 |
|
|
'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
|
440 |
|
|
'listen on Localhost, so system can use the local DNS service to perform'.
|
441 |
|
|
'lookups. Checking this box omits localhost from the list of DNS servers.');
|
442 |
b40bcb23
|
Sjon Hortensius
|
|
443 |
|
|
$form->add($section);
|
444 |
|
|
|
445 |
a005a836
|
Sjon Hortensius
|
$section = new Form_Section('Localization');
|
446 |
|
|
$section->addInput(new Form_Select(
|
447 |
a97531c5
|
Sjon Hortensius
|
'timezone',
|
448 |
a32c0623
|
Sjon Hortensius
|
'Timezone',
|
449 |
|
|
$pconfig['timezone'],
|
450 |
64c3b4cd
|
sbeaver
|
array_combine($timezonelist, $timezonelist)
|
451 |
a32c0623
|
Sjon Hortensius
|
))->setHelp('Select the location closest to you');
|
452 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Input(
|
453 |
a97531c5
|
Sjon Hortensius
|
'timeservers',
|
454 |
a32c0623
|
Sjon Hortensius
|
'Timeservers',
|
455 |
|
|
'text',
|
456 |
|
|
$pconfig['timeservers']
|
457 |
|
|
))->setHelp('Use a space to separate multiple hosts (only one required). '.
|
458 |
|
|
'Remember to set up at least one DNS server if you enter a host name here!');
|
459 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Select(
|
460 |
a97531c5
|
Sjon Hortensius
|
'language',
|
461 |
a32c0623
|
Sjon Hortensius
|
'Language',
|
462 |
|
|
$pconfig['language'],
|
463 |
|
|
get_locale_list()
|
464 |
|
|
))->setHelp('Choose a language for the webConfigurator');
|
465 |
b40bcb23
|
Sjon Hortensius
|
|
466 |
|
|
$form->add($section);
|
467 |
|
|
|
468 |
a5995a8e
|
Stephen Beaver
|
$csslist = array();
|
469 |
|
|
$css = glob("bootstrap/css/*.css");
|
470 |
|
|
foreach ($css as $file) {
|
471 |
|
|
$file = basename($file);
|
472 |
|
|
if(substr($file, 0, 9) !== 'bootstrap') {
|
473 |
|
|
$csslist[$file] = pathinfo($file, PATHINFO_FILENAME);
|
474 |
|
|
}
|
475 |
|
|
}
|
476 |
|
|
|
477 |
7aaa0663
|
Stephen Beaver
|
asort($csslist);
|
478 |
|
|
|
479 |
f0a9dec4
|
Phil Davis
|
if (!isset($pconfig['webguicss']) || !isset($csslist[$pconfig['webguicss']])) {
|
480 |
c040eeda
|
Phil Davis
|
$pconfig['webguicss'] = "pfSense.css";
|
481 |
|
|
}
|
482 |
|
|
|
483 |
477db933
|
Jared Dillard
|
$section = new Form_Section('Web Configurator');
|
484 |
a5995a8e
|
Stephen Beaver
|
|
485 |
|
|
$section->addInput(new Form_Select(
|
486 |
|
|
'webguicss',
|
487 |
|
|
'Theme',
|
488 |
|
|
$pconfig['webguicss'],
|
489 |
|
|
$csslist
|
490 |
9911c685
|
Stephen Beaver
|
))->setHelp('<span class="badge" title="This feature is in BETA">BETA</span> Choose an alternative css file (if installed) to change the appearance of the Web configurator. css files are located in /usr/local/www/bootstrap/css');
|
491 |
3d29d2eb
|
Jared Dillard
|
|
492 |
ddb84143
|
Stephen Beaver
|
$section->addInput(new Form_Select(
|
493 |
|
|
'webguifixedmenu',
|
494 |
477db933
|
Jared Dillard
|
'Top Navigation',
|
495 |
e82778da
|
Stephen Beaver
|
$pconfig['webguifixedmenu'],
|
496 |
|
|
["" => "Scrolls with page", "fixed" => "Fixed (Remains visible at top of page)"]
|
497 |
3d29d2eb
|
Jared Dillard
|
))->setHelp("<span class=\"badge bg-danger\" title=\"This feature is in BETA\">BETA</span>");
|
498 |
|
|
|
499 |
477db933
|
Jared Dillard
|
$section->addInput(new Form_Input(
|
500 |
|
|
'dashboardcolumns',
|
501 |
|
|
'Dashboard Columns',
|
502 |
9911c685
|
Stephen Beaver
|
'number',
|
503 |
|
|
$pconfig['dashboardcolumns'],
|
504 |
|
|
[min => 1, max => 4]
|
505 |
|
|
))->setHelp('<span class="badge" title="This feature is in BETA">BETA</span>');
|
506 |
477db933
|
Jared Dillard
|
|
507 |
a5995a8e
|
Stephen Beaver
|
$form->add($section);
|
508 |
|
|
|
509 |
b40bcb23
|
Sjon Hortensius
|
print $form;
|
510 |
69f9ff40
|
Sjon Hortensius
|
|
511 |
60ff91f1
|
Renato Botelho
|
include("foot.inc");
|