Falko Timme
2013-10-22 391e05cbee6ff84bce60b665be60b4e5f049ee7f
interface/lib/classes/functions.inc.php
@@ -129,11 +129,36 @@
      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;
      $url = (stristr($_SERVER['SERVER_PROTOCOL'],'HTTPS') || stristr($_SERVER['HTTPS'],'on'))?'https':'http';
      $url .= '://'.$_SERVER['SERVER_NAME'];
      if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
         $url .= ':'.$_SERVER['SERVER_PORT'];
      if($_SERVER['SERVER_NAME'] != '_') {
         $url .= '://'.$_SERVER['SERVER_NAME'];
         if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
            $url .= ':'.$_SERVER['SERVER_PORT'];
         }
      } else {
         $app->uses("getconf");
         $server_config = $app->getconf->get_server_config(1,'server');
         $url .= '://'.$server_config['hostname'];
         if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
            $url .= ':'.$_SERVER['SERVER_PORT'];
         }
      }
      return $url;
   }
@@ -212,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");
@@ -292,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
                                    );