aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-05-18 21:13:57 +0200
committerHarald Eilertsen <haraldei@anduin.net>2024-06-13 13:34:20 +0200
commit08d4bd94fac1831718c1eeac5f975acb7638a1f0 (patch)
treef6994340a4834789d431e13fb43496bf3d568eea /Zotlabs
parent76a92ac2e1ed2d22ad960739e56e5832872cfe23 (diff)
downloadvolse-hubzilla-08d4bd94fac1831718c1eeac5f975acb7638a1f0.tar.gz
volse-hubzilla-08d4bd94fac1831718c1eeac5f975acb7638a1f0.tar.bz2
volse-hubzilla-08d4bd94fac1831718c1eeac5f975acb7638a1f0.zip
Module\Rpost: Refactor redirect or login logic.
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Rpost.php63
1 files changed, 37 insertions, 26 deletions
diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php
index ba0588c25..2f1ba98d8 100644
--- a/Zotlabs/Module/Rpost.php
+++ b/Zotlabs/Module/Rpost.php
@@ -33,36 +33,12 @@ class Rpost extends \Zotlabs\Web\Controller {
function get() {
if(! local_channel()) {
- if(remote_channel()) {
- // redirect to your own site.
- // We can only do this with a GET request so you'll need to keep the text short or risk getting truncated
- // by the wretched beast called 'suhosin'. All the browsers now allow long GET requests, but suhosin
- // blocks them.
-
- $url = Libzot::get_rpost_path(App::get_observer());
- // make sure we're not looping to our own hub
- if(($url) && (! stristr($url, App::get_hostname()))) {
- foreach($_GET as $key => $arg) {
- if($key === 'q')
- continue;
- $url .= '&' . $key . '=' . $arg;
- }
- goaway($url);
- }
- }
-
- // The login procedure is going to bugger our $_REQUEST variables
- // so save them in the session.
-
- if(array_key_exists('body',$_REQUEST)) {
- $_SESSION['rpost'] = $_REQUEST;
- }
- return login();
+ return $this->redirect_or_login();
}
nav_set_selected('Post');
- if (local_channel() && array_key_exists('userfile',$_FILES)) {
+ if (array_key_exists('userfile',$_FILES)) {
$channel = App::get_channel();
$observer = App::get_observer();
@@ -211,6 +187,41 @@ class Rpost extends \Zotlabs\Web\Controller {
));
}
+ /**
+ * Redirect to the observer's instance if not local, or return login form.
+ *
+ * The request is saved in the session if there's a `body` request
+ * param present. (Otherwise not.)
+ *
+ * @return string A login form if not redirected. If the session was
+ * determned to belong to a remote channel, the function does not
+ * return.
+ */
+ private function redirect_or_login(): string {
+ if(remote_channel()) {
+ // redirect to your own site.
+ // We can only do this with a GET request so you'll need to keep the text short or risk getting truncated
+ // by the wretched beast called 'suhosin'. All the browsers now allow long GET requests, but suhosin
+ // blocks them.
+
+ $url = Libzot::get_rpost_path(App::get_observer());
+ // make sure we're not looping to our own hub
+ if(($url) && (! stristr($url, App::get_hostname()))) {
+ foreach($_GET as $key => $arg) {
+ if($key === 'q')
+ continue;
+ $url .= '&' . $key . '=' . $arg;
+ }
+ goaway($url);
+ }
+ }
+ // The login procedure is going to bugger our $_REQUEST variables
+ // so save them in the session.
+ if(array_key_exists('body',$_REQUEST)) {
+ $_SESSION['rpost'] = $_REQUEST;
+ }
+ return login();
+ }
}