]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use separate function to make absolute urls
authorBart Visscher <bartv@thisnet.nl>
Thu, 16 Feb 2012 18:45:00 +0000 (19:45 +0100)
committerBart Visscher <bartv@thisnet.nl>
Fri, 17 Feb 2012 21:07:14 +0000 (22:07 +0100)
16 files changed:
apps/bookmarks/templates/settings.php
apps/calendar/templates/calendar.php
apps/calendar/templates/settings.php
apps/contacts/templates/index.php
apps/contacts/templates/part.contactphoto.php
apps/contacts/templates/part.cropphoto.php
apps/contacts/templates/settings.php
apps/media/lib_ampache.php
apps/media/templates/settings.php
apps/user_openid/appinfo/app.php
apps/user_openid/user.php
core/lostpassword/index.php
index.php
lib/helper.php
lib/util.php
settings/templates/personal.php

index 97b6b256c09cc13cb4af7e03d4ece5320cd5c146..a985ee9d61b0b8e2d811372bfd3ca60b6dd22ad9 100644 (file)
@@ -8,7 +8,7 @@
 ?>
 <form id="bookmarks">
                <fieldset class="personalblock">
-                       <span class="bold"><?php echo $l->t('Bookmarklet:');?></span>&nbsp;<a class="bookmarks_addBml" href="javascript:(function(){url=encodeURIComponent(location.href);window.open('<?php echo OC_Helper::linkTo('bookmarks', 'addBm.php', null, true); ?>?url='+url, 'owncloud-bookmarks') })()"><?php echo $l->t('Add page to ownCloud'); ?></a>
+                       <span class="bold"><?php echo $l->t('Bookmarklet:');?></span>&nbsp;<a class="bookmarks_addBml" href="javascript:(function(){url=encodeURIComponent(location.href);window.open('<?php echo OC_Helper::linkToAbsolute('bookmarks', 'addBm.php'); ?>?url='+url, 'owncloud-bookmarks') })()"><?php echo $l->t('Add page to ownCloud'); ?></a>
                        <br/><em><?php echo $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?></em><br />
                </fieldset>
 </form>
index 2d5cdea4d740647f0fa1348b595e5b276edb645f..eb82d0d02ada02bec9eee382505a653c90e8c057 100755 (executable)
@@ -18,7 +18,7 @@
                                var missing_field_totime = '<?php echo addslashes($l->t('To Time')) ?>';
                                var missing_field_startsbeforeends = '<?php echo addslashes($l->t('The event ends before it starts')) ?>';
                                var missing_field_dberror = '<?php echo addslashes($l->t('There was a database fail')) ?>';
-                               var totalurl = '<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?>/calendars';
+                               var totalurl = '<?php echo OC_Helper::linkToAbsolute('calendar', 'caldav.php'); ?>/calendars';
                                $(document).ready(function() {
                                <?php
                                if(array_key_exists('showevent', $_)){
index e174378d02dffae696cd2412a62b42ce429bd291..979634874e4cdf9a0339aafb4ad9e3ce81332f95 100644 (file)
@@ -40,6 +40,6 @@
         </table>
 
         <?php echo $l->t('Calendar CalDAV syncing address:');?>
-        <?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br />
+        <?php echo OC_Helper::linkToAbsolute('calendar', 'caldav.php'); ?><br />
         </fieldset>
 </form>
index 4c0dfad617710ff827f6c651eadfa4c8242f7eb5..e81597f23d6df00680360e38b9c6b78d8b625173 100644 (file)
@@ -1,5 +1,5 @@
 <script type='text/javascript'>
-       var totalurl = '<?php echo OC_Helper::linkTo('contacts', 'carddav.php', null, true); ?>/addressbooks';
+       var totalurl = '<?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks';
 </script>
 <div id="controls">
        <form>
index 7d7ab2375617e78407afe003da2bf25004155e6e..9e3f5876cd14a197e5ee267205ae57fc63792423 100644 (file)
@@ -3,7 +3,7 @@ $id = $_['id'];
 $wattr = isset($_['width'])?'width="'.$_['width'].'"':'';
 $hattr = isset($_['height'])?'height="'.$_['height'].'"':'';
 ?>
-<img class="loading" id="contacts_details_photo" <?php echo $wattr; ?> <?php echo $hattr; ?> src="<?php echo OC_Helper::linkTo('contacts', 'photo.php', null, true); ?>?id=<?php echo $id; ?>&amp;refresh=<?php echo rand(); ?>" />
+<img class="loading" id="contacts_details_photo" <?php echo $wattr; ?> <?php echo $hattr; ?> src="<?php echo OC_Helper::linkToAbsolute('contacts', 'photo.php'); ?>?id=<?php echo $id; ?>&amp;refresh=<?php echo rand(); ?>" />
 <progress id="contacts_details_photo_progress" style="display:none;" value="0" max="100">0 %</progress>
 
 
index cb416f0e415ad6fcbde71dbe4d4ca5faf8eea3b2..5faa4aa6ac6a2352f14de0e15a6b6f86adc2612a 100644 (file)
@@ -38,13 +38,13 @@ OC_Log::write('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.',
                return true;
        });*/
 </script>
-<img id="cropbox" src="<?php echo OC_Helper::linkTo('contacts', 'dynphoto.php', null, true); ?>?tmp_path=<?php echo urlencode($tmp_path); ?>" />
+<img id="cropbox" src="<?php echo OC_Helper::linkToAbsolute('contacts', 'dynphoto.php'); ?>?tmp_path=<?php echo urlencode($tmp_path); ?>" />
 <form id="cropform"
        class="coords"
        method="post"
        enctype="multipart/form-data"
        target="crop_target"
-       action="<?php echo OC_Helper::linkTo('contacts', 'ajax/savecrop.php', null, true); ?>">
+       action="<?php echo OC_Helper::linkToAbsolute('contacts', 'ajax/savecrop.php'); ?>">
 
        <input type="hidden" id="id" name="id" value="<?php echo $id; ?>" />
        <input type="hidden" id="tmp_path" name="tmp_path" value="<?php echo $tmp_path; ?>" />
index c647e44c25b8f6b3c51853ad15d924597edaa615..8673e4521d9dd03a9a6474ef4792683932427078 100644 (file)
@@ -2,6 +2,6 @@
        <fieldset class="personalblock">
                <strong><?php echo $l->t('Contacts'); ?></strong><br />
                <?php echo $l->t('CardDAV syncing address:'); ?>
-               <?php echo OC_Helper::linkTo('apps/contacts', 'carddav.php', null, true); ?><br />
+               <?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?><br />
        </fieldset>
 </form>
index 138b65d1fd7f628757c83e153896780a4de727cd..97c0930860726873503e8a9b71da6802616e5e27 100644 (file)
@@ -207,7 +207,7 @@ class OC_MEDIA_AMPACHE{
                echo("\t\t<title>$name</title>\n");
                echo("\t\t<artist id='$artist'>$artistName</artist>\n");
                echo("\t\t<album id='$album'>$albumName</album>\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>$url</url>\n");
                echo("\t\t<time>{$song['song_length']}</time>\n");
index ac813c208503a9c57b2d90918592a73915c3d539..2907c616cf6830269f4024a9858d522d584d1e1a 100644 (file)
@@ -2,6 +2,6 @@
        <fieldset class="personalblock">
                <strong>Media</strong><br />
                Ampache address: 
-               <?php echo OC_Helper::linkTo('apps/media', '', null, true); ?><br />
+               <?php echo OC_Helper::linkToAbsolute('media', ''); ?><br />
        </fieldset>
 </form>
index 912019a9700adbd5913d031d498c69caefeea13a..cbcbe5442210a5b46a612785ee1cd73b3479d020 100644 (file)
@@ -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');
 
index a267e0205079c1d8cd26df5c7a827a3995f19c6d..8fec713aa7120c75b65b9fe74a98e8a152945be4 100644 (file)
@@ -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';
 
index ede94dab2d7542de382d439b233681cf1317a77e..30caa2d23dafb71ec4cd3ee9a0029d06d33a5daf 100644 (file)
@@ -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();
index 9bd460be3530266525e10e6c30cf4ea0a1994acb..18ea3022bc5dcd7489eb14ce3b50e93ae746ad25 100644 (file)
--- 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();
 }
 
index 6d3df6d97e7108064e876aada412134269ad15d3..b1e6d053a1947b1a1f6345e7da7821bd73e63d8b 100644 (file)
@@ -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
index 43fb4413f04bc699fdbf5ae977dd1de22bf5a501..4ba04fff3e890af9dbb95aeb5a555af2377e020a 100644 (file)
@@ -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();
                }
        }
index 80d2cb0a86f61d77e6650dc7c6fb91ae6c449efc..57731d979d9c29ab25665211f76e2b4cd1c6908c 100644 (file)
@@ -41,7 +41,7 @@
 
 <p class="personalblock">
        <strong>WebDAV</strong>
-       <?php echo OC_Helper::linkTo('files', 'webdav.php', null, true); ?><br />
+       <?php echo OC_Helper::linkToAbsolute('files', 'webdav.php'); ?><br />
        <em><?php echo $l->t('use this address to connect to your ownCloud in your file manager');?></em>
 </p>