Commit 9fe3e401 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) prevent some notices in refactored dhcp code

parent 05528a54
...@@ -139,6 +139,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -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") . ".<br/><br/>" . gettext("Only interfaces configured with a static IP will be shown") . "."; $savemsg = gettext("The DHCP Server can only be enabled on interfaces configured with static IP addresses") . ".<br/><br/>" . 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])) { if (empty($config['dhcpd'][$if])) {
$config['dhcpd'][$if] = array(); $config['dhcpd'][$if] = array();
} }
...@@ -153,15 +163,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -153,15 +163,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$act = null; $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) // point to source of data (pool or main dhcp section)
if (isset($pool)) { if (isset($pool)) {
$dhcpdconf = &$a_pools[$pool]; $dhcpdconf = &$a_pools[$pool];
......
...@@ -45,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -45,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
header("Location: services_dhcp.php"); header("Location: services_dhcp.php");
exit; 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']; $id = $_GET['id'];
} }
...@@ -56,7 +56,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -56,7 +56,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
'ddnsdomainprimary', 'ddnsdomainkeyname', 'ddnsdomainkey', 'ddnsupdate', 'ntp1', 'ntp2', 'tftp', 'ipaddr', 'ddnsdomainprimary', 'ddnsdomainkeyname', 'ddnsdomainkey', 'ddnsupdate', 'ntp1', 'ntp2', 'tftp', 'ipaddr',
'winsserver', 'dnsserver'); 'winsserver', 'dnsserver');
foreach ($config_copy_fieldnames as $fieldname) { 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]; $pconfig[$fieldname] = $config['dhcpd'][$if]['staticmap'][$id][$fieldname];
} elseif (isset($_GET[$fieldname])) { } elseif (isset($_GET[$fieldname])) {
$pconfig[$fieldname] = $_GET[$fieldname]; $pconfig[$fieldname] = $_GET[$fieldname];
......
...@@ -74,7 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -74,7 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
"IP addresses. Only interfaces configured with a static IP will be shown." "IP addresses. Only interfaces configured with a static IP will be shown."
); );
foreach ($config['interfaces'] as $if_id => $intf) { 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; $if = $if_id;
break; break;
} }
...@@ -445,7 +445,7 @@ include("head.inc"); ...@@ -445,7 +445,7 @@ include("head.inc");
/* active tabs */ /* active tabs */
$tab_array_main = array(); $tab_array_main = array();
foreach ($config['interfaces'] as $if_id => $intf) { 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); $ifname = !empty($intf['descr']) ? htmlspecialchars($intf['descr']) : strtoupper($if_id);
if ($if_id == $if) { if ($if_id == $if) {
$tab_array_main[] = array($ifname, true, "services_dhcpv6.php?if={$if_id}"); $tab_array_main[] = array($ifname, true, "services_dhcpv6.php?if={$if_id}");
...@@ -815,7 +815,7 @@ include("head.inc"); ...@@ -815,7 +815,7 @@ include("head.inc");
foreach ($config['dhcpdv6'][$if]['staticmap'] as $mapent): ?> foreach ($config['dhcpdv6'][$if]['staticmap'] as $mapent): ?>
<tr> <tr>
<td><?=htmlspecialchars($mapent['duid']);?></td> <td><?=htmlspecialchars($mapent['duid']);?></td>
<td><?=htmlspecialchars($mapent['ipaddrv6']);?></td> <td><?=isset($mapent['ipaddrv6']) ? htmlspecialchars($mapent['ipaddrv6']) : "";?></td>
<td><?=htmlspecialchars($mapent['hostname']);?></td> <td><?=htmlspecialchars($mapent['hostname']);?></td>
<td><?=htmlspecialchars($mapent['descr']);?></td> <td><?=htmlspecialchars($mapent['descr']);?></td>
<td> <td>
......
...@@ -37,7 +37,6 @@ function staticmapcmp($a, $b) ...@@ -37,7 +37,6 @@ function staticmapcmp($a, $b)
} }
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// handle identifiers and action // handle identifiers and action
if (!empty($_GET['if']) && !empty($config['interfaces'][$_GET['if']])) { if (!empty($_GET['if']) && !empty($config['interfaces'][$_GET['if']])) {
...@@ -46,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -46,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
header("Location: services_dhcpv6.php"); header("Location: services_dhcpv6.php");
exit; exit;
} }
if (!empty($config['dhcpdv6'][$if]['staticmap'][$_GET['id']])) { if (isset($if) && isset($_GET['id']) && !empty($config['dhcpdv6'][$if]['staticmap'][$_GET['id']])) {
$id = $_GET['id']; $id = $_GET['id'];
} }
...@@ -54,7 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -54,7 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = array(); $pconfig = array();
$config_copy_fieldnames = array('duid', 'hostname', 'ipaddrv6', 'filename' ,'rootpath' ,'descr'); $config_copy_fieldnames = array('duid', 'hostname', 'ipaddrv6', 'filename' ,'rootpath' ,'descr');
foreach ($config_copy_fieldnames as $fieldname) { foreach ($config_copy_fieldnames as $fieldname) {
if (isset($config['dhcpdv6'][$if]['staticmap'][$id][$fieldname])) { if (isset($if) && isset($id) && isset($config['dhcpdv6'][$if]['staticmap'][$id][$fieldname])) {
$pconfig[$fieldname] = $config['dhcpdv6'][$if]['staticmap'][$id][$fieldname]; $pconfig[$fieldname] = $config['dhcpdv6'][$if]['staticmap'][$id][$fieldname];
} elseif (isset($_GET[$fieldname])) { } elseif (isset($_GET[$fieldname])) {
$pconfig[$fieldname] = $_GET[$fieldname]; $pconfig[$fieldname] = $_GET[$fieldname];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment