Falko Timme
2013-10-22 391e05cbee6ff84bce60b665be60b4e5f049ee7f
- Display hostname next to IP (where available) in the jQuery IP suggestion box.
1 files modified
18 ■■■■ changed files
interface/lib/classes/functions.inc.php 18 ●●●● patch | view | raw | blame | history
interface/lib/classes/functions.inc.php
@@ -237,12 +237,24 @@
            // 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 @@
    
            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
                                                );