From 5ca959fa688255a8de61f89fe2751eb4d24a6912 Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Tue, 22 Mar 2016 09:22:07 -0400
Subject: [PATCH] fixed typo

---
 server/lib/classes/functions.inc.php |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/server/lib/classes/functions.inc.php b/server/lib/classes/functions.inc.php
index a4b217a..6a46d5e 100644
--- a/server/lib/classes/functions.inc.php
+++ b/server/lib/classes/functions.inc.php
@@ -129,6 +129,18 @@
 		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;
 
@@ -218,14 +230,15 @@
 		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'];
@@ -341,7 +354,7 @@
 
 		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>
@@ -358,7 +371,7 @@
 			}
 		} 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>

--
Gitblit v1.9.1