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