]> git.mxchange.org Git - friendica.git/blob - mod/dfrn_poll.php
Merge remote-tracking branch 'upstream/master' into develop
[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\XML;
18
19 require_once 'include/items.php';
20
21 function dfrn_poll_init(App $a)
22 {
23         Login::sessionAuth();
24
25         $dfrn_id         = defaults($_GET, 'dfrn_id'        , '');
26         $type            = defaults($_GET, 'type'           , 'data');
27         $last_update     = defaults($_GET, 'last_update'    , '');
28         $destination_url = defaults($_GET, 'destination_url', '');
29         $challenge       = defaults($_GET, 'challenge'      , '');
30         $sec             = defaults($_GET, 'sec'            , '');
31         $dfrn_version    = (float) defaults($_GET, 'dfrn_version'   , 2.0);
32         $perm            = defaults($_GET, 'perm'           , 'r');
33         $quiet                   = x($_GET, 'quiet');
34
35         // Possibly it is an OStatus compatible server that requests a user feed
36         $user_agent = defaults($_SERVER, 'HTTP_USER_AGENT', '');
37         if (($a->argc > 1) && ($dfrn_id == '') && !strstr($user_agent, 'Friendica')) {
38                 $nickname = $a->argv[1];
39                 header("Content-type: application/atom+xml");
40                 echo OStatus::feed($nickname, $last_update, 10);
41                 killme();
42         }
43
44         $direction = -1;
45
46         if (strpos($dfrn_id, ':') == 1) {
47                 $direction = intval(substr($dfrn_id, 0, 1));
48                 $dfrn_id = substr($dfrn_id, 2);
49         }
50
51         $hidewall = false;
52
53         if (($dfrn_id === '') && (!x($_POST, 'dfrn_id'))) {
54                 if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
55                         System::httpExit(403);
56                 }
57
58                 $user = '';
59                 if ($a->argc > 1) {
60                         $r = q("SELECT `hidewall`,`nickname` FROM `user` WHERE `user`.`nickname` = '%s' LIMIT 1",
61                                 DBA::escape($a->argv[1])
62                         );
63                         if (!$r) {
64                                 System::httpExit(404);
65                         }
66
67                         $hidewall = ($r[0]['hidewall'] && !local_user());
68
69                         $user = $r[0]['nickname'];
70                 }
71
72                 Logger::log('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $user);
73                 header("Content-type: application/atom+xml");
74                 echo DFRN::feed('', $user, $last_update, 0, $hidewall);
75                 killme();
76         }
77
78         if (($type === 'profile') && (!strlen($sec))) {
79                 $sql_extra = '';
80                 switch ($direction) {
81                         case -1:
82                                 $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", DBA::escape($dfrn_id), DBA::escape($dfrn_id));
83                                 $my_id = $dfrn_id;
84                                 break;
85                         case 0:
86                                 $sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
87                                 $my_id = '1:' . $dfrn_id;
88                                 break;
89                         case 1:
90                                 $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
91                                 $my_id = '0:' . $dfrn_id;
92                                 break;
93                         default:
94                                 $a->internalRedirect();
95                                 break; // NOTREACHED
96                 }
97
98                 $r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname`
99                         FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
100                         WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
101                         AND `user`.`nickname` = '%s' $sql_extra LIMIT 1",
102                         DBA::escape($a->argv[1])
103                 );
104
105                 if (DBA::isResult($r)) {
106                         $s = Network::fetchUrl($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
107
108                         Logger::log("dfrn_poll: old profile returns " . $s, Logger::DATA);
109
110                         if (strlen($s)) {
111                                 $xml = XML::parseString($s);
112
113                                 if ((int)$xml->status === 1) {
114                                         $_SESSION['authenticated'] = 1;
115                                         if (!x($_SESSION, 'remote')) {
116                                                 $_SESSION['remote'] = [];
117                                         }
118
119                                         $_SESSION['remote'][] = ['cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']];
120
121                                         $_SESSION['visitor_id'] = $r[0]['id'];
122                                         $_SESSION['visitor_home'] = $r[0]['url'];
123                                         $_SESSION['visitor_handle'] = $r[0]['addr'];
124                                         $_SESSION['visitor_visiting'] = $r[0]['uid'];
125                                         $_SESSION['my_url'] = $r[0]['url'];
126                                         if (!$quiet) {
127                                                 info(L10n::t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL);
128                                         }
129
130                                         // Visitors get 1 day session.
131                                         $session_id = session_id();
132                                         $expire = time() + 86400;
133                                         q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s'",
134                                                 DBA::escape($expire),
135                                                 DBA::escape($session_id)
136                                         );
137                                 }
138                         }
139
140                         $profile = (count($r) > 0 && isset($r[0]['nickname']) ? $r[0]['nickname'] : '');
141                         if (!empty($destination_url)) {
142                                 System::externalRedirect($destination_url);
143                         } else {
144                                 $a->internalRedirect('profile/' . $profile);
145                         }
146                 }
147                 $a->internalRedirect();
148         }
149
150         if ($type === 'profile-check' && $dfrn_version < 2.2) {
151                 if ((strlen($challenge)) && (strlen($sec))) {
152                         DBA::delete('profile_check', ["`expire` < ?", time()]);
153                         $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
154                                 DBA::escape($sec)
155                         );
156                         if (!DBA::isResult($r)) {
157                                 System::xmlExit(3, 'No ticket');
158                                 // NOTREACHED
159                         }
160
161                         $orig_id = $r[0]['dfrn_id'];
162                         if (strpos($orig_id, ':')) {
163                                 $orig_id = substr($orig_id, 2);
164                         }
165
166                         $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
167                                 intval($r[0]['cid'])
168                         );
169                         if (!DBA::isResult($c)) {
170                                 System::xmlExit(3, 'No profile');
171                         }
172
173                         $contact = $c[0];
174
175                         $sent_dfrn_id = hex2bin($dfrn_id);
176                         $challenge = hex2bin($challenge);
177
178                         $final_dfrn_id = '';
179
180                         if (($contact['duplex']) && strlen($contact['prvkey'])) {
181                                 openssl_private_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['prvkey']);
182                                 openssl_private_decrypt($challenge, $decoded_challenge, $contact['prvkey']);
183                         } else {
184                                 openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
185                                 openssl_public_decrypt($challenge, $decoded_challenge, $contact['pubkey']);
186                         }
187
188                         $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
189
190                         if (strpos($final_dfrn_id, ':') == 1) {
191                                 $final_dfrn_id = substr($final_dfrn_id, 2);
192                         }
193
194                         if ($final_dfrn_id != $orig_id) {
195                                 Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, Logger::DEBUG);
196                                 // did not decode properly - cannot trust this site
197                                 System::xmlExit(3, 'Bad decryption');
198                         }
199
200                         header("Content-type: text/xml");
201                         echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><dfrn_poll><status>0</status><challenge>$decoded_challenge</challenge><sec>$sec</sec></dfrn_poll>";
202                         killme();
203                         // NOTREACHED
204                 } else {
205                         // old protocol
206                         switch ($direction) {
207                                 case 1:
208                                         $dfrn_id = '0:' . $dfrn_id;
209                                         break;
210                                 case 0:
211                                         $dfrn_id = '1:' . $dfrn_id;
212                                         break;
213                                 default:
214                                         break;
215                         }
216
217                         DBA::delete('profile_check', ["`expire` < ?", time()]);
218                         $r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
219                                 DBA::escape($dfrn_id));
220                         if (DBA::isResult($r)) {
221                                 System::xmlExit(1);
222                                 return; // NOTREACHED
223                         }
224                         System::xmlExit(0);
225                         return; // NOTREACHED
226                 }
227         }
228 }
229
230 function dfrn_poll_post(App $a)
231 {
232         $dfrn_id      = x($_POST,'dfrn_id')      ? $_POST['dfrn_id']              : '';
233         $challenge    = x($_POST,'challenge')    ? $_POST['challenge']            : '';
234         $url          = x($_POST,'url')          ? $_POST['url']                  : '';
235         $sec          = x($_POST,'sec')          ? $_POST['sec']                  : '';
236         $ptype        = x($_POST,'type')         ? $_POST['type']                 : '';
237         $dfrn_version = x($_POST,'dfrn_version') ? (float) $_POST['dfrn_version'] : 2.0;
238         $perm         = x($_POST,'perm')         ? $_POST['perm']                 : 'r';
239
240         if ($ptype === 'profile-check') {
241                 if (strlen($challenge) && strlen($sec)) {
242                         Logger::log('dfrn_poll: POST: profile-check');
243
244                         DBA::delete('profile_check', ["`expire` < ?", time()]);
245                         $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
246                                 DBA::escape($sec)
247                         );
248                         if (!DBA::isResult($r)) {
249                                 System::xmlExit(3, 'No ticket');
250                                 // NOTREACHED
251                         }
252
253                         $orig_id = $r[0]['dfrn_id'];
254                         if (strpos($orig_id, ':')) {
255                                 $orig_id = substr($orig_id, 2);
256                         }
257
258                         $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
259                                 intval($r[0]['cid'])
260                         );
261                         if (!DBA::isResult($c)) {
262                                 System::xmlExit(3, 'No profile');
263                         }
264
265                         $contact = $c[0];
266
267                         $sent_dfrn_id = hex2bin($dfrn_id);
268                         $challenge = hex2bin($challenge);
269
270                         $final_dfrn_id = '';
271
272                         if ($contact['duplex'] && strlen($contact['prvkey'])) {
273                                 openssl_private_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['prvkey']);
274                                 openssl_private_decrypt($challenge, $decoded_challenge, $contact['prvkey']);
275                         } else {
276                                 openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
277                                 openssl_public_decrypt($challenge, $decoded_challenge, $contact['pubkey']);
278                         }
279
280                         $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
281
282                         if (strpos($final_dfrn_id, ':') == 1) {
283                                 $final_dfrn_id = substr($final_dfrn_id, 2);
284                         }
285
286                         if ($final_dfrn_id != $orig_id) {
287                                 Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, Logger::DEBUG);
288                                 // did not decode properly - cannot trust this site
289                                 System::xmlExit(3, 'Bad decryption');
290                         }
291
292                         header("Content-type: text/xml");
293                         echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><dfrn_poll><status>0</status><challenge>$decoded_challenge</challenge><sec>$sec</sec></dfrn_poll>";
294                         killme();
295                         // NOTREACHED
296                 }
297         }
298
299         $direction = -1;
300         if (strpos($dfrn_id, ':') == 1) {
301                 $direction = intval(substr($dfrn_id, 0, 1));
302                 $dfrn_id = substr($dfrn_id, 2);
303         }
304
305         $r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
306                 DBA::escape($dfrn_id),
307                 DBA::escape($challenge)
308         );
309
310         if (!DBA::isResult($r)) {
311                 killme();
312         }
313
314         $type = $r[0]['type'];
315         $last_update = $r[0]['last_update'];
316
317         DBA::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]);
318
319         $sql_extra = '';
320         switch ($direction) {
321                 case -1:
322                         $sql_extra = sprintf(" AND `issued-id` = '%s' ", DBA::escape($dfrn_id));
323                         $my_id = $dfrn_id;
324                         break;
325                 case 0:
326                         $sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
327                         $my_id = '1:' . $dfrn_id;
328                         break;
329                 case 1:
330                         $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
331                         $my_id = '0:' . $dfrn_id;
332                         break;
333                 default:
334                         $a->internalRedirect();
335                         break; // NOTREACHED
336         }
337
338         $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
339         if (!DBA::isResult($r)) {
340                 killme();
341         }
342
343         $contact = $r[0];
344         $owner_uid = $r[0]['uid'];
345         $contact_id = $r[0]['id'];
346
347         if ($type === 'reputation' && strlen($url)) {
348                 $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
349                         DBA::escape($url),
350                         intval($owner_uid)
351                 );
352                 $reputation = 0;
353                 $text = '';
354
355                 if (DBA::isResult($r)) {
356                         $reputation = $r[0]['rating'];
357                         $text = $r[0]['reason'];
358
359                         if ($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed
360                                 $reputation = 0;
361                                 $text = '';
362                         }
363                 }
364
365                 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
366                 <reputation>
367                         <url>$url</url>
368                         <rating>$reputation</rating>
369                         <description>$text</description>
370                 </reputation>
371                 ";
372                 killme();
373                 // NOTREACHED
374         } else {
375                 // Update the writable flag if it changed
376                 Logger::log('dfrn_poll: post request feed: ' . print_r($_POST, true), Logger::DATA);
377                 if ($dfrn_version >= 2.21) {
378                         if ($perm === 'rw') {
379                                 $writable = 1;
380                         } else {
381                                 $writable = 0;
382                         }
383
384                         if ($writable != $contact['writable']) {
385                                 q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
386                                         intval($writable),
387                                         intval($contact_id)
388                                 );
389                         }
390                 }
391
392                 header("Content-type: application/atom+xml");
393                 $o = DFRN::feed($dfrn_id, $a->argv[1], $last_update, $direction);
394                 echo $o;
395                 killme();
396         }
397 }
398
399 function dfrn_poll_content(App $a)
400 {
401         $dfrn_id         = x($_GET,'dfrn_id')         ? $_GET['dfrn_id']              : '';
402         $type            = x($_GET,'type')            ? $_GET['type']                 : 'data';
403         $last_update     = x($_GET,'last_update')     ? $_GET['last_update']          : '';
404         $destination_url = x($_GET,'destination_url') ? $_GET['destination_url']      : '';
405         $sec             = x($_GET,'sec')             ? $_GET['sec']                  : '';
406         $dfrn_version    = x($_GET,'dfrn_version')    ? (float) $_GET['dfrn_version'] : 2.0;
407         $perm            = x($_GET,'perm')            ? $_GET['perm']                 : 'r';
408         $quiet           = x($_GET,'quiet')           ? true                          : false;
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 = random_string();
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 (!x($_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                                         System::externalRedirect($destination_url . $appendix);
565                                         break;
566                         }
567                         // NOTREACHED
568                 } else {
569                         // XML reply
570                         header("Content-type: text/xml");
571                         echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"
572                                 . '<dfrn_poll>' . "\r\n"
573                                 . "\t" . '<status>' . $status . '</status>' . "\r\n"
574                                 . "\t" . '<dfrn_version>' . DFRN_PROTOCOL_VERSION . '</dfrn_version>' . "\r\n"
575                                 . "\t" . '<dfrn_id>' . $encrypted_id . '</dfrn_id>' . "\r\n"
576                                 . "\t" . '<challenge>' . $challenge . '</challenge>' . "\r\n"
577                                 . '</dfrn_poll>' . "\r\n";
578                         killme();
579                         // NOTREACHED
580                 }
581         }
582 }