Skip to content
Snippets Groups Projects
Commit 391e05cb authored by Falko Timme's avatar Falko Timme
Browse files

- Display hostname next to IP (where available) in the jQuery IP suggestion box.

parent 3327ed19
No related branches found
No related tags found
No related merge requests found
...@@ -237,12 +237,24 @@ class functions { ...@@ -237,12 +237,24 @@ class functions {
// IPv6 // 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"; $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(); $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)){ if(!empty($results) && is_array($results)){
foreach($results as $result){ 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"); $results = $app->db->queryAllRecords("SELECT ip_address AS ip FROM openvz_ip");
...@@ -317,7 +329,7 @@ class functions { ...@@ -317,7 +329,7 @@ class functions {
foreach($ips as $ip){ foreach($ips as $ip){
$result_array['cdata'][] = array( 'title' => $ip, $result_array['cdata'][] = array( 'title' => $ip,
'description' => $type, 'description' => $type.($server_by_ip[$ip] != ''? ' > '.$server_by_ip[$ip] : ''),
'onclick' => '', 'onclick' => '',
'fill_text' => $ip 'fill_text' => $ip
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment