From 7cf3e98090a3e9f0a9cc960d07c5f259adab6a19 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Thu, 14 Nov 2013 08:39:08 -0500
Subject: [PATCH] Merge remote-tracking branch 'origin/stable-3.0.5'

---
 interface/lib/classes/functions.inc.php |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php
index 5b98c20..0028b39 100644
--- a/interface/lib/classes/functions.inc.php
+++ b/interface/lib/classes/functions.inc.php
@@ -83,6 +83,20 @@
 		return number_format((double)$number, $number_format_decimals, $number_format_dec_point, $number_format_thousands_sep);
 	}
 	
+	//* convert currency formatted number back to floating number
+	public function currency_unformat($number) {
+		global $app;
+        
+		$number_format_dec_point = $app->lng('number_format_dec_point');
+		$number_format_thousands_sep = $app->lng('number_format_thousands_sep');
+		if($number_format_thousands_sep == 'number_format_thousands_sep') $number_format_thousands_sep = '';
+		
+		if($number_format_thousands_sep != '') $number = str_replace($number_format_thousands_sep, '', $number);
+		if($number_format_dec_point != '.' && $number_format_dec_point != '') $number = str_replace($number_format_dec_point, '.', $number);
+		
+		return (double)$number;
+	}
+	
 	public function get_ispconfig_url() {
 		global $app;
 		
@@ -177,12 +191,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");
@@ -257,7 +283,7 @@
 	
 			foreach($ips as $ip){
 				$result_array['cdata'][] = array(	'title' => $ip,
-													'description' => $type,
+													'description' => $type.($server_by_ip[$ip] != ''? ' &gt; '.$server_by_ip[$ip] : ''),
 													'onclick' => '',
 													'fill_text' => $ip
 												);

--
Gitblit v1.9.1