diff --git a/src/www/services_dhcp.php b/src/www/services_dhcp.php
index ebfea9809..a54824242 100644
--- a/src/www/services_dhcp.php
+++ b/src/www/services_dhcp.php
@@ -139,6 +139,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$savemsg = gettext("The DHCP Server can only be enabled on interfaces configured with static IP addresses") . ".
" . gettext("Only interfaces configured with a static IP will be shown") . ".";
}
+ /* If no interface is provided, choose first one from interfaces */
+ if (!isset($if)) {
+ foreach ($config['interfaces'] as $if_id => $intf) {
+ if (!empty($intf['enable']) && is_ipaddrv4($intf['ipaddr'])) {
+ $if = $if_id;
+ break;
+ }
+ }
+ }
+
if (empty($config['dhcpd'][$if])) {
$config['dhcpd'][$if] = array();
}
@@ -153,15 +163,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$act = null;
}
- /* If no interface is provided, choose first one from interfaces */
- if (!isset($if)) {
- foreach ($config['interfaces'] as $if_id => $intf) {
- if (!empty($intf['enable']) && is_ipaddrv4($intf['ipaddr'])) {
- $if = $if_id;
- break;
- }
- }
- }
// point to source of data (pool or main dhcp section)
if (isset($pool)) {
$dhcpdconf = &$a_pools[$pool];
diff --git a/src/www/services_dhcp_edit.php b/src/www/services_dhcp_edit.php
index 686c718bf..4e1da1d37 100644
--- a/src/www/services_dhcp_edit.php
+++ b/src/www/services_dhcp_edit.php
@@ -45,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
header("Location: services_dhcp.php");
exit;
}
- if (!empty($config['dhcpd'][$if]['staticmap'][$_GET['id']])) {
+ if (isset($if) && isset($_GET['id']) && !empty($config['dhcpd'][$if]['staticmap'][$_GET['id']])) {
$id = $_GET['id'];
}
@@ -56,7 +56,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
'ddnsdomainprimary', 'ddnsdomainkeyname', 'ddnsdomainkey', 'ddnsupdate', 'ntp1', 'ntp2', 'tftp', 'ipaddr',
'winsserver', 'dnsserver');
foreach ($config_copy_fieldnames as $fieldname) {
- if (isset($config['dhcpd'][$if]['staticmap'][$id][$fieldname])) {
+ if (isset($if) && isset($id) && isset($config['dhcpd'][$if]['staticmap'][$id][$fieldname])) {
$pconfig[$fieldname] = $config['dhcpd'][$if]['staticmap'][$id][$fieldname];
} elseif (isset($_GET[$fieldname])) {
$pconfig[$fieldname] = $_GET[$fieldname];
diff --git a/src/www/services_dhcpv6.php b/src/www/services_dhcpv6.php
index fec7f90cc..f55fd9b27 100644
--- a/src/www/services_dhcpv6.php
+++ b/src/www/services_dhcpv6.php
@@ -74,7 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
"IP addresses. Only interfaces configured with a static IP will be shown."
);
foreach ($config['interfaces'] as $if_id => $intf) {
- if (!empty($intf['enable']) && is_ipaddrv6($intf['ipaddrv6']) && !is_linklocal($oc['ipaddrv6'])) {
+ if (!empty($intf['enable']) && isset($intf['ipaddrv6']) && is_ipaddrv6($intf['ipaddrv6']) && !is_linklocal($intf['ipaddrv6'])) {
$if = $if_id;
break;
}
@@ -445,7 +445,7 @@ include("head.inc");
/* active tabs */
$tab_array_main = array();
foreach ($config['interfaces'] as $if_id => $intf) {
- if (!empty($intf['enable']) && is_ipaddrv6($intf['ipaddrv6'])) {
+ if (!empty($intf['enable']) && isset($intf['ipaddrv6']) && is_ipaddrv6($intf['ipaddrv6'])) {
$ifname = !empty($intf['descr']) ? htmlspecialchars($intf['descr']) : strtoupper($if_id);
if ($if_id == $if) {
$tab_array_main[] = array($ifname, true, "services_dhcpv6.php?if={$if_id}");
@@ -815,7 +815,7 @@ include("head.inc");
foreach ($config['dhcpdv6'][$if]['staticmap'] as $mapent): ?>