| | |
| | | return number_format((double)$number, $number_format_decimals, $number_format_dec_point, $number_format_thousands_sep); |
| | | } |
| | | |
| | | /** |
| | | * Function to change bytes to kB, MB, GB or TB |
| | | * @param int $size - size in bytes |
| | | * @param int precicion - after-comma-numbers (default: 2) |
| | | * @return string - formated bytes |
| | | */ |
| | | public function formatBytes($size, $precision = 2) { |
| | | $base=log($size)/log(1024); |
| | | $suffixes=array('', ' kB', ' MB', ' GB', ' TB'); |
| | | return round(pow(1024, $base-floor($base)), $precision).$suffixes[floor($base)]; |
| | | } |
| | | |
| | | public function get_ispconfig_url() { |
| | | global $app; |
| | | |
| | |
| | | global $app; |
| | | |
| | | if($type == 'IPv4'){ |
| | | $regex = "/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/"; |
| | | // $regex = "/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/"; |
| | | $regex = "/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"; |
| | | } else { |
| | | // 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"; |
| | | } |
| | | |
| | | $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 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($encode == true) { |
| | | if(function_exists('idn_to_ascii')) { |
| | | $domain = idn_to_ascii($domain); |
| | | $domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); |
| | | } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { |
| | | /* use idna class: |
| | | * @author Matthias Sommerfeld <mso@phlylabs.de> |
| | |
| | | } |
| | | } else { |
| | | if(function_exists('idn_to_utf8')) { |
| | | $domain = idn_to_utf8($domain); |
| | | $domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); |
| | | } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { |
| | | /* use idna class: |
| | | * @author Matthias Sommerfeld <mso@phlylabs.de> |