]> git.mxchange.org Git - friendica.git/blob - mod/dfrn_confirm.php
adapted 300px image size for default avatar
[friendica.git] / mod / dfrn_confirm.php
1 <?php
2 /**
3  * @file mod/dfrn_confirm.php
4  * @brief Module: dfrn_confirm
5  * Purpose: Friendship acceptance for DFRN contacts
6  *
7  * There are two possible entry points and three scenarios.
8  *
9  *   1. A form was submitted by our user approving a friendship that originated elsewhere.
10  *      This may also be called from dfrn_request to automatically approve a friendship.
11  *
12  *   2. We may be the target or other side of the conversation to scenario 1, and will
13  *      interact with that process on our own user's behalf.
14  *
15  *  @see PDF with dfrn specs: https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
16  *    You also find a graphic which describes the confirmation process at
17  *    https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_confirmation.png
18  */
19
20 use Friendica\App;
21 use Friendica\Core\Config;
22 use Friendica\Core\L10n;
23 use Friendica\Core\Protocol;
24 use Friendica\Core\System;
25 use Friendica\Database\DBA;
26 use Friendica\Model\Contact;
27 use Friendica\Model\Group;
28 use Friendica\Model\User;
29 use Friendica\Network\Probe;
30 use Friendica\Protocol\Diaspora;
31 use Friendica\Protocol\ActivityPub;
32 use Friendica\Util\Crypto;
33 use Friendica\Util\DateTimeFormat;
34 use Friendica\Util\Network;
35 use Friendica\Util\XML;
36
37 require_once 'include/enotify.php';
38 require_once 'include/items.php';
39
40 function dfrn_confirm_post(App $a, $handsfree = null)
41 {
42         $node = null;
43         if (is_array($handsfree)) {
44                 /*
45                  * We were called directly from dfrn_request due to automatic friend acceptance.
46                  * Any $_POST parameters we may require are supplied in the $handsfree array.
47                  *
48                  */
49                 $node = $handsfree['node'];
50                 $a->interactive = false; // notice() becomes a no-op since nobody is there to see it
51         } elseif ($a->argc > 1) {
52                 $node = $a->argv[1];
53         }
54
55         /*
56          * Main entry point. Scenario 1. Our user received a friend request notification (perhaps
57          * from another site) and clicked 'Approve'.
58          * $POST['source_url'] is not set. If it is, it indicates Scenario 2.
59          *
60          * We may also have been called directly from dfrn_request ($handsfree != null) due to
61          * this being a page type which supports automatic friend acceptance. That is also Scenario 1
62          * since we are operating on behalf of our registered user to approve a friendship.
63          */
64         if (!x($_POST, 'source_url')) {
65                 $uid = defaults($handsfree, 'uid', local_user());
66                 if (!$uid) {
67                         notice(L10n::t('Permission denied.') . EOL);
68                         return;
69                 }
70
71                 $user = DBA::selectFirst('user', [], ['uid' => $uid]);
72                 if (!DBA::isResult($user)) {
73                         notice(L10n::t('Profile not found.') . EOL);
74                         return;
75                 }
76
77                 // These data elements may come from either the friend request notification form or $handsfree array.
78                 if (is_array($handsfree)) {
79                         logger('Confirm in handsfree mode');
80                         $dfrn_id  = $handsfree['dfrn_id'];
81                         $intro_id = $handsfree['intro_id'];
82                         $duplex   = $handsfree['duplex'];
83                         $cid      = 0;
84                         $hidden   = intval(defaults($handsfree, 'hidden'  , 0));
85                 } else {
86                         $dfrn_id  = notags(trim(defaults($_POST, 'dfrn_id'   , '')));
87                         $intro_id =      intval(defaults($_POST, 'intro_id'  , 0));
88                         $duplex   =      intval(defaults($_POST, 'duplex'    , 0));
89                         $cid      =      intval(defaults($_POST, 'contact_id', 0));
90                         $hidden   =      intval(defaults($_POST, 'hidden'    , 0));
91                 }
92
93                 /*
94                  * Ensure that dfrn_id has precedence when we go to find the contact record.
95                  * We only want to search based on contact id if there is no dfrn_id,
96                  * e.g. for OStatus network followers.
97                  */
98                 if (strlen($dfrn_id)) {
99                         $cid = 0;
100                 }
101
102                 logger('Confirming request for dfrn_id (issued) ' . $dfrn_id);
103                 if ($cid) {
104                         logger('Confirming follower with contact_id: ' . $cid);
105                 }
106
107                 /*
108                  * The other person will have been issued an ID when they first requested friendship.
109                  * Locate their record. At this time, their record will have both pending and blocked set to 1.
110                  * There won't be any dfrn_id if this is a network follower, so use the contact_id instead.
111                  */
112                 $r = q("SELECT *
113                         FROM `contact`
114                         WHERE (
115                                 (`issued-id` != '' AND `issued-id` = '%s')
116                                 OR
117                                 (`id` = %d AND `id` != 0)
118                         )
119                         AND `uid` = %d
120                         AND `duplex` = 0
121                         LIMIT 1",
122                         DBA::escape($dfrn_id),
123                         intval($cid),
124                         intval($uid)
125                 );
126                 if (!DBA::isResult($r)) {
127                         logger('Contact not found in DB.');
128                         notice(L10n::t('Contact not found.') . EOL);
129                         notice(L10n::t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL);
130                         return;
131                 }
132
133                 $contact = $r[0];
134
135                 $contact_id   = $contact['id'];
136                 $relation     = $contact['rel'];
137                 $site_pubkey  = $contact['site-pubkey'];
138                 $dfrn_confirm = $contact['confirm'];
139                 $aes_allow    = $contact['aes_allow'];
140
141                 $network = ((strlen($contact['issued-id'])) ? Protocol::DFRN : Protocol::OSTATUS);
142
143                 if ($contact['network']) {
144                         $network = $contact['network'];
145                 }
146
147                 if ($network === Protocol::DFRN) {
148                         /*
149                          * Generate a key pair for all further communications with this person.
150                          * We have a keypair for every contact, and a site key for unknown people.
151                          * This provides a means to carry on relationships with other people if
152                          * any single key is compromised. It is a robust key. We're much more
153                          * worried about key leakage than anybody cracking it.
154                          */
155                         $res = Crypto::newKeypair(4096);
156
157                         $private_key = $res['prvkey'];
158                         $public_key  = $res['pubkey'];
159
160                         // Save the private key. Send them the public key.
161                         q("UPDATE `contact` SET `prvkey` = '%s' WHERE `id` = %d AND `uid` = %d",
162                                 DBA::escape($private_key),
163                                 intval($contact_id),
164                                 intval($uid)
165                         );
166
167                         $params = [];
168
169                         /*
170                          * Per the DFRN protocol, we will verify both ends by encrypting the dfrn_id with our
171                          * site private key (person on the other end can decrypt it with our site public key).
172                          * Then encrypt our profile URL with the other person's site public key. They can decrypt
173                          * it with their site private key. If the decryption on the other end fails for either
174                          * item, it indicates tampering or key failure on at least one site and we will not be
175                          * able to provide a secure communication pathway.
176                          *
177                          * If other site is willing to accept full encryption, (aes_allow is 1 AND we have php5.3
178                          * or later) then we encrypt the personal public key we send them using AES-256-CBC and a
179                          * random key which is encrypted with their site public key.
180                          */
181
182                         $src_aes_key = openssl_random_pseudo_bytes(64);
183
184                         $result = '';
185                         openssl_private_encrypt($dfrn_id, $result, $user['prvkey']);
186
187                         $params['dfrn_id'] = bin2hex($result);
188                         $params['public_key'] = $public_key;
189
190                         $my_url = System::baseUrl() . '/profile/' . $user['nickname'];
191
192                         openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
193                         $params['source_url'] = bin2hex($params['source_url']);
194
195                         if ($aes_allow && function_exists('openssl_encrypt')) {
196                                 openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
197                                 $params['aes_key'] = bin2hex($params['aes_key']);
198                                 $params['public_key'] = bin2hex(openssl_encrypt($public_key, 'AES-256-CBC', $src_aes_key));
199                         }
200
201                         $params['dfrn_version'] = DFRN_PROTOCOL_VERSION;
202                         if ($duplex == 1) {
203                                 $params['duplex'] = 1;
204                         }
205
206                         if ($user['page-flags'] == Contact::PAGE_COMMUNITY) {
207                                 $params['page'] = 1;
208                         }
209
210                         if ($user['page-flags'] == Contact::PAGE_PRVGROUP) {
211                                 $params['page'] = 2;
212                         }
213
214                         logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params, true), LOGGER_DATA);
215
216                         /*
217                          *
218                          * POST all this stuff to the other site.
219                          * Temporarily raise the network timeout to 120 seconds because the default 60
220                          * doesn't always give the other side quite enough time to decrypt everything.
221                          *
222                          */
223
224                         $res = Network::post($dfrn_confirm, $params, null, $redirects, 120)->getBody();
225
226                         logger(' Confirm: received data: ' . $res, LOGGER_DATA);
227
228                         // Now figure out what they responded. Try to be robust if the remote site is
229                         // having difficulty and throwing up errors of some kind.
230
231                         $leading_junk = substr($res, 0, strpos($res, '<?xml'));
232
233                         $res = substr($res, strpos($res, '<?xml'));
234                         if (!strlen($res)) {
235                                 // No XML at all, this exchange is messed up really bad.
236                                 // We shouldn't proceed, because the xml parser might choke,
237                                 // and $status is going to be zero, which indicates success.
238                                 // We can hardly call this a success.
239                                 notice(L10n::t('Response from remote site was not understood.') . EOL);
240                                 return;
241                         }
242
243                         if (strlen($leading_junk) && Config::get('system', 'debugging')) {
244                                 // This might be more common. Mixed error text and some XML.
245                                 // If we're configured for debugging, show the text. Proceed in either case.
246                                 notice(L10n::t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL);
247                         }
248
249                         if (stristr($res, "<status") === false) {
250                                 // wrong xml! stop here!
251                                 logger('Unexpected response posting to ' . $dfrn_confirm);
252                                 notice(L10n::t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL);
253                                 return;
254                         }
255
256                         $xml = XML::parseString($res);
257                         $status = (int) $xml->status;
258                         $message = unxmlify($xml->message);   // human readable text of what may have gone wrong.
259                         switch ($status) {
260                                 case 0:
261                                         info(L10n::t("Confirmation completed successfully.") . EOL);
262                                         break;
263                                 case 1:
264                                         // birthday paradox - generate new dfrn-id and fall through.
265                                         $new_dfrn_id = random_string();
266                                         q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d AND `uid` = %d",
267                                                 DBA::escape($new_dfrn_id),
268                                                 intval($contact_id),
269                                                 intval($uid)
270                                         );
271
272                                 case 2:
273                                         notice(L10n::t("Temporary failure. Please wait and try again.") . EOL);
274                                         break;
275                                 case 3:
276                                         notice(L10n::t("Introduction failed or was revoked.") . EOL);
277                                         break;
278                         }
279
280                         if (strlen($message)) {
281                                 notice(L10n::t('Remote site reported: ') . $message . EOL);
282                         }
283
284                         if (($status == 0) && $intro_id) {
285                                 $intro = DBA::selectFirst('intro', ['note'], ['id' => $intro_id]);
286                                 if (DBA::isResult($intro)) {
287                                         DBA::update('contact', ['reason' => $intro['note']], ['id' => $contact_id]);
288                                 }
289
290                                 // Success. Delete the notification.
291                                 DBA::delete('intro', ['id' => $intro_id]);
292                         }
293
294                         if ($status != 0) {
295                                 return;
296                         }
297                 }
298
299                 /*
300                  * We have now established a relationship with the other site.
301                  * Let's make our own personal copy of their profile photo so we don't have
302                  * to always load it from their site.
303                  *
304                  * We will also update the contact record with the nature and scope of the relationship.
305                  */
306                 Contact::updateAvatar($contact['photo'], $uid, $contact_id);
307
308                 logger('dfrn_confirm: confirm - imported photos');
309
310                 if ($network === Protocol::DFRN) {
311                         $new_relation = Contact::FOLLOWER;
312
313                         if (($relation == Contact::SHARING) || ($duplex)) {
314                                 $new_relation = Contact::FRIEND;
315                         }
316
317                         if (($relation == Contact::SHARING) && ($duplex)) {
318                                 $duplex = 0;
319                         }
320
321                         $r = q("UPDATE `contact` SET `rel` = %d,
322                                 `name-date` = '%s',
323                                 `uri-date` = '%s',
324                                 `blocked` = 0,
325                                 `pending` = 0,
326                                 `duplex` = %d,
327                                 `hidden` = %d,
328                                 `network` = '%s' WHERE `id` = %d
329                         ",
330                                 intval($new_relation),
331                                 DBA::escape(DateTimeFormat::utcNow()),
332                                 DBA::escape(DateTimeFormat::utcNow()),
333                                 intval($duplex),
334                                 intval($hidden),
335                                 DBA::escape(Protocol::DFRN),
336                                 intval($contact_id)
337                         );
338                 } else {
339                         if ($network == Protocol::ACTIVITYPUB) {
340                                 ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $uid);
341                                 $pending = true;
342                         } else {
343                                 $pending = false;
344                         }
345
346                         // $network !== Protocol::DFRN
347                         $network = defaults($contact, 'network', Protocol::OSTATUS);
348
349                         $arr = Probe::uri($contact['url'], $network);
350
351                         $notify  = defaults($contact, 'notify' , $arr['notify']);
352                         $poll    = defaults($contact, 'poll'   , $arr['poll']);
353
354                         $addr = $arr['addr'];
355
356                         $new_relation = $contact['rel'];
357                         $writable = $contact['writable'];
358
359                         if (in_array($network, [Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
360                                 if ($duplex) {
361                                         $new_relation = Contact::FRIEND;
362                                 } else {
363                                         $new_relation = Contact::FOLLOWER;
364                                 }
365
366                                 if ($new_relation != Contact::FOLLOWER) {
367                                         $writable = 1;
368                                 }
369                         }
370
371                         DBA::delete('intro', ['id' => $intro_id]);
372
373                         $fields = ['name-date' => DateTimeFormat::utcNow(),
374                                 'uri-date' => DateTimeFormat::utcNow(), 'addr' => $addr,
375                                 'notify' => $notify, 'poll' => $poll, 'blocked' => false,
376                                 'pending' => $pending, 'network' => $network,
377                                 'writable' => $writable, 'hidden' => $hidden, 'rel' => $new_relation];
378                         DBA::update('contact', $fields, ['id' => $contact_id]);
379                 }
380
381                 if (!DBA::isResult($r)) {
382                         notice(L10n::t('Unable to set contact photo.') . EOL);
383                 }
384
385                 // reload contact info
386                 $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
387                 if ((isset($new_relation) && $new_relation == Contact::FRIEND)) {
388                         if (DBA::isResult($contact) && ($contact['network'] === Protocol::DIASPORA)) {
389                                 $ret = Diaspora::sendShare($user, $contact);
390                                 logger('share returns: ' . $ret);
391                         }
392                 }
393
394                 Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']);
395
396                 if ($network == Protocol::ACTIVITYPUB && $duplex) {
397                         ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid);
398                 }
399
400                 // Let's send our user to the contact editor in case they want to
401                 // do anything special with this new friend.
402                 if ($handsfree === null) {
403                         $a->internalRedirect('contact/' . intval($contact_id));
404                 } else {
405                         return;
406                 }
407                 //NOTREACHED
408         }
409
410         /*
411          * End of Scenario 1. [Local confirmation of remote friend request].
412          *
413          * Begin Scenario 2. This is the remote response to the above scenario.
414          * This will take place on the site that originally initiated the friend request.
415          * In the section above where the confirming party makes a POST and
416          * retrieves xml status information, they are communicating with the following code.
417          */
418         if (x($_POST, 'source_url')) {
419                 // We are processing an external confirmation to an introduction created by our user.
420                 $public_key =         defaults($_POST, 'public_key', '');
421                 $dfrn_id    = hex2bin(defaults($_POST, 'dfrn_id'   , ''));
422                 $source_url = hex2bin(defaults($_POST, 'source_url', ''));
423                 $aes_key    =         defaults($_POST, 'aes_key'   , '');
424                 $duplex     =  intval(defaults($_POST, 'duplex'    , 0));
425                 $page       =  intval(defaults($_POST, 'page'      , 0));
426
427                 $forum = (($page == 1) ? 1 : 0);
428                 $prv   = (($page == 2) ? 1 : 0);
429
430                 logger('dfrn_confirm: requestee contacted: ' . $node);
431
432                 logger('dfrn_confirm: request: POST=' . print_r($_POST, true), LOGGER_DATA);
433
434                 // If $aes_key is set, both of these items require unpacking from the hex transport encoding.
435
436                 if (x($aes_key)) {
437                         $aes_key = hex2bin($aes_key);
438                         $public_key = hex2bin($public_key);
439                 }
440
441                 // Find our user's account
442                 $user = DBA::selectFirst('user', [], ['nickname' => $node]);
443                 if (!DBA::isResult($user)) {
444                         $message = L10n::t('No user record found for \'%s\' ', $node);
445                         System::xmlExit(3, $message); // failure
446                         // NOTREACHED
447                 }
448
449                 $my_prvkey = $user['prvkey'];
450                 $local_uid = $user['uid'];
451
452
453                 if (!strstr($my_prvkey, 'PRIVATE KEY')) {
454                         $message = L10n::t('Our site encryption key is apparently messed up.');
455                         System::xmlExit(3, $message);
456                 }
457
458                 // verify everything
459
460                 $decrypted_source_url = "";
461                 openssl_private_decrypt($source_url, $decrypted_source_url, $my_prvkey);
462
463
464                 if (!strlen($decrypted_source_url)) {
465                         $message = L10n::t('Empty site URL was provided or URL could not be decrypted by us.');
466                         System::xmlExit(3, $message);
467                         // NOTREACHED
468                 }
469
470                 $contact = DBA::selectFirst('contact', [], ['url' => $decrypted_source_url, 'uid' => $local_uid]);
471                 if (!DBA::isResult($contact)) {
472                         if (strstr($decrypted_source_url, 'http:')) {
473                                 $newurl = str_replace('http:', 'https:', $decrypted_source_url);
474                         } else {
475                                 $newurl = str_replace('https:', 'http:', $decrypted_source_url);
476                         }
477
478                         $contact = DBA::selectFirst('contact', [], ['url' => $newurl, 'uid' => $local_uid]);
479                         if (!DBA::isResult($contact)) {
480                                 // this is either a bogus confirmation (?) or we deleted the original introduction.
481                                 $message = L10n::t('Contact record was not found for you on our site.');
482                                 System::xmlExit(3, $message);
483                                 return; // NOTREACHED
484                         }
485                 }
486
487                 $relation = $contact['rel'];
488
489                 // Decrypt all this stuff we just received
490
491                 $foreign_pubkey = $contact['site-pubkey'];
492                 $dfrn_record = $contact['id'];
493
494                 if (!$foreign_pubkey) {
495                         $message = L10n::t('Site public key not available in contact record for URL %s.', $decrypted_source_url);
496                         System::xmlExit(3, $message);
497                 }
498
499                 $decrypted_dfrn_id = "";
500                 openssl_public_decrypt($dfrn_id, $decrypted_dfrn_id, $foreign_pubkey);
501
502                 if (strlen($aes_key)) {
503                         $decrypted_aes_key = "";
504                         openssl_private_decrypt($aes_key, $decrypted_aes_key, $my_prvkey);
505                         $dfrn_pubkey = openssl_decrypt($public_key, 'AES-256-CBC', $decrypted_aes_key);
506                 } else {
507                         $dfrn_pubkey = $public_key;
508                 }
509
510                 if (DBA::exists('contact', ['dfrn-id' => $decrypted_dfrn_id])) {
511                         $message = L10n::t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
512                         System::xmlExit(1, $message); // Birthday paradox - duplicate dfrn-id
513                         // NOTREACHED
514                 }
515
516                 $r = q("UPDATE `contact` SET `dfrn-id` = '%s', `pubkey` = '%s' WHERE `id` = %d",
517                         DBA::escape($decrypted_dfrn_id),
518                         DBA::escape($dfrn_pubkey),
519                         intval($dfrn_record)
520                 );
521                 if (!DBA::isResult($r)) {
522                         $message = L10n::t('Unable to set your contact credentials on our system.');
523                         System::xmlExit(3, $message);
524                 }
525
526                 // It's possible that the other person also requested friendship.
527                 // If it is a duplex relationship, ditch the issued-id if one exists.
528
529                 if ($duplex) {
530                         q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d",
531                                 intval($dfrn_record)
532                         );
533                 }
534
535                 // We're good but now we have to scrape the profile photo and send notifications.
536                 $contact = DBA::selectFirst('contact', ['photo'], ['id' => $dfrn_record]);
537                 if (DBA::isResult($contact)) {
538                         $photo = $contact['photo'];
539                 } else {
540                         $photo = System::baseUrl() . '/images/person-300.jpg';
541                 }
542
543                 Contact::updateAvatar($photo, $local_uid, $dfrn_record);
544
545                 logger('dfrn_confirm: request - photos imported');
546
547                 $new_relation = Contact::SHARING;
548
549                 if (($relation == Contact::FOLLOWER) || ($duplex)) {
550                         $new_relation = Contact::FRIEND;
551                 }
552
553                 if (($relation == Contact::FOLLOWER) && ($duplex)) {
554                         $duplex = 0;
555                 }
556
557                 $r = q("UPDATE `contact` SET
558                         `rel` = %d,
559                         `name-date` = '%s',
560                         `uri-date` = '%s',
561                         `blocked` = 0,
562                         `pending` = 0,
563                         `duplex` = %d,
564                         `forum` = %d,
565                         `prv` = %d,
566                         `network` = '%s' WHERE `id` = %d
567                 ",
568                         intval($new_relation),
569                         DBA::escape(DateTimeFormat::utcNow()),
570                         DBA::escape(DateTimeFormat::utcNow()),
571                         intval($duplex),
572                         intval($forum),
573                         intval($prv),
574                         DBA::escape(Protocol::DFRN),
575                         intval($dfrn_record)
576                 );
577                 if (!DBA::isResult($r)) {       // indicates schema is messed up or total db failure
578                         $message = L10n::t('Unable to update your contact profile details on our system');
579                         System::xmlExit(3, $message);
580                 }
581
582                 // Otherwise everything seems to have worked and we are almost done. Yay!
583                 // Send an email notification
584
585                 logger('dfrn_confirm: request: info updated');
586
587                 $combined = null;
588                 $r = q("SELECT `contact`.*, `user`.*
589                         FROM `contact`
590                         LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
591                         WHERE `contact`.`id` = %d
592                         LIMIT 1",
593                         intval($dfrn_record)
594                 );
595                 if (DBA::isResult($r)) {
596                         $combined = $r[0];
597
598                         if ($combined['notify-flags'] & NOTIFY_CONFIRM) {
599                                 $mutual = ($new_relation == Contact::FRIEND);
600                                 notification([
601                                         'type'         => NOTIFY_CONFIRM,
602                                         'notify_flags' => $combined['notify-flags'],
603                                         'language'     => $combined['language'],
604                                         'to_name'      => $combined['username'],
605                                         'to_email'     => $combined['email'],
606                                         'uid'          => $combined['uid'],
607                                         'link'         => System::baseUrl() . '/contact/' . $dfrn_record,
608                                         'source_name'  => ((strlen(stripslashes($combined['name']))) ? stripslashes($combined['name']) : L10n::t('[Name Withheld]')),
609                                         'source_link'  => $combined['url'],
610                                         'source_photo' => $combined['photo'],
611                                         'verb'         => ($mutual?ACTIVITY_FRIEND:ACTIVITY_FOLLOW),
612                                         'otype'        => 'intro'
613                                 ]);
614                         }
615                 }
616
617                 System::xmlExit(0); // Success
618                 return; // NOTREACHED
619                 ////////////////////// End of this scenario ///////////////////////////////////////////////
620         }
621
622         // somebody arrived here by mistake or they are fishing. Send them to the homepage.
623         $a->internalRedirect();
624         // NOTREACHED
625 }