diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-02-16 19:45:00 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-02-17 22:07:14 +0100 |
commit | f47444e1f776912cbf141ec9cc3763110f4e3552 (patch) | |
tree | e50acafa0fc13b943aafc7b8f424cab142236363 /lib | |
parent | 5f3c54922773068091dfe8b40e3b407512ef4cfe (diff) | |
download | nextcloud-server-f47444e1f776912cbf141ec9cc3763110f4e3552.tar.gz nextcloud-server-f47444e1f776912cbf141ec9cc3763110f4e3552.zip |
Use separate function to make absolute urls
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helper.php | 23 | ||||
-rw-r--r-- | lib/util.php | 6 |
2 files changed, 20 insertions, 9 deletions
diff --git a/lib/helper.php b/lib/helper.php index 6d3df6d97e7..b1e6d053a19 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -54,12 +54,6 @@ class OC_Helper { } } - if($absolute){ - // Checking if the request was made through HTTPS. The last in line is for IIS - $protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off'); - $urlLinkTo = ($protocol?'https':'http') . '://' . $_SERVER['HTTP_HOST'] . $urlLinkTo; - } - if($redirect_url) return $urlLinkTo.'?redirect_url='.urlencode($_SERVER["REQUEST_URI"]); else @@ -68,6 +62,23 @@ class OC_Helper { } /** + * @brief Creates an absolute url + * @param $app app + * @param $file file + * @param $redirect_url redirect_url variable is appended to the URL + * @returns the url + * + * Returns a absolute url to the given app and file. + */ + public static function linkToAbsolute( $app, $file, $redirect_url=NULL ) { + $urlLinkTo = self::linkTo( $app, $file, $redirect_url ); + // Checking if the request was made through HTTPS. The last in line is for IIS + $protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off'); + $urlLinkTo = ($protocol?'https':'http') . '://' . $_SERVER['HTTP_HOST'] . $urlLinkTo; + return $urlLinkTo; + } + + /** * @brief Creates path to an image * @param $app app * @param $image image name diff --git a/lib/util.php b/lib/util.php index 43fb4413f04..4ba04fff3e8 100644 --- a/lib/util.php +++ b/lib/util.php @@ -248,7 +248,7 @@ class OC_Util { */ public static function checkAppEnabled($app){ if( !OC_App::isEnabled($app)){ - header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } } @@ -259,7 +259,7 @@ class OC_Util { public static function checkLoggedIn(){ // Check if we are a user if( !OC_User::isLoggedIn()){ - header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } } @@ -271,7 +271,7 @@ class OC_Util { // Check if we are a user self::checkLoggedIn(); if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){ - header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } } |