X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FMagic.php;h=0722da3cd76c8c5c15162ba6876854e2276b7ce1;hb=51e55bca18ed3f73f474e203e3f3d1e2caba339f;hp=ecfe18e596b528b3587af7be1ae9b06b7201663a;hpb=d577ab98eb0f28f9f807795f54c87d80ef9c0dc2;p=friendica.git diff --git a/src/Module/Magic.php b/src/Module/Magic.php index ecfe18e596..0722da3cd7 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -28,22 +28,20 @@ class Magic extends BaseModule Logger::log('args: ' . print_r($_REQUEST, true), Logger::DATA); - $addr = ((x($_REQUEST, 'addr')) ? $_REQUEST['addr'] : ''); - $dest = ((x($_REQUEST, 'dest')) ? $_REQUEST['dest'] : ''); - $test = ((x($_REQUEST, 'test')) ? intval($_REQUEST['test']) : 0); - $owa = ((x($_REQUEST, 'owa')) ? intval($_REQUEST['owa']) : 0); + $addr = defaults($_REQUEST, 'addr', ''); + $dest = defaults($_REQUEST, 'dest', ''); + $test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0); + $owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0); + $cid = 0; - // NOTE: I guess $dest isn't just the profile url (could be also - // other profile pages e.g. photo). We need to find a solution - // to be able to redirct to other pages than the contact profile. - $cid = Contact::getIdForURL($dest); - - if (!$cid && !empty($addr)) { + if (!empty($addr)) { $cid = Contact::getIdForURL($addr); + } elseif (!empty($dest)) { + $cid = Contact::getIdForURL($dest); } if (!$cid) { - Logger::log('No contact record found: ' . print_r($_REQUEST, true), Logger::DEBUG); + Logger::info('No contact record found', $_REQUEST); // @TODO Finding a more elegant possibility to redirect to either internal or external URL $a->redirect($dest); } @@ -74,7 +72,7 @@ class Magic extends BaseModule $basepath = $exp[0]; $headers = []; - $headers['Accept'] = 'application/x-dfrn+json'; + $headers['Accept'] = 'application/x-dfrn+json, application/x-zot+json'; $headers['X-Open-Web-Auth'] = Strings::getRandomHex(); // Create a header that is signed with the local users private key. @@ -85,7 +83,7 @@ class Magic extends BaseModule ); // Try to get an authentication token from the other instance. - $curlResult = Network::curl($basepath . '/owa', false, $redirects, ['headers' => $headers]); + $curlResult = Network::curl($basepath . '/owa', false, ['headers' => $headers]); if ($curlResult->isSuccess()) { $j = json_decode($curlResult->getBody(), true); @@ -102,6 +100,7 @@ class Magic extends BaseModule $x = strpbrk($dest, '?&'); $args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token); + Logger::info('Redirecting', ['path' => $dest . $args]); System::externalRedirect($dest . $args); } }