From 90bc298b9c8a5470df23a184ae1c2ddbd6573b8a Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 15 Dec 2016 18:27:49 +0100 Subject: [PATCH] Implemented function resolveIPs(&$array) --- data.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/data.php b/data.php index b23b16ee..6ca94845 100644 --- a/data.php +++ b/data.php @@ -92,6 +92,23 @@ return $queryTypes; } + function resolveIPs(&$array) { + foreach ($array as $key => $value) + { + $hostname = gethostbyaddr($key); + // If we found a hostname for the IP, replace it + if($hostname) + { + // Generate HOST entry + $array[$hostname] = $array[$key]; + // Remove IP entry + unset($array[$key]); + } + } + // Have to repeat the sorting, since we changed the keys + arsort($array); + } + function getForwardDestinations() { global $log; $forwards = getForwards($log); @@ -151,20 +168,7 @@ if(istrue($setupVars["API_GET_CLIENT_HOSTNAME"])) { - foreach ($sources as $key => $value) - { - $hostname = gethostbyaddr($key); - // If we found a hostname for the IP, replace it - if($hostname) - { - // Generate HOST entry - $sources[$hostname] = $sources[$key]; - // Remove IP entry - unset($sources[$key]); - } - } - // Have to repeat the sorting, since we changed the keys - arsort($sources); + resolveIPs($sources); } return Array(