]> git.mxchange.org Git - friendica.git/blob - mod/dfrn_poll.php
Replace x() by isset(), !empty() or defaults()
[friendica.git] / mod / dfrn_poll.php
1 <?php
2
3 /**
4  * @file mod/dfrn_poll.php
5  */
6
7 use Friendica\App;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
10 use Friendica\Core\Logger;
11 use Friendica\Core\System;
12 use Friendica\Database\DBA;
13 use Friendica\Module\Login;
14 use Friendica\Protocol\DFRN;
15 use Friendica\Protocol\OStatus;
16 use Friendica\Util\Network;
17 use Friendica\Util\Strings;
18 use Friendica\Util\XML;
19
20 require_once 'include/items.php';
21
22 function dfrn_poll_init(App $a)
23 {
24         Login::sessionAuth();
25
26         $dfrn_id         = defaults($_GET, 'dfrn_id'        , '');
27         $type            = defaults($_GET, 'type'           , 'data');
28         $last_update     = defaults($_GET, 'last_update'    , '');
29         $destination_url = defaults($_GET, 'destination_url', '');
30         $challenge       = defaults($_GET, 'challenge'      , '');
31         $sec             = defaults($_GET, 'sec'            , '');
32         $dfrn_version    = (float) defaults($_GET, 'dfrn_version'   , 2.0);
33         $perm            = defaults($_GET, 'perm'           , 'r');
34         $quiet                   = !empty($_GET['quiet']);
35
36         // Possibly it is an OStatus compatible server that requests a user feed
37         $user_agent = defaults($_SERVER, 'HTTP_USER_AGENT', '');
38         if (($a->argc > 1) && ($dfrn_id == '') && !strstr($user_agent, 'Friendica')) {
39                 $nickname = $a->argv[1];
40                 header("Content-type: application/atom+xml");
41                 echo OStatus::feed($nickname, $last_update, 10);
42                 killme();
43         }
44
45         $direction = -1;
46
47         if (strpos($dfrn_id, ':') == 1) {
48                 $direction = intval(substr($dfrn_id, 0, 1));
49                 $dfrn_id = substr($dfrn_id, 2);
50         }
51
52         $hidewall = false;
53
54         if (($dfrn_id === '') && empty($_POST['dfrn_id'])) {
55                 if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
56                         System::httpExit(403);
57                 }
58
59                 $user = '';
60                 if ($a->argc > 1) {
61                         $r = q("SELECT `hidewall`,`nickname` FROM `user` WHERE `user`.`nickname` = '%s' LIMIT 1",
62                                 DBA::escape($a->argv[1])
63                         );
64                         if (!$r) {
65                                 System::httpExit(404);
66                         }
67
68                         $hidewall = ($r[0]['hidewall'] && !local_user());
69
70                         $user = $r[0]['nickname'];
71                 }
72
73                 Logger::log('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $user);
74                 header("Content-type: application/atom+xml");
75                 echo DFRN::feed('', $user, $last_update, 0, $hidewall);
76                 killme();
77         }
78
79         if (($type === 'profile') && (!strlen($sec))) {
80                 $sql_extra = '';
81                 switch ($direction) {
82                         case -1:
83                                 $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", DBA::escape($dfrn_id), DBA::escape($dfrn_id));
84                                 $my_id = $dfrn_id;
85                                 break;
86                         case 0:
87                                 $sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
88                                 $my_id = '1:' . $dfrn_id;
89                                 break;
90                         case 1:
91                                 $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
92                                 $my_id = '0:' . $dfrn_id;
93                                 break;
94                         default:
95                                 $a->internalRedirect();
96                                 break; // NOTREACHED
97                 }
98
99                 $r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname`
100                         FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
101                         WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
102                         AND `user`.`nickname` = '%s' $sql_extra LIMIT 1",
103                         DBA::escape($a->argv[1])
104                 );
105
106                 if (DBA::isResult($r)) {
107                         $s = Network::fetchUrl($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
108
109                         Logger::log("dfrn_poll: old profile returns " . $s, Logger::DATA);
110
111                         if (strlen($s)) {
112                                 $xml = XML::parseString($s);
113
114                                 if ((int)$xml->status === 1) {
115                                         $_SESSION['authenticated'] = 1;
116                                         if (empty($_SESSION['remote'])) {
117                                                 $_SESSION['remote'] = [];
118                                         }
119
120                                         $_SESSION['remote'][] = ['cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']];
121
122                                         $_SESSION['visitor_id'] = $r[0]['id'];
123                                         $_SESSION['visitor_home'] = $r[0]['url'];
124                                         $_SESSION['visitor_handle'] = $r[0]['addr'];
125                                         $_SESSION['visitor_visiting'] = $r[0]['uid'];
126                                         $_SESSION['my_url'] = $r[0]['url'];
127                                         if (!$quiet) {
128                                                 info(L10n::t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL);
129                                         }
130
131                                         // Visitors get 1 day session.
132                                         $session_id = session_id();
133                                         $expire = time() + 86400;
134                                         q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s'",
135                                                 DBA::escape($expire),
136                                                 DBA::escape($session_id)
137                                         );
138                                 }
139                         }
140
141                         $profile = (count($r) > 0 && isset($r[0]['nickname']) ? $r[0]['nickname'] : '');
142                         if (!empty($destination_url)) {
143                                 System::externalRedirect($destination_url);
144                         } else {
145                                 $a->internalRedirect('profile/' . $profile);
146                         }
147                 }
148                 $a->internalRedirect();
149         }
150
151         if ($type === 'profile-check' && $dfrn_version < 2.2) {
152                 if ((strlen($challenge)) && (strlen($sec))) {
153                         DBA::delete('profile_check', ["`expire` < ?", time()]);
154                         $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
155                                 DBA::escape($sec)
156                         );
157                         if (!DBA::isResult($r)) {
158                                 System::xmlExit(3, 'No ticket');
159                                 // NOTREACHED
160                         }
161
162                         $orig_id = $r[0]['dfrn_id'];
163                         if (strpos($orig_id, ':')) {
164                                 $orig_id = substr($orig_id, 2);
165                         }
166
167                         $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
168                                 intval($r[0]['cid'])
169                         );
170                         if (!DBA::isResult($c)) {
171                                 System::xmlExit(3, 'No profile');
172                         }
173
174                         $contact = $c[0];
175
176                         $sent_dfrn_id = hex2bin($dfrn_id);
177                         $challenge = hex2bin($challenge);
178
179                         $final_dfrn_id = '';
180
181                         if (($contact['duplex']) && strlen($contact['prvkey'])) {
182                                 openssl_private_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['prvkey']);
183                                 openssl_private_decrypt($challenge, $decoded_challenge, $contact['prvkey']);
184                         } else {
185                                 openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
186                                 openssl_public_decrypt($challenge, $decoded_challenge, $contact['pubkey']);
187                         }
188
189                         $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
190
191                         if (strpos($final_dfrn_id, ':') == 1) {
192                                 $final_dfrn_id = substr($final_dfrn_id, 2);
193                         }
194
195                         if ($final_dfrn_id != $orig_id) {
196                                 Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, Logger::DEBUG);
197                                 // did not decode properly - cannot trust this site
198                                 System::xmlExit(3, 'Bad decryption');
199                         }
200
201                         header("Content-type: text/xml");
202                         echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><dfrn_poll><status>0</status><challenge>$decoded_challenge</challenge><sec>$sec</sec></dfrn_poll>";
203                         killme();
204                         // NOTREACHED
205                 } else {
206                         // old protocol
207                         switch ($direction) {
208                                 case 1:
209                                         $dfrn_id = '0:' . $dfrn_id;
210                                         break;
211                                 case 0:
212                                         $dfrn_id = '1:' . $dfrn_id;
213                                         break;
214                                 default:
215                                         break;
216                         }
217
218                         DBA::delete('profile_check', ["`expire` < ?", time()]);
219                         $r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
220                                 DBA::escape($dfrn_id));
221                         if (DBA::isResult($r)) {
222                                 System::xmlExit(1);
223                                 return; // NOTREACHED
224                         }
225                         System::xmlExit(0);
226                         return; // NOTREACHED
227                 }
228         }
229 }
230
231 function dfrn_poll_post(App $a)
232 {
233         $dfrn_id      = defaults($_POST, 'dfrn_id'  , '');
234         $challenge    = defaults($_POST, 'challenge', '');
235         $url          = defaults($_POST, 'url'      , '');
236         $sec          = defaults($_POST, 'sec'      , '');
237         $ptype        = defaults($_POST, 'type'     , '');
238         $perm         = defaults($_POST, 'perm'     , 'r');
239         $dfrn_version = !empty($_POST['dfrn_version']) ? (float) $_POST['dfrn_version'] : 2.0;
240
241         if ($ptype === 'profile-check') {
242                 if (strlen($challenge) && strlen($sec)) {
243                         Logger::log('dfrn_poll: POST: profile-check');
244
245                         DBA::delete('profile_check', ["`expire` < ?", time()]);
246                         $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
247                                 DBA::escape($sec)
248                         );
249                         if (!DBA::isResult($r)) {
250                                 System::xmlExit(3, 'No ticket');
251                                 // NOTREACHED
252                         }
253
254                         $orig_id = $r[0]['dfrn_id'];
255                         if (strpos($orig_id, ':')) {
256                                 $orig_id = substr($orig_id, 2);
257                         }
258
259                         $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
260                                 intval($r[0]['cid'])
261                         );
262                         if (!DBA::isResult($c)) {
263                                 System::xmlExit(3, 'No profile');
264                         }
265
266                         $contact = $c[0];
267
268                         $sent_dfrn_id = hex2bin($dfrn_id);
269                         $challenge = hex2bin($challenge);
270
271                         $final_dfrn_id = '';
272
273                         if ($contact['duplex'] && strlen($contact['prvkey'])) {
274                                 openssl_private_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['prvkey']);
275                                 openssl_private_decrypt($challenge, $decoded_challenge, $contact['prvkey']);
276                         } else {
277                                 openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
278                                 openssl_public_decrypt($challenge, $decoded_challenge, $contact['pubkey']);
279                         }
280
281                         $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
282
283                         if (strpos($final_dfrn_id, ':') == 1) {
284                                 $final_dfrn_id = substr($final_dfrn_id, 2);
285                         }
286
287                         if ($final_dfrn_id != $orig_id) {
288                                 Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, Logger::DEBUG);
289                                 // did not decode properly - cannot trust this site
290                                 System::xmlExit(3, 'Bad decryption');
291                         }
292
293                         header("Content-type: text/xml");
294                         echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><dfrn_poll><status>0</status><challenge>$decoded_challenge</challenge><sec>$sec</sec></dfrn_poll>";
295                         killme();
296                         // NOTREACHED
297                 }
298         }
299
300         $direction = -1;
301         if (strpos($dfrn_id, ':') == 1) {
302                 $direction = intval(substr($dfrn_id, 0, 1));
303                 $dfrn_id = substr($dfrn_id, 2);
304         }
305
306         $r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
307                 DBA::escape($dfrn_id),
308                 DBA::escape($challenge)
309         );
310
311         if (!DBA::isResult($r)) {
312                 killme();
313         }
314
315         $type = $r[0]['type'];
316         $last_update = $r[0]['last_update'];
317
318         DBA::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]);
319
320         $sql_extra = '';
321         switch ($direction) {
322                 case -1:
323                         $sql_extra = sprintf(" AND `issued-id` = '%s' ", DBA::escape($dfrn_id));
324                         $my_id = $dfrn_id;
325                         break;
326                 case 0:
327                         $sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
328                         $my_id = '1:' . $dfrn_id;
329                         break;
330                 case 1:
331                         $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
332                         $my_id = '0:' . $dfrn_id;
333                         break;
334                 default:
335                         $a->internalRedirect();
336                         break; // NOTREACHED
337         }
338
339         $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
340         if (!DBA::isResult($r)) {
341                 killme();
342         }
343
344         $contact = $r[0];
345         $owner_uid = $r[0]['uid'];
346         $contact_id = $r[0]['id'];
347
348         if ($type === 'reputation' && strlen($url)) {
349                 $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
350                         DBA::escape($url),
351                         intval($owner_uid)
352                 );
353                 $reputation = 0;
354                 $text = '';
355
356                 if (DBA::isResult($r)) {
357                         $reputation = $r[0]['rating'];
358                         $text = $r[0]['reason'];
359
360                         if ($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed
361                                 $reputation = 0;
362                                 $text = '';
363                         }
364                 }
365
366                 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
367                 <reputation>
368                         <url>$url</url>
369                         <rating>$reputation</rating>
370                         <description>$text</description>
371                 </reputation>
372                 ";
373                 killme();
374                 // NOTREACHED
375         } else {
376                 // Update the writable flag if it changed
377                 Logger::log('dfrn_poll: post request feed: ' . print_r($_POST, true), Logger::DATA);
378                 if ($dfrn_version >= 2.21) {
379                         if ($perm === 'rw') {
380                                 $writable = 1;
381                         } else {
382                                 $writable = 0;
383                         }
384
385                         if ($writable != $contact['writable']) {
386                                 q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
387                                         intval($writable),
388                                         intval($contact_id)
389                                 );
390                         }
391                 }
392
393                 header("Content-type: application/atom+xml");
394                 $o = DFRN::feed($dfrn_id, $a->argv[1], $last_update, $direction);
395                 echo $o;
396                 killme();
397         }
398 }
399
400 function dfrn_poll_content(App $a)
401 {
402         $dfrn_id         = defaults($_GET, 'dfrn_id'        , '');
403         $type            = defaults($_GET, 'type'           , 'data');
404         $last_update     = defaults($_GET, 'last_update'    , '');
405         $destination_url = defaults($_GET, 'destination_url', '');
406         $sec             = defaults($_GET, 'sec'            , '');
407         $dfrn_version    = !empty($_GET['dfrn_version'])    ? (float) $_GET['dfrn_version'] : 2.0;
408         $quiet           = !empty($_GET['quiet']);
409
410         $direction = -1;
411         if (strpos($dfrn_id, ':') == 1) {
412                 $direction = intval(substr($dfrn_id, 0, 1));
413                 $dfrn_id = substr($dfrn_id, 2);
414         }
415
416         if ($dfrn_id != '') {
417                 // initial communication from external contact
418                 $hash = Strings::getRandomHex();
419
420                 $status = 0;
421
422                 DBA::delete('challenge', ["`expire` < ?", time()]);
423
424                 if ($type !== 'profile') {
425                         $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` )
426                                 VALUES( '%s', '%s', '%s', '%s', '%s' ) ",
427                                 DBA::escape($hash),
428                                 DBA::escape($dfrn_id),
429                                 intval(time() + 60 ),
430                                 DBA::escape($type),
431                                 DBA::escape($last_update)
432                         );
433                 }
434
435                 $sql_extra = '';
436                 switch ($direction) {
437                         case -1:
438                                 if ($type === 'profile') {
439                                         $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", DBA::escape($dfrn_id), DBA::escape($dfrn_id));
440                                 } else {
441                                         $sql_extra = sprintf(" AND `issued-id` = '%s' ", DBA::escape($dfrn_id));
442                                 }
443
444                                 $my_id = $dfrn_id;
445                                 break;
446                         case 0:
447                                 $sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
448                                 $my_id = '1:' . $dfrn_id;
449                                 break;
450                         case 1:
451                                 $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
452                                 $my_id = '0:' . $dfrn_id;
453                                 break;
454                         default:
455                                 $a->internalRedirect();
456                                 break; // NOTREACHED
457                 }
458
459                 $nickname = $a->argv[1];
460
461                 $r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname`
462                         FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
463                         WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
464                         AND `user`.`nickname` = '%s' $sql_extra LIMIT 1",
465                         DBA::escape($nickname)
466                 );
467                 if (DBA::isResult($r)) {
468                         $challenge = '';
469                         $encrypted_id = '';
470                         $id_str = $my_id . '.' . mt_rand(1000, 9999);
471
472                         if (($r[0]['duplex'] && strlen($r[0]['pubkey'])) || !strlen($r[0]['prvkey'])) {
473                                 openssl_public_encrypt($hash, $challenge, $r[0]['pubkey']);
474                                 openssl_public_encrypt($id_str, $encrypted_id, $r[0]['pubkey']);
475                         } else {
476                                 openssl_private_encrypt($hash, $challenge, $r[0]['prvkey']);
477                                 openssl_private_encrypt($id_str, $encrypted_id, $r[0]['prvkey']);
478                         }
479
480                         $challenge = bin2hex($challenge);
481                         $encrypted_id = bin2hex($encrypted_id);
482                 } else {
483                         $status = 1;
484                         $challenge = '';
485                         $encrypted_id = '';
486                 }
487
488                 if (($type === 'profile') && (strlen($sec))) {
489                         // heluecht: I don't know why we don't fail immediately when the user or contact hadn't been found.
490                         // Since it doesn't make sense to continue from this point on, we now fail here. This should be safe.
491                         if (!DBA::isResult($r)) {
492                                 System::httpExit(404, ["title" => L10n::t('Page not found.')]);
493                         }
494
495                         // URL reply
496                         if ($dfrn_version < 2.2) {
497                                 $s = Network::fetchUrl($r[0]['poll']
498                                         . '?dfrn_id=' . $encrypted_id
499                                         . '&type=profile-check'
500                                         . '&dfrn_version=' . DFRN_PROTOCOL_VERSION
501                                         . '&challenge=' . $challenge
502                                         . '&sec=' . $sec
503                                 );
504                         } else {
505                                 $s = Network::post($r[0]['poll'], [
506                                         'dfrn_id' => $encrypted_id,
507                                         'type' => 'profile-check',
508                                         'dfrn_version' => DFRN_PROTOCOL_VERSION,
509                                         'challenge' => $challenge,
510                                         'sec' => $sec
511                                 ])->getBody();
512                         }
513
514                         Logger::log("dfrn_poll: sec profile: " . $s, Logger::DATA);
515
516                         if (strlen($s) && strstr($s, '<?xml')) {
517                                 $xml = XML::parseString($s);
518
519                                 Logger::log('dfrn_poll: profile: parsed xml: ' . print_r($xml, true), Logger::DATA);
520
521                                 Logger::log('dfrn_poll: secure profile: challenge: ' . $xml->challenge . ' expecting ' . $hash);
522                                 Logger::log('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec);
523
524                                 if (((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) {
525                                         $_SESSION['authenticated'] = 1;
526                                         if (empty($_SESSION['remote'])) {
527                                                 $_SESSION['remote'] = [];
528                                         }
529
530                                         $_SESSION['remote'][] = ['cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']];
531                                         $_SESSION['visitor_id'] = $r[0]['id'];
532                                         $_SESSION['visitor_home'] = $r[0]['url'];
533                                         $_SESSION['visitor_visiting'] = $r[0]['uid'];
534                                         $_SESSION['my_url'] = $r[0]['url'];
535                                         if (!$quiet) {
536                                                 info(L10n::t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL);
537                                         }
538
539                                         // Visitors get 1 day session.
540                                         $session_id = session_id();
541                                         $expire = time() + 86400;
542                                         q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s'",
543                                                 DBA::escape($expire),
544                                                 DBA::escape($session_id)
545                                         );
546                                 }
547                         }
548
549                         $profile = ((DBA::isResult($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
550
551                         switch ($destination_url) {
552                                 case 'profile':
553                                         $a->internalRedirect('profile/' . $profile . '?f=&tab=profile');
554                                         break;
555                                 case 'photos':
556                                         $a->internalRedirect('photos/' . $profile);
557                                         break;
558                                 case 'status':
559                                 case '':
560                                         $a->internalRedirect('profile/' . $profile);
561                                         break;
562                                 default:
563                                         $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
564                                         if (filter_var($url, FILTER_VALIDATE_URL)) {
565                                                 System::externalRedirect($destination_url . $appendix);
566                                         } else {
567                                                 $a->internalRedirect($destination_url . $appendix);
568                                         }
569                                         break;
570                         }
571                         // NOTREACHED
572                 } else {
573                         // XML reply
574                         header("Content-type: text/xml");
575                         echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"
576                                 . '<dfrn_poll>' . "\r\n"
577                                 . "\t" . '<status>' . $status . '</status>' . "\r\n"
578                                 . "\t" . '<dfrn_version>' . DFRN_PROTOCOL_VERSION . '</dfrn_version>' . "\r\n"
579                                 . "\t" . '<dfrn_id>' . $encrypted_id . '</dfrn_id>' . "\r\n"
580                                 . "\t" . '<challenge>' . $challenge . '</challenge>' . "\r\n"
581                                 . '</dfrn_poll>' . "\r\n";
582                         killme();
583                         // NOTREACHED
584                 }
585         }
586 }