]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_request.php
Merge remote-tracking branch 'upstream/develop' into manage
[friendica.git] / mod / dfrn_request.php
index 0e24accc013855f307e70b8c5ddcf1249ad58aa7..19879c21bb334ddc35d94b98505cee1bd2e6f3c6 100644 (file)
@@ -30,15 +30,13 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
 
-require_once 'include/enotify.php';
-
 function dfrn_request_init(App $a)
 {
        if ($a->argc > 1) {
                $which = $a->argv[1];
+               Profile::load($a, $which);
        }
 
-       Profile::load($a, $which);
        return;
 }
 
@@ -56,6 +54,9 @@ function dfrn_request_init(App $a)
  * in order to link our friend request with our own server cell.
  * After logging in, we click 'submit' to approve the linkage.
  *
+ * @param App $a
+ * @throws ImagickException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  */
 function dfrn_request_post(App $a)
 {
@@ -167,7 +168,7 @@ function dfrn_request_post(App $a)
                                $r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `site-pubkey` = '%s' LIMIT 1",
                                        intval(local_user()),
                                        DBA::escape($dfrn_url),
-                                       $parms['key'] // this was already escaped
+                                       defaults($parms, 'key', '') // Potentially missing
                                );
                                if (DBA::isResult($r)) {
                                        Group::addMember(User::getDefaultGroup(local_user(), $r[0]["network"]), $r[0]['id']);
@@ -186,8 +187,8 @@ function dfrn_request_post(App $a)
                                        $dfrn_request = $contact_record['request'];
                                }
 
-                               if (strlen($dfrn_request) && strlen($confirm_key)) {
-                                       $s = Network::fetchUrl($dfrn_request . '?confirm_key=' . $confirm_key);
+                               if (!empty($dfrn_request) && strlen($confirm_key)) {
+                                       Network::fetchUrl($dfrn_request . '?confirm_key=' . $confirm_key);
                                }
 
                                // (ignore reply, nothing we can do it failed)
@@ -229,7 +230,6 @@ function dfrn_request_post(App $a)
        }
 
        $nickname       = $a->profile['nickname'];
-       $notify_flags   = $a->profile['notify-flags'];
        $uid            = $a->profile['uid'];
        $maxreq         = intval($a->profile['maxreq']);
        $contact_record = null;
@@ -270,8 +270,6 @@ function dfrn_request_post(App $a)
                        }
                }
 
-               $real_name = !empty($_POST['realname']) ? Strings::escapeTags(trim($_POST['realname'])) : '';
-
                $url = trim($_POST['dfrn_url']);
                if (!strlen($url)) {
                        notice(L10n::t("Invalid locator") . EOL);
@@ -419,7 +417,7 @@ function dfrn_request_post(App $a)
                        $hash = Strings::getRandomHex() . (string) time();   // Generate a confirm_key
 
                        if (is_array($contact_record)) {
-                               $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
+                               q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
                                        VALUES ( %d, %d, 1, %d, '%s', '%s', '%s' )",
                                        intval($uid),
                                        intval($contact_record['id']),
@@ -478,7 +476,7 @@ function dfrn_request_post(App $a)
 
 function dfrn_request_content(App $a)
 {
-       if (($a->argc != 2) || (!count($a->profile))) {
+       if ($a->argc != 2 || empty($a->profile)) {
                return "";
        }
 
@@ -546,7 +544,7 @@ function dfrn_request_content(App $a)
                        $auto_confirm = false;
 
                        if (DBA::isResult($r)) {
-                               if ($r[0]['page-flags'] != Contact::PAGE_NORMAL && $r[0]['page-flags'] != Contact::PAGE_PRVGROUP) {
+                               if ($r[0]['page-flags'] != User::PAGE_FLAGS_NORMAL && $r[0]['page-flags'] != User::PAGE_FLAGS_PRVGROUP) {
                                        $auto_confirm = true;
                                }
 
@@ -574,7 +572,7 @@ function dfrn_request_content(App $a)
                                                'node'     => $r[0]['nickname'],
                                                'dfrn_id'  => $r[0]['issued-id'],
                                                'intro_id' => $intro[0]['id'],
-                                               'duplex'   => (($r[0]['page-flags'] == Contact::PAGE_FREELOVE) ? 1 : 0),
+                                               'duplex'   => (($r[0]['page-flags'] == User::PAGE_FLAGS_FREELOVE) ? 1 : 0),
                                        ];
                                        dfrn_confirm_post($a, $handsfree);
                                }
@@ -585,14 +583,13 @@ function dfrn_request_content(App $a)
                                // If we are auto_confirming, this record will have already been nuked
                                // in dfrn_confirm_post()
 
-                               $r = q("UPDATE `intro` SET `blocked` = 0 WHERE `hash` = '%s'",
+                               q("UPDATE `intro` SET `blocked` = 0 WHERE `hash` = '%s'",
                                        DBA::escape($_GET['confirm_key'])
                                );
                        }
                }
 
-               killme();
-               return; // NOTREACHED
+               exit();
        } else {
                // Normal web request. Display our user's introduction form.
                if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
@@ -626,7 +623,7 @@ function dfrn_request_content(App $a)
                 * because nobody is going to read the comments and
                 * it doesn't matter if they know you or not.
                 */
-               if ($a->profile['page-flags'] == Contact::PAGE_NORMAL) {
+               if ($a->profile['page-flags'] == User::PAGE_FLAGS_NORMAL) {
                        $tpl = Renderer::getMarkupTemplate('dfrn_request.tpl');
                } else {
                        $tpl = Renderer::getMarkupTemplate('auto_request.tpl');
@@ -634,10 +631,7 @@ function dfrn_request_content(App $a)
 
                $page_desc = L10n::t("Please enter your 'Identity Address' from one of the following supported communications networks:");
 
-               $invite_desc = sprintf(
-                       L10n::t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica site and join us today</a>.'),
-                       get_server() . '/servers'
-               );
+               $invite_desc = L10n::t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica site and join us today</a>.', get_server() . '/servers');
 
                $o = Renderer::replaceMacros($tpl, [
                        '$header' => L10n::t('Friend/Connection Request'),
@@ -660,6 +654,4 @@ function dfrn_request_content(App $a)
                ]);
                return $o;
        }
-
-       return; // Somebody is fishing.
 }