From a6bfa4ba238a7bd940dff8a46c95ad1e9db09dc8 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 5 Nov 2005 21:29:11 +0000 Subject: [PATCH] When displaying DHCP leases, call gethostbyaddr() to resolve the hostname if we do not have the record in the database Also check to make sure gethostbyaddr() would return a real value Ticket 7390 --- usr/local/www/diag_dhcp_leases.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/usr/local/www/diag_dhcp_leases.php b/usr/local/www/diag_dhcp_leases.php index 2db2d75128..474f453f8a 100755 --- a/usr/local/www/diag_dhcp_leases.php +++ b/usr/local/www/diag_dhcp_leases.php @@ -115,8 +115,14 @@ while ($data = array_shift($return)) { } if ($data[0] == "client-hostname") { $d = array_shift($return); - $leases[$i]['hostname'] = $d[0]; - } + if($d[0] <> "") { + $leases[$i]['hostname'] = $d[0]; + } else { + if(gethostbyaddr($leases[$i]['ip']) <> "") { + $leases[$i]['hostname'] = gethostbyaddr($leases[$i]['ip']); + } + } + } if ($data[0] == "hardware") { $d = array_shift($return); if ($d[0] == "ethernet") {