]> git.mxchange.org Git - friendica.git/commitdiff
Renamed System::redirect() to $a->redirect()
authorPhilipp Holzer <admin@philipp.info>
Sat, 13 Oct 2018 18:02:04 +0000 (20:02 +0200)
committerPhilipp Holzer <admin@philipp.info>
Mon, 22 Oct 2018 20:13:22 +0000 (22:13 +0200)
62 files changed:
boot.php
include/api.php
include/items.php
mod/admin.php
mod/api.php
mod/cal.php
mod/delegate.php
mod/dfrn_confirm.php
mod/dfrn_poll.php
mod/dfrn_request.php
mod/display.php
mod/events.php
mod/filerm.php
mod/follow.php
mod/group.php
mod/home.php
mod/ignored.php
mod/item.php
mod/like.php
mod/lostpass.php
mod/manage.php
mod/message.php
mod/network.php
mod/nogroup.php
mod/notice.php
mod/notifications.php
mod/notify.php
mod/openid.php
mod/ostatus_subscribe.php
mod/photos.php
mod/profile.php
mod/profile_photo.php
mod/profiles.php
mod/randprof.php
mod/redir.php
mod/register.php
mod/regmod.php
mod/removeme.php
mod/repair_ostatus.php
mod/settings.php
mod/starred.php
mod/tagrm.php
mod/toggle_mobile.php
mod/unfollow.php
mod/videos.php
mod/wallmessage.php
src/App.php
src/BaseModule.php
src/Core/System.php
src/Core/UserImport.php
src/Model/Contact.php
src/Model/Profile.php
src/Model/User.php
src/Module/Acctlink.php
src/Module/Contact.php
src/Module/Login.php
src/Module/Logout.php
src/Module/Magic.php
src/Module/Objects.php
src/Module/Tos.php
src/Protocol/DFRN.php
tests/ApiTest.php

index d55f4b7bc979f23bda425417172f329b50949c1b..91f62c4b4fb32731e84ecb266414c90bc6e2f0ad 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -598,21 +598,6 @@ function killme()
        exit();
 }
 
-/**
- * @brief Redirect to another URL and terminate this process.
- */
-function goaway($path = '')
-{
-       if (strstr(normalise_link($path), 'http://')) {
-               $url = $path;
-       } else {
-               $url = System::baseUrl() . '/' . ltrim($path, '/');
-       }
-
-       header("Location: $url");
-       killme();
-}
-
 /**
  * @brief Returns the user id of locally logged in user or false.
  *
index a2c7f072017c80fe046592cbe34bd284fe5af10a..c746ff0b61320aa2e30a05c91f262ee77b059fe7 100644 (file)
@@ -4809,7 +4809,9 @@ function api_friendica_remoteauth()
 
        logger($contact['name'] . ' ' . $sec, LOGGER_DEBUG);
        $dest = ($url ? '&destination_url=' . $url : '');
-       goaway(
+
+       $app = get_app();
+       $app->redirect(
                $contact['poll'] . '?dfrn_id=' . $dfrn_id
                . '&dfrn_version=' . DFRN_PROTOCOL_VERSION
                . '&type=profile&sec=' . $sec . $dest
index 27a7db767b4d16c6ee8a8a8a57abc02507524a27..0847dd65b6ce77698081ac8a27ad7f0ea926d418 100644 (file)
@@ -354,7 +354,7 @@ function drop_item($id)
 
        if (!DBA::isResult($item)) {
                notice(L10n::t('Item not found.') . EOL);
-               goaway('/network');
+               $a->redirect('network');
        }
 
        if ($item['deleted']) {
@@ -401,17 +401,17 @@ function drop_item($id)
                }
                // Now check how the user responded to the confirmation query
                if (!empty($_REQUEST['canceled'])) {
-                       goaway('/display/' . $item['guid']);
+                       $a->redirect('display/' . $item['guid']);
                }
 
                // delete the item
                Item::deleteForUser(['id' => $item['id']], local_user());
 
-               goaway('/network');
+               $a->redirect('network');
                //NOTREACHED
        } else {
                notice(L10n::t('Permission denied.') . EOL);
-               goaway('/display/' . $item['guid']);
+               $a->redirect('display/' . $item['guid']);
                //NOTREACHED
        }
 }
index 2714b0b86450e98d545a23e397f51f781a9b3208..fb4c923209035424721e0448a6e21c7cb727c26b 100644 (file)
@@ -82,7 +82,7 @@ function admin_post(App $a)
                                        if ($a->isAjax()) {
                                                return;
                                        }
-                                       goaway('admin/');
+                                       $a->redirect('admin/');
                                        return;
                                }
 
@@ -135,7 +135,7 @@ function admin_post(App $a)
                }
        }
 
-       goaway($return_path);
+       $a->redirect($return_path);
        return; // NOTREACHED
 }
 
@@ -340,7 +340,7 @@ function admin_page_tos_post(App $a)
        Config::set('system', 'tosprivstatement', $displayprivstatement);
        Config::set('system', 'tostext', $tostext);
 
-       goaway('admin/tos');
+       $a->redirect('admin/tos');
 
        return; // NOTREACHED
 }
@@ -429,7 +429,7 @@ function admin_page_blocklist_post(App $a)
                Config::set('system', 'blocklist', $blocklist);
                info(L10n::t('Site blocklist updated.') . EOL);
        }
-       goaway('admin/blocklist');
+       $a->redirect('admin/blocklist');
 
        return; // NOTREACHED
 }
@@ -461,7 +461,7 @@ function admin_page_contactblock_post(App $a)
                }
                notice(L10n::tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));
        }
-       goaway('admin/contactblock');
+       $a->redirect('admin/contactblock');
        return; // NOTREACHED
 }
 
@@ -569,7 +569,7 @@ function admin_page_deleteitem_post(App $a)
        }
 
        info(L10n::t('Item marked for deletion.') . EOL);
-       goaway('admin/deleteitem');
+       $a->redirect('admin/deleteitem');
        return; // NOTREACHED
 }
 
@@ -965,7 +965,7 @@ function admin_page_site_post(App $a)
                $parsed = @parse_url($new_url);
                if (!is_array($parsed) || !x($parsed, 'host') || !x($parsed, 'scheme')) {
                        notice(L10n::t("Can not parse base url. Must have at least <scheme>://<domain>"));
-                       goaway('admin/site');
+                       $a->redirect('admin/site');
                }
 
                /* steps:
@@ -995,7 +995,7 @@ function admin_page_site_post(App $a)
 
                        if (!DBA::isResult($r)) {
                                notice("Failed updating '$table_name': " . DBA::errorMessage());
-                               goaway('admin/site');
+                               $a->redirect('admin/site');
                        }
                }
                // update tables
@@ -1024,7 +1024,7 @@ function admin_page_site_post(App $a)
 
                info("Relocation started. Could take a while to complete.");
 
-               goaway('admin/site');
+               $a->redirect('admin/site');
        }
        // end relocate
 
@@ -1298,7 +1298,7 @@ function admin_page_site_post(App $a)
        Config::set('system', 'rino_encrypt', $rino);
 
        info(L10n::t('Site settings updated.') . EOL);
-       goaway('admin/site');
+       $a->redirect('admin/site');
        return; // NOTREACHED
 }
 
@@ -1570,7 +1570,7 @@ function admin_page_dbsync(App $a)
                        Config::set('system', 'build', intval($curr) + 1);
                }
                info(L10n::t('Update has been marked successful') . EOL);
-               goaway('admin/dbsync');
+               $a->redirect('admin/dbsync');
        }
 
        if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
@@ -1745,7 +1745,7 @@ function admin_page_users_post(App $a)
                        user_deny($hash);
                }
        }
-       goaway('admin/users');
+       $a->redirect('admin/users');
        return; // NOTREACHED
 }
 
@@ -1768,7 +1768,7 @@ function admin_page_users(App $a)
                $user = DBA::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
                if (!DBA::isResult($user)) {
                        notice('User not found' . EOL);
-                       goaway('admin/users');
+                       $a->redirect('admin/users');
                        return ''; // NOTREACHED
                }
                switch ($a->argv[2]) {
@@ -1788,7 +1788,7 @@ function admin_page_users(App $a)
                                notice(sprintf(($user['blocked'] ? L10n::t("User '%s' unblocked") : L10n::t("User '%s' blocked")), $user['username']) . EOL);
                                break;
                }
-               goaway('admin/users');
+               $a->redirect('admin/users');
                return ''; // NOTREACHED
        }
 
@@ -1986,7 +1986,7 @@ function admin_page_addons(App $a)
                                info(L10n::t("Addon %s enabled.", $addon));
                        }
                        Config::set("system", "addon", implode(", ", $a->addons));
-                       goaway('admin/addons');
+                       $a->redirect('admin/addons');
                        return ''; // NOTREACHED
                }
 
@@ -2020,7 +2020,7 @@ function admin_page_addons(App $a)
                        '$page' => L10n::t('Addons'),
                        '$toggle' => L10n::t('Toggle'),
                        '$settings' => L10n::t('Settings'),
-                       '$baseurl' => System::baseUrl(true),
+                       '$baseurl' => $a->getBaseURL(true),
 
                        '$addon' => $addon,
                        '$status' => $status,
@@ -2042,10 +2042,10 @@ function admin_page_addons(App $a)
         * List addons
         */
        if (x($_GET, "a") && $_GET['a'] == "r") {
-               BaseModule::checkFormSecurityTokenRedirectOnError(System::baseUrl() . '/admin/addons', 'admin_themes', 't');
+               BaseModule::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/addons', 'admin_themes', 't');
                Addon::reload();
                info("Addons reloaded");
-               goaway(System::baseUrl() . '/admin/addons');
+               $a->redirect('admin/addons');
        }
 
        $addons = [];
@@ -2235,7 +2235,7 @@ function admin_page_themes(App $a)
                        }
 
                        Config::set('system', 'allowed_themes', $s);
-                       goaway('admin/themes');
+                       $a->redirect('admin/themes');
                        return ''; // NOTREACHED
                }
 
@@ -2316,7 +2316,7 @@ function admin_page_themes(App $a)
                        }
                }
                info("Themes reloaded");
-               goaway(System::baseUrl() . '/admin/themes');
+               $a->redirect('admin/themes');
        }
 
        /*
@@ -2365,7 +2365,7 @@ function admin_page_logs_post(App $a)
        }
 
        info(L10n::t("Log settings updated."));
-       goaway('admin/logs');
+       $a->redirect('admin/logs');
        return; // NOTREACHED
 }
 
@@ -2513,7 +2513,7 @@ function admin_page_features_post(App $a)
                }
        }
 
-       goaway('admin/features');
+       $a->redirect('admin/features');
        return; // NOTREACHED
 }
 
index e978461655071c7774390b7d89dfe3d675ca0899..df921dfbc8a9c727af92e460525702af5ab37f93 100644 (file)
@@ -5,6 +5,7 @@
 use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Module\Login;
 
@@ -76,7 +77,7 @@ function api_content(App $a)
                                if (strstr($consumer->callback_url, $glue)) {
                                        $glue = "?";
                                }
-                               goaway($consumer->callback_url . $glue . "oauth_token=" . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . "&oauth_verifier=" . OAuthUtil::urlencode_rfc3986($verifier));
+                               $a->redirect($consumer->callback_url . $glue . 'oauth_token=' . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . '&oauth_verifier=' . OAuthUtil::urlencode_rfc3986($verifier));
                                killme();
                        }
 
index b55e078d83404981f34d2c19436946595e7d3cc8..b356a295cb530779472be4ff245a99c1bb68a874 100644 (file)
@@ -301,7 +301,7 @@ function cal_content(App $a)
                // Respect the export feature setting for all other /cal pages if it's not the own profile
                if ((local_user() !== intval($owner_uid)) && !Feature::isEnabled($owner_uid, "export_calendar")) {
                        notice(L10n::t('Permission denied.') . EOL);
-                       goaway('cal/' . $nick);
+                       $a->redirect('cal/' . $nick);
                }
 
                // Get the export data by uid
@@ -322,7 +322,7 @@ function cal_content(App $a)
                                $return_path = "cal/" . $nick;
                        }
 
-                       goaway($return_path);
+                       $a->redirect($return_path);
                }
 
                // If nothing went wrong we can echo the export content
index 2b29632dda00bc265800937b642c59406f6546b6..e525e1ab80d76a402356f96c582fa3de0292835d 100644 (file)
@@ -62,7 +62,7 @@ function delegate_content(App $a)
        if ($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
                // delegated admins can view but not change delegation permissions
                if (x($_SESSION, 'submanage')) {
-                       goaway(System::baseUrl() . '/delegate');
+                       $a->redirect('delegate');
                }
 
                $user_id = $a->argv[2];
@@ -77,17 +77,17 @@ function delegate_content(App $a)
                                DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
                        }
                }
-               goaway(System::baseUrl() . '/delegate');
+               $a->redirect('delegate');
        }
 
        if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
                // delegated admins can view but not change delegation permissions
                if (x($_SESSION, 'submanage')) {
-                       goaway(System::baseUrl() . '/delegate');
+                       $a->redirect('delegate');
                }
 
                DBA::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]);
-               goaway(System::baseUrl() . '/delegate');
+               $a->redirect('delegate');
        }
 
        // find everybody that currently has delegated management to this account/page
index 48ce3c6aa65684bfe6b47e7ba1794e8709327fb6..3345bca61193e713c1f999bc33b5b49f017a9056 100644 (file)
@@ -400,7 +400,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                // Let's send our user to the contact editor in case they want to
                // do anything special with this new friend.
                if ($handsfree === null) {
-                       goaway(System::baseUrl() . '/contact/' . intval($contact_id));
+                       $a->redirect('contact/' . intval($contact_id));
                } else {
                        return;
                }
@@ -620,6 +620,6 @@ function dfrn_confirm_post(App $a, $handsfree = null)
        }
 
        // somebody arrived here by mistake or they are fishing. Send them to the homepage.
-       goaway(System::baseUrl());
+       $a->redirect();
        // NOTREACHED
 }
index af597d76ff7a6c55d3be3b29a5fc77c5f9ee62fb..af6d000268422df5cc34660a6c7546fddd46c520 100644 (file)
@@ -90,7 +90,7 @@ function dfrn_poll_init(App $a)
                                $my_id = '0:' . $dfrn_id;
                                break;
                        default:
-                               goaway(System::baseUrl());
+                               $a->redirect();
                                break; // NOTREACHED
                }
 
@@ -136,9 +136,9 @@ function dfrn_poll_init(App $a)
                                }
                        }
                        $profile = $r[0]['nickname'];
-                       goaway((strlen($destination_url)) ? $destination_url : System::baseUrl() . '/profile/' . $profile);
+                       $a->redirect((strlen($destination_url)) ? $destination_url : 'profile/' . $profile);
                }
-               goaway(System::baseUrl());
+               $a->redirect();
        }
 
        if ($type === 'profile-check' && $dfrn_version < 2.2) {
@@ -325,7 +325,7 @@ function dfrn_poll_post(App $a)
                        $my_id = '0:' . $dfrn_id;
                        break;
                default:
-                       goaway(System::baseUrl());
+                       $a->redirect();
                        break; // NOTREACHED
        }
 
@@ -446,7 +446,7 @@ function dfrn_poll_content(App $a)
                                $my_id = '0:' . $dfrn_id;
                                break;
                        default:
-                               goaway(System::baseUrl());
+                               $a->redirect();
                                break; // NOTREACHED
                }
 
@@ -509,14 +509,14 @@ function dfrn_poll_content(App $a)
 
                        switch ($destination_url) {
                                case 'profile':
-                                       $dest = System::baseUrl() . '/profile/' . $profile . '?f=&tab=profile';
+                                       $dest = 'profile/' . $profile . '?f=&tab=profile';
                                        break;
                                case 'photos':
-                                       $dest = System::baseUrl() . '/photos/' . $profile;
+                                       $dest = 'photos/' . $profile;
                                        break;
                                case 'status':
                                case '':
-                                       $dest = System::baseUrl() . '/profile/' . $profile;
+                                       $dest = 'profile/' . $profile;
                                        break;
                                default:
                                        $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
@@ -558,9 +558,9 @@ function dfrn_poll_content(App $a)
                                        );
                                }
 
-                               goaway($dest);
+                               $a->redirect($dest);
                        }
-                       goaway($dest);
+                       $a->redirect($dest);
                        // NOTREACHED
                } else {
                        // XML reply
index 67db2c6285cdd1776657f8e7174203da8c2510e4..c74df9a7d6f91160db1588f1e461cab2dc044e35 100644 (file)
@@ -62,7 +62,7 @@ function dfrn_request_post(App $a)
        }
 
        if (x($_POST, 'cancel')) {
-               goaway(System::baseUrl());
+               $a->redirect();
        }
 
        /*
@@ -173,9 +173,9 @@ function dfrn_request_post(App $a)
                                                Contact::updateAvatar($photo, local_user(), $r[0]["id"], true);
                                        }
 
-                                       $forwardurl = System::baseUrl() . "/contact/" . $r[0]['id'];
+                                       $forwardurl = "contact/" . $r[0]['id'];
                                } else {
-                                       $forwardurl = System::baseUrl() . "/contact";
+                                       $forwardurl = "contact";
                                }
 
                                // Allow the blocked remote notification to complete
@@ -188,14 +188,14 @@ function dfrn_request_post(App $a)
                                }
 
                                // (ignore reply, nothing we can do it failed)
-                               goaway($forwardurl);
+                               $a->redirect($forwardurl);
                                return; // NOTREACHED
                        }
                }
 
                // invalid/bogus request
                notice(L10n::t('Unrecoverable protocol error.') . EOL);
-               goaway(System::baseUrl());
+               $a->redirect();
                return; // NOTREACHED
        }
 
@@ -331,19 +331,19 @@ function dfrn_request_post(App $a)
                                $url = Network::isUrlValid($url);
                                if (!$url) {
                                        notice(L10n::t('Invalid profile URL.') . EOL);
-                                       goaway(System::baseUrl() . '/' . $a->cmd);
+                                       $a->redirect($a->cmd);
                                        return; // NOTREACHED
                                }
 
                                if (!Network::isUrlAllowed($url)) {
                                        notice(L10n::t('Disallowed profile URL.') . EOL);
-                                       goaway(System::baseUrl() . '/' . $a->cmd);
+                                       $a->redirect($a->cmd);
                                        return; // NOTREACHED
                                }
 
                                if (Network::isUrlBlocked($url)) {
                                        notice(L10n::t('Blocked domain') . EOL);
-                                       goaway(System::baseUrl() . '/' . $a->cmd);
+                                       $a->redirect($a->cmd);
                                        return; // NOTREACHED
                                }
 
@@ -351,7 +351,7 @@ function dfrn_request_post(App $a)
 
                                if (!count($parms)) {
                                        notice(L10n::t('Profile location is not valid or does not contain profile information.') . EOL);
-                                       goaway(System::baseUrl() . '/' . $a->cmd);
+                                       $a->redirect($a->cmd);
                                } else {
                                        if (!x($parms, 'fn')) {
                                                notice(L10n::t('Warning: profile location has no identifiable owner name.') . EOL);
@@ -436,7 +436,7 @@ function dfrn_request_post(App $a)
                        $dfrn_url = bin2hex(System::baseUrl() . '/profile/' . $nickname);
                        $aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
 
-                       goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
+                       $a->redirect($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
                                . '&dfrn_version=' . DFRN_PROTOCOL_VERSION
                                . '&confirm_key=' . $hash
                                . (($aes_allow) ? "&aes_allow=1" : "")
@@ -459,11 +459,11 @@ function dfrn_request_post(App $a)
 
                                $uri = urlencode($uri);
                        } else {
-                               $uri = System::baseUrl() . '/profile/' . $nickname;
+                               $uri = 'profile/' . $nickname;
                        }
 
                        $url = str_replace('{uri}', $uri, $url);
-                       goaway($url);
+                       $a->redirect($url);
                        // NOTREACHED
                        // END $network != Protocol::PHANTOM
                } else {
index 081c3ce6cf4302a709d83b807f755c445f848f4f..f1ffad7b7ca7f9a15979041984e87ddd2df062c1 100644 (file)
@@ -79,7 +79,7 @@ function display_init(App $a)
        }
 
        if (ActivityPub::isRequest()) {
-               goaway(str_replace('display/', 'objects/', $a->query_string));
+               $a->redirect(str_replace('display/', 'objects/', $a->query_string));
        }
 
        if ($item["id"] != $item["parent"]) {
index d6ad97eac67910c0671a3678853f04b80280742a..e1f0678e456f8fa4c482ebe0600cd5c74a4f77f0 100644 (file)
@@ -100,7 +100,7 @@ function events_post(App $a)
        $type     = 'event';
 
        $action = ($event_id == '') ? 'new' : "event/" . $event_id;
-       $onerror_url = System::baseUrl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
+       $onerror_url = "events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
 
        if (strcmp($finish, $start) < 0 && !$nofinish) {
                notice(L10n::t('Event can not end before it has started.') . EOL);
@@ -108,7 +108,7 @@ function events_post(App $a)
                        echo L10n::t('Event can not end before it has started.');
                        killme();
                }
-               goaway($onerror_url);
+               $a->redirect($onerror_url);
        }
 
        if (!$summary || ($start === NULL_DATE)) {
@@ -117,7 +117,7 @@ function events_post(App $a)
                        echo L10n::t('Event title and start time are required.');
                        killme();
                }
-               goaway($onerror_url);
+               $a->redirect($onerror_url);
        }
 
        $share = intval(defaults($_POST, 'share', 0));
@@ -187,7 +187,7 @@ function events_post(App $a)
                Worker::add(PRIORITY_HIGH, "Notifier", "event", $item_id);
        }
 
-       goaway('/events');
+       $a->redirect('events');
 }
 
 function events_content(App $a)
@@ -577,6 +577,6 @@ function events_content(App $a)
                        info(L10n::t('Event removed') . EOL);
                }
 
-               goaway(System::baseUrl() . '/events');
+               $a->redirect('events');
        }
 }
index 7fb978ae6952e8aeebfeccdbc7c517163481f50e..d56890999caddc787b6fe3bab03268c62a2228a9 100644 (file)
@@ -25,7 +25,7 @@ function filerm_content(App $a) {
                file_tag_unsave_file(local_user(),$item_id,$term, $category);
        }
 
-       //goaway('/network');
+       //$a->redirect('network');
 
        killme();
 }
index 70dfb627ed6fabc15d26e5e15424aebf6bf4c0ef..572eea1da68a1426e16cf76d77922b6aedc749ec 100644 (file)
@@ -20,7 +20,7 @@ function follow_post(App $a)
        }
 
        if (isset($_REQUEST['cancel'])) {
-               goaway('contacts');
+               $a->redirect('contacts');
        }
 
        $uid = local_user();
@@ -37,14 +37,14 @@ function follow_post(App $a)
                if ($result['message']) {
                        notice($result['message']);
                }
-               goaway($return_url);
+               $a->redirect($return_url);
        } elseif ($result['cid']) {
-               goaway('contact/' . $result['cid']);
+               $a->redirect('contact/' . $result['cid']);
        }
 
        info(L10n::t('The contact could not be added.'));
 
-       goaway($return_url);
+       $a->redirect($return_url);
        // NOTREACHED
 }
 
@@ -54,7 +54,7 @@ function follow_content(App $a)
 
        if (!local_user()) {
                notice(L10n::t('Permission denied.'));
-               goaway($return_url);
+               $a->redirect($return_url);
                // NOTREACHED
        }
 
@@ -74,7 +74,7 @@ function follow_content(App $a)
                if ($r[0]['pending']) {
                        notice(L10n::t('You already added this contact.'));
                        $submit = '';
-                       //goaway($_SESSION['return_url']);
+                       //$a->redirect($_SESSION['return_url']);
                        // NOTREACHED
                }
        }
@@ -84,21 +84,21 @@ function follow_content(App $a)
        if (($ret['network'] == Protocol::DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
                notice(L10n::t("Diaspora support isn't enabled. Contact can't be added."));
                $submit = '';
-               //goaway($_SESSION['return_url']);
+               //$a->redirect($_SESSION['return_url']);
                // NOTREACHED
        }
 
        if (($ret['network'] == Protocol::OSTATUS) && Config::get('system', 'ostatus_disabled')) {
                notice(L10n::t("OStatus support is disabled. Contact can't be added."));
                $submit = '';
-               //goaway($_SESSION['return_url']);
+               //$a->redirect($_SESSION['return_url']);
                // NOTREACHED
        }
 
        if ($ret['network'] == Protocol::PHANTOM) {
                notice(L10n::t("The network type couldn't be detected. Contact can't be added."));
                $submit = '';
-               //goaway($_SESSION['return_url']);
+               //$a->redirect($_SESSION['return_url']);
                // NOTREACHED
        }
 
@@ -118,7 +118,7 @@ function follow_content(App $a)
 
        if (!$r) {
                notice(L10n::t('Permission denied.'));
-               goaway($return_url);
+               $a->redirect($return_url);
                // NOTREACHED
        }
 
index 129cf18c2a24febbd72c57badf990ae87a5d0099..beae6a52e1e14d8fbbc9477bfd172b76e79075ef 100644 (file)
@@ -38,12 +38,12 @@ function group_post(App $a) {
                        info(L10n::t('Group created.') . EOL);
                        $r = Model\Group::getIdByName(local_user(), $name);
                        if ($r) {
-                               goaway(System::baseUrl() . '/group/' . $r);
+                               $a->redirect('group/' . $r);
                        }
                } else {
                        notice(L10n::t('Could not create group.') . EOL);
                }
-               goaway(System::baseUrl() . '/group');
+               $a->redirect('group');
                return; // NOTREACHED
        }
 
@@ -56,7 +56,7 @@ function group_post(App $a) {
                );
                if (!DBA::isResult($r)) {
                        notice(L10n::t('Group not found.') . EOL);
-                       goaway(System::baseUrl() . '/contact');
+                       $a->redirect('contact');
                        return; // NOTREACHED
                }
                $group = $r[0];
@@ -88,7 +88,7 @@ function group_content(App $a) {
 
        // With no group number provided we jump to the unassigned contacts as a starting point
        if ($a->argc == 1) {
-               goaway('group/none');
+               $a->redirect('group/none');
        }
 
        // Switch to text mode interface if we have more than 'n' contacts or group members
@@ -159,7 +159,7 @@ function group_content(App $a) {
                                notice(L10n::t('Unable to remove group.') . EOL);
                        }
                }
-               goaway(System::baseUrl() . '/group');
+               $a->redirect('group');
                // NOTREACHED
        }
 
@@ -183,7 +183,7 @@ function group_content(App $a) {
 
                if (!DBA::isResult($r)) {
                        notice(L10n::t('Group not found.') . EOL);
-                       goaway(System::baseUrl() . '/contact');
+                       $a->redirect('contact');
                }
 
                $group = $r[0];
index 33d736a4e1cba2793efd62c8e576a90135f5740f..868bc9e488b1d82b212b1f1ca99c6b3cfe355c3f 100644 (file)
@@ -16,11 +16,11 @@ function home_init(App $a) {
        Addon::callHooks('home_init',$ret);
 
        if (local_user() && ($a->user['nickname'])) {
-               goaway(System::baseUrl()."/network");
+               $a->redirect('network');
        }
 
        if (strlen(Config::get('system','singleuser'))) {
-               goaway(System::baseUrl()."/profile/" . Config::get('system','singleuser'));
+               $a->redirect('profile/' . Config::get('system','singleuser'));
        }
 
 }}
index 8502874ce537ee04e01e2854e65aa05e08c887eb..c433313165de7dea99932fa0700643ec2f0c0016 100644 (file)
@@ -43,7 +43,7 @@ function ignored_init(App $a)
                        $rand = "?$rand";
                }
 
-               goaway(System::baseUrl() . "/" . $return_path . $rand);
+               $a->redirect($return_path . $rand);
        }
 
        // the json doesn't really matter, it will either be 0 or 1
index 5d4a23caa7a28802a4c9f82210c07c5f640e9aa7..bc978c9d8dbe0bc9c99d1441f193dadbc52b190c 100644 (file)
@@ -115,7 +115,7 @@ function item_post(App $a) {
                if (!DBA::isResult($parent_item)) {
                        notice(L10n::t('Unable to locate original post.') . EOL);
                        if (!empty($_REQUEST['return'])) {
-                               goaway($return_path);
+                               $a->redirect($return_path);
                        }
                        killme();
                }
@@ -165,7 +165,7 @@ function item_post(App $a) {
                notice(L10n::t('Permission denied.') . EOL) ;
 
                if (!empty($_REQUEST['return'])) {
-                       goaway($return_path);
+                       $a->redirect($return_path);
                }
 
                killme();
@@ -283,7 +283,7 @@ function item_post(App $a) {
                        }
                        info(L10n::t('Empty post discarded.') . EOL);
                        if (!empty($_REQUEST['return'])) {
-                               goaway($return_path);
+                               $a->redirect($return_path);
                        }
                        killme();
                }
@@ -678,7 +678,7 @@ function item_post(App $a) {
        if (!empty($datarray['cancel'])) {
                logger('mod_item: post cancelled by addon.');
                if ($return_path) {
-                       goaway($return_path);
+                       $a->redirect($return_path);
                }
 
                $json = ['cancel' => 1];
@@ -714,7 +714,7 @@ function item_post(App $a) {
 
                if (!empty($_REQUEST['return']) && strlen($return_path)) {
                        logger('return: ' . $return_path);
-                       goaway($return_path);
+                       $a->redirect($return_path);
                }
                killme();
        } else {
@@ -729,14 +729,14 @@ function item_post(App $a) {
 
        if (!$post_id) {
                logger("Item wasn't stored.");
-               goaway($return_path);
+               $a->redirect($return_path);
        }
 
        $datarray = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
 
        if (!DBA::isResult($datarray)) {
                logger("Item with id ".$post_id." couldn't be fetched.");
-               goaway($return_path);
+               $a->redirect($return_path);
        }
 
        // update filetags in pconfig
@@ -844,13 +844,14 @@ function item_post(App $a) {
 function item_post_return($baseurl, $api_source, $return_path)
 {
        // figure out how to return, depending on from whence we came
+    $a = get_app();
 
        if ($api_source) {
                return;
        }
 
        if ($return_path) {
-               goaway($return_path);
+               $a->redirect($return_path);
        }
 
        $json = ['success' => 1];
index 08e3febbbc1a0b4dfc729771d17547e410a60963..a2617494de736d13729ac00ebc864a888d34f3ad 100644 (file)
@@ -28,7 +28,7 @@ function like_content(App $a) {
        // See if we've been passed a return path to redirect to
        $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
 
-       like_content_return(System::baseUrl(), $return_path);
+       like_content_return($a, $return_path);
        killme(); // NOTREACHED
 }
 
@@ -36,7 +36,7 @@ function like_content(App $a) {
 // Decide how to return. If we were called with a 'return' argument,
 // then redirect back to the calling page. If not, just quietly end
 
-function like_content_return($baseurl, $return_path) {
+function like_content_return(App $a, $return_path) {
        if ($return_path) {
                $rand = '_=' . time();
                if (strpos($return_path, '?')) {
@@ -45,7 +45,7 @@ function like_content_return($baseurl, $return_path) {
                        $rand = "?$rand";
                }
 
-               goaway($baseurl . "/" . $return_path . $rand);
+               $a->redirect($return_path . $rand);
        }
 
        killme();
index 166da25fc24b56b494ac60eea109dcf40e8725a0..22172082a8e0109566a9cd82e790fec63dfeefeb 100644 (file)
@@ -19,14 +19,14 @@ function lostpass_post(App $a)
 {
        $loginame = notags(trim($_POST['login-name']));
        if (!$loginame) {
-               goaway(System::baseUrl());
+               $a->redirect();
        }
 
        $condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame];
        $user = DBA::selectFirst('user', ['uid', 'username', 'email', 'language'], $condition);
        if (!DBA::isResult($user)) {
                notice(L10n::t('No valid account found.') . EOL);
-               goaway(System::baseUrl());
+               $a->redirect();
        }
 
        $pwdreset_token = autoname(12) . mt_rand(1000, 9999);
@@ -78,7 +78,7 @@ function lostpass_post(App $a)
                'body'     => $body
        ]);
 
-       goaway(System::baseUrl());
+       $a->redirect();
 }
 
 function lostpass_content(App $a)
index d38d90ce60e648b9ffb439d5a9fd801b1e3addad..2b0dfa8da7113d7f50339988726c4f6608ca5119 100644 (file)
@@ -119,7 +119,7 @@ function manage_post(App $a) {
        $ret = [];
        Addon::callHooks('home_init',$ret);
 
-       goaway( System::baseUrl() . "/profile/" . $a->user['nickname'] );
+       $a->redirect('profile/' . $a->user['nickname'] );
        // NOTREACHED
 }
 
index f9c5c29ec773a934f3795453c8c6a15b257848f3..fc9fafceb449b71cd64ac3b7ebfe8db2d56ffc7c 100644 (file)
@@ -87,7 +87,7 @@ function message_post(App $a)
                $a->argc = 2;
                $a->argv[1] = 'new';
        } else {
-               goaway($a->cmd . '/' . $ret);
+               $a->redirect($a->cmd . '/' . $ret);
        }
 }
 
@@ -155,7 +155,7 @@ function message_content(App $a)
 
                // Now check how the user responded to the confirmation query
                if (!empty($_REQUEST['canceled'])) {
-                       goaway('/message');
+                       $a->redirect('message');
                }
 
                $cmd = $a->argv[1];
@@ -163,7 +163,7 @@ function message_content(App $a)
                        $message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]);
                        if(!DBA::isResult($message)){
                                info(L10n::t('Conversation not found.') . EOL);
-                               goaway('/message');
+                               $a->redirect('message');
                        }
 
                        if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
@@ -173,10 +173,10 @@ function message_content(App $a)
                        $conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]);
                        if(!DBA::isResult($conversation)){
                                info(L10n::t('Conversation removed.') . EOL);
-                               goaway('/message');
+                               $a->redirect('message');
                        }
 
-                       goaway('/message/' . $conversation['id'] );
+                       $a->redirect('message/' . $conversation['id'] );
                } else {
                        $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                                intval($a->argv[2]),
@@ -190,7 +190,7 @@ function message_content(App $a)
                                        info(L10n::t('Conversation removed.') . EOL);
                                }
                        }
-                       goaway('/message' );
+                       $a->redirect('message');
                }
        }
 
index fb0093849e1ef4b618641c51bf33de99cb65c905..06d5dbd2f9456a07723d5f6d194481da3787a849 100644 (file)
@@ -38,7 +38,7 @@ function network_init(App $a)
        $search = (x($_GET, 'search') ? escape_tags($_GET['search']) : '');
 
        if (($search != '') && !empty($_GET['submit'])) {
-               goaway('search?search=' . urlencode($search));
+               $a->redirect('search?search=' . urlencode($search));
        }
 
        if (x($_GET, 'save')) {
@@ -140,7 +140,7 @@ function network_init(App $a)
 
                        $redir_url = ($net_queries ? $net_baseurl . '?' . $net_queries : $net_baseurl);
 
-                       goaway(System::baseUrl() . $redir_url);
+                       $a->redirect($redir_url);
                }
        }
 
@@ -618,7 +618,7 @@ function networkThreadedView(App $a, $update, $parent)
                                killme();
                        }
                        notice(L10n::t('No such group') . EOL);
-                       goaway('network/0');
+                       $a->redirect('network/0');
                        // NOTREACHED
                }
 
@@ -672,7 +672,7 @@ function networkThreadedView(App $a, $update, $parent)
                        }
                } else {
                        notice(L10n::t('Invalid contact.') . EOL);
-                       goaway('network');
+                       $a->redirect('network');
                        // NOTREACHED
                }
        }
index 18681d7683c619c91ab0faa7f0af03a5e515f7c0..ff292a21ca4ab4a1527c7180be7a9f55f2319da9 100644 (file)
@@ -24,5 +24,5 @@ function nogroup_content(App $a)
                return '';
        }
 
-       goaway(System::baseUrl() . '/group/none');
+       $a->redirect('group/none');
 }
index 133fd22fce242024001ac4015c193998411c9d6f..199c6d1b5d59dff1eeec553de8e6a8c271e4167f 100644 (file)
@@ -15,8 +15,7 @@ function notice_init(App $a)
        $r = q("SELECT `user`.`nickname` FROM `user` LEFT JOIN `item` ON `item`.`uid` = `user`.`uid` WHERE `item`.`id` = %d", intval($id));
        if (DBA::isResult($r)) {
                $nick = $r[0]['nickname'];
-               $url = System::baseUrl() . "/display/$nick/$id";
-               goaway($url);
+               $a->redirect('display/' . $nick . '/' . $id);
        } else {
                $a->error = 404;
                notice(L10n::t('Item not found.') . EOL);
index 1885f96447c9f7e54276cd059bd26cddcaa2482c..8de26aaf2da0aba0017719bd74ccde1357af7f8d 100644 (file)
@@ -17,7 +17,7 @@ use Friendica\Module\Login;
 function notifications_post(App $a)
 {
        if (!local_user()) {
-               goaway(System::baseUrl());
+               $a->redirect();
        }
 
        $request_id = (($a->argc > 1) ? $a->argv[1] : 0);
@@ -52,12 +52,12 @@ function notifications_post(App $a)
                                        'self' => false, 'blocked' => true, 'pending' => true];
                                DBA::delete('contact', $condition);
                        }
-                       goaway('notifications/intros');
+                       $a->redirect('notifications/intros');
                }
 
                if ($_POST['submit'] == L10n::t('Ignore')) {
                        DBA::update('intro', ['ignore' => true], ['id' => $intro_id]);
-                       goaway('notifications/intros');
+                       $a->redirect('notifications/intros');
                }
        }
 }
index a277e59813ecb53a11907a2a7e9736a609408cdb..4f9aa62fa11202a4096707e74477358ff5fa0589 100644 (file)
@@ -37,10 +37,10 @@ function notify_init(App $a)
                                }
                        }
 
-                       goaway($note['link']);
+                       $a->redirect($note['link']);
                }
 
-               goaway(System::baseUrl(true));
+               $a->redirect();
        }
 
        if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
index 41aabe7a97811e42ace2ec2772d16a96aac5b4e9..3e9486a6d88082bee974be412cf90993d0211701 100644 (file)
@@ -14,7 +14,7 @@ function openid_content(App $a) {
 
        $noid = Config::get('system','no_openid');
        if($noid)
-               goaway(System::baseUrl());
+               $a->redirect();
 
        logger('mod_openid ' . print_r($_REQUEST,true), LOGGER_DATA);
 
@@ -28,7 +28,7 @@ function openid_content(App $a) {
 
                        if(! strlen($authid)) {
                                logger(L10n::t('OpenID protocol error. No ID returned.') . EOL);
-                               goaway(System::baseUrl());
+                               $a->redirect();
                        }
 
                        // NOTE: we search both for normalised and non-normalised form of $authid
@@ -56,7 +56,7 @@ function openid_content(App $a) {
                                // just in case there was no return url set
                                // and we fell through
 
-                               goaway(System::baseUrl());
+                               $a->redirect();
                        }
 
                        // Successful OpenID login - but we can't match it to an existing account.
@@ -64,7 +64,7 @@ function openid_content(App $a) {
 
                        if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
                                notice(L10n::t('Account not found and OpenID registration is not permitted on this site.') . EOL);
-                               goaway(System::baseUrl());
+                               $a->redirect();
                        }
 
                        unset($_SESSION['register']);
@@ -108,12 +108,12 @@ function openid_content(App $a) {
 
                        $args .= '&openid_url=' . urlencode(notags(trim($authid)));
 
-                       goaway(System::baseUrl() . '/register?' . $args);
+                       $a->redirect('register?' . $args);
 
                        // NOTREACHED
                }
        }
        notice(L10n::t('Login failed.') . EOL);
-       goaway(System::baseUrl());
+       $a->redirect();
        // NOTREACHED
 }
index 7012ecd4bcc58f35e3cf9aba74050270e1eed1fd..d5d07d6707b8afbdcb8d53590ff83235d96e358e 100644 (file)
@@ -15,7 +15,7 @@ function ostatus_subscribe_content(App $a) {
 
        if (! local_user()) {
                notice(L10n::t('Permission denied.') . EOL);
-               goaway('/ostatus_subscribe');
+               $a->redirect('ostatus_subscribe');
                // NOTREACHED
        }
 
index 55c8881e4cecd17d74d278fbc2e75dd8bb4d817d..3851e00bb6f712740109bcbb95607811b88cfda6 100644 (file)
@@ -196,7 +196,7 @@ function photos_post(App $a)
                $album = hex2bin($a->argv[3]);
 
                if ($album === L10n::t('Profile Photos') || $album === 'Contact Photos' || $album === L10n::t('Contact Photos')) {
-                       goaway($_SESSION['photo_return']);
+                       $a->redirect($_SESSION['photo_return']);
                        return; // NOTREACHED
                }
 
@@ -207,13 +207,13 @@ function photos_post(App $a)
 
                if (!DBA::isResult($r)) {
                        notice(L10n::t('Album not found.') . EOL);
-                       goaway($_SESSION['photo_return']);
+                       $a->redirect($_SESSION['photo_return']);
                        return; // NOTREACHED
                }
 
                // Check if the user has responded to a delete confirmation query
                if (!empty($_REQUEST['canceled'])) {
-                       goaway($_SESSION['photo_return']);
+                       $a->redirect($_SESSION['photo_return']);
                }
 
                // RENAME photo album
@@ -227,8 +227,7 @@ function photos_post(App $a)
                        // Update the photo albums cache
                        Photo::clearAlbumCache($page_owner_uid);
 
-                       $newurl = System::baseUrl() . '/photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum);
-                       goaway($newurl);
+                       $a->redirect('photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum));
                        return; // NOTREACHED
                }
 
@@ -281,7 +280,7 @@ function photos_post(App $a)
                                        $res[] = "'" . DBA::escape($rr['rid']) . "'" ;
                                }
                        } else {
-                               goaway($_SESSION['photo_return']);
+                               $a->redirect($_SESSION['photo_return']);
                                return; // NOTREACHED
                        }
 
@@ -299,14 +298,14 @@ function photos_post(App $a)
                        Photo::clearAlbumCache($page_owner_uid);
                }
 
-               goaway('photos/' . $a->data['user']['nickname']);
+               $a->redirect('photos/' . $a->data['user']['nickname']);
                return; // NOTREACHED
        }
 
 
        // Check if the user has responded to a delete confirmation query for a single photo
        if ($a->argc > 2 && !empty($_REQUEST['canceled'])) {
-               goaway($_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
        }
 
        if ($a->argc > 2 && defaults($_POST, 'delete', '') === L10n::t('Delete Photo')) {
@@ -356,7 +355,7 @@ function photos_post(App $a)
                        Photo::clearAlbumCache($page_owner_uid);
                }
 
-               goaway('photos/' . $a->data['user']['nickname']);
+               $a->redirect('photos/' . $a->data['user']['nickname']);
                return; // NOTREACHED
        }
 
@@ -697,7 +696,7 @@ function photos_post(App $a)
                                }
                        }
                }
-               goaway($_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
                return; // NOTREACHED
        }
 
@@ -928,7 +927,7 @@ function photos_post(App $a)
        // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
        // if they do not wish to be redirected
 
-       goaway($_SESSION['photo_return']);
+       $a->redirect($_SESSION['photo_return']);
        // NOTREACHED
 }
 
index 8d5ae8758533cc10a743e2859bb0a2ee45630ad6..238af8d96e764d306107f27f87e1a53adcc89866 100644 (file)
@@ -34,7 +34,7 @@ function profile_init(App $a)
        } else {
                $r = q("SELECT `nickname` FROM `user` WHERE `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 ORDER BY RAND() LIMIT 1");
                if (DBA::isResult($r)) {
-                       goaway(System::baseUrl() . '/profile/' . $r[0]['nickname']);
+                       $a->redirect('profile/' . $r[0]['nickname']);
                } else {
                        logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
                        notice(L10n::t('Requested profile is not available.') . EOL);
index 5fdff41e8c6b6d54820f5a45bac9279197032c69..7006349a6413791537e09e2170c44922ae150820 100644 (file)
@@ -135,7 +135,7 @@ function profile_photo_post(App $a)
                        }
                }
 
-               goaway($url);
+               $a->redirect($url);
                return; // NOTREACHED
        }
 
@@ -168,7 +168,7 @@ function profile_photo_post(App $a)
        @unlink($src);
 
        $imagecrop = profile_photo_crop_ui_head($a, $ph);
-       goaway(System::baseUrl() . '/profile_photo/use/' . $imagecrop['hash']);
+       $a->redirect('profile_photo/use/' . $imagecrop['hash']);
 }
 
 function profile_photo_content(App $a)
@@ -225,7 +225,7 @@ function profile_photo_content(App $a)
                                Worker::add(PRIORITY_LOW, "Directory", $url);
                        }
 
-                       goaway(System::baseUrl() . '/profile/' . $a->user['nickname']);
+                       $a->redirect('profile/' . $a->user['nickname']);
                        return; // NOTREACHED
                }
                $ph = new Image($r[0]['data'], $r[0]['type']);
index 22f192b4ce6fa8f34f5308fdae4f80c2109f3f47..6f75879fecb46b0109366be5994b2a5b64ada842 100644 (file)
@@ -38,7 +38,7 @@ function profiles_init(App $a) {
                );
                if (! DBA::isResult($r)) {
                        notice(L10n::t('Profile not found.') . EOL);
-                       goaway('profiles');
+                       $a->redirect('profiles');
                        return; // NOTREACHED
                }
 
@@ -59,7 +59,7 @@ function profiles_init(App $a) {
                        info(L10n::t('Profile deleted.').EOL);
                }
 
-               goaway('profiles');
+               $a->redirect('profiles');
                return; // NOTREACHED
        }
 
@@ -93,10 +93,10 @@ function profiles_init(App $a) {
 
                info(L10n::t('New profile created.') . EOL);
                if (DBA::isResult($r3) && count($r3) == 1) {
-                       goaway('profiles/' . $r3[0]['id']);
+                       $a->redirect('profiles/' . $r3[0]['id']);
                }
 
-               goaway('profiles');
+               $a->redirect('profiles');
        }
 
        if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
@@ -132,10 +132,10 @@ function profiles_init(App $a) {
                );
                info(L10n::t('New profile created.') . EOL);
                if ((DBA::isResult($r3)) && (count($r3) == 1)) {
-                       goaway('profiles/'.$r3[0]['id']);
+                       $a->redirect('profiles/'.$r3[0]['id']);
                }
 
-               goaway('profiles');
+               $a->redirect('profiles');
 
                return; // NOTREACHED
        }
@@ -654,7 +654,7 @@ function profiles_content(App $a) {
                        );
                        if (DBA::isResult($r)) {
                                //Go to the default profile.
-                               goaway('profiles/' . $r[0]['id']);
+                               $a->redirect('profiles/' . $r[0]['id']);
                        }
                }
 
index 18bcb236f8a98504e94acbe860b41c2d2ee82e08..13944c128f9a45f155f6fb029ff0ec2e4b2b984d 100644 (file)
@@ -13,8 +13,8 @@ function randprof_init(App $a)
        $x = GContact::getRandomUrl();
 
        if ($x) {
-               goaway(Contact::magicLink($x));
+               $a->redirect(Contact::magicLink($x));
        }
 
-       goaway(System::baseUrl() . '/profile');
+       $a->redirect('profile');
 }
index e989ad015a83045b5f98ce9e202e416bce03731a..726e8619ecd8c2f569712a85d3bad0763315693c 100644 (file)
@@ -27,7 +27,7 @@ function redir_init(App $a) {
                $contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]);
                if (!DBA::isResult($contact)) {
                        notice(L10n::t('Contact not found.'));
-                       goaway(System::baseUrl());
+                       $a->redirect();
                }
 
                $contact_url = $contact['url'];
@@ -36,7 +36,7 @@ function redir_init(App $a) {
                        || (!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
                        || (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
                {
-                       goaway($url != '' ? $url : $contact_url);
+                       $a->redirect($url != '' ? $url : $contact_url);
                }
 
                if ($contact['uid'] == 0 && local_user()) {
@@ -52,7 +52,7 @@ function redir_init(App $a) {
                                // Local user is already authenticated.
                                $target_url = $url != '' ? $url : $contact_url;
                                logger($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG);
-                               goaway($target_url);
+                               $a->redirect($target_url);
                        }
                }
 
@@ -73,7 +73,7 @@ function redir_init(App $a) {
                                                // Remote user is already authenticated.
                                                $target_url = $url != '' ? $url : $contact_url;
                                                logger($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG);
-                                               goaway($target_url);
+                                               $a->redirect($target_url);
                                        }
                                }
                        }
@@ -102,7 +102,7 @@ function redir_init(App $a) {
 
                        $dest = (!empty($url) ? '&destination_url=' . $url : '');
 
-                       goaway($contact['poll'] . '?dfrn_id=' . $dfrn_id
+                       $a->redirect($contact['poll'] . '?dfrn_id=' . $dfrn_id
                                . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet);
                }
 
@@ -121,9 +121,9 @@ function redir_init(App $a) {
                }
 
                logger('redirecting to ' . $url, LOGGER_DEBUG);
-               goaway($url);
+               $a->redirect($url);
        }
 
        notice(L10n::t('Contact not found.'));
-       goaway(System::baseUrl());
+       $a->redirect();
 }
index 7ee0f0d8fdae4d1ca74b0bac991c641d3cc630e9..c3231cda69ffc2f1d87a985e4e6c716c2a9ac086 100644 (file)
@@ -100,7 +100,7 @@ function register_post(App $a)
 
                        if ($res) {
                                info(L10n::t('Registration successful. Please check your email for further instructions.') . EOL);
-                               goaway();
+                               $a->redirect();
                        } else {
                                notice(
                                        L10n::t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.',
@@ -111,12 +111,12 @@ function register_post(App $a)
                        }
                } else {
                        info(L10n::t('Registration successful.') . EOL);
-                       goaway();
+                       $a->redirect();
                }
        } elseif (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE) {
                if (!strlen(Config::get('config', 'admin_email'))) {
                        notice(L10n::t('Your registration can not be processed.') . EOL);
-                       goaway();
+                       $a->redirect();
                }
 
                Model\Register::createForApproval($user['uid'], Config::get('system', 'language'), $_POST['permonlybox']);
@@ -159,7 +159,7 @@ function register_post(App $a)
                );
 
                info(L10n::t('Your registration is pending approval by the site owner.') . EOL);
-               goaway();
+               $a->redirect();
        }
 
        return;
index 3f6f0e04e3253e6073f686548e16450b3374d225..d2fc4c0602b89082eff3d4a85e6a591eecaf5478 100644 (file)
@@ -101,11 +101,11 @@ function regmod_content(App $a)
 
        if ($cmd === 'deny') {
                user_deny($hash);
-               goaway('admin/users/');
+               $a->redirect('admin/users/');
        }
 
        if ($cmd === 'allow') {
                user_allow($hash);
-               goaway('admin/users/');
+               $a->redirect('admin/users/');
        }
 }
index b386ec12f5ccabd09280900a32fc0a3b1139c7d1..a53bc3ecebecb19bde1715914aef4a85501012ba 100644 (file)
@@ -64,7 +64,7 @@ function removeme_post(App $a)
 function removeme_content(App $a)
 {
        if (!local_user()) {
-               goaway(System::baseUrl());
+               $a->redirect();
        }
 
        $hash = random_string();
@@ -76,7 +76,7 @@ function removeme_content(App $a)
 
        $tpl = get_markup_template('removeme.tpl');
        $o = replace_macros($tpl, [
-               '$basedir' => System::baseUrl(),
+               '$basedir' => $a->getBaseURL(),
                '$hash' => $hash,
                '$title' => L10n::t('Remove My Account'),
                '$desc' => L10n::t('This will completely remove your account. Once this has been done it is not recoverable.'),
index 4499220817449b83684020ca1da731e3a6d170e9..1ecf7650419ee850f761a00be63312099ca1f99b 100644 (file)
@@ -14,7 +14,7 @@ function repair_ostatus_content(App $a) {
 
        if (! local_user()) {
                notice(L10n::t('Permission denied.') . EOL);
-               goaway('/ostatus_repair');
+               $a->redirect('ostatus_repair');
                // NOTREACHED
        }
 
index cb88823997268ebd54100780c1224edeccc0238f..8606cbd6cdde7e69faff3cf6ffb74c5599bbbaa0 100644 (file)
@@ -160,7 +160,7 @@ function settings_post(App $a)
 
                $key = $_POST['remove'];
                DBA::delete('tokens', ['id' => $key, 'uid' => local_user()]);
-               goaway(System::baseUrl(true)."/settings/oauth/");
+               $a->redirect('settings/oauth/', true);
                return;
        }
 
@@ -206,7 +206,7 @@ function settings_post(App $a)
                                );
                        }
                }
-               goaway(System::baseUrl(true)."/settings/oauth/");
+               $a->redirect('settings/oauth/', true);
                return;
        }
 
@@ -371,7 +371,7 @@ function settings_post(App $a)
                );
 
                Addon::callHooks('display_settings_post', $_POST);
-               goaway('settings/display');
+               $a->redirect('settings/display');
                return; // NOTREACHED
        }
 
@@ -380,7 +380,7 @@ function settings_post(App $a)
        if (x($_POST,'resend_relocate')) {
                Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', local_user());
                info(L10n::t("Relocate message has been send to your contacts"));
-               goaway('settings');
+               $a->redirect('settings');
        }
 
        Addon::callHooks('settings_post', $_POST);
@@ -649,7 +649,7 @@ function settings_post(App $a)
        // Update the global contact for the user
        GContact::updateForUser(local_user());
 
-       goaway('settings');
+       $a->redirect('settings');
        return; // NOTREACHED
 }
 
@@ -716,7 +716,7 @@ function settings_content(App $a)
                        BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't');
 
                        DBA::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]);
-                       goaway(System::baseUrl(true)."/settings/oauth/");
+                       $a->redirect('settings/oauth/', true);
                        return;
                }
 
@@ -732,7 +732,7 @@ function settings_content(App $a)
                $tpl = get_markup_template('settings/oauth.tpl');
                $o .= replace_macros($tpl, [
                        '$form_security_token' => BaseModule::getFormSecurityToken("settings_oauth"),
-                       '$baseurl'      => System::baseUrl(true),
+                       '$baseurl'      => $a->getBaseURL(true),
                        '$title'        => L10n::t('Connected Apps'),
                        '$add'          => L10n::t('Add application'),
                        '$edit'         => L10n::t('Edit'),
@@ -795,7 +795,7 @@ function settings_content(App $a)
                $legacy_contact            = PConfig::get(local_user(), 'ostatus', 'legacy_contact');
 
                if (x($legacy_contact)) {
-                       /// @todo Isn't it supposed to be a goaway() call?
+                       /// @todo Isn't it supposed to be a $a->redirect() call?
                        $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . System::baseUrl().'/ostatus_subscribe?url=' . urlencode($legacy_contact) . '">';
                }
 
index e75a09674082bfb432114371f9962302ba07bf6c..dcb0ff542b15c71e57362bffc5f0759253a0338b 100644 (file)
@@ -42,7 +42,7 @@ function starred_init(App $a) {
                        $rand = "?$rand";
                }
 
-               goaway(System::baseUrl() . "/" . $return_path . $rand);
+               $a->redirect($return_path . $rand);
        }
 
        // the json doesn't really matter, it will either be 0 or 1
index db0b765799ba7ab9582e9e1b9b4ac2cf9f450be3..ae1bc63db541370f6e94b3d8f501c04224d83595 100644 (file)
@@ -13,11 +13,11 @@ use Friendica\Model\Item;
 function tagrm_post(App $a)
 {
        if (!local_user()) {
-               goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
        }
 
        if (x($_POST,'submit') && ($_POST['submit'] === L10n::t('Cancel'))) {
-               goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
        }
 
        $tag =  (x($_POST,'tag')  ? hex2bin(notags(trim($_POST['tag']))) : '');
@@ -25,7 +25,7 @@ function tagrm_post(App $a)
 
        $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
        if (!DBA::isResult($item)) {
-               goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
        }
 
        $arr = explode(',', $item['tag']);
@@ -41,7 +41,7 @@ function tagrm_post(App $a)
        Item::update(['tag' => $tag_str], ['id' => $item_id]);
 
        info(L10n::t('Tag removed') . EOL );
-       goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+       $a->redirect($_SESSION['photo_return']);
 
        // NOTREACHED
 }
@@ -53,25 +53,25 @@ function tagrm_content(App $a)
        $o = '';
 
        if (!local_user()) {
-               goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
                // NOTREACHED
        }
 
        $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
        if (!$item_id) {
-               goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
                // NOTREACHED
        }
 
        $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
        if (!DBA::isResult($item)) {
-               goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
        }
 
        $arr = explode(',', $item['tag']);
 
        if (!count($arr)) {
-               goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+               $a->redirect($_SESSION['photo_return']);
        }
 
        $o .= '<h3>' . L10n::t('Remove Item Tag') . '</h3>';
index 2449de4aa217e3e85d5a0440b09c9fa47a0f630f..2821e0a646bef02e3e6297d22a1d57d861c251b7 100644 (file)
@@ -14,8 +14,8 @@ function toggle_mobile_init(App $a) {
        if (isset($_GET['address'])) {
                $address = $_GET['address'];
        } else {
-               $address = System::baseUrl();
+               $address = '';
        }
 
-       goaway($address);
+       $a->redirect($address);
 }
index 6a058608e7a0dd5c2808c580f3262fe48cb5d9aa..f092e05ff85bf626a1abb4760d0e0ae17bd6fdee 100644 (file)
@@ -12,13 +12,13 @@ use Friendica\Model\Contact;
 use Friendica\Model\Profile;
 use Friendica\Model\User;
 
-function unfollow_post()
+function unfollow_post(App $a)
 {
        $return_url = 'contacts';
 
        if (!local_user()) {
                notice(L10n::t('Permission denied.'));
-               goaway('/login');
+               $a->redirect('login');
                // NOTREACHED
        }
 
@@ -32,17 +32,17 @@ function unfollow_post()
 
        if (!DBA::isResult($contact)) {
                notice(L10n::t("You aren't following this contact."));
-               goaway($return_url);
+               $a->redirect($return_url);
                // NOTREACHED
        }
 
        if (!empty($_REQUEST['cancel'])) {
-               goaway($return_url . '/' . $contact['id']);
+               $a->redirect($return_url . '/' . $contact['id']);
        }
 
        if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
                notice(L10n::t('Unfollowing is currently not supported by your network.'));
-               goaway($return_url . '/' . $contact['id']);
+               $a->redirect($return_url . '/' . $contact['id']);
                // NOTREACHED
        }
 
@@ -63,7 +63,7 @@ function unfollow_post()
        }
 
        info(L10n::t('Contact unfollowed'));
-       goaway($return_path);
+       $a->redirect($return_path);
        // NOTREACHED
 }
 
@@ -73,7 +73,7 @@ function unfollow_content(App $a)
 
        if (!local_user()) {
                notice(L10n::t('Permission denied.'));
-               goaway('/login');
+               $a->redirect('login');
                // NOTREACHED
        }
 
@@ -88,13 +88,13 @@ function unfollow_content(App $a)
 
        if (!DBA::isResult($contact)) {
                notice(L10n::t("You aren't following this contact."));
-               goaway($return_url);
+               $a->redirect($return_url);
                // NOTREACHED
        }
 
        if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
                notice(L10n::t('Unfollowing is currently not supported by your network.'));
-               goaway('contact/' . $contact['id']);
+               $a->redirect('contact/' . $contact['id']);
                // NOTREACHED
        }
 
@@ -105,7 +105,7 @@ function unfollow_content(App $a)
 
        if (!DBA::isResult($self)) {
                notice(L10n::t('Permission denied.'));
-               goaway($return_url);
+               $a->redirect($return_url);
                // NOTREACHED
        }
 
index b66a7cbcda937cb192bcec78c4720b9936cada13..b311a7a5fe38303ff10fe6693733a2aee43b80e5 100644 (file)
@@ -115,14 +115,14 @@ function videos_post(App $a)
        $owner_uid = $a->data['user']['uid'];
 
        if (local_user() != $owner_uid) {
-               goaway(System::baseUrl() . '/videos/' . $a->data['user']['nickname']);
+               $a->redirect('videos/' . $a->data['user']['nickname']);
        }
 
        if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) {
                // Check if we should do HTML-based delete confirmation
                if (empty($_REQUEST['confirm'])) {
                        if (!empty($_REQUEST['canceled'])) {
-                               goaway(System::baseUrl() . '/videos/' . $a->data['user']['nickname']);
+                               $a->redirect('videos/' . $a->data['user']['nickname']);
                        }
 
                        $drop_url = $a->query_string;
@@ -169,11 +169,11 @@ function videos_post(App $a)
                        }
                }
 
-               goaway(System::baseUrl() . '/videos/' . $a->data['user']['nickname']);
+               $a->redirect('videos/' . $a->data['user']['nickname']);
                return; // NOTREACHED
        }
 
-       goaway(System::baseUrl() . '/videos/' . $a->data['user']['nickname']);
+       $a->redirect('videos/' . $a->data['user']['nickname']);
 }
 
 function videos_content(App $a)
index 5e08420ecb109f6cd16767574f51815982038c9e..882cb1e0bfcc1d7ab7bc828d0a4fbdbeb35ec81b 100644 (file)
@@ -69,7 +69,7 @@ function wallmessage_post(App $a) {
                        info(L10n::t('Message sent.') . EOL);
        }
 
-       goaway('profile/'.$user['nickname']);
+       $a->redirect('profile/'.$user['nickname']);
 }
 
 
index 5a29d55ed48a00855d5f7e1966a54cd7091df16a..98685802b525873fa846fc8f064266cc7f2e04d9 100644 (file)
@@ -1999,4 +1999,22 @@ class App
                /// @TODO Looks unsafe (remote-inclusion), is maybe not but Core\Theme::getPathForFile() uses file_exists() but does not escape anything
                require_once $template;
        }
+
+       /**
+        * Redirects to another URL and exits this process.
+        *
+        * @param string $toUrl The destination URL (Default is empty, which is the default page of the Friendica node)
+        * @param bool $ssl if true, base URL will try to get called with https:// (works just for relative paths)
+        */
+       public function redirect($toUrl = '', $ssl = false)
+       {
+               if (strstr(normalise_link($toUrl), 'http://')) {
+                       $redirectTo = $toUrl;
+               } else {
+                       $redirectTo = self::getApp()->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
+               }
+
+               header("Location: $redirectTo");
+               exit();
+       }
 }
index e77b1a1491e3714f2c1cef34a39dcc43166cb033..bb88b50ba3d64f77ee23d348a4b04bed3cc51f1a 100644 (file)
@@ -60,7 +60,8 @@ abstract class BaseModule extends BaseObject
         */
        public static function post()
        {
-               // goaway('module');
+               // $a = self::getApp();
+               // $a->redirect('module');
        }
 
        /**
index b2c17750da5a259cfa0b2d8566f9c7f305486f31..ca05a44d6573a4020353af42b682c9a27f4f4d5e 100644 (file)
@@ -239,7 +239,6 @@ class System extends BaseObject
        /// @todo Move the following functions from boot.php
        /*
        function killme()
-       function goaway($s)
        function local_user()
        function public_contact()
        function remote_user()
index e62084049e3240baed70bd218babf683686f048f..1056edf11b9e426b86a21104196ada41e9d2a1b6 100644 (file)
@@ -272,6 +272,6 @@ class UserImport
                Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', $newuid);
 
                info(L10n::t("Done. You can now login with your username and password"));
-               goaway(System::baseUrl() . "/login");
+               $a->redirect('login');
        }
 }
index 472875a80bc1a05088b1db840d1ac6518f9d654e..3851b7f4aa809dc2c6cbcdc31449104f9b40c0a5 100644 (file)
@@ -1639,7 +1639,7 @@ class Contact extends BaseObject
                                        $myaddr = bin2hex($a->user['nickname'] . '@' . $a->getHostName());
                                }
 
-                               goaway($ret['request'] . "&addr=$myaddr");
+                               $a->redirect($ret['request'] . "&addr=$myaddr");
 
                                // NOTREACHED
                        }
index f6fb3167d775cbe33d23dee5dfe296c4e335acc0..52ec5ccf0850570e3598f04145334f540fb01a40 100644 (file)
@@ -1047,7 +1047,7 @@ class Profile
                // Try to avoid recursion - but send them home to do a proper magic auth.
                $query = str_replace(array('?zrl=', '&zid='), array('?rzrl=', '&rzrl='), $a->query_string);
                // The other instance needs to know where to redirect.
-               $dest = urlencode(System::baseUrl() . '/' . $query);
+               $dest = urlencode($a->getBaseURL() . '/' . $query);
 
                // We need to extract the basebath from the profile url
                // to redirect the visitors '/magic' module.
@@ -1055,14 +1055,14 @@ class Profile
                $urlarr = explode('/profile/', $contact['url']);
                $basepath = $urlarr[0];
 
-               if ($basepath != System::baseUrl() && !strstr($dest, '/magic') && !strstr($dest, '/rmagic')) {
+               if ($basepath != $a->getBaseURL() && !strstr($dest, '/magic') && !strstr($dest, '/rmagic')) {
                        $magic_path = $basepath . '/magic' . '?f=&owa=1&dest=' . $dest;
 
                        // We have to check if the remote server does understand /magic without invoking something
                        $serverret = Network::curl($basepath . '/magic');
                        if ($serverret->isSuccess()) {
                                logger('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, LOGGER_DEBUG);
-                               goaway($magic_path);
+                               $a->redirect($magic_path);
                        }
                }
        }
index bca3e73f5dd6d898588f48dde020c6dd1d49f4ea..03c35d10138abac5502a4188c6d9dd3a3a15d8e7 100644 (file)
@@ -450,7 +450,7 @@ class User
                                } catch (Exception $e) {
                                        throw new Exception(L10n::t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . EOL . EOL . L10n::t('The error message was:') . $e->getMessage(), 0, $e);
                                }
-                               goaway($authurl);
+                               $a->redirect($authurl);
                                // NOTREACHED
                        }
 
@@ -783,6 +783,8 @@ class User
                        return;
                }
 
+               $a = get_app();
+
                logger('Removing user: ' . $uid);
 
                $user = DBA::selectFirst('user', [], ['uid' => $uid]);
@@ -807,7 +809,7 @@ class User
                if ($uid == local_user()) {
                        unset($_SESSION['authenticated']);
                        unset($_SESSION['uid']);
-                       goaway();;
+                       $a->redirect();
                }
        }
 }
index 29aa99140c5316948c5035d791b26ebb712dc805..7f956a8250243d604341f68cf1d4546a9324609a 100644 (file)
@@ -18,7 +18,7 @@ class Acctlink extends BaseModule
                        $url = defaults(Probe::uri(trim($addr)), 'url', false);
 
                        if ($url) {
-                               goaway($url);
+                               self::getApp()->redirect($url);
                                exit();
                        }
                }
index 0eb912e00a7b962d5c5f13bfcedc623d643f4f19..1aa2aa0fe8d6f91fb01572d6b7010d6587fd6984 100644 (file)
@@ -66,9 +66,9 @@ class Contact extends BaseModule
                if (DBA::isResult($contact)) {
                        if ($contact['self']) {
                                if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) {
-                                       goaway('profile/' . $contact['nick']);
+                                       $a->redirect('profile/' . $contact['nick']);
                                } else {
-                                       goaway('profile/' . $contact['nick'] . '?tab=profile');
+                                       $a->redirect('profile/' . $contact['nick'] . '?tab=profile');
                                }
                        }
 
@@ -168,7 +168,7 @@ class Contact extends BaseModule
                        info(L10n::tt('%d contact edited.', '%d contacts edited.', $count_actions));
                }
 
-               goaway('contact');
+               $a->redirect('contact');
        }
 
        public static function post()
@@ -191,7 +191,7 @@ class Contact extends BaseModule
 
                if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) {
                        notice(L10n::t('Could not access contact record.') . EOL);
-                       goaway('contact');
+                       $a->redirect('contact');
                        return; // NOTREACHED
                }
 
@@ -374,19 +374,19 @@ class Contact extends BaseModule
                        $orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false]);
                        if (!DBA::isResult($orig_record)) {
                                notice(L10n::t('Could not access contact record.') . EOL);
-                               goaway('contact');
+                               $a->redirect('contact');
                                return; // NOTREACHED
                        }
 
                        if ($cmd === 'update' && ($orig_record['uid'] != 0)) {
                                self::updateContactFromPoll($contact_id);
-                               goaway('contact/' . $contact_id);
+                               $a->redirect('contact/' . $contact_id);
                                // NOTREACHED
                        }
 
                        if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) {
                                self::updateContactFromProbe($contact_id);
-                               goaway('crepair/' . $contact_id);
+                               $a->redirect('crepair/' . $contact_id);
                                // NOTREACHED
                        }
 
@@ -396,7 +396,7 @@ class Contact extends BaseModule
                                $blocked = Model\Contact::isBlockedByUser($contact_id, local_user());
                                info(($blocked ? L10n::t('Contact has been blocked') : L10n::t('Contact has been unblocked')) . EOL);
 
-                               goaway('contact/' . $contact_id);
+                               $a->redirect('contact/' . $contact_id);
                                return; // NOTREACHED
                        }
 
@@ -406,7 +406,7 @@ class Contact extends BaseModule
                                $ignored = Model\Contact::isIgnoredByUser($contact_id, local_user());
                                info(($ignored ? L10n::t('Contact has been ignored') : L10n::t('Contact has been unignored')) . EOL);
 
-                               goaway('contact/' . $contact_id);
+                               $a->redirect('contact/' . $contact_id);
                                return; // NOTREACHED
                        }
 
@@ -417,7 +417,7 @@ class Contact extends BaseModule
                                        info((($archived) ? L10n::t('Contact has been archived') : L10n::t('Contact has been unarchived')) . EOL);
                                }
 
-                               goaway('contact/' . $contact_id);
+                               $a->redirect('contact/' . $contact_id);
                                return; // NOTREACHED
                        }
 
@@ -451,13 +451,13 @@ class Contact extends BaseModule
                                }
                                // Now check how the user responded to the confirmation query
                                if (!empty($_REQUEST['canceled'])) {
-                                       goaway('contact');
+                                       $a->redirect('contact');
                                }
 
                                self::dropContact($orig_record);
                                info(L10n::t('Contact has been removed.') . EOL);
 
-                               goaway('contact');
+                               $a->redirect('contact');
                                return; // NOTREACHED
                        }
                        if ($cmd === 'posts') {
index deb6afcfbc03e0dae8624f88ffe53a4918e03fb4..92b0daed13d2c40abc77f1bccd6227f76728d0ac 100644 (file)
@@ -10,6 +10,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Authentication;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\User;
 use Friendica\Util\DateTimeFormat;
@@ -39,7 +40,7 @@ class Login extends BaseModule
                }
 
                if (local_user()) {
-                       goaway(self::getApp()->getBaseURL());
+                       $a->redirect();
                }
 
                return self::form($_SESSION['return_url'], intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED);
@@ -83,10 +84,12 @@ class Login extends BaseModule
        {
                $noid = Config::get('system', 'no_openid');
 
+               $a = self::getApp();
+
                // if it's an email address or doesn't resolve to a URL, fail.
                if ($noid || strpos($openid_url, '@') || !Network::isUrlValid($openid_url)) {
                        notice(L10n::t('Login failed.') . EOL);
-                       goaway(self::getApp()->getBaseURL());
+                       $a->redirect();
                        // NOTREACHED
                }
 
@@ -98,7 +101,7 @@ class Login extends BaseModule
                        $_SESSION['openid'] = $openid_url;
                        $_SESSION['remember'] = $remember;
                        $openid->returnUrl = self::getApp()->getBaseURL(true) . '/openid';
-                       goaway($openid->authUrl());
+                       $a->redirect($openid->authUrl());
                } catch (Exception $e) {
                        notice(L10n::t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '<br /><br >' . L10n::t('The error message was:') . ' ' . $e->getMessage());
                }
@@ -122,6 +125,8 @@ class Login extends BaseModule
                        'user_record' => null
                ];
 
+               $a = self::getApp();
+
                /*
                 * An addon indicates successful login by setting 'authenticated' to non-zero value and returning a user record
                 * Addons should never set 'authenticated' except to indicate success - as hooks may be chained
@@ -144,7 +149,7 @@ class Login extends BaseModule
                } catch (Exception $e) {
                        logger('authenticate: failed login attempt: ' . notags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']);
                        info('Login failed. Please check your credentials.' . EOL);
-                       goaway('/');
+                       $a->redirect();
                }
 
                if (!$remember) {
@@ -163,7 +168,7 @@ class Login extends BaseModule
                        $return_url = '';
                }
 
-               goaway($return_url);
+               $a->redirect($return_url);
        }
 
        /**
@@ -173,6 +178,8 @@ class Login extends BaseModule
         */
        public static function sessionAuth()
        {
+               $a = self::getApp();
+
                // When the "Friendica" cookie is set, take the value to authenticate and renew the cookie.
                if (isset($_COOKIE["Friendica"])) {
                        $data = json_decode($_COOKIE["Friendica"]);
@@ -191,7 +198,7 @@ class Login extends BaseModule
                                        if ($data->hash != Authentication::getCookieHashForUser($user)) {
                                                logger("Hash for user " . $data->uid . " doesn't fit.");
                                                Authentication::deleteSession();
-                                               goaway(self::getApp()->getBaseURL());
+                                               $a->redirect();
                                        }
 
                                        // Renew the cookie
@@ -228,7 +235,7 @@ class Login extends BaseModule
                                        logger('Session address changed. Paranoid setting in effect, blocking session. ' .
                                                $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']);
                                        Authentication::deleteSession();
-                                       goaway(self::getApp()->getBaseURL());
+                                       $a->redirect();
                                }
 
                                $user = DBA::selectFirst('user', [],
@@ -242,7 +249,7 @@ class Login extends BaseModule
                                );
                                if (!DBA::isResult($user)) {
                                        Authentication::deleteSession();
-                                       goaway(self::getApp()->getBaseURL());
+                                       $a->redirect();
                                }
 
                                // Make sure to refresh the last login time for the user if the user
index b12ba10287ce30e70852b59ad4fe344cd62f49cb..e5198af858f29ea8d61fa256214751aa0cd2a1e3 100644 (file)
@@ -8,6 +8,7 @@ use Friendica\BaseModule;
 use Friendica\Core\Addon;
 use Friendica\Core\Authentication;
 use Friendica\Core\L10n;
+use Friendica\Core\System;
 
 require_once 'boot.php';
 
@@ -26,6 +27,6 @@ class Logout extends BaseModule
                Addon::callHooks("logging_out");
                Authentication::deleteSession();
                info(L10n::t('Logged out.') . EOL);
-               goaway(self::getApp()->getBaseURL());
+               self::getApp()->redirect();
        }
 }
index 768fe69ebbedb94e410f2d6de19e8ba9e55d82ba..97cdb648f337180267ea366b00949604386690df 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Util\HTTPSignature;
@@ -41,7 +42,7 @@ class Magic extends BaseModule
 
                if (!$cid) {
                        logger('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG);
-                       goaway($dest);
+                       $a->redirect($dest);
                }
 
                $contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
@@ -55,7 +56,7 @@ class Magic extends BaseModule
                        }
 
                        logger('Contact is already authenticated', LOGGER_DEBUG);
-                       goaway($dest);
+                       $a->redirect($dest);
                }
 
                if (local_user()) {
@@ -99,10 +100,10 @@ class Magic extends BaseModule
                                                $x = strpbrk($dest, '?&');
                                                $args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token);
 
-                                               goaway($dest . $args);
+                                               $a->redirect($dest . $args);
                                        }
                                }
-                               goaway($dest);
+                               $a->redirect($dest);
                        }
                }
 
@@ -111,6 +112,6 @@ class Magic extends BaseModule
                        return $ret;
                }
 
-               goaway($dest);
+               $a->redirect($dest);
        }
 }
index ba9dace2e567295d825c908e364a6cf533a5e561..0f9493db61d9384433852add315a2cce96085af5 100644 (file)
@@ -24,7 +24,7 @@ class Objects extends BaseModule
                }
 
                if (!ActivityPub::isRequest()) {
-                       goaway(str_replace('objects/', 'display/', $a->query_string));
+                       $a->redirect(str_replace('objects/', 'display/', $a->query_string));
                }
 
                $item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'wall' => true, 'private' => false]);
index e8a152b5078f28577d1dd77a8914e6cc6d2456af..055fdb88b9353efc87e7a9bef71ef8f3307d4f4c 100644 (file)
@@ -49,7 +49,7 @@ class Tos extends BaseModule
        public static function init()
        {
                if (strlen(Config::get('system','singleuser'))) {
-                       goaway(System::baseUrl()."/profile/" . Config::get('system','singleuser'));
+                       self::getApp()->redirect('profile/' . Config::get('system','singleuser'));
                }
        }
        /**
index 21a0f4394491345d755225baf45e48b62f4ac67a..be91651f2a2461ad6234d35c3f88d4eec01a5617 100644 (file)
@@ -3037,7 +3037,7 @@ class DFRN
 
                        logger('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
                        $dest = (($url) ? '&destination_url=' . $url : '');
-                       goaway($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
+                       $a->redirect($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
                                . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest);
                }
 
index 4d6d6f082be26f57355d27c483fc61853ba17c4a..c509c7d2a4233b3ea69ab5b7a6d823246ae357da 100644 (file)
@@ -3379,7 +3379,7 @@ class ApiTest extends DatabaseTest
         */
        public function testApiFriendicaRemoteauthWithCorrectUrl()
        {
-               $this->markTestIncomplete("We can't use an assertion here because of goaway().");
+               $this->markTestIncomplete("We can't use an assertion here because of App->redirect().");
                $_GET['url'] = 'url';
                $_GET['c_url'] = $this->selfUser['nurl'];
                api_friendica_remoteauth();