summaryrefslogtreecommitdiffstats
path: root/usr/local/www/status_dhcp_leases.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-02-22 11:21:56 +0545
committerRenato Botelho <garga@FreeBSD.org>2015-02-23 09:29:53 -0300
commitaeb5bf8e93ba387c3d0862e371a5c11c65f4046b (patch)
tree6d2619ee0f9ed5bc18bd0a927d28a458d9126d8e /usr/local/www/status_dhcp_leases.php
parent8261c0b6accf95eb2a34066d5eb86f11d797bb0e (diff)
downloadpfsense-aeb5bf8e93ba387c3d0862e371a5c11c65f4046b.zip
pfsense-aeb5bf8e93ba387c3d0862e371a5c11c65f4046b.tar.gz
Status_dhcp_leases fix edit button for static entries with no IP address
The edit button for static entries always has an index id=0 and thus pressing the edit button goes to (mostly) edit the wrong entry. It was easier and made the code cleaner to get rid of the looping through the staticmap array every time trying to matach IP, MAC address... That data ('if' and 'staticmap_array_index') is easily gathered further up, the first time the staticmap array for each DHCP interface is traversed. I think this should also be more efficient when there are many static mapping entries. Forum: https://forum.pfsense.org/index.php?topic=89072.msg493241#msg493241
Diffstat (limited to 'usr/local/www/status_dhcp_leases.php')
-rw-r--r--usr/local/www/status_dhcp_leases.php24
1 files changed, 6 insertions, 18 deletions
diff --git a/usr/local/www/status_dhcp_leases.php b/usr/local/www/status_dhcp_leases.php
index 88803c4..191d9f5 100644
--- a/usr/local/www/status_dhcp_leases.php
+++ b/usr/local/www/status_dhcp_leases.php
@@ -274,17 +274,21 @@ if(count($pools) > 0) {
foreach($config['interfaces'] as $ifname => $ifarr) {
if (is_array($config['dhcpd'][$ifname]) &&
is_array($config['dhcpd'][$ifname]['staticmap'])) {
+ $staticmap_array_index = 0;
foreach($config['dhcpd'][$ifname]['staticmap'] as $static) {
$slease = array();
$slease['ip'] = $static['ipaddr'];
$slease['type'] = "static";
$slease['mac'] = $static['mac'];
+ $slease['if'] = $ifname;
$slease['start'] = "";
$slease['end'] = "";
$slease['hostname'] = htmlentities($static['hostname']);
$slease['act'] = "static";
$slease['online'] = in_array(strtolower($slease['mac']), $arpdata_mac) ? 'online' : 'offline';
+ $slease['staticmap_array_index'] = $staticmap_array_index;
$leases[] = $slease;
+ $staticmap_array_index++;
}
}
}
@@ -349,23 +353,7 @@ foreach ($leases as $data) {
$fspane = "&nbsp;";
}
$lip = ip2ulong($data['ip']);
- if ($data['act'] == "static") {
- foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
- if(is_array($dhcpifconf['staticmap'])) {
- $staticmap_array_index = 0;
- foreach ($dhcpifconf['staticmap'] as $staticent) {
- if ($data['ip'] == $staticent['ipaddr']) {
- $data['if'] = $dhcpif;
- break;
- }
- $staticmap_array_index++;
- }
- }
- /* exit as soon as we have an interface */
- if ($data['if'] != "")
- break;
- }
- } else {
+ if ($data['act'] != "static") {
foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
if (!is_array($dhcpifconf['range']))
continue;
@@ -407,7 +395,7 @@ foreach ($leases as $data) {
echo "<a href=\"services_dhcp_edit.php?if={$data['if']}&amp;mac={$data['mac']}&amp;hostname={$data['hostname']}\">";
echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("add a static mapping for this MAC address") ."\" alt=\"add\" /></a>&nbsp;\n";
} else {
- echo "<a href=\"services_dhcp_edit.php?if={$data['if']}&amp;id={$staticmap_array_index}\">";
+ echo "<a href=\"services_dhcp_edit.php?if={$data['if']}&amp;id={$data['staticmap_array_index']}\">";
echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_e.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("edit the static mapping for this entry") ."\" alt=\"add\" />&nbsp;\n";
}
OpenPOWER on IntegriCloud