]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Magic.php
Merge pull request #6225 from annando/http-error
[friendica.git] / src / Module / Magic.php
index 01c5d5d464abf90ba0035a17b2a4f1da92ad8d1f..f0be114e3dbb056aa1c46897360d3e4ef1158d3d 100644 (file)
@@ -28,10 +28,10 @@ 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);
 
                // 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
@@ -43,14 +43,14 @@ class Magic extends BaseModule
                }
 
                if (!$cid) {
-                       Logger::log('No contact record found: ' . print_r($_REQUEST, true), Logger::DEBUG);
+                       Logger::log('No contact record found: ' . json_encode($_REQUEST), Logger::DEBUG);
                        // @TODO Finding a more elegant possibility to redirect to either internal or external URL
                        $a->redirect($dest);
                }
                $contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
 
                // Redirect if the contact is already authenticated on this site.
-               if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], normalise_link(self::getApp()->getBaseURL())) !== false) {
+               if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(self::getApp()->getBaseURL())) !== false) {
                        if ($test) {
                                $ret['success'] = true;
                                $ret['message'] .= 'Local site - you are already authenticated.' . EOL;
@@ -95,7 +95,7 @@ class Magic extends BaseModule
                                                if ($j['encrypted_token']) {
                                                        // The token is encrypted. If the local user is really the one the other instance
                                                        // thinks he/she is, the token can be decrypted with the local users public key.
-                                                       openssl_private_decrypt(base64url_decode($j['encrypted_token']), $token, $user['prvkey']);
+                                                       openssl_private_decrypt(Strings::base64UrlDecode($j['encrypted_token']), $token, $user['prvkey']);
                                                } else {
                                                        $token = $j['token'];
                                                }