From b3d268b0a9e394dcc1d43a9c35469c010e21bbef Mon Sep 17 00:00:00 2001 From: Flavio Garcia Date: Thu, 11 Dec 2008 13:07:49 +0000 Subject: [PATCH] Adding get root url method. Refers #29. --- MyFuses.class.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/MyFuses.class.php b/MyFuses.class.php index 954c21d..d8147c6 100755 --- a/MyFuses.class.php +++ b/MyFuses.class.php @@ -855,6 +855,27 @@ public static function getSelfPath() { return $self; } + public static function getRootUrl() { + + $rootUrl = "http://" . $_SERVER[ 'HTTP_HOST' ]; + + if( substr( $rootUrl, -1 ) != "/" ) { + $rootUrl .= "/"; + } + + $scriptNameX = explode( "/", $_SERVER[ 'SCRIPT_NAME' ] ); + + $pos = ( count( $scriptNameX ) - 1 ); + + unset( $scriptNameX[ 0 ] ); + unset( $scriptNameX[ $pos ] ); + + $rootUrl = $rootUrl . implode( "/", $scriptNameX ) . "/"; + + return $rootUrl; + + } + public static function getSelf() { $self = "http://" . $_SERVER[ 'HTTP_HOST' ];