Fix full url on http protocol
[gitphp.git] / include / Util.class.php
blob:a/include/Util.class.php -> blob:b/include/Util.class.php
--- a/include/Util.class.php
+++ b/include/Util.class.php
@@ -44,6 +44,11 @@
 		return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
 	}
 
+	public static function NullFile()
+	{
+		return self::IsWindows() ? 'NUL' : '/dev/null';
+	}
+
 	/**
 	 * Tests if this is a 64 bit machine
 	 *
@@ -63,10 +68,10 @@
 	public static function MakeSlug($str)
 	{
 		$from = array(
-			'/'
+			'/&'
 		);
 		$to = array(
-			'-'
+			'--'
 		);
 		return str_replace($from, $to, $str);
 	}
@@ -162,7 +167,31 @@
 			else
 				$baseurl = 'http://' . $baseurl;
 		}
+		if (GitPHP_Util::IsWindows())
+			$baseurl = rtrim($baseurl, "\\");
 		return rtrim($baseurl, "/");
+	}
+
+	/**
+	 * Tests whether a function is allowed to be called
+	 *
+	 * @param string $function functio name
+	 * @return true if allowed
+	 */
+	public static function FunctionAllowed($function)
+	{
+		if (empty($function))
+			return false;
+
+		$disabled = @ini_get('disable_functions');
+		if (!$disabled) {
+			// no disabled functions
+			// or ini_get is disabled so we can't reliably figure this out
+			return true;
+		}
+
+		$disabledlist = explode(', ', $disabled);
+		return !in_array($function, $disabledlist);
 	}
 
 }

comments