Store urls on router rather than in template
[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
@@ -147,13 +147,21 @@
 	/**
 	 * Get the base install url (without index)
 	 *
+	 * @param boolean $full true to return full url (include protocol and hostname)
 	 * @return string base url
 	 */
-	public static function BaseUrl()
+	public static function BaseUrl($full = false)
 	{
 		$baseurl = $_SERVER['SCRIPT_NAME'];
-		if (substr_compare($baseurl, '.php', -4) === 0)
+		if (substr_compare($baseurl, 'index.php', -9) === 0)
 			$baseurl = dirname($baseurl);
+		if ($full) {
+			$baseurl = $_SERVER['HTTP_HOST'] . $baseurl;
+			if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))
+				$baseurl = 'https://' . $baseurl;
+			else
+				$baserul = 'http://' . $baseurl;
+		}
 		return rtrim($baseurl, "/");
 	}
 

comments