From d35b34d03ffe0d92cbaeb4410c913550150fab4e Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Mon, 04 May 2015 13:56:31 -0400
Subject: [PATCH] - prepared layout change for login page

---
 server/lib/classes/functions.inc.php |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/server/lib/classes/functions.inc.php b/server/lib/classes/functions.inc.php
index a4b217a..5632a58 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;
 
@@ -225,7 +237,7 @@
 		}
 
 		$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'];

--
Gitblit v1.9.1