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 |
5b237745
|
Scott Ullrich
|
|
59 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
60 |
|
|
##|*IDENT=page-system-generalsetup
|
61 |
5230f468
|
jim-p
|
##|*NAME=System: General Setup
|
62 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'System: General Setup' page.
|
63 |
|
|
##|*MATCH=system.php*
|
64 |
|
|
##|-PRIV
|
65 |
|
|
|
66 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
67 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
68 |
|
|
require_once("filter.inc");
|
69 |
|
|
require_once("shaper.inc");
|
70 |
60ff91f1
|
Renato Botelho
|
require_once("system.inc");
|
71 |
5b237745
|
Scott Ullrich
|
|
72 |
|
|
$pconfig['hostname'] = $config['system']['hostname'];
|
73 |
|
|
$pconfig['domain'] = $config['system']['domain'];
|
74 |
2ee8dea1
|
Phil Davis
|
list($pconfig['dns1'], $pconfig['dns2'], $pconfig['dns3'], $pconfig['dns4']) = $config['system']['dnsserver'];
|
75 |
0d8a219e
|
Scott Ullrich
|
|
76 |
d623f2da
|
Seth Mos
|
$arr_gateways = return_gateways_array();
|
77 |
|
|
|
78 |
477db933
|
Jared Dillard
|
// set default colmns to two if unset
|
79 |
8f65151c
|
Phil Davis
|
if (!isset($config['system']['webgui']['dashboardcolumns'])) {
|
80 |
477db933
|
Jared Dillard
|
$config['system']['webgui']['dashboardcolumns'] = 2;
|
81 |
|
|
}
|
82 |
|
|
|
83 |
d623f2da
|
Seth Mos
|
$pconfig['dns1gw'] = $config['system']['dns1gw'];
|
84 |
|
|
$pconfig['dns2gw'] = $config['system']['dns2gw'];
|
85 |
|
|
$pconfig['dns3gw'] = $config['system']['dns3gw'];
|
86 |
|
|
$pconfig['dns4gw'] = $config['system']['dns4gw'];
|
87 |
e180a6e3
|
Scott Ullrich
|
|
88 |
5b237745
|
Scott Ullrich
|
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
|
89 |
|
|
$pconfig['timezone'] = $config['system']['timezone'];
|
90 |
|
|
$pconfig['timeservers'] = $config['system']['timeservers'];
|
91 |
3e139f90
|
Vinicius Coque
|
$pconfig['language'] = $config['system']['language'];
|
92 |
a5995a8e
|
Stephen Beaver
|
$pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
|
93 |
3d29d2eb
|
Jared Dillard
|
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
|
94 |
477db933
|
Jared Dillard
|
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
|
95 |
24f15b3a
|
NOYB
|
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
|
96 |
c05363c8
|
NOYB
|
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
|
97 |
|
|
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
|
98 |
|
|
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
|
99 |
b1b8784a
|
NOYB
|
$pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
|
100 |
8ca95ed8
|
jim-p
|
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
|
101 |
|
|
|
102 |
2ee8dea1
|
Phil Davis
|
if (!$pconfig['timezone']) {
|
103 |
ecaca752
|
Renato Botelho
|
if (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
|
104 |
|
|
$pconfig['timezone'] = $g['default_timezone'];
|
105 |
|
|
} else {
|
106 |
|
|
$pconfig['timezone'] = "Etc/UTC";
|
107 |
|
|
}
|
108 |
2ee8dea1
|
Phil Davis
|
}
|
109 |
ecaca752
|
Renato Botelho
|
|
110 |
2ee8dea1
|
Phil Davis
|
if (!$pconfig['timeservers']) {
|
111 |
5b237745
|
Scott Ullrich
|
$pconfig['timeservers'] = "pool.ntp.org";
|
112 |
2ee8dea1
|
Phil Davis
|
}
|
113 |
04ad7c7c
|
Scott Ullrich
|
|
114 |
79eaddf4
|
Renato Botelho
|
$changedesc = gettext("System") . ": ";
|
115 |
62d01225
|
Bill Marquette
|
$changecount = 0;
|
116 |
417c6042
|
Bill Marquette
|
|
117 |
5b237745
|
Scott Ullrich
|
function is_timezone($elt) {
|
118 |
|
|
return !preg_match("/\/$/", $elt);
|
119 |
|
|
}
|
120 |
|
|
|
121 |
2ee8dea1
|
Phil Davis
|
if ($pconfig['timezone'] <> $_POST['timezone']) {
|
122 |
744306c6
|
jim-p
|
filter_pflog_start(true);
|
123 |
aa1ab1da
|
Scott Ullrich
|
}
|
124 |
|
|
|
125 |
60ff91f1
|
Renato Botelho
|
$timezonelist = system_get_timezone_list();
|
126 |
5b237745
|
Scott Ullrich
|
|
127 |
77446beb
|
Matthew Grooms
|
$multiwan = false;
|
128 |
7922db8a
|
Seth Mos
|
$interfaces = get_configured_interface_list();
|
129 |
2ee8dea1
|
Phil Davis
|
foreach ($interfaces as $interface) {
|
130 |
|
|
if (interface_has_gateway($interface)) {
|
131 |
77446beb
|
Matthew Grooms
|
$multiwan = true;
|
132 |
7922db8a
|
Seth Mos
|
}
|
133 |
|
|
}
|
134 |
77446beb
|
Matthew Grooms
|
|
135 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
136 |
|
|
|
137 |
c668c964
|
Scott Ullrich
|
$changecount++;
|
138 |
1180e4f0
|
Sjon Hortensius
|
|
139 |
5b237745
|
Scott Ullrich
|
unset($input_errors);
|
140 |
|
|
$pconfig = $_POST;
|
141 |
|
|
|
142 |
|
|
/* input validation */
|
143 |
cfbfd941
|
smos
|
$reqdfields = explode(" ", "hostname domain");
|
144 |
2ee8dea1
|
Phil Davis
|
$reqdfieldsn = array(gettext("Hostname"), gettext("Domain"));
|
145 |
04ad7c7c
|
Scott Ullrich
|
|
146 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
147 |
04ad7c7c
|
Scott Ullrich
|
|
148 |
a5995a8e
|
Stephen Beaver
|
if ($_POST['webguicss']) {
|
149 |
|
|
$config['system']['webgui']['webguicss'] = $_POST['webguicss'];
|
150 |
|
|
} else {
|
151 |
|
|
unset($config['system']['webgui']['webguicss']);
|
152 |
|
|
}
|
153 |
8f65151c
|
Phil Davis
|
|
154 |
ddb84143
|
Stephen Beaver
|
if ($_POST['webguifixedmenu']) {
|
155 |
|
|
$config['system']['webgui']['webguifixedmenu'] = $_POST['webguifixedmenu'];
|
156 |
|
|
} else {
|
157 |
|
|
unset($config['system']['webgui']['webguifixedmenu']);
|
158 |
|
|
}
|
159 |
477db933
|
Jared Dillard
|
|
160 |
|
|
if ($_POST['dashboardcolumns']) {
|
161 |
|
|
$config['system']['webgui']['dashboardcolumns'] = $_POST['dashboardcolumns'];
|
162 |
|
|
} else {
|
163 |
|
|
unset($config['system']['webgui']['dashboardcolumns']);
|
164 |
8f65151c
|
Phil Davis
|
}
|
165 |
|
|
|
166 |
2d86ee95
|
Phil Davis
|
if ($_POST['hostname']) {
|
167 |
|
|
if (!is_hostname($_POST['hostname'])) {
|
168 |
|
|
$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
|
169 |
|
|
} else {
|
170 |
|
|
if (!is_unqualified_hostname($_POST['hostname'])) {
|
171 |
|
|
$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
|
172 |
|
|
}
|
173 |
|
|
}
|
174 |
5b237745
|
Scott Ullrich
|
}
|
175 |
|
|
if ($_POST['domain'] && !is_domain($_POST['domain'])) {
|
176 |
7465d12c
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
|
177 |
5b237745
|
Scott Ullrich
|
}
|
178 |
d623f2da
|
Seth Mos
|
|
179 |
58b07c57
|
NewEraCracker
|
$dnslist = $ignore_posted_dnsgw = array();
|
180 |
df4471e2
|
Phil Davis
|
|
181 |
2ee8dea1
|
Phil Davis
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
|
182 |
d623f2da
|
Seth Mos
|
$dnsname="dns{$dnscounter}";
|
183 |
|
|
$dnsgwname="dns{$dnscounter}gw";
|
184 |
a936104b
|
Stephen Beaver
|
$dnslist[] = $_POST[$dnsname];
|
185 |
|
|
|
186 |
d623f2da
|
Seth Mos
|
if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
|
187 |
762faef5
|
Phil Davis
|
$input_errors[] = sprintf(gettext("A valid IP address must be specified for DNS server %s."), $dnscounter);
|
188 |
52acb1ff
|
Phil Davis
|
} else {
|
189 |
2ee8dea1
|
Phil Davis
|
if (($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
|
190 |
52acb1ff
|
Phil Davis
|
// A real gateway has been selected.
|
191 |
|
|
if (is_ipaddr($_POST[$dnsname])) {
|
192 |
2ee8dea1
|
Phil Davis
|
if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
|
193 |
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]);
|
194 |
52acb1ff
|
Phil Davis
|
}
|
195 |
2ee8dea1
|
Phil Davis
|
if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false)) {
|
196 |
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]);
|
197 |
52acb1ff
|
Phil Davis
|
}
|
198 |
|
|
} else {
|
199 |
df4471e2
|
Phil Davis
|
// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
|
200 |
|
|
$ignore_posted_dnsgw[$dnsgwname] = true;
|
201 |
52acb1ff
|
Phil Davis
|
}
|
202 |
13ea7caa
|
smos
|
}
|
203 |
d623f2da
|
Seth Mos
|
}
|
204 |
5b237745
|
Scott Ullrich
|
}
|
205 |
d623f2da
|
Seth Mos
|
|
206 |
c25e42c8
|
Mark Furneaux
|
if (count(array_filter($dnslist)) != count(array_unique(array_filter($dnslist)))) {
|
207 |
f700dc99
|
Chris Buechler
|
$input_errors[] = gettext('Each configured DNS server must have a unique IP address. Remove the duplicated IP.');
|
208 |
|
|
}
|
209 |
|
|
|
210 |
985fc0fb
|
Ermal Lu?i
|
$direct_networks_list = explode(" ", filter_get_direct_networks_list());
|
211 |
c98d28e1
|
Seth Mos
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
|
212 |
|
|
$dnsitem = "dns{$dnscounter}";
|
213 |
d623f2da
|
Seth Mos
|
$dnsgwitem = "dns{$dnscounter}gw";
|
214 |
c98d28e1
|
Seth Mos
|
if ($_POST[$dnsgwitem]) {
|
215 |
2ee8dea1
|
Phil Davis
|
if (interface_has_gateway($_POST[$dnsgwitem])) {
|
216 |
|
|
foreach ($direct_networks_list as $direct_network) {
|
217 |
|
|
if (ip_in_subnet($_POST[$dnsitem], $direct_network)) {
|
218 |
1bab4a10
|
NOYB
|
$input_errors[] = sprintf(gettext("A gateway can not be assigned to DNS '%s' server which is on a directly connected network."), $_POST[$dnsitem]);
|
219 |
c98d28e1
|
Seth Mos
|
}
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
}
|
223 |
|
|
}
|
224 |
|
|
|
225 |
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.
|
226 |
|
|
$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
|
227 |
|
|
$_POST['timeservers'] = trim($_POST['timeservers']);
|
228 |
5b237745
|
Scott Ullrich
|
foreach (explode(' ', $_POST['timeservers']) as $ts) {
|
229 |
|
|
if (!is_domain($ts)) {
|
230 |
7465d12c
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
|
231 |
5b237745
|
Scott Ullrich
|
}
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
if (!$input_errors) {
|
235 |
f1a34790
|
N0YB
|
update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
|
236 |
|
|
update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
|
237 |
9eab73da
|
Bill Marquette
|
update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
|
238 |
|
|
update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
|
239 |
04ad7c7c
|
Scott Ullrich
|
|
240 |
2ee8dea1
|
Phil Davis
|
if ($_POST['language'] && $_POST['language'] != $config['system']['language']) {
|
241 |
3e139f90
|
Vinicius Coque
|
$config['system']['language'] = $_POST['language'];
|
242 |
ceecd29b
|
Renato Botelho
|
set_language();
|
243 |
3e139f90
|
Vinicius Coque
|
}
|
244 |
|
|
|
245 |
24f15b3a
|
NOYB
|
unset($config['system']['webgui']['webguileftcolumnhyper']);
|
246 |
|
|
$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
|
247 |
|
|
|
248 |
c05363c8
|
NOYB
|
unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
|
249 |
|
|
$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
|
250 |
|
|
|
251 |
|
|
unset($config['system']['webgui']['systemlogsfilterpanel']);
|
252 |
|
|
$config['system']['webgui']['systemlogsfilterpanel'] = $_POST['systemlogsfilterpanel'] ? true : false;
|
253 |
|
|
|
254 |
|
|
unset($config['system']['webgui']['systemlogsmanagelogpanel']);
|
255 |
|
|
$config['system']['webgui']['systemlogsmanagelogpanel'] = $_POST['systemlogsmanagelogpanel'] ? true : false;
|
256 |
|
|
|
257 |
b1b8784a
|
NOYB
|
unset($config['system']['webgui']['statusmonitoringsettingspanel']);
|
258 |
|
|
$config['system']['webgui']['statusmonitoringsettingspanel'] = $_POST['statusmonitoringsettingspanel'] ? true : false;
|
259 |
|
|
|
260 |
4fbf63aa
|
Bill Marquette
|
/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
|
261 |
52acb1ff
|
Phil Davis
|
$olddnsservers = $config['system']['dnsserver'];
|
262 |
5b237745
|
Scott Ullrich
|
unset($config['system']['dnsserver']);
|
263 |
2ee8dea1
|
Phil Davis
|
if ($_POST['dns1']) {
|
264 |
5b237745
|
Scott Ullrich
|
$config['system']['dnsserver'][] = $_POST['dns1'];
|
265 |
2ee8dea1
|
Phil Davis
|
}
|
266 |
|
|
if ($_POST['dns2']) {
|
267 |
5b237745
|
Scott Ullrich
|
$config['system']['dnsserver'][] = $_POST['dns2'];
|
268 |
2ee8dea1
|
Phil Davis
|
}
|
269 |
|
|
if ($_POST['dns3']) {
|
270 |
93e0800d
|
Scott Ullrich
|
$config['system']['dnsserver'][] = $_POST['dns3'];
|
271 |
2ee8dea1
|
Phil Davis
|
}
|
272 |
|
|
if ($_POST['dns4']) {
|
273 |
93e0800d
|
Scott Ullrich
|
$config['system']['dnsserver'][] = $_POST['dns4'];
|
274 |
2ee8dea1
|
Phil Davis
|
}
|
275 |
04ad7c7c
|
Scott Ullrich
|
|
276 |
07bd3f83
|
Scott Ullrich
|
$olddnsallowoverride = $config['system']['dnsallowoverride'];
|
277 |
20b90e0a
|
Scott Ullrich
|
|
278 |
0d8a219e
|
Scott Ullrich
|
unset($config['system']['dnsallowoverride']);
|
279 |
5b237745
|
Scott Ullrich
|
$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
|
280 |
e180a6e3
|
Scott Ullrich
|
|
281 |
2ee8dea1
|
Phil Davis
|
if ($_POST['dnslocalhost'] == "yes") {
|
282 |
8ca95ed8
|
jim-p
|
$config['system']['dnslocalhost'] = true;
|
283 |
2ee8dea1
|
Phil Davis
|
} else {
|
284 |
8ca95ed8
|
jim-p
|
unset($config['system']['dnslocalhost']);
|
285 |
2ee8dea1
|
Phil Davis
|
}
|
286 |
8ca95ed8
|
jim-p
|
|
287 |
e180a6e3
|
Scott Ullrich
|
/* which interface should the dns servers resolve through? */
|
288 |
df4471e2
|
Phil Davis
|
$outdnscounter = 0;
|
289 |
d623f2da
|
Seth Mos
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
|
290 |
|
|
$dnsname="dns{$dnscounter}";
|
291 |
|
|
$dnsgwname="dns{$dnscounter}gw";
|
292 |
52acb1ff
|
Phil Davis
|
$olddnsgwname = $config['system'][$dnsgwname];
|
293 |
df4471e2
|
Phil Davis
|
|
294 |
2ee8dea1
|
Phil Davis
|
if ($ignore_posted_dnsgw[$dnsgwname]) {
|
295 |
df4471e2
|
Phil Davis
|
$thisdnsgwname = "none";
|
296 |
2ee8dea1
|
Phil Davis
|
} else {
|
297 |
df4471e2
|
Phil Davis
|
$thisdnsgwname = $pconfig[$dnsgwname];
|
298 |
2ee8dea1
|
Phil Davis
|
}
|
299 |
df4471e2
|
Phil Davis
|
|
300 |
|
|
// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
|
301 |
|
|
$config['system'][$dnsgwname] = "none";
|
302 |
|
|
$pconfig[$dnsgwname] = "none";
|
303 |
|
|
$pconfig[$dnsname] = "";
|
304 |
|
|
|
305 |
|
|
if ($_POST[$dnsname]) {
|
306 |
|
|
// Only the non-blank DNS servers were put into the config above.
|
307 |
|
|
// So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
|
308 |
|
|
// 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.
|
309 |
|
|
$outdnscounter++;
|
310 |
|
|
$outdnsname="dns{$outdnscounter}";
|
311 |
|
|
$outdnsgwname="dns{$outdnscounter}gw";
|
312 |
|
|
$pconfig[$outdnsname] = $_POST[$dnsname];
|
313 |
2ee8dea1
|
Phil Davis
|
if ($_POST[$dnsgwname]) {
|
314 |
df4471e2
|
Phil Davis
|
$config['system'][$outdnsgwname] = $thisdnsgwname;
|
315 |
|
|
$pconfig[$outdnsgwname] = $thisdnsgwname;
|
316 |
|
|
} else {
|
317 |
|
|
// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
|
318 |
|
|
unset($config['system'][$outdnsgwname]);
|
319 |
|
|
$pconfig[$outdnsgwname] = "";
|
320 |
|
|
}
|
321 |
d623f2da
|
Seth Mos
|
}
|
322 |
df4471e2
|
Phil Davis
|
if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter-1] != $_POST[$dnsname]))) {
|
323 |
52acb1ff
|
Phil Davis
|
// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
|
324 |
|
|
// Remove the route. Later calls will add the correct new route if needed.
|
325 |
2ee8dea1
|
Phil Davis
|
if (is_ipaddrv4($olddnsservers[$dnscounter-1])) {
|
326 |
52acb1ff
|
Phil Davis
|
mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
|
327 |
312c32c9
|
Renato Botelho
|
} else if (is_ipaddrv6($olddnsservers[$dnscounter-1])) {
|
328 |
|
|
mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
|
329 |
2ee8dea1
|
Phil Davis
|
}
|
330 |
52acb1ff
|
Phil Davis
|
}
|
331 |
d623f2da
|
Seth Mos
|
}
|
332 |
04ad7c7c
|
Scott Ullrich
|
|
333 |
2ee8dea1
|
Phil Davis
|
if ($changecount > 0) {
|
334 |
62d01225
|
Bill Marquette
|
write_config($changedesc);
|
335 |
2ee8dea1
|
Phil Davis
|
}
|
336 |
04ad7c7c
|
Scott Ullrich
|
|
337 |
5b237745
|
Scott Ullrich
|
$retval = 0;
|
338 |
3cfdba5f
|
Scott Ullrich
|
$retval = system_hostname_configure();
|
339 |
|
|
$retval |= system_hosts_generate();
|
340 |
|
|
$retval |= system_resolvconf_generate();
|
341 |
2ee8dea1
|
Phil Davis
|
if (isset($config['dnsmasq']['enable'])) {
|
342 |
1e2c8821
|
Warren Baker
|
$retval |= services_dnsmasq_configure();
|
343 |
2ee8dea1
|
Phil Davis
|
} elseif (isset($config['unbound']['enable'])) {
|
344 |
1e2c8821
|
Warren Baker
|
$retval |= services_unbound_configure();
|
345 |
2ee8dea1
|
Phil Davis
|
}
|
346 |
3cfdba5f
|
Scott Ullrich
|
$retval |= system_timezone_configure();
|
347 |
|
|
$retval |= system_ntp_configure();
|
348 |
|
|
|
349 |
2ee8dea1
|
Phil Davis
|
if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
|
350 |
b8292903
|
Ermal
|
$retval |= send_event("service reload dns");
|
351 |
2ee8dea1
|
Phil Davis
|
}
|
352 |
3cfdba5f
|
Scott Ullrich
|
|
353 |
e7d967d8
|
Scott Ullrich
|
// Reload the filter - plugins might need to be run.
|
354 |
0027de0a
|
Ermal Lu?i
|
$retval |= filter_configure();
|
355 |
1180e4f0
|
Sjon Hortensius
|
|
356 |
5b237745
|
Scott Ullrich
|
$savemsg = get_std_save_message($retval);
|
357 |
|
|
}
|
358 |
df4471e2
|
Phil Davis
|
|
359 |
|
|
unset($ignore_posted_dnsgw);
|
360 |
5b237745
|
Scott Ullrich
|
}
|
361 |
4df96eff
|
Scott Ullrich
|
|
362 |
2ee8dea1
|
Phil Davis
|
$pgtitle = array(gettext("System"), gettext("General Setup"));
|
363 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
364 |
|
|
|
365 |
8f65151c
|
Phil Davis
|
if ($input_errors) {
|
366 |
41ea4cf3
|
Sjon Hortensius
|
print_input_errors($input_errors);
|
367 |
8f65151c
|
Phil Davis
|
}
|
368 |
ddb84143
|
Stephen Beaver
|
|
369 |
8f65151c
|
Phil Davis
|
if ($savemsg) {
|
370 |
1f70d78c
|
NewEraCracker
|
print_info_box($savemsg, 'success');
|
371 |
8f65151c
|
Phil Davis
|
}
|
372 |
5b237745
|
Scott Ullrich
|
?>
|
373 |
41ea4cf3
|
Sjon Hortensius
|
<div id="container">
|
374 |
b40bcb23
|
Sjon Hortensius
|
<?php
|
375 |
1180e4f0
|
Sjon Hortensius
|
|
376 |
b40bcb23
|
Sjon Hortensius
|
$form = new Form;
|
377 |
a32c0623
|
Sjon Hortensius
|
$section = new Form_Section('System');
|
378 |
|
|
$section->addInput(new Form_Input(
|
379 |
a97531c5
|
Sjon Hortensius
|
'hostname',
|
380 |
a32c0623
|
Sjon Hortensius
|
'Hostname',
|
381 |
|
|
'text',
|
382 |
|
|
$pconfig['hostname'],
|
383 |
|
|
['placeholder' => 'pfSense']
|
384 |
|
|
))->setHelp('Name of the firewall host, without domain part');
|
385 |
|
|
$section->addInput(new Form_Input(
|
386 |
a97531c5
|
Sjon Hortensius
|
'domain',
|
387 |
a32c0623
|
Sjon Hortensius
|
'Domain',
|
388 |
|
|
'text',
|
389 |
|
|
$pconfig['domain'],
|
390 |
|
|
['placeholder' => 'mycorp.com, home, office, private, etc.']
|
391 |
|
|
))->setHelp('Do not use \'local\' as a domain name. It will cause local '.
|
392 |
|
|
'hosts running mDNS (avahi, bonjour, etc.) to be unable to resolve '.
|
393 |
|
|
'local hosts not running mDNS.');
|
394 |
b40bcb23
|
Sjon Hortensius
|
$form->add($section);
|
395 |
|
|
|
396 |
70dc5cd6
|
Phil Davis
|
$section = new Form_Section('DNS Server Settings');
|
397 |
b40bcb23
|
Sjon Hortensius
|
|
398 |
8f65151c
|
Phil Davis
|
for ($i=1; $i<5; $i++) {
|
399 |
54c605d4
|
Stephen Beaver
|
// if (!isset($pconfig['dns'.$i]))
|
400 |
|
|
// continue;
|
401 |
|
|
|
402 |
|
|
$group = new Form_Group('DNS Server ' . $i);
|
403 |
|
|
|
404 |
|
|
$group->add(new Form_Input(
|
405 |
c52e1c1f
|
Stephen Beaver
|
'dns' . $i,
|
406 |
54c605d4
|
Stephen Beaver
|
'DNS Server',
|
407 |
|
|
'text',
|
408 |
c52e1c1f
|
Stephen Beaver
|
$pconfig['dns'. $i]
|
409 |
54c605d4
|
Stephen Beaver
|
))->setHelp(($i == 4) ? 'Address':null);
|
410 |
b40bcb23
|
Sjon Hortensius
|
|
411 |
|
|
$help = "Enter IP addresses to be used by the system for DNS resolution. " .
|
412 |
|
|
"These are also used for the DHCP service, DNS forwarder and for PPTP VPN clients.";
|
413 |
|
|
|
414 |
54c605d4
|
Stephen Beaver
|
if ($multiwan) {
|
415 |
b40bcb23
|
Sjon Hortensius
|
$options = array('none' => 'none');
|
416 |
|
|
|
417 |
8f65151c
|
Phil Davis
|
foreach ($arr_gateways as $gwname => $gwitem) {
|
418 |
|
|
if ((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
|
419 |
b40bcb23
|
Sjon Hortensius
|
continue;
|
420 |
|
|
}
|
421 |
54c605d4
|
Stephen Beaver
|
|
422 |
8f65151c
|
Phil Davis
|
if ((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
|
423 |
b40bcb23
|
Sjon Hortensius
|
continue;
|
424 |
|
|
}
|
425 |
1180e4f0
|
Sjon Hortensius
|
|
426 |
b40bcb23
|
Sjon Hortensius
|
$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
|
427 |
|
|
}
|
428 |
1180e4f0
|
Sjon Hortensius
|
|
429 |
a97531c5
|
Sjon Hortensius
|
$group->add(new Form_Select(
|
430 |
c52e1c1f
|
Stephen Beaver
|
'dns' . $i . 'gw',
|
431 |
e4dd8be4
|
NOYB
|
'Gateway',
|
432 |
c52e1c1f
|
Stephen Beaver
|
$pconfig['dns' . $i . 'gw'],
|
433 |
a97531c5
|
Sjon Hortensius
|
$options
|
434 |
54c605d4
|
Stephen Beaver
|
))->setHelp(($i == 4) ? 'Gateway':null);;
|
435 |
1180e4f0
|
Sjon Hortensius
|
|
436 |
b40bcb23
|
Sjon Hortensius
|
$help .= '<br/>'. "In addition, optionally select the gateway for each DNS server. " .
|
437 |
|
|
"When using multiple WAN connections there should be at least one unique DNS server per gateway.";
|
438 |
|
|
}
|
439 |
1180e4f0
|
Sjon Hortensius
|
|
440 |
8f65151c
|
Phil Davis
|
if ($i == 4) {
|
441 |
54c605d4
|
Stephen Beaver
|
$group->setHelp($help);
|
442 |
8f65151c
|
Phil Davis
|
}
|
443 |
54c605d4
|
Stephen Beaver
|
|
444 |
b40bcb23
|
Sjon Hortensius
|
$section->add($group);
|
445 |
|
|
}
|
446 |
1180e4f0
|
Sjon Hortensius
|
|
447 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Checkbox(
|
448 |
a97531c5
|
Sjon Hortensius
|
'dnsallowoverride',
|
449 |
70dc5cd6
|
Phil Davis
|
'DNS Server Override',
|
450 |
b40bcb23
|
Sjon Hortensius
|
'Allow DNS server list to be overridden by DHCP/PPP on WAN',
|
451 |
|
|
$pconfig['dnsallowoverride']
|
452 |
e4dd8be4
|
NOYB
|
))->setHelp(sprintf(gettext('If this option is set, %s will use DNS servers '.
|
453 |
a32c0623
|
Sjon Hortensius
|
'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
|
454 |
|
|
'the DNS forwarder). However, they will not be assigned to DHCP and PPTP '.
|
455 |
|
|
'VPN clients.'), $g['product_name']));
|
456 |
b40bcb23
|
Sjon Hortensius
|
|
457 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Checkbox(
|
458 |
a97531c5
|
Sjon Hortensius
|
'dnslocalhost',
|
459 |
70dc5cd6
|
Phil Davis
|
'Disable DNS Forwarder',
|
460 |
b40bcb23
|
Sjon Hortensius
|
'Do not use the DNS Forwarder as a DNS server for the firewall',
|
461 |
|
|
$pconfig['dnslocalhost']
|
462 |
e4dd8be4
|
NOYB
|
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS '.
|
463 |
a32c0623
|
Sjon Hortensius
|
'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
|
464 |
e4dd8be4
|
NOYB
|
'listen on Localhost, so system can use the local DNS service to perform '.
|
465 |
a32c0623
|
Sjon Hortensius
|
'lookups. Checking this box omits localhost from the list of DNS servers.');
|
466 |
b40bcb23
|
Sjon Hortensius
|
|
467 |
|
|
$form->add($section);
|
468 |
|
|
|
469 |
a005a836
|
Sjon Hortensius
|
$section = new Form_Section('Localization');
|
470 |
|
|
$section->addInput(new Form_Select(
|
471 |
a97531c5
|
Sjon Hortensius
|
'timezone',
|
472 |
a32c0623
|
Sjon Hortensius
|
'Timezone',
|
473 |
|
|
$pconfig['timezone'],
|
474 |
64c3b4cd
|
sbeaver
|
array_combine($timezonelist, $timezonelist)
|
475 |
1bab4a10
|
NOYB
|
))->setHelp('Select the timezone or location within the timezone to be used by this system.');
|
476 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Input(
|
477 |
a97531c5
|
Sjon Hortensius
|
'timeservers',
|
478 |
a32c0623
|
Sjon Hortensius
|
'Timeservers',
|
479 |
|
|
'text',
|
480 |
|
|
$pconfig['timeservers']
|
481 |
|
|
))->setHelp('Use a space to separate multiple hosts (only one required). '.
|
482 |
1bab4a10
|
NOYB
|
'Remember to set up at least one DNS server if a host name is entered here!');
|
483 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Select(
|
484 |
a97531c5
|
Sjon Hortensius
|
'language',
|
485 |
a32c0623
|
Sjon Hortensius
|
'Language',
|
486 |
|
|
$pconfig['language'],
|
487 |
|
|
get_locale_list()
|
488 |
|
|
))->setHelp('Choose a language for the webConfigurator');
|
489 |
b40bcb23
|
Sjon Hortensius
|
|
490 |
|
|
$form->add($section);
|
491 |
|
|
|
492 |
a5995a8e
|
Stephen Beaver
|
$csslist = array();
|
493 |
|
|
|
494 |
ed80365b
|
Stephen Beaver
|
// List pfSense files, then any BETA files followed by any user-contributed files
|
495 |
|
|
$cssfiles = glob("/usr/local/www/css/*.css");
|
496 |
|
|
|
497 |
|
|
if(is_array($cssfiles)) {
|
498 |
|
|
arsort($cssfiles);
|
499 |
|
|
$usrcss = $pfscss = $betacss = array();
|
500 |
|
|
|
501 |
|
|
foreach ($cssfiles as $css) {
|
502 |
|
|
if (strpos($css, "BETA") != 0) {
|
503 |
|
|
array_push($betacss, $css);
|
504 |
|
|
} else if (strpos($css, "pfSense") != 0) {
|
505 |
|
|
array_push($pfscss, $css);
|
506 |
|
|
} else {
|
507 |
|
|
array_push($usrcss, $css);
|
508 |
|
|
}
|
509 |
|
|
}
|
510 |
|
|
|
511 |
|
|
$css = array_merge($pfscss, $betacss, $usrcss);
|
512 |
|
|
|
513 |
|
|
foreach ($css as $file) {
|
514 |
|
|
$file = basename($file);
|
515 |
|
|
$csslist[$file] = pathinfo($file, PATHINFO_FILENAME);
|
516 |
|
|
}
|
517 |
|
|
}
|
518 |
7aaa0663
|
Stephen Beaver
|
|
519 |
f0a9dec4
|
Phil Davis
|
if (!isset($pconfig['webguicss']) || !isset($csslist[$pconfig['webguicss']])) {
|
520 |
c040eeda
|
Phil Davis
|
$pconfig['webguicss'] = "pfSense.css";
|
521 |
|
|
}
|
522 |
|
|
|
523 |
1176360c
|
k-paulius
|
$section = new Form_Section('webConfigurator');
|
524 |
a5995a8e
|
Stephen Beaver
|
|
525 |
|
|
$section->addInput(new Form_Select(
|
526 |
|
|
'webguicss',
|
527 |
|
|
'Theme',
|
528 |
|
|
$pconfig['webguicss'],
|
529 |
|
|
$csslist
|
530 |
ee7c0a00
|
Stephen Beaver
|
))->setHelp(sprintf(gettext('Choose an alternative css file (if installed) to change the appearance of the webConfigurator. css files are located in /usr/local/www/css/%s'), '<span id="csstxt"></span>'));
|
531 |
3d29d2eb
|
Jared Dillard
|
|
532 |
ddb84143
|
Stephen Beaver
|
$section->addInput(new Form_Select(
|
533 |
|
|
'webguifixedmenu',
|
534 |
477db933
|
Jared Dillard
|
'Top Navigation',
|
535 |
e82778da
|
Stephen Beaver
|
$pconfig['webguifixedmenu'],
|
536 |
b50d30c3
|
Stephen Beaver
|
["" => gettext("Scrolls with page"), "fixed" => gettext("Fixed (Remains visible at top of page)")]
|
537 |
b21e4009
|
Jared Dillard
|
))->setHelp("The fixed option is intended for large screens only.");
|
538 |
3d29d2eb
|
Jared Dillard
|
|
539 |
477db933
|
Jared Dillard
|
$section->addInput(new Form_Input(
|
540 |
|
|
'dashboardcolumns',
|
541 |
|
|
'Dashboard Columns',
|
542 |
9911c685
|
Stephen Beaver
|
'number',
|
543 |
|
|
$pconfig['dashboardcolumns'],
|
544 |
|
|
[min => 1, max => 4]
|
545 |
8376c93e
|
Jared Dillard
|
));
|
546 |
477db933
|
Jared Dillard
|
|
547 |
54bf2312
|
NOYB
|
$group = new Form_Group('Associated Panels Show/Hide');
|
548 |
c05363c8
|
NOYB
|
|
549 |
|
|
$group->add(new Form_Checkbox(
|
550 |
|
|
'dashboardavailablewidgetspanel',
|
551 |
|
|
null,
|
552 |
|
|
'Available Widgets',
|
553 |
|
|
$pconfig['dashboardavailablewidgetspanel']
|
554 |
|
|
))->setHelp('Show the Available Widgets panel on the Dashboard.');
|
555 |
|
|
|
556 |
|
|
$group->add(new Form_Checkbox(
|
557 |
|
|
'systemlogsfilterpanel',
|
558 |
|
|
null,
|
559 |
|
|
'Log Filter',
|
560 |
|
|
$pconfig['systemlogsfilterpanel']
|
561 |
|
|
))->setHelp('Show the Log Filter panel in System Logs.');
|
562 |
|
|
|
563 |
|
|
$group->add(new Form_Checkbox(
|
564 |
|
|
'systemlogsmanagelogpanel',
|
565 |
|
|
null,
|
566 |
643bfab8
|
NOYB
|
'Manage Log',
|
567 |
c05363c8
|
NOYB
|
$pconfig['systemlogsmanagelogpanel']
|
568 |
|
|
))->setHelp('Show the Manage Log panel in System Logs.');
|
569 |
|
|
|
570 |
b1b8784a
|
NOYB
|
$group->add(new Form_Checkbox(
|
571 |
|
|
'statusmonitoringsettingspanel',
|
572 |
|
|
null,
|
573 |
|
|
'Monitoring Settings',
|
574 |
|
|
$pconfig['statusmonitoringsettingspanel']
|
575 |
|
|
))->setHelp('Show the Settings panel in Status Monitoring.');
|
576 |
|
|
|
577 |
ea78f829
|
NOYB
|
$group->setHelp('These options allow certain panels to be automatically hidden on page load. A control is provided in the title bar to un-hide the panel.');
|
578 |
c05363c8
|
NOYB
|
|
579 |
|
|
$section->add($group);
|
580 |
|
|
|
581 |
24f15b3a
|
NOYB
|
$section->addInput(new Form_Checkbox(
|
582 |
|
|
'webguileftcolumnhyper',
|
583 |
|
|
'Left Column Labels',
|
584 |
|
|
'Active',
|
585 |
|
|
$pconfig['webguileftcolumnhyper']
|
586 |
ea78f829
|
NOYB
|
))->setHelp('If selected, clicking a label in the left column will select/toggle the first item of the group.');
|
587 |
24f15b3a
|
NOYB
|
|
588 |
a5995a8e
|
Stephen Beaver
|
$form->add($section);
|
589 |
|
|
|
590 |
b40bcb23
|
Sjon Hortensius
|
print $form;
|
591 |
ee7c0a00
|
Stephen Beaver
|
|
592 |
|
|
$csswarning = sprintf(gettext("%sUser-created themes are unsupported, use at your own risk."), "<br />");
|
593 |
|
|
|
594 |
8c4ef875
|
NOYB
|
?>
|
595 |
|
|
</div>
|
596 |
ee7c0a00
|
Stephen Beaver
|
|
597 |
|
|
<script>
|
598 |
|
|
//<![CDATA[
|
599 |
|
|
events.push(function() {
|
600 |
|
|
|
601 |
|
|
function setThemeWarning() {
|
602 |
|
|
if ($('#webguicss').val().startsWith("pfSense")) {
|
603 |
|
|
$('#csstxt').html("").addClass("text-default");
|
604 |
|
|
} else {
|
605 |
|
|
$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
|
606 |
|
|
}
|
607 |
|
|
}
|
608 |
|
|
|
609 |
|
|
$('#webguicss').change(function() {
|
610 |
|
|
setThemeWarning();
|
611 |
|
|
});
|
612 |
|
|
|
613 |
|
|
setThemeWarning();
|
614 |
|
|
});
|
615 |
|
|
//]]>
|
616 |
|
|
</script>
|
617 |
|
|
|
618 |
8c4ef875
|
NOYB
|
<?php
|
619 |
60ff91f1
|
Renato Botelho
|
include("foot.inc");
|
620 |
8c4ef875
|
NOYB
|
?>
|