diff options
author | Phil Davis <phil.davis@inf.org> | 2016-12-13 19:02:02 +0545 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-13 19:02:02 +0545 |
commit | 86115e712b428279f95166401788de919267a888 (patch) | |
tree | 25490cd29d45ce1af556aa695a8f49c99e30c77a /src/usr/local/www/status_dhcp_leases.php | |
parent | cc9213e0bc41942a300ab246bae2ca3312f046fe (diff) | |
download | pfsense-86115e712b428279f95166401788de919267a888.zip pfsense-86115e712b428279f95166401788de919267a888.tar.gz |
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.
Diffstat (limited to 'src/usr/local/www/status_dhcp_leases.php')
-rw-r--r-- | src/usr/local/www/status_dhcp_leases.php | 73 |
1 files changed, 58 insertions, 15 deletions
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) { <th><!-- icon --></th> <th><?=gettext("IP address")?></th> <th><?=gettext("MAC address")?></th> +<?php +/* only make CID column when we have one */ +if ($got_cid) { +?> + <th><?=gettext("Client Id")?></th> +<?php +} +?> <th><?=gettext("Hostname")?></th> <th><?=gettext("Description")?></th> <th><?=gettext("Start")?></th> @@ -358,12 +374,15 @@ if (count($pools) > 0) { <?php $dhcp_leases_subnet_counter = array(); //array to sum up # of leases / subnet $iflist = get_configured_interface_with_descr(); //get interface descr for # of leases +$no_leases_displayed = true; foreach ($leases as $data): if ($data['act'] != $active_string && $data['act'] != $static_string && $_GET['all'] != 1) { continue; } + $no_leases_displayed = false; + if ($data['act'] == $active_string) { /* Active DHCP Lease */ $icon = 'fa-check-circle-o'; @@ -422,6 +441,14 @@ foreach ($leases as $data): (<?=$mac_man[$mac_hi]?>) <?php endif; ?> </td> +<?php +/* only make CID column when we have one */ +if ($got_cid) { +?> + <td><?=$data['cid']?></td> +<?php +} +?> <td><?=$data['hostname']?></td> <td><?=$data['descr']?></td> <? if ($data['type'] != "static"): ?> @@ -450,6 +477,12 @@ foreach ($leases as $data): </td> </tr> <?php endforeach; ?> +<?php if ($no_leases_displayed): ?> + <tr> + <td></td> + <td><?=gettext("No leases to display")?></td> + </tr> +<?php endif; ?> </tbody> </table> </div> @@ -469,6 +502,7 @@ foreach ($leases as $data): </thead> <tbody> <?php +if (count($dhcp_leases_subnet_counter)) { ksort($dhcp_leases_subnet_counter); foreach ($dhcp_leases_subnet_counter as $listcounters): ?> @@ -478,7 +512,16 @@ foreach ($leases as $data): <td><?=$listcounters['to']?></td> <td><?=$listcounters['count']?></td> </tr> -<?php endforeach; ?> +<?php + endforeach; +} else { +?> + <tr> + <td><?=gettext("No leases are in use")?></td> + </tr> +<?php + } +?> </tbody> </table> </div> |