From d00ddc01afdef3e626ae0e711e52f830cbdf923a Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Fri, 19 Oct 2018 20:11:27 +0200 Subject: [PATCH] Split goaway to System::externalRedirectTo() and App->internalRedirect() --- include/api.php | 3 +- include/items.php | 8 ++--- mod/admin.php | 58 +++++++++++++++++------------------ mod/api.php | 2 +- mod/cal.php | 4 +-- mod/delegate.php | 8 ++--- mod/dfrn_confirm.php | 4 +-- mod/dfrn_poll.php | 60 +++++++++++++++++++------------------ mod/dfrn_request.php | 20 ++++++------- mod/display.php | 2 +- mod/events.php | 8 ++--- mod/filerm.php | 2 +- mod/follow.php | 20 ++++++------- mod/group.php | 12 ++++---- mod/home.php | 4 +-- mod/ignored.php | 2 +- mod/item.php | 16 +++++----- mod/like.php | 2 +- mod/lostpass.php | 6 ++-- mod/manage.php | 2 +- mod/message.php | 12 ++++---- mod/network.php | 8 ++--- mod/nogroup.php | 2 +- mod/notice.php | 2 +- mod/notifications.php | 6 ++-- mod/notify.php | 4 +-- mod/openid.php | 12 ++++---- mod/ostatus_subscribe.php | 2 +- mod/photos.php | 20 ++++++------- mod/profile.php | 2 +- mod/profile_photo.php | 8 ++--- mod/profiles.php | 14 ++++----- mod/randprof.php | 4 +-- mod/redir.php | 16 +++++----- mod/register.php | 8 ++--- mod/regmod.php | 4 +-- mod/removeme.php | 2 +- mod/repair_ostatus.php | 2 +- mod/settings.php | 14 ++++----- mod/starred.php | 2 +- mod/tagrm.php | 16 +++++----- mod/toggle_mobile.php | 2 +- mod/unfollow.php | 18 +++++------ mod/videos.php | 8 ++--- mod/wallmessage.php | 2 +- src/App.php | 17 ++++++----- src/BaseModule.php | 4 +-- src/Core/Authentication.php | 2 +- src/Core/System.php | 18 +++++++++++ src/Core/UserImport.php | 2 +- src/Model/Contact.php | 6 ++-- src/Model/Profile.php | 2 +- src/Model/User.php | 4 +-- src/Module/Acctlink.php | 3 +- src/Module/Contact.php | 24 +++++++-------- src/Module/Login.php | 19 ++++++------ src/Module/Logout.php | 2 +- src/Module/Magic.php | 10 +++---- src/Module/Objects.php | 2 +- src/Module/Tos.php | 2 +- src/Protocol/DFRN.php | 2 +- 61 files changed, 286 insertions(+), 266 deletions(-) diff --git a/include/api.php b/include/api.php index c746ff0b61..e6846c8f63 100644 --- a/include/api.php +++ b/include/api.php @@ -4810,8 +4810,7 @@ function api_friendica_remoteauth() logger($contact['name'] . ' ' . $sec, LOGGER_DEBUG); $dest = ($url ? '&destination_url=' . $url : ''); - $app = get_app(); - $app->redirect( + System::externalRedirect(( $contact['poll'] . '?dfrn_id=' . $dfrn_id . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest diff --git a/include/items.php b/include/items.php index 0847dd65b6..54ae7a82ce 100644 --- a/include/items.php +++ b/include/items.php @@ -354,7 +354,7 @@ function drop_item($id) if (!DBA::isResult($item)) { notice(L10n::t('Item not found.') . EOL); - $a->redirect('network'); + $a->internalRedirect('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'])) { - $a->redirect('display/' . $item['guid']); + $a->internalRedirect('display/' . $item['guid']); } // delete the item Item::deleteForUser(['id' => $item['id']], local_user()); - $a->redirect('network'); + $a->internalRedirect('network'); //NOTREACHED } else { notice(L10n::t('Permission denied.') . EOL); - $a->redirect('display/' . $item['guid']); + $a->internalRedirect('display/' . $item['guid']); //NOTREACHED } } diff --git a/mod/admin.php b/mod/admin.php index fb4c923209..39a28158c1 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -82,7 +82,7 @@ function admin_post(App $a) if ($a->isAjax()) { return; } - $a->redirect('admin/'); + $a->internalRedirect('admin/'); return; } @@ -135,7 +135,7 @@ function admin_post(App $a) } } - $a->redirect($return_path); + $a->internalRedirect($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); - $a->redirect('admin/tos'); + $a->internalRedirect('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); } - $a->redirect('admin/blocklist'); + $a->internalRedirect('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))); } - $a->redirect('admin/contactblock'); + $a->internalRedirect('admin/contactblock'); return; // NOTREACHED } @@ -569,7 +569,7 @@ function admin_page_deleteitem_post(App $a) } info(L10n::t('Item marked for deletion.') . EOL); - $a->redirect('admin/deleteitem'); + $a->internalRedirect('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 ://")); - $a->redirect('admin/site'); + $a->internalRedirect('admin/site'); } /* steps: @@ -973,13 +973,13 @@ function admin_page_site_post(App $a) * send relocate for every local user * */ - $old_url = System::baseUrl(true); + $old_url = $a->getBaseURL(true); // Generate host names for relocation the addresses in the format user@address.tld $new_host = str_replace("http://", "@", normalise_link($new_url)); $old_host = str_replace("http://", "@", normalise_link($old_url)); - function update_table($table_name, $fields, $old_url, $new_url) + function update_table(App $a, $table_name, $fields, $old_url, $new_url) { $dbold = DBA::escape($old_url); $dbnew = DBA::escape($new_url); @@ -995,20 +995,20 @@ function admin_page_site_post(App $a) if (!DBA::isResult($r)) { notice("Failed updating '$table_name': " . DBA::errorMessage()); - $a->redirect('admin/site'); + $a->internalRedirect('admin/site'); } } // update tables // update profile links in the format "http://server.tld" - update_table("profile", ['photo', 'thumb'], $old_url, $new_url); - update_table("term", ['url'], $old_url, $new_url); - update_table("contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url); - update_table("gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url); - update_table("item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url); + update_table($a, "profile", ['photo', 'thumb'], $old_url, $new_url); + update_table($a, "term", ['url'], $old_url, $new_url); + update_table($a, "contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url); + update_table($a, "gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url); + update_table($a, "item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url); // update profile addresses in the format "user@server.tld" - update_table("contact", ['addr'], $old_host, $new_host); - update_table("gcontact", ['connect', 'addr'], $old_host, $new_host); + update_table($a, "contact", ['addr'], $old_host, $new_host); + update_table($a, "gcontact", ['connect', 'addr'], $old_host, $new_host); // update config Config::set('system', 'hostname', parse_url($new_url, PHP_URL_HOST)); @@ -1024,7 +1024,7 @@ function admin_page_site_post(App $a) info("Relocation started. Could take a while to complete."); - $a->redirect('admin/site'); + $a->internalRedirect('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); - $a->redirect('admin/site'); + $a->internalRedirect('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); - $a->redirect('admin/dbsync'); + $a->internalRedirect('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); } } - $a->redirect('admin/users'); + $a->internalRedirect('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); - $a->redirect('admin/users'); + $a->internalRedirect('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; } - $a->redirect('admin/users'); + $a->internalRedirect('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)); - $a->redirect('admin/addons'); + $a->internalRedirect('admin/addons'); return ''; // NOTREACHED } @@ -2045,7 +2045,7 @@ function admin_page_addons(App $a) BaseModule::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/addons', 'admin_themes', 't'); Addon::reload(); info("Addons reloaded"); - $a->redirect('admin/addons'); + $a->internalRedirect('admin/addons'); } $addons = []; @@ -2235,7 +2235,7 @@ function admin_page_themes(App $a) } Config::set('system', 'allowed_themes', $s); - $a->redirect('admin/themes'); + $a->internalRedirect('admin/themes'); return ''; // NOTREACHED } @@ -2316,7 +2316,7 @@ function admin_page_themes(App $a) } } info("Themes reloaded"); - $a->redirect('admin/themes'); + $a->internalRedirect('admin/themes'); } /* @@ -2365,7 +2365,7 @@ function admin_page_logs_post(App $a) } info(L10n::t("Log settings updated.")); - $a->redirect('admin/logs'); + $a->internalRedirect('admin/logs'); return; // NOTREACHED } @@ -2513,7 +2513,7 @@ function admin_page_features_post(App $a) } } - $a->redirect('admin/features'); + $a->internalRedirect('admin/features'); return; // NOTREACHED } diff --git a/mod/api.php b/mod/api.php index df921dfbc8..716b484461 100644 --- a/mod/api.php +++ b/mod/api.php @@ -77,7 +77,7 @@ function api_content(App $a) if (strstr($consumer->callback_url, $glue)) { $glue = "?"; } - $a->redirect($consumer->callback_url . $glue . 'oauth_token=' . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . '&oauth_verifier=' . OAuthUtil::urlencode_rfc3986($verifier)); + $a->internalRedirect($consumer->callback_url . $glue . 'oauth_token=' . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . '&oauth_verifier=' . OAuthUtil::urlencode_rfc3986($verifier)); killme(); } diff --git a/mod/cal.php b/mod/cal.php index b356a295cb..6f483acc16 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -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); - $a->redirect('cal/' . $nick); + $a->internalRedirect('cal/' . $nick); } // Get the export data by uid @@ -322,7 +322,7 @@ function cal_content(App $a) $return_path = "cal/" . $nick; } - $a->redirect($return_path); + $a->internalRedirect($return_path); } // If nothing went wrong we can echo the export content diff --git a/mod/delegate.php b/mod/delegate.php index e525e1ab80..e38ce058e5 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -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')) { - $a->redirect('delegate'); + $a->internalRedirect('delegate'); } $user_id = $a->argv[2]; @@ -77,17 +77,17 @@ function delegate_content(App $a) DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]); } } - $a->redirect('delegate'); + $a->internalRedirect('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')) { - $a->redirect('delegate'); + $a->internalRedirect('delegate'); } DBA::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]); - $a->redirect('delegate'); + $a->internalRedirect('delegate'); } // find everybody that currently has delegated management to this account/page diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 3345bca611..f685d9e237 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -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) { - $a->redirect('contact/' . intval($contact_id)); + $a->internalRedirect('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. - $a->redirect(); + $a->internalRedirect(); // NOTREACHED } diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index af6d000268..4e7521b0ed 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -90,7 +90,7 @@ function dfrn_poll_init(App $a) $my_id = '0:' . $dfrn_id; break; default: - $a->redirect(); + $a->internalRedirect(); break; // NOTREACHED } @@ -109,7 +109,7 @@ function dfrn_poll_init(App $a) if (strlen($s)) { $xml = XML::parseString($s); - if ((int) $xml->status === 1) { + if ((int)$xml->status === 1) { $_SESSION['authenticated'] = 1; if (!x($_SESSION, 'remote')) { $_SESSION['remote'] = []; @@ -135,10 +135,15 @@ function dfrn_poll_init(App $a) ); } } - $profile = $r[0]['nickname']; - $a->redirect((strlen($destination_url)) ? $destination_url : 'profile/' . $profile); + + $profile = (count($r) > 0 && isset($r[0]['nickname']) ? $r[0]['nickname'] : ''); + if (!empty($destination_url)) { + System::externalRedirect($destination_url); + } else { + $a->internalRedirect('profile/' . $profile); + } } - $a->redirect(); + $a->internalRedirect(); } if ($type === 'profile-check' && $dfrn_version < 2.2) { @@ -325,7 +330,7 @@ function dfrn_poll_post(App $a) $my_id = '0:' . $dfrn_id; break; default: - $a->redirect(); + $a->internalRedirect(); break; // NOTREACHED } @@ -446,7 +451,7 @@ function dfrn_poll_content(App $a) $my_id = '0:' . $dfrn_id; break; default: - $a->redirect(); + $a->internalRedirect(); break; // NOTREACHED } @@ -505,25 +510,6 @@ function dfrn_poll_content(App $a) ])->getBody(); } - $profile = ((DBA::isResult($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname); - - switch ($destination_url) { - case 'profile': - $dest = 'profile/' . $profile . '?f=&tab=profile'; - break; - case 'photos': - $dest = 'photos/' . $profile; - break; - case 'status': - case '': - $dest = 'profile/' . $profile; - break; - default: - $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1'); - $dest = $destination_url . $appendix; - break; - } - logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); if (strlen($s) && strstr($s, 'redirect($dest); } - $a->redirect($dest); + + $profile = ((DBA::isResult($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname); + + switch ($destination_url) { + case 'profile': + $a->internalRedirect('profile/' . $profile . '?f=&tab=profile'; + break; + case 'photos': + $a->internalRedirect('photos/' . $profile; + break; + case 'status': + case '': + $a->internalRedirect('profile/' . $profile; + break; + default: + $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1'); + System::externalRedirect($destination_url . $appendix); + break; + } // NOTREACHED } else { // XML reply diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index c74df9a7d6..645f625c3c 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -62,7 +62,7 @@ function dfrn_request_post(App $a) } if (x($_POST, 'cancel')) { - $a->redirect(); + $a->internalRedirect(); } /* @@ -188,14 +188,14 @@ function dfrn_request_post(App $a) } // (ignore reply, nothing we can do it failed) - $a->redirect($forwardurl); + $a->internalRedirect($forwardurl); return; // NOTREACHED } } // invalid/bogus request notice(L10n::t('Unrecoverable protocol error.') . EOL); - $a->redirect(); + $a->internalRedirect(); 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); - $a->redirect($a->cmd); + $a->internalRedirect($a->cmd); return; // NOTREACHED } if (!Network::isUrlAllowed($url)) { notice(L10n::t('Disallowed profile URL.') . EOL); - $a->redirect($a->cmd); + $a->internalRedirect($a->cmd); return; // NOTREACHED } if (Network::isUrlBlocked($url)) { notice(L10n::t('Blocked domain') . EOL); - $a->redirect($a->cmd); + $a->internalRedirect($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); - $a->redirect($a->cmd); + $a->internalRedirect($a->cmd); } else { if (!x($parms, 'fn')) { notice(L10n::t('Warning: profile location has no identifiable owner name.') . EOL); @@ -433,10 +433,10 @@ function dfrn_request_post(App $a) } // "Homecoming" - send the requestor back to their site to record the introduction. - $dfrn_url = bin2hex(System::baseUrl() . '/profile/' . $nickname); + $dfrn_url = bin2hex($a->getBaseURL() . '/profile/' . $nickname); $aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0); - $a->redirect($parms['dfrn-request'] . "?dfrn_url=$dfrn_url" + System::externalRedirect($parms['dfrn-request'] . "?dfrn_url=$dfrn_url" . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&confirm_key=' . $hash . (($aes_allow) ? "&aes_allow=1" : "") @@ -463,7 +463,7 @@ function dfrn_request_post(App $a) } $url = str_replace('{uri}', $uri, $url); - $a->redirect($url); + System::externalRedirect($url); // NOTREACHED // END $network != Protocol::PHANTOM } else { diff --git a/mod/display.php b/mod/display.php index f1ffad7b7c..38cdfe41d3 100644 --- a/mod/display.php +++ b/mod/display.php @@ -79,7 +79,7 @@ function display_init(App $a) } if (ActivityPub::isRequest()) { - $a->redirect(str_replace('display/', 'objects/', $a->query_string)); + $a->internalRedirect(str_replace('display/', 'objects/', $a->query_string)); } if ($item["id"] != $item["parent"]) { diff --git a/mod/events.php b/mod/events.php index e1f0678e45..9a0da74dcd 100644 --- a/mod/events.php +++ b/mod/events.php @@ -108,7 +108,7 @@ function events_post(App $a) echo L10n::t('Event can not end before it has started.'); killme(); } - $a->redirect($onerror_url); + $a->internalRedirect($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(); } - $a->redirect($onerror_url); + $a->internalRedirect($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); } - $a->redirect('events'); + $a->internalRedirect('events'); } function events_content(App $a) @@ -577,6 +577,6 @@ function events_content(App $a) info(L10n::t('Event removed') . EOL); } - $a->redirect('events'); + $a->internalRedirect('events'); } } diff --git a/mod/filerm.php b/mod/filerm.php index d56890999c..733d67b593 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -25,7 +25,7 @@ function filerm_content(App $a) { file_tag_unsave_file(local_user(),$item_id,$term, $category); } - //$a->redirect('network'); + //$a->internalRedirect('network'); killme(); } diff --git a/mod/follow.php b/mod/follow.php index 572eea1da6..0c91e09512 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -20,7 +20,7 @@ function follow_post(App $a) } if (isset($_REQUEST['cancel'])) { - $a->redirect('contacts'); + $a->internalRedirect('contacts'); } $uid = local_user(); @@ -37,14 +37,14 @@ function follow_post(App $a) if ($result['message']) { notice($result['message']); } - $a->redirect($return_url); + $a->internalRedirect($return_url); } elseif ($result['cid']) { - $a->redirect('contact/' . $result['cid']); + $a->internalRedirect('contact/' . $result['cid']); } info(L10n::t('The contact could not be added.')); - $a->redirect($return_url); + $a->internalRedirect($return_url); // NOTREACHED } @@ -54,7 +54,7 @@ function follow_content(App $a) if (!local_user()) { notice(L10n::t('Permission denied.')); - $a->redirect($return_url); + $a->internalRedirect($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 = ''; - //$a->redirect($_SESSION['return_url']); + //$a->internalRedirect($_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 = ''; - //$a->redirect($_SESSION['return_url']); + //$a->internalRedirect($_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 = ''; - //$a->redirect($_SESSION['return_url']); + //$a->internalRedirect($_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 = ''; - //$a->redirect($_SESSION['return_url']); + //$a->internalRedirect($_SESSION['return_url']); // NOTREACHED } @@ -118,7 +118,7 @@ function follow_content(App $a) if (!$r) { notice(L10n::t('Permission denied.')); - $a->redirect($return_url); + $a->internalRedirect($return_url); // NOTREACHED } diff --git a/mod/group.php b/mod/group.php index beae6a52e1..404448ebb7 100644 --- a/mod/group.php +++ b/mod/group.php @@ -38,12 +38,12 @@ function group_post(App $a) { info(L10n::t('Group created.') . EOL); $r = Model\Group::getIdByName(local_user(), $name); if ($r) { - $a->redirect('group/' . $r); + $a->internalRedirect('group/' . $r); } } else { notice(L10n::t('Could not create group.') . EOL); } - $a->redirect('group'); + $a->internalRedirect('group'); return; // NOTREACHED } @@ -56,7 +56,7 @@ function group_post(App $a) { ); if (!DBA::isResult($r)) { notice(L10n::t('Group not found.') . EOL); - $a->redirect('contact'); + $a->internalRedirect('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) { - $a->redirect('group/none'); + $a->internalRedirect('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); } } - $a->redirect('group'); + $a->internalRedirect('group'); // NOTREACHED } @@ -183,7 +183,7 @@ function group_content(App $a) { if (!DBA::isResult($r)) { notice(L10n::t('Group not found.') . EOL); - $a->redirect('contact'); + $a->internalRedirect('contact'); } $group = $r[0]; diff --git a/mod/home.php b/mod/home.php index 868bc9e488..bf5b5d27ff 100644 --- a/mod/home.php +++ b/mod/home.php @@ -16,11 +16,11 @@ function home_init(App $a) { Addon::callHooks('home_init',$ret); if (local_user() && ($a->user['nickname'])) { - $a->redirect('network'); + $a->internalRedirect('network'); } if (strlen(Config::get('system','singleuser'))) { - $a->redirect('profile/' . Config::get('system','singleuser')); + $a->internalRedirect('profile/' . Config::get('system','singleuser')); } }} diff --git a/mod/ignored.php b/mod/ignored.php index c433313165..4f14119fef 100644 --- a/mod/ignored.php +++ b/mod/ignored.php @@ -43,7 +43,7 @@ function ignored_init(App $a) $rand = "?$rand"; } - $a->redirect($return_path . $rand); + $a->internalRedirect($return_path . $rand); } // the json doesn't really matter, it will either be 0 or 1 diff --git a/mod/item.php b/mod/item.php index bc978c9d8d..cd64b70f85 100644 --- a/mod/item.php +++ b/mod/item.php @@ -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'])) { - $a->redirect($return_path); + $a->internalRedirect($return_path); } killme(); } @@ -165,7 +165,7 @@ function item_post(App $a) { notice(L10n::t('Permission denied.') . EOL) ; if (!empty($_REQUEST['return'])) { - $a->redirect($return_path); + $a->internalRedirect($return_path); } killme(); @@ -283,7 +283,7 @@ function item_post(App $a) { } info(L10n::t('Empty post discarded.') . EOL); if (!empty($_REQUEST['return'])) { - $a->redirect($return_path); + $a->internalRedirect($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) { - $a->redirect($return_path); + $a->internalRedirect($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); - $a->redirect($return_path); + $a->internalRedirect($return_path); } killme(); } else { @@ -729,14 +729,14 @@ function item_post(App $a) { if (!$post_id) { logger("Item wasn't stored."); - $a->redirect($return_path); + $a->internalRedirect($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."); - $a->redirect($return_path); + $a->internalRedirect($return_path); } // update filetags in pconfig @@ -851,7 +851,7 @@ function item_post_return($baseurl, $api_source, $return_path) } if ($return_path) { - $a->redirect($return_path); + $a->internalRedirect($return_path); } $json = ['success' => 1]; diff --git a/mod/like.php b/mod/like.php index a2617494de..296e563bf4 100644 --- a/mod/like.php +++ b/mod/like.php @@ -45,7 +45,7 @@ function like_content_return(App $a, $return_path) { $rand = "?$rand"; } - $a->redirect($return_path . $rand); + $a->internalRedirect($return_path . $rand); } killme(); diff --git a/mod/lostpass.php b/mod/lostpass.php index 22172082a8..9cde1c9ff4 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -19,14 +19,14 @@ function lostpass_post(App $a) { $loginame = notags(trim($_POST['login-name'])); if (!$loginame) { - $a->redirect(); + $a->internalRedirect(); } $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); - $a->redirect(); + $a->internalRedirect(); } $pwdreset_token = autoname(12) . mt_rand(1000, 9999); @@ -78,7 +78,7 @@ function lostpass_post(App $a) 'body' => $body ]); - $a->redirect(); + $a->internalRedirect(); } function lostpass_content(App $a) diff --git a/mod/manage.php b/mod/manage.php index 2b0dfa8da7..b5aed6f8b3 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -119,7 +119,7 @@ function manage_post(App $a) { $ret = []; Addon::callHooks('home_init',$ret); - $a->redirect('profile/' . $a->user['nickname'] ); + $a->internalRedirect('profile/' . $a->user['nickname'] ); // NOTREACHED } diff --git a/mod/message.php b/mod/message.php index fc9fafceb4..418dfc080d 100644 --- a/mod/message.php +++ b/mod/message.php @@ -87,7 +87,7 @@ function message_post(App $a) $a->argc = 2; $a->argv[1] = 'new'; } else { - $a->redirect($a->cmd . '/' . $ret); + $a->internalRedirect($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'])) { - $a->redirect('message'); + $a->internalRedirect('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); - $a->redirect('message'); + $a->internalRedirect('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); - $a->redirect('message'); + $a->internalRedirect('message'); } - $a->redirect('message/' . $conversation['id'] ); + $a->internalRedirect('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); } } - $a->redirect('message'); + $a->internalRedirect('message'); } } diff --git a/mod/network.php b/mod/network.php index 06d5dbd2f9..b697cb3a63 100644 --- a/mod/network.php +++ b/mod/network.php @@ -38,7 +38,7 @@ function network_init(App $a) $search = (x($_GET, 'search') ? escape_tags($_GET['search']) : ''); if (($search != '') && !empty($_GET['submit'])) { - $a->redirect('search?search=' . urlencode($search)); + $a->internalRedirect('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); - $a->redirect($redir_url); + $a->internalRedirect($redir_url); } } @@ -618,7 +618,7 @@ function networkThreadedView(App $a, $update, $parent) killme(); } notice(L10n::t('No such group') . EOL); - $a->redirect('network/0'); + $a->internalRedirect('network/0'); // NOTREACHED } @@ -672,7 +672,7 @@ function networkThreadedView(App $a, $update, $parent) } } else { notice(L10n::t('Invalid contact.') . EOL); - $a->redirect('network'); + $a->internalRedirect('network'); // NOTREACHED } } diff --git a/mod/nogroup.php b/mod/nogroup.php index ff292a21ca..438c4ff440 100644 --- a/mod/nogroup.php +++ b/mod/nogroup.php @@ -24,5 +24,5 @@ function nogroup_content(App $a) return ''; } - $a->redirect('group/none'); + $a->internalRedirect('group/none'); } diff --git a/mod/notice.php b/mod/notice.php index 199c6d1b5d..b40f0ee69c 100644 --- a/mod/notice.php +++ b/mod/notice.php @@ -15,7 +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']; - $a->redirect('display/' . $nick . '/' . $id); + $a->internalRedirect('display/' . $nick . '/' . $id); } else { $a->error = 404; notice(L10n::t('Item not found.') . EOL); diff --git a/mod/notifications.php b/mod/notifications.php index 8de26aaf2d..d5cfbf276d 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -17,7 +17,7 @@ use Friendica\Module\Login; function notifications_post(App $a) { if (!local_user()) { - $a->redirect(); + $a->internalRedirect(); } $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); } - $a->redirect('notifications/intros'); + $a->internalRedirect('notifications/intros'); } if ($_POST['submit'] == L10n::t('Ignore')) { DBA::update('intro', ['ignore' => true], ['id' => $intro_id]); - $a->redirect('notifications/intros'); + $a->internalRedirect('notifications/intros'); } } } diff --git a/mod/notify.php b/mod/notify.php index 4f9aa62fa1..6ec36d8f99 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -37,10 +37,10 @@ function notify_init(App $a) } } - $a->redirect($note['link']); + System::externalRedirect($note['link']); } - $a->redirect(); + $a->internalRedirect(); } if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') { diff --git a/mod/openid.php b/mod/openid.php index 3e9486a6d8..93a07a4b43 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -14,7 +14,7 @@ function openid_content(App $a) { $noid = Config::get('system','no_openid'); if($noid) - $a->redirect(); + $a->internalRedirect(); 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); - $a->redirect(); + $a->internalRedirect(); } // 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 - $a->redirect(); + $a->internalRedirect(); } // 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); - $a->redirect(); + $a->internalRedirect(); } unset($_SESSION['register']); @@ -108,12 +108,12 @@ function openid_content(App $a) { $args .= '&openid_url=' . urlencode(notags(trim($authid))); - $a->redirect('register?' . $args); + $a->internalRedirect('register?' . $args); // NOTREACHED } } notice(L10n::t('Login failed.') . EOL); - $a->redirect(); + $a->internalRedirect(); // NOTREACHED } diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index d5d07d6707..7fce9d0b69 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -15,7 +15,7 @@ function ostatus_subscribe_content(App $a) { if (! local_user()) { notice(L10n::t('Permission denied.') . EOL); - $a->redirect('ostatus_subscribe'); + $a->internalRedirect('ostatus_subscribe'); // NOTREACHED } diff --git a/mod/photos.php b/mod/photos.php index 3851e00bb6..0c77504e1a 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -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')) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_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); - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); return; // NOTREACHED } // Check if the user has responded to a delete confirmation query if (!empty($_REQUEST['canceled'])) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); } // RENAME photo album @@ -227,7 +227,7 @@ function photos_post(App $a) // Update the photo albums cache Photo::clearAlbumCache($page_owner_uid); - $a->redirect('photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum)); + $a->internalRedirect('photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum)); return; // NOTREACHED } @@ -280,7 +280,7 @@ function photos_post(App $a) $res[] = "'" . DBA::escape($rr['rid']) . "'" ; } } else { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); return; // NOTREACHED } @@ -298,14 +298,14 @@ function photos_post(App $a) Photo::clearAlbumCache($page_owner_uid); } - $a->redirect('photos/' . $a->data['user']['nickname']); + $a->internalRedirect('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'])) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); } if ($a->argc > 2 && defaults($_POST, 'delete', '') === L10n::t('Delete Photo')) { @@ -355,7 +355,7 @@ function photos_post(App $a) Photo::clearAlbumCache($page_owner_uid); } - $a->redirect('photos/' . $a->data['user']['nickname']); + $a->internalRedirect('photos/' . $a->data['user']['nickname']); return; // NOTREACHED } @@ -696,7 +696,7 @@ function photos_post(App $a) } } } - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); return; // NOTREACHED } @@ -927,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 - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); // NOTREACHED } diff --git a/mod/profile.php b/mod/profile.php index 238af8d96e..6f0ab9e077 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -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)) { - $a->redirect('profile/' . $r[0]['nickname']); + $a->internalRedirect('profile/' . $r[0]['nickname']); } else { logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG); notice(L10n::t('Requested profile is not available.') . EOL); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 7006349a64..beed99d117 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -74,7 +74,7 @@ function profile_photo_post(App $a) $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = %d LIMIT 1", DBA::escape($image_id), DBA::escape(local_user()), intval($scale)); - $url = System::baseUrl() . '/profile/' . $a->user['nickname']; + $url = 'profile/' . $a->user['nickname']; if (DBA::isResult($r)) { $base_image = $r[0]; @@ -135,7 +135,7 @@ function profile_photo_post(App $a) } } - $a->redirect($url); + $a->internalRedirect($url); return; // NOTREACHED } @@ -168,7 +168,7 @@ function profile_photo_post(App $a) @unlink($src); $imagecrop = profile_photo_crop_ui_head($a, $ph); - $a->redirect('profile_photo/use/' . $imagecrop['hash']); + $a->internalRedirect('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); } - $a->redirect('profile/' . $a->user['nickname']); + $a->internalRedirect('profile/' . $a->user['nickname']); return; // NOTREACHED } $ph = new Image($r[0]['data'], $r[0]['type']); diff --git a/mod/profiles.php b/mod/profiles.php index 6f75879fec..734b5f19ee 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -38,7 +38,7 @@ function profiles_init(App $a) { ); if (! DBA::isResult($r)) { notice(L10n::t('Profile not found.') . EOL); - $a->redirect('profiles'); + $a->internalRedirect('profiles'); return; // NOTREACHED } @@ -59,7 +59,7 @@ function profiles_init(App $a) { info(L10n::t('Profile deleted.').EOL); } - $a->redirect('profiles'); + $a->internalRedirect('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) { - $a->redirect('profiles/' . $r3[0]['id']); + $a->internalRedirect('profiles/' . $r3[0]['id']); } - $a->redirect('profiles'); + $a->internalRedirect('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)) { - $a->redirect('profiles/'.$r3[0]['id']); + $a->internalRedirect('profiles/'.$r3[0]['id']); } - $a->redirect('profiles'); + $a->internalRedirect('profiles'); return; // NOTREACHED } @@ -654,7 +654,7 @@ function profiles_content(App $a) { ); if (DBA::isResult($r)) { //Go to the default profile. - $a->redirect('profiles/' . $r[0]['id']); + $a->internalRedirect('profiles/' . $r[0]['id']); } } diff --git a/mod/randprof.php b/mod/randprof.php index 13944c128f..4da149afdc 100644 --- a/mod/randprof.php +++ b/mod/randprof.php @@ -13,8 +13,8 @@ function randprof_init(App $a) $x = GContact::getRandomUrl(); if ($x) { - $a->redirect(Contact::magicLink($x)); + $a->internalRedirect(Contact::magicLink($x)); } - $a->redirect('profile'); + $a->internalRedirect('profile'); } diff --git a/mod/redir.php b/mod/redir.php index 726e8619ec..3336f882ad 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -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.')); - $a->redirect(); + $a->internalRedirect(); } $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. { - $a->redirect($url != '' ? $url : $contact_url); + System::externalRedirect($url != '' ? $url : $contact_url); } if ($contact['uid'] == 0 && local_user()) { @@ -52,12 +52,12 @@ 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); - $a->redirect($target_url); + System::externalRedirect($target_url); } } if (remote_user()) { - $host = substr(System::baseUrl() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''), strpos(System::baseUrl(), '://') + 3); + $host = substr($a->getBaseURL() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''), strpos($a->getBaseURL(), '://') + 3); $remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1); // On a local instance we have to check if the local user has already authenticated @@ -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); - $a->redirect($target_url); + System::externalRedirect($target_url); } } } @@ -102,7 +102,7 @@ function redir_init(App $a) { $dest = (!empty($url) ? '&destination_url=' . $url : ''); - $a->redirect($contact['poll'] . '?dfrn_id=' . $dfrn_id + System::externalRedirect($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); - $a->redirect($url); + $a->internalRedirect($url); } notice(L10n::t('Contact not found.')); - $a->redirect(); + $a->internalRedirect(); } diff --git a/mod/register.php b/mod/register.php index c3231cda69..0a139ad752 100644 --- a/mod/register.php +++ b/mod/register.php @@ -100,7 +100,7 @@ function register_post(App $a) if ($res) { info(L10n::t('Registration successful. Please check your email for further instructions.') . EOL); - $a->redirect(); + $a->internalRedirect(); } else { notice( L10n::t('Failed to send email message. Here your accout details:
login: %s
password: %s

You can change your password after login.', @@ -111,12 +111,12 @@ function register_post(App $a) } } else { info(L10n::t('Registration successful.') . EOL); - $a->redirect(); + $a->internalRedirect(); } } 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); - $a->redirect(); + $a->internalRedirect(); } 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); - $a->redirect(); + $a->internalRedirect(); } return; diff --git a/mod/regmod.php b/mod/regmod.php index d2fc4c0602..a7aebf6b0a 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -101,11 +101,11 @@ function regmod_content(App $a) if ($cmd === 'deny') { user_deny($hash); - $a->redirect('admin/users/'); + $a->internalRedirect('admin/users/'); } if ($cmd === 'allow') { user_allow($hash); - $a->redirect('admin/users/'); + $a->internalRedirect('admin/users/'); } } diff --git a/mod/removeme.php b/mod/removeme.php index a53bc3eceb..86d46a177b 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -64,7 +64,7 @@ function removeme_post(App $a) function removeme_content(App $a) { if (!local_user()) { - $a->redirect(); + $a->internalRedirect(); } $hash = random_string(); diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php index 1ecf765041..3a3ce42067 100644 --- a/mod/repair_ostatus.php +++ b/mod/repair_ostatus.php @@ -14,7 +14,7 @@ function repair_ostatus_content(App $a) { if (! local_user()) { notice(L10n::t('Permission denied.') . EOL); - $a->redirect('ostatus_repair'); + $a->internalRedirect('ostatus_repair'); // NOTREACHED } diff --git a/mod/settings.php b/mod/settings.php index 8606cbd6cd..970c5b7ee4 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -160,7 +160,7 @@ function settings_post(App $a) $key = $_POST['remove']; DBA::delete('tokens', ['id' => $key, 'uid' => local_user()]); - $a->redirect('settings/oauth/', true); + $a->internalRedirect('settings/oauth/', true); return; } @@ -206,7 +206,7 @@ function settings_post(App $a) ); } } - $a->redirect('settings/oauth/', true); + $a->internalRedirect('settings/oauth/', true); return; } @@ -371,7 +371,7 @@ function settings_post(App $a) ); Addon::callHooks('display_settings_post', $_POST); - $a->redirect('settings/display'); + $a->internalRedirect('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")); - $a->redirect('settings'); + $a->internalRedirect('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()); - $a->redirect('settings'); + $a->internalRedirect('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()]); - $a->redirect('settings/oauth/', true); + $a->internalRedirect('settings/oauth/', true); return; } @@ -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 $a->redirect() call? + /// @todo Isn't it supposed to be a $a->internalRedirect() call? $a->page['htmlhead'] = ''; } diff --git a/mod/starred.php b/mod/starred.php index dcb0ff542b..9b46b522bb 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -42,7 +42,7 @@ function starred_init(App $a) { $rand = "?$rand"; } - $a->redirect($return_path . $rand); + $a->internalRedirect($return_path . $rand); } // the json doesn't really matter, it will either be 0 or 1 diff --git a/mod/tagrm.php b/mod/tagrm.php index ae1bc63db5..105cc0b3d5 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -13,11 +13,11 @@ use Friendica\Model\Item; function tagrm_post(App $a) { if (!local_user()) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); } if (x($_POST,'submit') && ($_POST['submit'] === L10n::t('Cancel'))) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_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)) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_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 ); - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); // NOTREACHED } @@ -53,25 +53,25 @@ function tagrm_content(App $a) $o = ''; if (!local_user()) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); // NOTREACHED } $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); if (!$item_id) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); // NOTREACHED } $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]); if (!DBA::isResult($item)) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); } $arr = explode(',', $item['tag']); if (!count($arr)) { - $a->redirect($_SESSION['photo_return']); + $a->internalRedirect($_SESSION['photo_return']); } $o .= '

' . L10n::t('Remove Item Tag') . '

'; diff --git a/mod/toggle_mobile.php b/mod/toggle_mobile.php index 2821e0a646..ad77dd1ccd 100644 --- a/mod/toggle_mobile.php +++ b/mod/toggle_mobile.php @@ -17,5 +17,5 @@ function toggle_mobile_init(App $a) { $address = ''; } - $a->redirect($address); + $a->internalRedirect($address); } diff --git a/mod/unfollow.php b/mod/unfollow.php index f092e05ff8..6ec8a8fdb4 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -18,7 +18,7 @@ function unfollow_post(App $a) if (!local_user()) { notice(L10n::t('Permission denied.')); - $a->redirect('login'); + $a->internalRedirect('login'); // NOTREACHED } @@ -32,17 +32,17 @@ function unfollow_post(App $a) if (!DBA::isResult($contact)) { notice(L10n::t("You aren't following this contact.")); - $a->redirect($return_url); + $a->internalRedirect($return_url); // NOTREACHED } if (!empty($_REQUEST['cancel'])) { - $a->redirect($return_url . '/' . $contact['id']); + $a->internalRedirect($return_url . '/' . $contact['id']); } if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { notice(L10n::t('Unfollowing is currently not supported by your network.')); - $a->redirect($return_url . '/' . $contact['id']); + $a->internalRedirect($return_url . '/' . $contact['id']); // NOTREACHED } @@ -63,7 +63,7 @@ function unfollow_post(App $a) } info(L10n::t('Contact unfollowed')); - $a->redirect($return_path); + $a->internalRedirect($return_path); // NOTREACHED } @@ -73,7 +73,7 @@ function unfollow_content(App $a) if (!local_user()) { notice(L10n::t('Permission denied.')); - $a->redirect('login'); + $a->internalRedirect('login'); // NOTREACHED } @@ -88,13 +88,13 @@ function unfollow_content(App $a) if (!DBA::isResult($contact)) { notice(L10n::t("You aren't following this contact.")); - $a->redirect($return_url); + $a->internalRedirect($return_url); // NOTREACHED } if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { notice(L10n::t('Unfollowing is currently not supported by your network.')); - $a->redirect('contact/' . $contact['id']); + $a->internalRedirect('contact/' . $contact['id']); // NOTREACHED } @@ -105,7 +105,7 @@ function unfollow_content(App $a) if (!DBA::isResult($self)) { notice(L10n::t('Permission denied.')); - $a->redirect($return_url); + $a->internalRedirect($return_url); // NOTREACHED } diff --git a/mod/videos.php b/mod/videos.php index b311a7a5fe..521201394b 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -115,14 +115,14 @@ function videos_post(App $a) $owner_uid = $a->data['user']['uid']; if (local_user() != $owner_uid) { - $a->redirect('videos/' . $a->data['user']['nickname']); + $a->internalRedirect('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'])) { - $a->redirect('videos/' . $a->data['user']['nickname']); + $a->internalRedirect('videos/' . $a->data['user']['nickname']); } $drop_url = $a->query_string; @@ -169,11 +169,11 @@ function videos_post(App $a) } } - $a->redirect('videos/' . $a->data['user']['nickname']); + $a->internalRedirect('videos/' . $a->data['user']['nickname']); return; // NOTREACHED } - $a->redirect('videos/' . $a->data['user']['nickname']); + $a->internalRedirect('videos/' . $a->data['user']['nickname']); } function videos_content(App $a) diff --git a/mod/wallmessage.php b/mod/wallmessage.php index 882cb1e0bf..dcec6ef9c6 100644 --- a/mod/wallmessage.php +++ b/mod/wallmessage.php @@ -69,7 +69,7 @@ function wallmessage_post(App $a) { info(L10n::t('Message sent.') . EOL); } - $a->redirect('profile/'.$user['nickname']); + $a->internalRedirect('profile/'.$user['nickname']); } diff --git a/src/App.php b/src/App.php index 98685802b5..b6fe2b9512 100644 --- a/src/App.php +++ b/src/App.php @@ -2001,20 +2001,21 @@ class App } /** - * Redirects to another URL and exits this process. + * Redirects to another service relative to the current Friendica base. + * If you want to redirect to a external URL, use System::externalRedirectTo() * * @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) + * + * @throws InternalServerErrorException In Case the given URL is not relative to the Friendica node */ - public function redirect($toUrl = '', $ssl = false) + public function internalRedirect($toUrl = '', $ssl = false) { - if (strstr(normalise_link($toUrl), 'http://')) { - $redirectTo = $toUrl; - } else { - $redirectTo = self::getApp()->getBaseURL($ssl) . '/' . ltrim($toUrl, '/'); + if (filter_var($toUrl, FILTER_VALIDATE_URL)) { + throw new InternalServerErrorException('URL is not a relative path, please use System::externalRedirectTo'); } - header("Location: $redirectTo"); - exit(); + $redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/'); + System::externalRedirect($redirectTo); } } diff --git a/src/BaseModule.php b/src/BaseModule.php index bb88b50ba3..522f0b783f 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -61,7 +61,7 @@ abstract class BaseModule extends BaseObject public static function post() { // $a = self::getApp(); - // $a->redirect('module'); + // $a->internalRedirect('module'); } /** @@ -139,7 +139,7 @@ abstract class BaseModule extends BaseObject logger('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename); logger('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); notice(self::getFormSecurityStandardErrorMessage()); - goaway(System::baseUrl() . $err_redirect); + $a->internalRedirect($err_redirect); } } diff --git a/src/Core/Authentication.php b/src/Core/Authentication.php index 3a4471d2a4..72caa9be43 100644 --- a/src/Core/Authentication.php +++ b/src/Core/Authentication.php @@ -194,7 +194,7 @@ class Authentication extends BaseObject Addon::callHooks('logged_in', $a->user); if (($a->module !== 'home') && isset($_SESSION['return_url'])) { - goaway($a->getbaseUrl() . '/' . $_SESSION['return_url']); + $a->internalRedirect($_SESSION['return_url']); } } } diff --git a/src/Core/System.php b/src/Core/System.php index ca05a44d65..e071866ee9 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -5,6 +5,7 @@ namespace Friendica\Core; use Friendica\BaseObject; +use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\XML; /** @@ -236,6 +237,23 @@ class System extends BaseObject return max($load_arr[0], $load_arr[1]); } + /** + * Redirects to an external URL (fully qualified URL) + * If you want to route relative to the current Friendica base, use App->internalRedirect() + * + * @param string $url The new Location to redirect + * @throws InternalServerErrorException If the URL is not fully qualified + */ + public static function externalRedirect($url) + { + if (!filter_var($url, FILTER_VALIDATE_URL)) { + throw new InternalServerErrorException('URL is not a fully qualified URL, please use App->internalRedirect() instead'); + } + + header("Location: $url"); + exit(); + } + /// @todo Move the following functions from boot.php /* function killme() diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index 1056edf11b..54f3ec0615 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -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")); - $a->redirect('login'); + $a->internalRedirect('login'); } } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 3851b7f4aa..343340800d 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1639,7 +1639,7 @@ class Contact extends BaseObject $myaddr = bin2hex($a->user['nickname'] . '@' . $a->getHostName()); } - $a->redirect($ret['request'] . "&addr=$myaddr"); + $a->internalRedirect($ret['request'] . "&addr=$myaddr"); // NOTREACHED } @@ -2025,7 +2025,7 @@ class Contact extends BaseObject * @brief Returns a magic link to authenticate remote visitors * * @param string $contact_url The address of the target contact profile - * @param integer $url An url that we will be redirected to after the authentication + * @param string $url An url that we will be redirected to after the authentication * * @return string with "redir" link */ @@ -2058,7 +2058,7 @@ class Contact extends BaseObject * @brief Returns a magic link to authenticate remote visitors * * @param array $contact The contact array with "uid", "network" and "url" - * @param integer $url An url that we will be redirected to after the authentication + * @param string $url An url that we will be redirected to after the authentication * * @return string with "redir" link */ diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 52ec5ccf08..4de49022cb 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -1062,7 +1062,7 @@ class Profile $serverret = Network::curl($basepath . '/magic'); if ($serverret->isSuccess()) { logger('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, LOGGER_DEBUG); - $a->redirect($magic_path); + System::externalRedirect($magic_path); } } } diff --git a/src/Model/User.php b/src/Model/User.php index 03c35d1013..27ed28fd4f 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -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); } - $a->redirect($authurl); + System::externalRedirect($authurl); // NOTREACHED } @@ -809,7 +809,7 @@ class User if ($uid == local_user()) { unset($_SESSION['authenticated']); unset($_SESSION['uid']); - $a->redirect(); + $a->internalRedirect(); } } } diff --git a/src/Module/Acctlink.php b/src/Module/Acctlink.php index 7f956a8250..692e905914 100644 --- a/src/Module/Acctlink.php +++ b/src/Module/Acctlink.php @@ -4,6 +4,7 @@ namespace Friendica\Module; use Friendica\BaseModule; use Friendica\Network\Probe; +use Friendica\Core\System; /** * Redirects to another URL based on the parameter 'addr' @@ -18,7 +19,7 @@ class Acctlink extends BaseModule $url = defaults(Probe::uri(trim($addr)), 'url', false); if ($url) { - self::getApp()->redirect($url); + System::externalRedirect($url); exit(); } } diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 1aa2aa0fe8..1b19aaadb5 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -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'])) { - $a->redirect('profile/' . $contact['nick']); + $a->internalRedirect('profile/' . $contact['nick']); } else { - $a->redirect('profile/' . $contact['nick'] . '?tab=profile'); + $a->internalRedirect('profile/' . $contact['nick'] . '?tab=profile'); } } @@ -168,7 +168,7 @@ class Contact extends BaseModule info(L10n::tt('%d contact edited.', '%d contacts edited.', $count_actions)); } - $a->redirect('contact'); + $a->internalRedirect('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); - $a->redirect('contact'); + $a->internalRedirect('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); - $a->redirect('contact'); + $a->internalRedirect('contact'); return; // NOTREACHED } if ($cmd === 'update' && ($orig_record['uid'] != 0)) { self::updateContactFromPoll($contact_id); - $a->redirect('contact/' . $contact_id); + $a->internalRedirect('contact/' . $contact_id); // NOTREACHED } if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) { self::updateContactFromProbe($contact_id); - $a->redirect('crepair/' . $contact_id); + $a->internalRedirect('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); - $a->redirect('contact/' . $contact_id); + $a->internalRedirect('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); - $a->redirect('contact/' . $contact_id); + $a->internalRedirect('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); } - $a->redirect('contact/' . $contact_id); + $a->internalRedirect('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'])) { - $a->redirect('contact'); + $a->internalRedirect('contact'); } self::dropContact($orig_record); info(L10n::t('Contact has been removed.') . EOL); - $a->redirect('contact'); + $a->internalRedirect('contact'); return; // NOTREACHED } if ($cmd === 'posts') { diff --git a/src/Module/Login.php b/src/Module/Login.php index 92b0daed13..2e04eb83be 100644 --- a/src/Module/Login.php +++ b/src/Module/Login.php @@ -40,7 +40,7 @@ class Login extends BaseModule } if (local_user()) { - $a->redirect(); + $a->internalRedirect(); } return self::form($_SESSION['return_url'], intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED); @@ -89,19 +89,18 @@ class Login extends BaseModule // 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); - $a->redirect(); + $a->internalRedirect(); // NOTREACHED } // Otherwise it's probably an openid. try { - $a = get_app(); $openid = new LightOpenID($a->getHostName()); $openid->identity = $openid_url; $_SESSION['openid'] = $openid_url; $_SESSION['remember'] = $remember; - $openid->returnUrl = self::getApp()->getBaseURL(true) . '/openid'; - $a->redirect($openid->authUrl()); + $openid->returnUrl = $a->getBaseURL(true) . '/openid'; + System::externalRedirect($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.') . '

' . L10n::t('The error message was:') . ' ' . $e->getMessage()); } @@ -149,7 +148,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); - $a->redirect(); + $a->internalRedirect(); } if (!$remember) { @@ -168,7 +167,7 @@ class Login extends BaseModule $return_url = ''; } - $a->redirect($return_url); + $a->internalRedirect($return_url); } /** @@ -198,7 +197,7 @@ class Login extends BaseModule if ($data->hash != Authentication::getCookieHashForUser($user)) { logger("Hash for user " . $data->uid . " doesn't fit."); Authentication::deleteSession(); - $a->redirect(); + $a->internalRedirect(); } // Renew the cookie @@ -235,7 +234,7 @@ class Login extends BaseModule logger('Session address changed. Paranoid setting in effect, blocking session. ' . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); Authentication::deleteSession(); - $a->redirect(); + $a->internalRedirect(); } $user = DBA::selectFirst('user', [], @@ -249,7 +248,7 @@ class Login extends BaseModule ); if (!DBA::isResult($user)) { Authentication::deleteSession(); - $a->redirect(); + $a->internalRedirect(); } // Make sure to refresh the last login time for the user if the user diff --git a/src/Module/Logout.php b/src/Module/Logout.php index e5198af858..f212a89402 100644 --- a/src/Module/Logout.php +++ b/src/Module/Logout.php @@ -27,6 +27,6 @@ class Logout extends BaseModule Addon::callHooks("logging_out"); Authentication::deleteSession(); info(L10n::t('Logged out.') . EOL); - self::getApp()->redirect(); + self::getApp()->internalRedirect(); } } diff --git a/src/Module/Magic.php b/src/Module/Magic.php index 97cdb648f3..2b46d46183 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -42,7 +42,7 @@ class Magic extends BaseModule if (!$cid) { logger('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG); - $a->redirect($dest); + $a->internalRedirect($dest); } $contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]); @@ -56,7 +56,7 @@ class Magic extends BaseModule } logger('Contact is already authenticated', LOGGER_DEBUG); - $a->redirect($dest); + $a->internalRedirect($dest); } if (local_user()) { @@ -100,10 +100,10 @@ class Magic extends BaseModule $x = strpbrk($dest, '?&'); $args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token); - $a->redirect($dest . $args); + $a->internalRedirect($dest . $args); } } - $a->redirect($dest); + $a->internalRedirect($dest); } } @@ -112,6 +112,6 @@ class Magic extends BaseModule return $ret; } - $a->redirect($dest); + $a->internalRedirect($dest); } } diff --git a/src/Module/Objects.php b/src/Module/Objects.php index 0f9493db61..d51d5785a5 100644 --- a/src/Module/Objects.php +++ b/src/Module/Objects.php @@ -24,7 +24,7 @@ class Objects extends BaseModule } if (!ActivityPub::isRequest()) { - $a->redirect(str_replace('objects/', 'display/', $a->query_string)); + $a->internalRedirect(str_replace('objects/', 'display/', $a->query_string)); } $item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'wall' => true, 'private' => false]); diff --git a/src/Module/Tos.php b/src/Module/Tos.php index 055fdb88b9..db8b55885a 100644 --- a/src/Module/Tos.php +++ b/src/Module/Tos.php @@ -49,7 +49,7 @@ class Tos extends BaseModule public static function init() { if (strlen(Config::get('system','singleuser'))) { - self::getApp()->redirect('profile/' . Config::get('system','singleuser')); + self::getApp()->internalRedirect('profile/' . Config::get('system','singleuser')); } } /** diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index be91651f2a..e8cf4a631a 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -3037,7 +3037,7 @@ class DFRN logger('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); $dest = (($url) ? '&destination_url=' . $url : ''); - $a->redirect($r[0]['poll'] . '?dfrn_id=' . $dfrn_id + System::externalRedirect($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest); }