From 86115e712b428279f95166401788de919267a888 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 13 Dec 2016 19:02:02 +0545 Subject: Status DHCP Leases show CID and other enhancements 1) If there is a Client Id specified then show it (otherwise it is possible to define a Static Mapping that has only Client Id and all other fields empty, which would look like an empty row in the displayed table). 2) Ignore empty static lease entries - when an interface has no static mappings the "static" section of the DHCP server settings can be "" which was resulting in a single-element that was empty being displayed as an empty row. 3) If there are no leases to display, then make a row with the message "No leases to display" so the user knows the system at least tried. 4) If there are no leases in use, then make a row with the message "No leases are in use" so the user knows the system at least tried. --- src/usr/local/www/status_dhcp_leases.php | 73 +++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 15 deletions(-) (limited to 'src/usr') diff --git a/src/usr/local/www/status_dhcp_leases.php b/src/usr/local/www/status_dhcp_leases.php index 0f92537..d1203e4 100644 --- a/src/usr/local/www/status_dhcp_leases.php +++ b/src/usr/local/www/status_dhcp_leases.php @@ -275,25 +275,33 @@ if (count($pools) > 0) { asort($pools); } +$got_cid = false; + 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_string; - $slease['mac'] = $static['mac']; - $slease['if'] = $ifname; - $slease['start'] = ""; - $slease['end'] = ""; - $slease['hostname'] = htmlentities($static['hostname']); - $slease['descr'] = htmlentities($static['descr']); - $slease['act'] = $static_string; - $slease['online'] = in_array(strtolower($slease['mac']), $arpdata_mac) ? $online_string : $offline_string; - $slease['staticmap_array_index'] = $staticmap_array_index; - $leases[] = $slease; - $staticmap_array_index++; + if (!empty($static['mac']) || !empty($static['cid'])) { + $slease = array(); + $slease['ip'] = $static['ipaddr']; + $slease['type'] = $static_string; + if (!empty($static['cid'])) { + $slease['cid'] = $static['cid']; + $got_cid = true; + } + $slease['mac'] = $static['mac']; + $slease['if'] = $ifname; + $slease['start'] = ""; + $slease['end'] = ""; + $slease['hostname'] = htmlentities($static['hostname']); + $slease['descr'] = htmlentities($static['descr']); + $slease['act'] = $static_string; + $slease['online'] = in_array(strtolower($slease['mac']), $arpdata_mac) ? $online_string : $offline_string; + $slease['staticmap_array_index'] = $staticmap_array_index; + $leases[] = $slease; + $staticmap_array_index++; + } } } } @@ -345,6 +353,14 @@ if (count($pools) > 0) { + + + @@ -358,12 +374,15 @@ if (count($pools) > 0) { ) + + + @@ -450,6 +477,12 @@ foreach ($leases as $data): + + + + + + @@ -469,6 +502,7 @@ foreach ($leases as $data): @@ -478,7 +512,16 @@ foreach ($leases as $data): - + + + + + -- cgit v1.1 From dadc11d7a7aae33ef284a4f8f4258d04e17d27fc Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 13 Dec 2016 20:46:10 +0545 Subject: status_dcp_leases change if statement style --- src/usr/local/www/status_dhcp_leases.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/usr') diff --git a/src/usr/local/www/status_dhcp_leases.php b/src/usr/local/www/status_dhcp_leases.php index d1203e4..60748d4 100644 --- a/src/usr/local/www/status_dhcp_leases.php +++ b/src/usr/local/www/status_dhcp_leases.php @@ -502,7 +502,7 @@ if ($got_cid) { @@ -514,14 +514,12 @@ if (count($dhcp_leases_subnet_counter)) { - + -- cgit v1.1