From e81e687e84b8a0625f7d336e72f29705ec322c53 Mon Sep 17 00:00:00 2001
From: Franco Fichtner
Date: Sat, 11 Apr 2015 11:20:26 +0200
Subject: [PATCH] www: permanently move the old system.php to
system_general.php
---
src/etc/inc/priv.defs.inc | 2 +-
.../OPNsense/Core/ACL_Legacy_Page_Map.txt | 2 +-
src/www/services_dhcp.php | 2 +-
src/www/services_dhcpv6.php | 2 +-
src/www/services_dnsmasq.php | 9 +-
src/www/services_dyndns_edit.php | 2 +-
src/www/services_rfc2136_edit.php | 3 +-
src/www/services_unbound.php | 9 +-
src/www/system.php | 516 -----------------
src/www/system_general.php | 518 +++++++++++++++++-
10 files changed, 533 insertions(+), 532 deletions(-)
delete mode 100644 src/www/system.php
diff --git a/src/etc/inc/priv.defs.inc b/src/etc/inc/priv.defs.inc
index cf0882a06..1078ac31b 100644
--- a/src/etc/inc/priv.defs.inc
+++ b/src/etc/inc/priv.defs.inc
@@ -1102,7 +1102,7 @@ $priv_list['page-system-generalsetup'] = array();
$priv_list['page-system-generalsetup']['name'] = gettext("WebCfg - System: General Setup page");
$priv_list['page-system-generalsetup']['descr'] = gettext("Allow access to the 'System: General Setup' page.");
$priv_list['page-system-generalsetup']['match'] = array();
-$priv_list['page-system-generalsetup']['match'][] = "system.php*";
+$priv_list['page-system-generalsetup']['match'][] = "system_general.php*";
$priv_list['page-system-advanced-admin'] = array();
$priv_list['page-system-advanced-admin']['name'] = gettext("WebCfg - System: Advanced: Admin Access Page");
diff --git a/src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.txt b/src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.txt
index a3c4c3f4c..2c449c224 100644
--- a/src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.txt
+++ b/src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.txt
@@ -179,7 +179,7 @@ page-status-rrdgraph-settings=status_rrd_graph_settings.php*
page-status-services=status_services.php*
page-status-upnpstatus=status_upnp.php*
page-diagnostics-wirelessstatus=status_wireless.php*
-page-system-generalsetup=system.php*
+page-system-generalsetup=system_general.php*
page-system-advanced-admin=system_advanced_admin.php*
page-system-advanced-firewall=system_advanced_firewall.php*
page-system-advanced-misc=system_advanced_misc.php*
diff --git a/src/www/services_dhcp.php b/src/www/services_dhcp.php
index 67ef2b7ff..46369db6c 100644
--- a/src/www/services_dhcp.php
+++ b/src/www/services_dhcp.php
@@ -1150,7 +1150,7 @@ include("head.inc");
| |
=gettext("Note:");?>
- =gettext("The DNS servers entered in"); ?> =gettext("System: " .
+ =gettext("The DNS servers entered in"); ?> =gettext("System: " .
"General setup"); ?> =gettext("(or the"); ?> =gettext("DNS " .
"forwarder"); ?>, =gettext("if enabled)"); ?> =gettext("will " .
"be assigned to clients by the DHCP server."); ?>
diff --git a/src/www/services_dhcpv6.php b/src/www/services_dhcpv6.php
index 6877e7aa8..dcfc0f97e 100644
--- a/src/www/services_dhcpv6.php
+++ b/src/www/services_dhcpv6.php
@@ -811,7 +811,7 @@ include("head.inc");
| |
=gettext("Note:");?>
- =gettext("The DNS servers entered in"); ?> =gettext("System: " .
+ =gettext("The DNS servers entered in"); ?> =gettext("System: " .
"General setup"); ?> =gettext("(or the"); ?> =gettext("DNS " .
"forwarder"); ?>, =gettext("if enabled)"); ?> =gettext("will " .
"be assigned to clients by the DHCP server."); ?>
diff --git a/src/www/services_dnsmasq.php b/src/www/services_dnsmasq.php
index 53c00e31a..a19cc61f8 100644
--- a/src/www/services_dnsmasq.php
+++ b/src/www/services_dnsmasq.php
@@ -1,4 +1,5 @@
and Manuel Kasper .
@@ -207,7 +208,7 @@ function show_advanced_dns() {
" their hostname when requesting a DHCP lease will be registered".
" in the DNS forwarder, so that their name can be resolved.".
" You should also set the domain in %sSystem:".
- " General setup%s to the proper value."),'','')?>
+ " General setup%s to the proper value."),'','')?>
|
@@ -218,7 +219,7 @@ function show_advanced_dns() {
','');?>
+ "System: General setup%s to the proper value."),'','');?>
@@ -338,8 +339,8 @@ function show_advanced_dns() {
" DNS server list to be overridden by DHCP/PPP on WAN"".
" is checked. If you don't use that option (or if you use".
" a static IP address on WAN), you must manually specify at".
- " least one DNS server on the %sSystem:".
- "General setup%s page."),'','','','');?>
+ " least one DNS server on the %sSystem: General setup%s page."),
+ '','','','');?>
diff --git a/src/www/services_dyndns_edit.php b/src/www/services_dyndns_edit.php
index 9d6a9538a..91a35f0dc 100644
--- a/src/www/services_dyndns_edit.php
+++ b/src/www/services_dyndns_edit.php
@@ -444,7 +444,7 @@ include("head.inc");
=gettext("Note:");?>
','');?> |
+ by DHCP/PPP on WAN for dynamic DNS updates to work."),'','');?>
diff --git a/src/www/services_rfc2136_edit.php b/src/www/services_rfc2136_edit.php
index 2a0ff2257..abe3f7a10 100644
--- a/src/www/services_rfc2136_edit.php
+++ b/src/www/services_rfc2136_edit.php
@@ -1,4 +1,5 @@
=gettext("Note:");?>
', '');?> |
+ "by DHCP/PPP on WAN for dynamic DNS updates to work."),'', '');?>
diff --git a/src/www/services_unbound.php b/src/www/services_unbound.php
index db9bfe1f0..c3d61ffe0 100644
--- a/src/www/services_unbound.php
+++ b/src/www/services_unbound.php
@@ -1,7 +1,8 @@
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -303,7 +304,7 @@ function show_advanced_dns() {
" their hostname when requesting a DHCP lease will be registered".
" in the DNS Resolver, so that their name can be resolved.".
" You should also set the domain in %sSystem:".
- " General setup%s to the proper value."),'','')?>
+ " General setup%s to the proper value."),'','')?>
@@ -314,7 +315,7 @@ function show_advanced_dns() {
','');?>
+ "System: General setup%s to the proper value."),'','');?>
@@ -356,7 +357,7 @@ function show_advanced_dns() {
" entered in %sSystem: General setup%s".
" or those obtained via DHCP or PPP on WAN if the "Allow".
" DNS server list to be overridden by DHCP/PPP on WAN"".
- " is checked."),'','');?>
+ " is checked."),'','');?>
diff --git a/src/www/system.php b/src/www/system.php
deleted file mode 100644
index daa4caf73..000000000
--- a/src/www/system.php
+++ /dev/null
@@ -1,516 +0,0 @@
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-require_once("guiconfig.inc");
-require_once("functions.inc");
-require_once("filter.inc");
-require_once("shaper.inc");
-
-function get_locale_list()
-{
- $locales = array('en_US' => gettext('English'));
- asort($locales);
- return $locales;
-}
-
-
-$pconfig['hostname'] = $config['system']['hostname'];
-$pconfig['domain'] = $config['system']['domain'];
-list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $config['system']['dnsserver'];
-
-$arr_gateways = return_gateways_array();
-
-$pconfig['dns1gw'] = $config['system']['dns1gw'];
-$pconfig['dns2gw'] = $config['system']['dns2gw'];
-$pconfig['dns3gw'] = $config['system']['dns3gw'];
-$pconfig['dns4gw'] = $config['system']['dns4gw'];
-
-$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
-$pconfig['timezone'] = $config['system']['timezone'];
-$pconfig['timeupdateinterval'] = $config['system']['time-update-interval'];
-$pconfig['timeservers'] = $config['system']['timeservers'];
-$pconfig['theme'] = $config['system']['theme'];
-$pconfig['language'] = $config['system']['language'];
-
-$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
-
-if (!isset($pconfig['timeupdateinterval']))
- $pconfig['timeupdateinterval'] = 300;
-if (!$pconfig['timezone'])
- $pconfig['timezone'] = "Etc/UTC";
-if (!$pconfig['timeservers'])
- $pconfig['timeservers'] = "pool.ntp.org";
-
-$changedesc = gettext("System") . ": ";
-$changecount = 0;
-
-if($pconfig['timezone'] <> $_POST['timezone']) {
- filter_pflog_start(true);
-}
-
-$timezonelist = array_map(
- function ($path) { return str_replace('/usr/share/zoneinfo/', '', $path); },
- glob('/usr/share/zoneinfo/*/*')
-);
-
-$multiwan = false;
-$interfaces = get_configured_interface_list();
-foreach($interfaces as $interface) {
- if(interface_has_gateway($interface)) {
- $multiwan = true;
- }
-}
-
-if ($_POST) {
-
- $changecount++;
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- $reqdfields = explode(" ", "hostname domain");
- $reqdfieldsn = array(gettext("Hostname"),gettext("Domain"));
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
-
- if ($_POST['hostname'] && !is_hostname($_POST['hostname'])) {
- $input_errors[] = gettext("The hostname may only contain the characters a-z, 0-9 and '-'.");
- }
- if ($_POST['domain'] && !is_domain($_POST['domain'])) {
- $input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
- }
-
- $ignore_posted_dnsgw = array();
-
- for ($dnscounter=1; $dnscounter<5; $dnscounter++){
- $dnsname="dns{$dnscounter}";
- $dnsgwname="dns{$dnscounter}gw";
- if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
- $input_errors[] = gettext("A valid IP address must be specified for DNS server $dnscounter.");
- } else {
- if(($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
- // A real gateway has been selected.
- if (is_ipaddr($_POST[$dnsname])) {
- if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false )) {
- $input_errors[] = gettext("You can not specify IPv6 gateway '{$_POST[$dnsgwname]}' for IPv4 DNS server '{$_POST[$dnsname]}'");
- }
- if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false )) {
- $input_errors[] = gettext("You can not specify IPv4 gateway '{$_POST[$dnsgwname]}' for IPv6 DNS server '{$_POST[$dnsname]}'");
- }
- } else {
- // The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
- $ignore_posted_dnsgw[$dnsgwname] = true;
- }
- }
- }
- }
-
- $direct_networks_list = explode(" ", filter_get_direct_networks_list());
- for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
- $dnsitem = "dns{$dnscounter}";
- $dnsgwitem = "dns{$dnscounter}gw";
- if ($_POST[$dnsgwitem]) {
- if(interface_has_gateway($_POST[$dnsgwitem])) {
- foreach($direct_networks_list as $direct_network) {
- if(ip_in_subnet($_POST[$dnsitem], $direct_network)) {
- $input_errors[] = sprintf(gettext("You can not assign a gateway to DNS '%s' server which is on a directly connected network."),$_POST[$dnsitem]);
- }
- }
- }
- }
- }
-
- $t = (int)$_POST['timeupdateinterval'];
- if (($t < 0) || (($t > 0) && ($t < 6)) || ($t > 1440)) {
- $input_errors[] = gettext("The time update interval must be either 0 (disabled) or between 6 and 1440.");
- }
- # it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
- $_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
- $_POST['timeservers'] = trim($_POST['timeservers']);
- foreach (explode(' ', $_POST['timeservers']) as $ts) {
- if (!is_domain($ts)) {
- $input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
- }
- }
-
- if (!$input_errors) {
- update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
- update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
-
- update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
- update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
- update_if_changed("NTP update interval", $config['system']['time-update-interval'], $_POST['timeupdateinterval']);
-
- if($_POST['language'] && $_POST['language'] != $config['system']['language']) {
- $config['system']['language'] = $_POST['language'];
- set_language($config['system']['language']);
- }
-
- update_if_changed("System Theme", $config['theme'], $_POST['theme']);
-
- /* XXX - billm: these still need updating after figuring out how to check if they actually changed */
- $olddnsservers = $config['system']['dnsserver'];
- unset($config['system']['dnsserver']);
- if ($_POST['dns1'])
- $config['system']['dnsserver'][] = $_POST['dns1'];
- if ($_POST['dns2'])
- $config['system']['dnsserver'][] = $_POST['dns2'];
- if ($_POST['dns3'])
- $config['system']['dnsserver'][] = $_POST['dns3'];
- if ($_POST['dns4'])
- $config['system']['dnsserver'][] = $_POST['dns4'];
-
- $olddnsallowoverride = $config['system']['dnsallowoverride'];
-
- unset($config['system']['dnsallowoverride']);
- $config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
-
- if($_POST['dnslocalhost'] == "yes")
- $config['system']['dnslocalhost'] = true;
- else
- unset($config['system']['dnslocalhost']);
-
- /* which interface should the dns servers resolve through? */
- $outdnscounter = 0;
- for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
- $dnsname="dns{$dnscounter}";
- $dnsgwname="dns{$dnscounter}gw";
- $olddnsgwname = $config['system'][$dnsgwname];
-
- if ($ignore_posted_dnsgw[$dnsgwname])
- $thisdnsgwname = "none";
- else
- $thisdnsgwname = $pconfig[$dnsgwname];
-
- // "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
- $config['system'][$dnsgwname] = "none";
- $pconfig[$dnsgwname] = "none";
- $pconfig[$dnsname] = "";
-
- if ($_POST[$dnsname]) {
- // Only the non-blank DNS servers were put into the config above.
- // So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
- // 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.
- $outdnscounter++;
- $outdnsname="dns{$outdnscounter}";
- $outdnsgwname="dns{$outdnscounter}gw";
- $pconfig[$outdnsname] = $_POST[$dnsname];
- if($_POST[$dnsgwname]) {
- $config['system'][$outdnsgwname] = $thisdnsgwname;
- $pconfig[$outdnsgwname] = $thisdnsgwname;
- } else {
- // Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
- unset($config['system'][$outdnsgwname]);
- $pconfig[$outdnsgwname] = "";
- }
- }
- if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter-1] != $_POST[$dnsname]))) {
- // A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
- // Remove the route. Later calls will add the correct new route if needed.
- if (is_ipaddrv4($olddnsservers[$dnscounter-1]))
- mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
- else
- if (is_ipaddrv6($olddnsservers[$dnscounter-1]))
- mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
- }
- }
-
- if ($changecount > 0)
- write_config($changedesc);
-
- $retval = 0;
- $retval = system_hostname_configure();
- $retval |= system_hosts_generate();
- $retval |= system_resolvconf_generate();
- if (isset($config['dnsmasq']['enable']))
- $retval |= services_dnsmasq_configure();
- elseif (isset($config['unbound']['enable']))
- $retval |= services_unbound_configure();
- $retval |= system_timezone_configure();
- $retval |= system_ntp_configure();
-
- if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
- configd_run("dns reload");
- }
-
- // Reload the filter - plugins might need to be run.
- $retval |= filter_configure();
-
- $savemsg = get_std_save_message($retval);
- }
-
- unset($ignore_posted_dnsgw);
-}
-
-$pgtitle = array(gettext("System"),gettext("General Setup"));
-include("head.inc");
-
-?>
-
-
-
-
-
-
-
-
diff --git a/src/www/system_general.php b/src/www/system_general.php
index b73292a22..7ffa648e7 100644
--- a/src/www/system_general.php
+++ b/src/www/system_general.php
@@ -1,2 +1,516 @@
-
- require_once("system.php");
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require_once("guiconfig.inc");
+require_once("functions.inc");
+require_once("filter.inc");
+require_once("shaper.inc");
+
+function get_locale_list()
+{
+ $locales = array('en_US' => gettext('English'));
+ asort($locales);
+ return $locales;
+}
+
+
+$pconfig['hostname'] = $config['system']['hostname'];
+$pconfig['domain'] = $config['system']['domain'];
+list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $config['system']['dnsserver'];
+
+$arr_gateways = return_gateways_array();
+
+$pconfig['dns1gw'] = $config['system']['dns1gw'];
+$pconfig['dns2gw'] = $config['system']['dns2gw'];
+$pconfig['dns3gw'] = $config['system']['dns3gw'];
+$pconfig['dns4gw'] = $config['system']['dns4gw'];
+
+$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
+$pconfig['timezone'] = $config['system']['timezone'];
+$pconfig['timeupdateinterval'] = $config['system']['time-update-interval'];
+$pconfig['timeservers'] = $config['system']['timeservers'];
+$pconfig['theme'] = $config['system']['theme'];
+$pconfig['language'] = $config['system']['language'];
+
+$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
+
+if (!isset($pconfig['timeupdateinterval']))
+ $pconfig['timeupdateinterval'] = 300;
+if (!$pconfig['timezone'])
+ $pconfig['timezone'] = "Etc/UTC";
+if (!$pconfig['timeservers'])
+ $pconfig['timeservers'] = "pool.ntp.org";
+
+$changedesc = gettext("System") . ": ";
+$changecount = 0;
+
+if($pconfig['timezone'] <> $_POST['timezone']) {
+ filter_pflog_start(true);
+}
+
+$timezonelist = array_map(
+ function ($path) { return str_replace('/usr/share/zoneinfo/', '', $path); },
+ glob('/usr/share/zoneinfo/*/*')
+);
+
+$multiwan = false;
+$interfaces = get_configured_interface_list();
+foreach($interfaces as $interface) {
+ if(interface_has_gateway($interface)) {
+ $multiwan = true;
+ }
+}
+
+if ($_POST) {
+
+ $changecount++;
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = explode(" ", "hostname domain");
+ $reqdfieldsn = array(gettext("Hostname"),gettext("Domain"));
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
+
+ if ($_POST['hostname'] && !is_hostname($_POST['hostname'])) {
+ $input_errors[] = gettext("The hostname may only contain the characters a-z, 0-9 and '-'.");
+ }
+ if ($_POST['domain'] && !is_domain($_POST['domain'])) {
+ $input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
+ }
+
+ $ignore_posted_dnsgw = array();
+
+ for ($dnscounter=1; $dnscounter<5; $dnscounter++){
+ $dnsname="dns{$dnscounter}";
+ $dnsgwname="dns{$dnscounter}gw";
+ if (($_POST[$dnsname] && !is_ipaddr($_POST[$dnsname]))) {
+ $input_errors[] = gettext("A valid IP address must be specified for DNS server $dnscounter.");
+ } else {
+ if(($_POST[$dnsgwname] <> "") && ($_POST[$dnsgwname] <> "none")) {
+ // A real gateway has been selected.
+ if (is_ipaddr($_POST[$dnsname])) {
+ if ((is_ipaddrv4($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false )) {
+ $input_errors[] = gettext("You can not specify IPv6 gateway '{$_POST[$dnsgwname]}' for IPv4 DNS server '{$_POST[$dnsname]}'");
+ }
+ if ((is_ipaddrv6($_POST[$dnsname])) && (validate_address_family($_POST[$dnsname], $_POST[$dnsgwname]) === false )) {
+ $input_errors[] = gettext("You can not specify IPv4 gateway '{$_POST[$dnsgwname]}' for IPv6 DNS server '{$_POST[$dnsname]}'");
+ }
+ } else {
+ // The user selected a gateway but did not provide a DNS address. Be nice and set the gateway back to "none".
+ $ignore_posted_dnsgw[$dnsgwname] = true;
+ }
+ }
+ }
+ }
+
+ $direct_networks_list = explode(" ", filter_get_direct_networks_list());
+ for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
+ $dnsitem = "dns{$dnscounter}";
+ $dnsgwitem = "dns{$dnscounter}gw";
+ if ($_POST[$dnsgwitem]) {
+ if(interface_has_gateway($_POST[$dnsgwitem])) {
+ foreach($direct_networks_list as $direct_network) {
+ if(ip_in_subnet($_POST[$dnsitem], $direct_network)) {
+ $input_errors[] = sprintf(gettext("You can not assign a gateway to DNS '%s' server which is on a directly connected network."),$_POST[$dnsitem]);
+ }
+ }
+ }
+ }
+ }
+
+ $t = (int)$_POST['timeupdateinterval'];
+ if (($t < 0) || (($t > 0) && ($t < 6)) || ($t > 1440)) {
+ $input_errors[] = gettext("The time update interval must be either 0 (disabled) or between 6 and 1440.");
+ }
+ # it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
+ $_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
+ $_POST['timeservers'] = trim($_POST['timeservers']);
+ foreach (explode(' ', $_POST['timeservers']) as $ts) {
+ if (!is_domain($ts)) {
+ $input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
+ }
+ }
+
+ if (!$input_errors) {
+ update_if_changed("hostname", $config['system']['hostname'], $_POST['hostname']);
+ update_if_changed("domain", $config['system']['domain'], $_POST['domain']);
+
+ update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
+ update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
+ update_if_changed("NTP update interval", $config['system']['time-update-interval'], $_POST['timeupdateinterval']);
+
+ if($_POST['language'] && $_POST['language'] != $config['system']['language']) {
+ $config['system']['language'] = $_POST['language'];
+ set_language($config['system']['language']);
+ }
+
+ update_if_changed("System Theme", $config['theme'], $_POST['theme']);
+
+ /* XXX - billm: these still need updating after figuring out how to check if they actually changed */
+ $olddnsservers = $config['system']['dnsserver'];
+ unset($config['system']['dnsserver']);
+ if ($_POST['dns1'])
+ $config['system']['dnsserver'][] = $_POST['dns1'];
+ if ($_POST['dns2'])
+ $config['system']['dnsserver'][] = $_POST['dns2'];
+ if ($_POST['dns3'])
+ $config['system']['dnsserver'][] = $_POST['dns3'];
+ if ($_POST['dns4'])
+ $config['system']['dnsserver'][] = $_POST['dns4'];
+
+ $olddnsallowoverride = $config['system']['dnsallowoverride'];
+
+ unset($config['system']['dnsallowoverride']);
+ $config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
+
+ if($_POST['dnslocalhost'] == "yes")
+ $config['system']['dnslocalhost'] = true;
+ else
+ unset($config['system']['dnslocalhost']);
+
+ /* which interface should the dns servers resolve through? */
+ $outdnscounter = 0;
+ for ($dnscounter=1; $dnscounter<5; $dnscounter++) {
+ $dnsname="dns{$dnscounter}";
+ $dnsgwname="dns{$dnscounter}gw";
+ $olddnsgwname = $config['system'][$dnsgwname];
+
+ if ($ignore_posted_dnsgw[$dnsgwname])
+ $thisdnsgwname = "none";
+ else
+ $thisdnsgwname = $pconfig[$dnsgwname];
+
+ // "Blank" out the settings for this index, then we set them below using the "outdnscounter" index.
+ $config['system'][$dnsgwname] = "none";
+ $pconfig[$dnsgwname] = "none";
+ $pconfig[$dnsname] = "";
+
+ if ($_POST[$dnsname]) {
+ // Only the non-blank DNS servers were put into the config above.
+ // So we similarly only add the corresponding gateways sequentially to the config (and to pconfig), as we find non-blank DNS servers.
+ // 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.
+ $outdnscounter++;
+ $outdnsname="dns{$outdnscounter}";
+ $outdnsgwname="dns{$outdnscounter}gw";
+ $pconfig[$outdnsname] = $_POST[$dnsname];
+ if($_POST[$dnsgwname]) {
+ $config['system'][$outdnsgwname] = $thisdnsgwname;
+ $pconfig[$outdnsgwname] = $thisdnsgwname;
+ } else {
+ // Note: when no DNS GW name is chosen, the entry is set to "none", so actually this case never happens.
+ unset($config['system'][$outdnsgwname]);
+ $pconfig[$outdnsgwname] = "";
+ }
+ }
+ if (($olddnsgwname != "") && ($olddnsgwname != "none") && (($olddnsgwname != $thisdnsgwname) || ($olddnsservers[$dnscounter-1] != $_POST[$dnsname]))) {
+ // A previous DNS GW name was specified. It has now gone or changed, or the DNS server address has changed.
+ // Remove the route. Later calls will add the correct new route if needed.
+ if (is_ipaddrv4($olddnsservers[$dnscounter-1]))
+ mwexec("/sbin/route delete " . escapeshellarg($olddnsservers[$dnscounter-1]));
+ else
+ if (is_ipaddrv6($olddnsservers[$dnscounter-1]))
+ mwexec("/sbin/route delete -inet6 " . escapeshellarg($olddnsservers[$dnscounter-1]));
+ }
+ }
+
+ if ($changecount > 0)
+ write_config($changedesc);
+
+ $retval = 0;
+ $retval = system_hostname_configure();
+ $retval |= system_hosts_generate();
+ $retval |= system_resolvconf_generate();
+ if (isset($config['dnsmasq']['enable']))
+ $retval |= services_dnsmasq_configure();
+ elseif (isset($config['unbound']['enable']))
+ $retval |= services_unbound_configure();
+ $retval |= system_timezone_configure();
+ $retval |= system_ntp_configure();
+
+ if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
+ configd_run("dns reload");
+ }
+
+ // Reload the filter - plugins might need to be run.
+ $retval |= filter_configure();
+
+ $savemsg = get_std_save_message($retval);
+ }
+
+ unset($ignore_posted_dnsgw);
+}
+
+$pgtitle = array(gettext("System"),gettext("General Setup"));
+include("head.inc");
+
+?>
+
+
+
+
+
+
+
+