From: Bart Visscher Date: Thu, 16 Feb 2012 18:45:00 +0000 (+0100) Subject: Use separate function to make absolute urls X-Git-Tag: v4.0.0beta~201^2~51 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f47444e1f776912cbf141ec9cc3763110f4e3552;p=nextcloud-server.git Use separate function to make absolute urls --- diff --git a/apps/bookmarks/templates/settings.php b/apps/bookmarks/templates/settings.php index 97b6b256c09..a985ee9d61b 100644 --- a/apps/bookmarks/templates/settings.php +++ b/apps/bookmarks/templates/settings.php @@ -8,7 +8,7 @@ ?>
- t('Bookmarklet:');?> t('Add page to ownCloud'); ?> + t('Bookmarklet:');?> t('Add page to ownCloud'); ?>
t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?>
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 2d5cdea4d74..eb82d0d02ad 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -18,7 +18,7 @@ var missing_field_totime = 't('To Time')) ?>'; var missing_field_startsbeforeends = 't('The event ends before it starts')) ?>'; var missing_field_dberror = 't('There was a database fail')) ?>'; - var totalurl = '/calendars'; + var totalurl = '/calendars'; $(document).ready(function() { t('Calendar CalDAV syncing address:');?> -
+
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index 4c0dfad6177..e81597f23d6 100644 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -1,5 +1,5 @@
diff --git a/apps/contacts/templates/part.contactphoto.php b/apps/contacts/templates/part.contactphoto.php index 7d7ab237561..9e3f5876cd1 100644 --- a/apps/contacts/templates/part.contactphoto.php +++ b/apps/contacts/templates/part.contactphoto.php @@ -3,7 +3,7 @@ $id = $_['id']; $wattr = isset($_['width'])?'width="'.$_['width'].'"':''; $hattr = isset($_['height'])?'height="'.$_['height'].'"':''; ?> - src="?id=&refresh=" /> + src="?id=&refresh=" /> diff --git a/apps/contacts/templates/part.cropphoto.php b/apps/contacts/templates/part.cropphoto.php index cb416f0e415..5faa4aa6ac6 100644 --- a/apps/contacts/templates/part.cropphoto.php +++ b/apps/contacts/templates/part.cropphoto.php @@ -38,13 +38,13 @@ OC_Log::write('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.', return true; });*/ - + + action=""> diff --git a/apps/contacts/templates/settings.php b/apps/contacts/templates/settings.php index c647e44c25b..8673e4521d9 100644 --- a/apps/contacts/templates/settings.php +++ b/apps/contacts/templates/settings.php @@ -2,6 +2,6 @@
t('Contacts'); ?>
t('CardDAV syncing address:'); ?> -
+
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index 138b65d1fd7..97c09308607 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -207,7 +207,7 @@ class OC_MEDIA_AMPACHE{ echo("\t\t$name\n"); echo("\t\t$artistName\n"); echo("\t\t$albumName\n"); - $url=OC_Helper::linkTo('media', 'server/xml.server.php', null, true)."?action=play&song=$id&auth={$_GET['auth']}"; + $url=OC_Helper::linkToAbsolute('media', 'server/xml.server.php')."?action=play&song=$id&auth={$_GET['auth']}"; $url=self::fixXmlString($url); echo("\t\t$url\n"); echo("\t\t\n"); diff --git a/apps/media/templates/settings.php b/apps/media/templates/settings.php index ac813c20850..2907c616cf6 100644 --- a/apps/media/templates/settings.php +++ b/apps/media/templates/settings.php @@ -2,6 +2,6 @@
Media
Ampache address: -
+
diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php index 912019a9700..cbcbe544221 100644 --- a/apps/user_openid/appinfo/app.php +++ b/apps/user_openid/appinfo/app.php @@ -14,8 +14,8 @@ if(strpos($_SERVER["REQUEST_URI"],'?') and !strpos($_SERVER["REQUEST_URI"],'=')) } } -OC_Util::addHeader('link',array('rel'=>'openid.server', 'href'=>OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$userName)); -OC_Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$userName)); +OC_Util::addHeader('link',array('rel'=>'openid.server', 'href'=>OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName)); +OC_Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName)); OC_APP::registerPersonal('user_openid','settings'); diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php index a267e020507..8fec713aa71 100644 --- a/apps/user_openid/user.php +++ b/apps/user_openid/user.php @@ -43,7 +43,7 @@ if(!OC_User::userExists($USERNAME)){ OC_Log::write('user_openid',$USERNAME.' doesn\'t exist',OC_Log::WARN); $USERNAME=''; } -$IDENTITY=OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$USERNAME; +$IDENTITY=OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$USERNAME; require_once 'phpmyid.php'; diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php index ede94dab2d7..30caa2d23da 100644 --- a/core/lostpassword/index.php +++ b/core/lostpassword/index.php @@ -16,7 +16,7 @@ if (isset($_POST['user'])) { OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token); $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', ''); if (!empty($email)) { - $link = OC_Helper::linkTo('core/lostpassword', 'resetpassword.php', null, true).'?user='.$_POST['user'].'&token='.$token; + $link = OC_Helper::linkToAbsolute('core/lostpassword', 'resetpassword.php').'?user='.$_POST['user'].'&token='.$token; $tmpl = new OC_Template('core/lostpassword', 'email'); $tmpl->assign('link', $link); $msg = $tmpl->fetchPage(); diff --git a/index.php b/index.php index 9bd460be353..18ea3022bc5 100644 --- a/index.php +++ b/index.php @@ -44,7 +44,7 @@ if($not_installed) { // Handle WebDAV if($_SERVER['REQUEST_METHOD']=='PROPFIND'){ - header('location: '.OC_Helper::linkTo('files','webdav.php')); + header('location: '.OC_Helper::linkToAbsolute('files','webdav.php')); exit(); } 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 @@ -67,6 +61,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 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(); } } diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 80d2cb0a86f..57731d979d9 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -41,7 +41,7 @@

WebDAV -
+
t('use this address to connect to your ownCloud in your file manager');?>