From 391e05cbee6ff84bce60b665be60b4e5f049ee7f Mon Sep 17 00:00:00 2001 From: Falko Timme <ft@falkotimme.com> Date: Tue, 22 Oct 2013 18:48:51 +0200 Subject: [PATCH] - Display hostname next to IP (where available) in the jQuery IP suggestion box. --- interface/lib/classes/functions.inc.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index f7088347ed..64074d4b46 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -237,12 +237,24 @@ class functions { // IPv6 $regex = "/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i"; } + + $server_by_id = array(); + $server_by_ip = array(); + $servers = $app->db->queryAllRecords("SELECT * FROM server"); + if(is_array($servers) && !empty($servers)){ + foreach($servers as $server){ + $server_by_id[$server['server_id']] = $server['server_name']; + } + } $ips = array(); - $results = $app->db->queryAllRecords("SELECT ip_address AS ip FROM server_ip WHERE ip_type = '".$type."'"); + $results = $app->db->queryAllRecords("SELECT ip_address AS ip, server_id FROM server_ip WHERE ip_type = '".$type."'"); if(!empty($results) && is_array($results)){ foreach($results as $result){ - if(preg_match($regex, $result['ip'])) $ips[] = $result['ip']; + if(preg_match($regex, $result['ip'])){ + $ips[] = $result['ip']; + $server_by_ip[$result['ip']] = $server_by_id[$result['server_id']]; + } } } $results = $app->db->queryAllRecords("SELECT ip_address AS ip FROM openvz_ip"); @@ -317,7 +329,7 @@ class functions { foreach($ips as $ip){ $result_array['cdata'][] = array( 'title' => $ip, - 'description' => $type, + 'description' => $type.($server_by_ip[$ip] != ''? ' > '.$server_by_ip[$ip] : ''), 'onclick' => '', 'fill_text' => $ip ); -- GitLab