From cab7ea5faaa2f3510c8488e7d19d083fc05ac6ca Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Wed, 18 Sep 2013 04:17:27 -0400
Subject: [PATCH] - Fixed missing global $app in new _decode function

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

diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php
index 0801c1c..661e557 100644
--- a/interface/lib/classes/functions.inc.php
+++ b/interface/lib/classes/functions.inc.php
@@ -130,10 +130,21 @@
 	}
 	
 	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;
 	}
@@ -303,7 +314,7 @@
 	}
 
     public function intval($string, $force_numeric = false) {
-        if(intval($string) == 2147483647) {
+        if(intval($string) == 2147483647 || ($string > 0 && intval($string) < 0)) {
             if($force_numeric == true) return floatval($string);
             elseif(preg_match('/^([-]?)[0]*([1-9][0-9]*)([^0-9].*)*$/', $string, $match)) return $match[1].$match[2];
             else return 0;
@@ -311,7 +322,13 @@
             return intval($string);
         }
     }
-    
+
+    public function formatBytes($size, $precision = 2) {
+        $base=log($size)/log(1024);
+        $suffixes=array('','k','M','G','T');
+        return round(pow(1024,$base-floor($base)),$precision).$suffixes[floor($base)];
+    }
+
     /** IDN converter wrapper.
      * all converter classes should be placed in ISPC_CLASS_PATH.'/idn/'
      */
@@ -384,4 +401,4 @@
 		
 }
 
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1