Factor out base url into a common function
[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
@@ -144,5 +144,18 @@
 		return $files;
 	}
 
+	/**
+	 * Get the base install url (without index)
+	 *
+	 * @return string base url
+	 */
+	public static function BaseUrl()
+	{
+		$baseurl = $_SERVER['SCRIPT_NAME'];
+		if (substr_compare($baseurl, '.php', -4) === 0)
+			$baseurl = dirname($baseurl);
+		return rtrim($baseurl, "/");
+	}
+
 }
 

comments