1 |
04ad7c7c
|
Scott Ullrich
|
<?php
|
2 |
62d01225
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
system.php
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
04ad7c7c
|
Scott Ullrich
|
|
7 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
ce77a9c4
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
9 |
5b237745
|
Scott Ullrich
|
All rights reserved.
|
10 |
04ad7c7c
|
Scott Ullrich
|
|
11 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
04ad7c7c
|
Scott Ullrich
|
|
14 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
1180e4f0
|
Sjon Hortensius
|
this list of conditions and the following disclaimer.
|
16 |
04ad7c7c
|
Scott Ullrich
|
|
17 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
1180e4f0
|
Sjon Hortensius
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
04ad7c7c
|
Scott Ullrich
|
|
21 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
1d333258
|
Scott Ullrich
|
/*
|
33 |
|
|
pfSense_BUILDER_BINARIES: /bin/kill /usr/bin/tar
|
34 |
|
|
pfSense_MODULE: system
|
35 |
|
|
*/
|
36 |
5b237745
|
Scott Ullrich
|
|
37 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
38 |
|
|
##|*IDENT=page-system-generalsetup
|
39 |
|
|
##|*NAME=System: General Setup page
|
40 |
|
|
##|*DESCR=Allow access to the 'System: General Setup' page.
|
41 |
|
|
##|*MATCH=system.php*
|
42 |
|
|
##|-PRIV
|
43 |
|
|
|
44 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
45 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
46 |
|
|
require_once("filter.inc");
|
47 |
|
|
require_once("shaper.inc");
|
48 |
5b237745
|
Scott Ullrich
|
|
49 |
|
|
$pconfig['hostname'] = $config['system']['hostname'];
|
50 |
|
|
$pconfig['domain'] = $config['system']['domain'];
|
51 |
93e0800d
|
Scott Ullrich
|
list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $config['system']['dnsserver'];
|
52 |
0d8a219e
|
Scott Ullrich
|
|
53 |
d623f2da
|
Seth Mos
|
$arr_gateways = return_gateways_array();
|
54 |
|
|
|
55 |
|
|
$pconfig['dns1gw'] = $config['system']['dns1gw'];
|
56 |
|
|
$pconfig['dns2gw'] = $config['system']['dns2gw'];
|
57 |
|
|
$pconfig['dns3gw'] = $config['system']['dns3gw'];
|
58 |
|
|
$pconfig['dns4gw'] = $config['system']['dns4gw'];
|
59 |
e180a6e3
|
Scott Ullrich
|
|
60 |
5b237745
|
Scott Ullrich
|
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
|
61 |
|
|
$pconfig['timezone'] = $config['system']['timezone'];
|
62 |
|
|
$pconfig['timeupdateinterval'] = $config['system']['time-update-interval'];
|
63 |
|
|
$pconfig['timeservers'] = $config['system']['timeservers'];
|
64 |
f0f7a3eb
|
Scott Ullrich
|
$pconfig['theme'] = $config['system']['theme'];
|
65 |
3e139f90
|
Vinicius Coque
|
$pconfig['language'] = $config['system']['language'];
|
66 |
5b237745
|
Scott Ullrich
|
|
67 |
8ca95ed8
|
jim-p
|
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
|
68 |
|
|
|
69 |
5b237745
|
Scott Ullrich
|
if (!isset($pconfig['timeupdateinterval']))
|
70 |
|
|
$pconfig['timeupdateinterval'] = 300;
|
71 |
|
|
if (!$pconfig['timezone'])
|
72 |
|
|
$pconfig['timezone'] = "Etc/UTC";
|
73 |
|
|
if (!$pconfig['timeservers'])
|
74 |
|
|
$pconfig['timeservers'] = "pool.ntp.org";
|
75 |
04ad7c7c
|
Scott Ullrich
|
|
76 |
79eaddf4
|
Renato Botelho
|
$changedesc = gettext("System") . ": ";
|
77 |
62d01225
|
Bill Marquette
|
$changecount = 0;
|
78 |
417c6042
|
Bill Marquette
|
|
79 |
5b237745
|
Scott Ullrich
|
function is_timezone($elt) {
|
80 |
|
|
return !preg_match("/\/$/", $elt);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
a97531c5
|
Sjon Hortensius
|
if($pconfig['timezone'] != $_POST['timezone']) {
|
84 |
744306c6
|
jim-p
|
filter_pflog_start(true);
|
85 |
aa1ab1da
|
Scott Ullrich
|
}
|
86 |
|
|
|
87 |
5b237745
|
Scott Ullrich
|
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
|
88 |
|
|
$timezonelist = array_filter($timezonelist, 'is_timezone');
|
89 |
|
|
sort($timezonelist);
|
90 |
|
|
|
91 |
77446beb
|
Matthew Grooms
|
$multiwan = false;
|
92 |
7922db8a
|
Seth Mos
|
$interfaces = get_configured_interface_list();
|
93 |
|
|
foreach($interfaces as $interface) {
|
94 |
|
|
if(interface_has_gateway($interface)) {
|
95 |
77446beb
|
Matthew Grooms
|
$multiwan = true;
|
96 |
7922db8a
|
Seth Mos
|
}
|
97 |
|
|
}
|
98 |
77446beb
|
Matthew Grooms
|
|
99 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
100 |
|
|
|
101 |
c668c964
|
Scott Ullrich
|
$changecount++;
|
102 |
1180e4f0
|
Sjon Hortensius
|
|
103 |
5b237745
|
Scott Ullrich
|
unset($input_errors);
|
104 |
|
|
$pconfig = $_POST;
|
105 |
|
|
|
106 |
|
|
/* input validation */
|
107 |
cfbfd941
|
smos
|
$reqdfields = explode(" ", "hostname domain");
|
108 |
38fb1109
|
Vinicius Coque
|
$reqdfieldsn = array(gettext("Hostname"),gettext("Domain"));
|
109 |
04ad7c7c
|
Scott Ullrich
|
|
110 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
111 |
04ad7c7c
|
Scott Ullrich
|
|
112 |
2d86ee95
|
Phil Davis
|
if ($_POST['hostname']) {
|
113 |
|
|
if (!is_hostname($_POST['hostname'])) {
|
114 |
|
|
$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'.");
|
115 |
|
|
} else {
|
116 |
|
|
if (!is_unqualified_hostname($_POST['hostname'])) {
|
117 |
|
|
$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
5b237745
|
Scott Ullrich
|
}
|
121 |
|
|
if ($_POST['domain'] && !is_domain($_POST['domain'])) {
|
122 |
7465d12c
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
|
123 |
5b237745
|
Scott Ullrich
|
}
|
124 |
d623f2da
|
Seth Mos
|
|
125 |
df4471e2
|
Phil Davis
|
$ignore_posted_dnsgw = array();
|
126 |
|
|
|
127 |
d623f2da
|
Seth Mos
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++){
|
128 |
|
|
$dnsname="dns{$dnscounter}";
|
129 |
|
|
$dnsgwname="dns{$dnscounter}gw";
|
130 |
|
|
if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
|
131 |
52acb1ff
|
Phil Davis
|
$input_errors[] = gettext("A valid IP address must be specified for DNS server $dnscounter.");
|
132 |
|
|
} else {
|
133 |
a97531c5
|
Sjon Hortensius
|
if(($_POST[$dnsgwname] != "") && ($_POST[$dnsgwname] != "none")) {
|
134 |
52acb1ff
|
Phil Davis
|
// A real gateway has been selected.
|
135 |
|
|
if (is_ipaddr($_POST[$dnsname])) {
|
136 |
|
|
if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false )) {
|
137 |
|
|
$input_errors[] = gettext("You can not specify IPv6 gateway '{$_POST[$dnsgwname]}' for IPv4 DNS server '{$_POST[$dnsname]}'");
|
138 |
|
|
}
|
139 |
|
|
if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false )) {
|
140 |
|
|
$input_errors[] = gettext("You can not specify IPv4 gateway '{$_POST[$dnsgwname]}' for IPv6 DNS server '{$_POST[$dnsname]}'");
|
141 |
|
|
}
|
142 |
|
|
} else {
|
143 |
df4471e2
|
Phil Davis
|
// The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
|
144 |
|
|
$ignore_posted_dnsgw[$dnsgwname] = true;
|
145 |
52acb1ff
|
Phil Davis
|
}
|
146 |
13ea7caa
|
smos
|
}
|
147 |
d623f2da
|
Seth Mos
|
}
|
148 |
5b237745
|
Scott Ullrich
|
}
|
149 |
d623f2da
|
Seth Mos
|
|
150 |
985fc0fb
|
Ermal Lu?i
|
$direct_networks_list = explode(" ", filter_get_direct_networks_list());
|
151 |
c98d28e1
|
Seth Mos
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
|
152 |
|
|
$dnsitem = "dns{$dnscounter}";
|
153 |
d623f2da
|
Seth Mos
|
$dnsgwitem = "dns{$dnscounter}gw";
|
154 |
c98d28e1
|
Seth Mos
|
if ($_POST[$dnsgwitem]) {
|
155 |
|
|
if(interface_has_gateway($_POST[$dnsgwitem])) {
|
156 |
|
|
foreach($direct_networks_list as $direct_network) {
|
157 |
|
|
if(ip_in_subnet($_POST[$dnsitem], $direct_network)) {
|
158 |
d1d0a1ad
|
Vinicius Coque
|
$input_errors[] = sprintf(gettext("You can not assign a gateway to DNS '%s' server which is on a directly connected network."),$_POST[$dnsitem]);
|
159 |
c98d28e1
|
Seth Mos
|
}
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
|
165 |
5b237745
|
Scott Ullrich
|
$t = (int)$_POST['timeupdateinterval'];
|
166 |
|
|
if (($t < 0) || (($t > 0) && ($t < 6)) || ($t > 1440)) {
|
167 |
7465d12c
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("The time update interval must be either 0 (disabled) or between 6 and 1440.");
|
168 |
5b237745
|
Scott Ullrich
|
}
|
169 |
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.
|
170 |
|
|
$_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
|
171 |
|
|
$_POST['timeservers'] = trim($_POST['timeservers']);
|
172 |
5b237745
|
Scott Ullrich
|
foreach (explode(' ', $_POST['timeservers']) as $ts) {
|
173 |
|
|
if (!is_domain($ts)) {
|
174 |
7465d12c
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
|
175 |
5b237745
|
Scott Ullrich
|
}
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
if (!$input_errors) {
|
179 |
f1a34790
|
N0YB
|
update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
|
180 |
|
|
update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
|
181 |
79f8694f
|
Bill Marquette
|
|
182 |
9eab73da
|
Bill Marquette
|
update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
|
183 |
|
|
update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
|
184 |
|
|
update_if_changed("NTP update interval", $config['system']['time-update-interval'], $_POST['timeupdateinterval']);
|
185 |
04ad7c7c
|
Scott Ullrich
|
|
186 |
3e139f90
|
Vinicius Coque
|
if($_POST['language'] && $_POST['language'] != $config['system']['language']) {
|
187 |
|
|
$config['system']['language'] = $_POST['language'];
|
188 |
|
|
set_language($config['system']['language']);
|
189 |
|
|
}
|
190 |
|
|
|
191 |
f0f7a3eb
|
Scott Ullrich
|
/* pfSense themes */
|
192 |
7321c93c
|
Chris Buechler
|
if (! $g['disablethemeselection']) {
|
193 |
1180e4f0
|
Sjon Hortensius
|
update_if_changed("System Theme", $config['theme'], $_POST['theme']);
|
194 |
7321c93c
|
Chris Buechler
|
}
|
195 |
f0f7a3eb
|
Scott Ullrich
|
|
196 |
4fbf63aa
|
Bill Marquette
|
/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
|
197 |
52acb1ff
|
Phil Davis
|
$olddnsservers = $config['system']['dnsserver'];
|
198 |
5b237745
|
Scott Ullrich
|
unset($config['system']['dnsserver']);
|
199 |
|
|
if ($_POST['dns1'])
|
200 |
|
|
$config['system']['dnsserver'][] = $_POST['dns1'];
|
201 |
|
|
if ($_POST['dns2'])
|
202 |
|
|
$config['system']['dnsserver'][] = $_POST['dns2'];
|
203 |
93e0800d
|
Scott Ullrich
|
if ($_POST['dns3'])
|
204 |
|
|
$config['system']['dnsserver'][] = $_POST['dns3'];
|
205 |
|
|
if ($_POST['dns4'])
|
206 |
|
|
$config['system']['dnsserver'][] = $_POST['dns4'];
|
207 |
04ad7c7c
|
Scott Ullrich
|
|
208 |
07bd3f83
|
Scott Ullrich
|
$olddnsallowoverride = $config['system']['dnsallowoverride'];
|
209 |
20b90e0a
|
Scott Ullrich
|
|
210 |
0d8a219e
|
Scott Ullrich
|
unset($config['system']['dnsallowoverride']);
|
211 |
5b237745
|
Scott Ullrich
|
$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
|
212 |
e180a6e3
|
Scott Ullrich
|
|
213 |
8ca95ed8
|
jim-p
|
if($_POST['dnslocalhost'] == "yes")
|
214 |
|
|
$config['system']['dnslocalhost'] = true;
|
215 |
|
|
else
|
216 |
|
|
unset($config['system']['dnslocalhost']);
|
217 |
|
|
|
218 |
e180a6e3
|
Scott Ullrich
|
/* which interface should the dns servers resolve through? */
|
219 |
df4471e2
|
Phil Davis
|
$outdnscounter = 0;
|
220 |
d623f2da
|
Seth Mos
|
for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
|
221 |
|
|
$dnsname="dns{$dnscounter}";
|
222 |
|
|
$dnsgwname="dns{$dnscounter}gw";
|
223 |
52acb1ff
|
Phil Davis
|
$olddnsgwname = $config['system'][$dnsgwname];
|
224 |
df4471e2
|
Phil Davis
|
|
225 |
|
|
if ($ignore_posted_dnsgw[$dnsgwname])
|
226 |
|
|
$thisdnsgwname = "none";
|
227 |
|
|
else
|
228 |
|
|
$thisdnsgwname = $pconfig[$dnsgwname];
|
229 |
|
|
|
230 |
|
|
// "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
|
231 |
|
|
$config['system'][$dnsgwname] = "none";
|
232 |
|
|
$pconfig[$dnsgwname] = "none";
|
233 |
|
|
$pconfig[$dnsname] = "";
|
234 |
|
|
|
235 |
|
|
if ($_POST[$dnsname]) {
|
236 |
|
|
// Only the non-blank DNS servers were put into the config above.
|
237 |
|
|
// So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
|
238 |
|
|
// 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.
|
239 |
|
|
$outdnscounter++;
|
240 |
|
|
$outdnsname="dns{$outdnscounter}";
|
241 |
|
|
$outdnsgwname="dns{$outdnscounter}gw";
|
242 |
|
|
$pconfig[$outdnsname] = $_POST[$dnsname];
|
243 |
|
|
if($_POST[$dnsgwname]) {
|
244 |
|
|
$config['system'][$outdnsgwname] = $thisdnsgwname;
|
245 |
|
|
$pconfig[$outdnsgwname] = $thisdnsgwname;
|
246 |
|
|
} else {
|
247 |
|
|
// Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
|
248 |
|
|
unset($config['system'][$outdnsgwname]);
|
249 |
|
|
$pconfig[$outdnsgwname] = "";
|
250 |
|
|
}
|
251 |
d623f2da
|
Seth Mos
|
}
|
252 |
df4471e2
|
Phil Davis
|
if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter-1] != $_POST[$dnsname]))) {
|
253 |
52acb1ff
|
Phil Davis
|
// A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
|
254 |
|
|
// Remove the route. Later calls will add the correct new route if needed.
|
255 |
|
|
if (is_ipaddrv4($olddnsservers[$dnscounter-1]))
|
256 |
|
|
mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
|
257 |
|
|
else
|
258 |
|
|
if (is_ipaddrv6($olddnsservers[$dnscounter-1]))
|
259 |
|
|
mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
|
260 |
|
|
}
|
261 |
d623f2da
|
Seth Mos
|
}
|
262 |
04ad7c7c
|
Scott Ullrich
|
|
263 |
62d01225
|
Bill Marquette
|
if ($changecount > 0)
|
264 |
|
|
write_config($changedesc);
|
265 |
04ad7c7c
|
Scott Ullrich
|
|
266 |
5b237745
|
Scott Ullrich
|
$retval = 0;
|
267 |
3cfdba5f
|
Scott Ullrich
|
$retval = system_hostname_configure();
|
268 |
|
|
$retval |= system_hosts_generate();
|
269 |
|
|
$retval |= system_resolvconf_generate();
|
270 |
1e2c8821
|
Warren Baker
|
if (isset($config['dnsmasq']['enable']))
|
271 |
|
|
$retval |= services_dnsmasq_configure();
|
272 |
|
|
elseif (isset($config['unbound']['enable']))
|
273 |
|
|
$retval |= services_unbound_configure();
|
274 |
3cfdba5f
|
Scott Ullrich
|
$retval |= system_timezone_configure();
|
275 |
|
|
$retval |= system_ntp_configure();
|
276 |
|
|
|
277 |
|
|
if ($olddnsallowoverride != $config['system']['dnsallowoverride'])
|
278 |
b8292903
|
Ermal
|
$retval |= send_event("service reload dns");
|
279 |
3cfdba5f
|
Scott Ullrich
|
|
280 |
e7d967d8
|
Scott Ullrich
|
// Reload the filter - plugins might need to be run.
|
281 |
0027de0a
|
Ermal Lu?i
|
$retval |= filter_configure();
|
282 |
1180e4f0
|
Sjon Hortensius
|
|
283 |
5b237745
|
Scott Ullrich
|
$savemsg = get_std_save_message($retval);
|
284 |
|
|
}
|
285 |
df4471e2
|
Phil Davis
|
|
286 |
|
|
unset($ignore_posted_dnsgw);
|
287 |
5b237745
|
Scott Ullrich
|
}
|
288 |
4df96eff
|
Scott Ullrich
|
|
289 |
7465d12c
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("System"),gettext("General Setup"));
|
290 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
291 |
|
|
|
292 |
41ea4cf3
|
Sjon Hortensius
|
if ($input_errors)
|
293 |
|
|
print_input_errors($input_errors);
|
294 |
|
|
if ($savemsg)
|
295 |
|
|
print_info_box($savemsg);
|
296 |
5b237745
|
Scott Ullrich
|
?>
|
297 |
41ea4cf3
|
Sjon Hortensius
|
<div id="container">
|
298 |
b40bcb23
|
Sjon Hortensius
|
<?php
|
299 |
1180e4f0
|
Sjon Hortensius
|
|
300 |
b40bcb23
|
Sjon Hortensius
|
require('classes/Form.class.php');
|
301 |
|
|
$form = new Form;
|
302 |
a32c0623
|
Sjon Hortensius
|
$section = new Form_Section('System');
|
303 |
|
|
$section->addInput(new Form_Input(
|
304 |
a97531c5
|
Sjon Hortensius
|
'hostname',
|
305 |
a32c0623
|
Sjon Hortensius
|
'Hostname',
|
306 |
|
|
'text',
|
307 |
|
|
$pconfig['hostname'],
|
308 |
|
|
['placeholder' => 'pfSense']
|
309 |
|
|
))->setHelp('Name of the firewall host, without domain part');
|
310 |
|
|
$section->addInput(new Form_Input(
|
311 |
a97531c5
|
Sjon Hortensius
|
'domain',
|
312 |
a32c0623
|
Sjon Hortensius
|
'Domain',
|
313 |
|
|
'text',
|
314 |
|
|
$pconfig['domain'],
|
315 |
|
|
['placeholder' => 'mycorp.com, home, office, private, etc.']
|
316 |
|
|
))->setHelp('Do not use \'local\' as a domain name. It will cause local '.
|
317 |
|
|
'hosts running mDNS (avahi, bonjour, etc.) to be unable to resolve '.
|
318 |
|
|
'local hosts not running mDNS.');
|
319 |
b40bcb23
|
Sjon Hortensius
|
$form->add($section);
|
320 |
|
|
|
321 |
a005a836
|
Sjon Hortensius
|
$section = new Form_Section('DNS server settings');
|
322 |
b40bcb23
|
Sjon Hortensius
|
|
323 |
|
|
for ($i=1; $i<5; $i++)
|
324 |
|
|
{
|
325 |
|
|
if (!isset($pconfig['dns'.$i]))
|
326 |
|
|
continue;
|
327 |
|
|
|
328 |
a005a836
|
Sjon Hortensius
|
$group = new Form_Group('DNS Server');
|
329 |
a97531c5
|
Sjon Hortensius
|
$group->add(new Form_Input('dns['.$i.']', 'DNS Server', 'text', $pconfig['dns'.$i]));
|
330 |
b40bcb23
|
Sjon Hortensius
|
$help = "Enter IP addresses to be used by the system for DNS resolution. " .
|
331 |
|
|
"These are also used for the DHCP service, DNS forwarder and for PPTP VPN clients.";
|
332 |
|
|
|
333 |
|
|
if ($multiwan)
|
334 |
|
|
{
|
335 |
|
|
$options = array('none' => 'none');
|
336 |
|
|
|
337 |
|
|
foreach($arr_gateways as $gwname => $gwitem)
|
338 |
|
|
{
|
339 |
|
|
if((is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv6($gwitem['gateway'])))) {
|
340 |
|
|
continue;
|
341 |
|
|
}
|
342 |
|
|
if((is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && (is_ipaddrv4($gwitem['gateway'])))) {
|
343 |
|
|
continue;
|
344 |
|
|
}
|
345 |
1180e4f0
|
Sjon Hortensius
|
|
346 |
b40bcb23
|
Sjon Hortensius
|
$options[$gwname] = $gwname.' - '.$gwitem['friendlyiface'].' - '.$gwitem['gateway'];
|
347 |
|
|
}
|
348 |
1180e4f0
|
Sjon Hortensius
|
|
349 |
a97531c5
|
Sjon Hortensius
|
$group->add(new Form_Select(
|
350 |
|
|
'gateway',
|
351 |
|
|
'Gateway',
|
352 |
|
|
$pconfig['dns'.$i.'gw'],
|
353 |
|
|
$options
|
354 |
|
|
));
|
355 |
1180e4f0
|
Sjon Hortensius
|
|
356 |
b40bcb23
|
Sjon Hortensius
|
$help .= '<br/>'. "In addition, optionally select the gateway for each DNS server. " .
|
357 |
|
|
"When using multiple WAN connections there should be at least one unique DNS server per gateway.";
|
358 |
|
|
}
|
359 |
1180e4f0
|
Sjon Hortensius
|
|
360 |
b40bcb23
|
Sjon Hortensius
|
$group->setHelp($help);
|
361 |
|
|
$section->add($group);
|
362 |
|
|
}
|
363 |
1180e4f0
|
Sjon Hortensius
|
|
364 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Checkbox(
|
365 |
a97531c5
|
Sjon Hortensius
|
'dnsallowoverride',
|
366 |
b40bcb23
|
Sjon Hortensius
|
'DNS server override',
|
367 |
|
|
'Allow DNS server list to be overridden by DHCP/PPP on WAN',
|
368 |
|
|
$pconfig['dnsallowoverride']
|
369 |
a32c0623
|
Sjon Hortensius
|
))->setHelp(sprintf(gettext('If this option is set, %s will use DNS servers'.
|
370 |
|
|
'assigned by a DHCP/PPP server on WAN for its own purposes (including '.
|
371 |
|
|
'the DNS forwarder). However, they will not be assigned to DHCP and PPTP '.
|
372 |
|
|
'VPN clients.'), $g['product_name']));
|
373 |
b40bcb23
|
Sjon Hortensius
|
|
374 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Checkbox(
|
375 |
a97531c5
|
Sjon Hortensius
|
'dnslocalhost',
|
376 |
b40bcb23
|
Sjon Hortensius
|
'Disable DNS forwarder',
|
377 |
|
|
'Do not use the DNS Forwarder as a DNS server for the firewall',
|
378 |
|
|
$pconfig['dnslocalhost']
|
379 |
a32c0623
|
Sjon Hortensius
|
))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS'.
|
380 |
|
|
'server where the DNS Forwarder or DNS Resolver is enabled and set to '.
|
381 |
|
|
'listen on Localhost, so system can use the local DNS service to perform'.
|
382 |
|
|
'lookups. Checking this box omits localhost from the list of DNS servers.');
|
383 |
b40bcb23
|
Sjon Hortensius
|
|
384 |
|
|
$form->add($section);
|
385 |
|
|
|
386 |
a005a836
|
Sjon Hortensius
|
$section = new Form_Section('Localization');
|
387 |
|
|
$section->addInput(new Form_Select(
|
388 |
a97531c5
|
Sjon Hortensius
|
'timezone',
|
389 |
a32c0623
|
Sjon Hortensius
|
'Timezone',
|
390 |
|
|
$pconfig['timezone'],
|
391 |
|
|
$timezonelist
|
392 |
|
|
))->setHelp('Select the location closest to you');
|
393 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Input(
|
394 |
a97531c5
|
Sjon Hortensius
|
'timeservers',
|
395 |
a32c0623
|
Sjon Hortensius
|
'Timeservers',
|
396 |
|
|
'text',
|
397 |
|
|
$pconfig['timeservers']
|
398 |
|
|
))->setHelp('Use a space to separate multiple hosts (only one required). '.
|
399 |
|
|
'Remember to set up at least one DNS server if you enter a host name here!');
|
400 |
a005a836
|
Sjon Hortensius
|
$section->addInput(new Form_Select(
|
401 |
a97531c5
|
Sjon Hortensius
|
'language',
|
402 |
a32c0623
|
Sjon Hortensius
|
'Language',
|
403 |
|
|
$pconfig['language'],
|
404 |
|
|
get_locale_list()
|
405 |
|
|
))->setHelp('Choose a language for the webConfigurator');
|
406 |
b40bcb23
|
Sjon Hortensius
|
|
407 |
|
|
$form->add($section);
|
408 |
|
|
|
409 |
|
|
print $form;
|
410 |
69f9ff40
|
Sjon Hortensius
|
|
411 |
|
|
include("foot.inc");
|