]> git.mxchange.org Git - friendica.git/blob - include/poller.php
Merge remote branch 'upstream/master'
[friendica.git] / include / poller.php
1 <?php
2
3 require_once("boot.php");
4 require_once("include/quoteconvert.php");
5
6
7 function poller_run($argv, $argc){
8         global $a, $db;
9
10         if(is_null($a)) {
11                 $a = new App;
12         }
13   
14         if(is_null($db)) {
15             @include(".htconfig.php");
16         require_once("dba.php");
17             $db = new dba($db_host, $db_user, $db_pass, $db_data);
18         unset($db_host, $db_user, $db_pass, $db_data);
19         };
20
21
22         require_once('include/session.php');
23         require_once('include/datetime.php');
24         require_once('library/simplepie/simplepie.inc');
25         require_once('include/items.php');
26         require_once('include/Contact.php');
27         require_once('include/email.php');
28         require_once('include/socgraph.php');
29
30         load_config('config');
31         load_config('system');
32
33         $a->set_baseurl(get_config('system','url'));
34
35         load_hooks();
36
37         logger('poller: start');
38         
39         // run queue delivery process in the background
40
41         proc_run('php',"include/queue.php");
42         
43         // expire any expired accounts
44
45         q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0 
46                 AND `account_expires_on` != '0000-00-00 00:00:00' 
47                 AND `account_expires_on` < UTC_TIMESTAMP() ");
48   
49         $abandon_days = intval(get_config('system','account_abandon_days'));
50         if($abandon_days < 1)
51                 $abandon_days = 0;
52
53         
54
55         // once daily run birthday_updates and then expire in background
56
57         $d1 = get_config('system','last_expire_day');
58         $d2 = intval(datetime_convert('UTC','UTC','now','d'));
59
60         if($d2 != intval($d1)) {
61
62                 update_contact_birthdays();
63
64                 update_suggestions();
65
66                 set_config('system','last_expire_day',$d2);
67                 proc_run('php','include/expire.php');
68         }
69
70         // clear old cache
71         Cache::clear();
72
73         $manual_id  = 0;
74         $generation = 0;
75         $hub_update = false;
76         $force      = false;
77         $restart    = false;
78
79         if(($argc > 1) && ($argv[1] == 'force'))
80                 $force = true;
81
82         if(($argc > 1) && ($argv[1] == 'restart')) {
83                 $restart = true;
84                 $generation = intval($argv[2]);
85                 if(! $generation)
86                         killme();               
87         }
88
89         if(($argc > 1) && intval($argv[1])) {
90                 $manual_id = intval($argv[1]);
91                 $force     = true;
92         }
93
94         $sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
95
96         reload_plugins();
97
98         $d = datetime_convert();
99
100         if(! $restart)
101                 proc_run('php','include/cronhooks.php');
102
103         // Only poll from those with suitable relationships,
104         // and which have a polling address and ignore Diaspora since 
105         // we are unable to match those posts with a Diaspora GUID and prevent duplicates.
106
107         $abandon_sql = (($abandon_days) 
108                 ? sprintf(" AND `user`.`login_date` > UTC_TIMESTAMP() - INTERVAL %d DAY ", intval($abandon_days)) 
109                 : '' 
110         );
111
112         $contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` 
113                 WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
114                 AND NOT `network` IN ( '%s', '%s' )
115                 $sql_extra 
116                 AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0 
117                 AND `user`.`account_expired` = 0 $abandon_sql ORDER BY RAND()",
118                 intval(CONTACT_IS_SHARING),
119                 intval(CONTACT_IS_FRIEND),
120                 dbesc(NETWORK_DIASPORA),
121                 dbesc(NETWORK_FACEBOOK)
122         );
123
124         if(! count($contacts)) {
125                 return;
126         }
127
128         foreach($contacts as $c) {
129
130                 $res = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
131                         intval($c['id'])
132                 );
133
134                 if((! $res) || (! count($res)))
135                         continue;
136
137                 foreach($res as $contact) {
138
139                         $xml = false;
140
141                         if($manual_id)
142                                 $contact['last-update'] = '0000-00-00 00:00:00';
143
144                         if($contact['network'] === NETWORK_DFRN || $contact['network'] === NETWORK_OSTATUS)
145                                 $contact['priority'] = 2;
146
147                         if($contact['priority'] || $contact['subhub']) {
148
149                                 $hub_update = true;
150                                 $update     = false;
151
152                                 $t = $contact['last-update'];
153
154                                 // We should be getting everything via a hub. But just to be sure, let's check once a day.
155                                 // (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
156                                 // This also lets us update our subscription to the hub, and add or replace hubs in case it
157                                 // changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'. 
158
159
160                                 if($contact['subhub']) {
161                                         $interval = get_config('system','pushpoll_frequency');
162                                         $contact['priority'] = (($interval !== false) ? intval($interval) : 3);
163                                         $hub_update = false;
164         
165                                         if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force)
166                                                         $hub_update = true;
167                                 }
168                                 else
169                                         $hub_update = false;
170
171                                 /**
172                                  * Based on $contact['priority'], should we poll this site now? Or later?
173                                  */                     
174
175                                 switch ($contact['priority']) {
176                                         case 5:
177                                                 if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 month"))
178                                                         $update = true;
179                                                 break;                                  
180                                         case 4:
181                                                 if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 week"))
182                                                         $update = true;
183                                                 break;
184                                         case 3:
185                                                 if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
186                                                         $update = true;
187                                                 break;
188                                         case 2:
189                                                 if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 12 hour"))
190                                                         $update = true;
191                                                 break;
192                                         case 1:
193                                         default:
194                                                 if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 hour"))
195                                                         $update = true;
196                                                 break;
197                                 }
198                                 if((! $update) && (! $force))
199                                         continue;
200                         }
201
202                         // Check to see if we are running out of memory - if so spawn a new process and kill this one
203
204                         $avail_memory = return_bytes(ini_get('memory_limit'));
205                         $memused = memory_get_peak_usage(true);
206                         if(intval($avail_memory)) {
207                                 if(($memused / $avail_memory) > 0.95) {
208                                         if($generation + 1 > 10) {
209                                                 logger('poller: maximum number of spawns exceeded. Terminating.');
210                                                 killme();
211                                         }
212                                         logger('poller: memory exceeded. ' . $memused . ' bytes used. Spawning new poll.');
213                                         proc_run('php', 'include/poller.php', 'restart', (string) $generation + 1);
214                                         killme();
215                                 }
216                         }
217
218                         $importer_uid = $contact['uid'];
219                 
220                         $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
221                                 intval($importer_uid)
222                         );
223                         if(! count($r))
224                                 continue;
225
226                         $importer = $r[0];
227
228                         logger("poller: poll: ({$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
229
230                         $last_update = (($contact['last-update'] === '0000-00-00 00:00:00') 
231                                 ? datetime_convert('UTC','UTC','now - 30 days', ATOM_TIME)
232                                 : datetime_convert('UTC','UTC',$contact['last-update'], ATOM_TIME)
233                         );
234
235                         if($contact['network'] === NETWORK_DFRN) {
236
237                                 $idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
238
239                                 if(intval($contact['duplex']) && $contact['dfrn-id'])
240                                         $idtosend = '0:' . $orig_id;
241                                 if(intval($contact['duplex']) && $contact['issued-id'])
242                                         $idtosend = '1:' . $orig_id;
243
244                                 // they have permission to write to us. We already filtered this in the contact query.
245                                 $perm = 'rw';
246
247                                 $url = $contact['poll'] . '?dfrn_id=' . $idtosend 
248                                         . '&dfrn_version=' . DFRN_PROTOCOL_VERSION 
249                                         . '&type=data&last_update=' . $last_update 
250                                         . '&perm=' . $perm ;
251         
252                                 $handshake_xml = fetch_url($url);
253
254                                 logger('poller: handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA);
255
256
257                                 if(! $handshake_xml) {
258                                         logger("poller: $url appears to be dead - marking for death ");
259                                         // dead connection - might be a transient event, or this might
260                                         // mean the software was uninstalled or the domain expired. 
261                                         // Will keep trying for one month.
262                                         mark_for_death($contact);
263
264                                         // set the last-update so we don't keep polling
265
266                                         $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
267                                                 dbesc(datetime_convert()),
268                                                 intval($contact['id'])
269                                         );
270
271                                         continue;
272                                 }
273
274                                 if(! strstr($handshake_xml,'<?xml')) {
275                                         logger('poller: response from ' . $url . ' did not contain XML.');
276                                         $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
277                                                 dbesc(datetime_convert()),
278                                                 intval($contact['id'])
279                                         );
280                                         continue;
281                                 }
282
283
284                                 $res = parse_xml_string($handshake_xml);
285         
286                                 if(intval($res->status) == 1) {
287                                         logger("poller: $url replied status 1 - marking for death ");
288
289                                         // we may not be friends anymore. Will keep trying for one month.
290                                         // set the last-update so we don't keep polling
291
292                                         $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
293                                                 dbesc(datetime_convert()),
294                                                 intval($contact['id'])
295                                         );
296
297                                         mark_for_death($contact);
298                                 }
299                                 else {
300                                         if($contact['term-date'] != '0000-00-00 00:00:00') {
301                                                 logger("poller: $url back from the dead - removing mark for death");
302                                                 unmark_for_death($contact);
303                                         }
304                                 }
305
306                                 if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id)))
307                                         continue;
308
309                                 if(((float) $res->dfrn_version > 2.21) && ($contact['poco'] == '')) {
310                                         q("update contact set poco = '%s' where id = %d limit 1",
311                                                 dbesc(str_replace('/profile/','/poco/', $contact['url'])),
312                                                 intval($contact['id'])
313                                         );
314                                 }
315
316                                 $postvars = array();
317
318                                 $sent_dfrn_id = hex2bin((string) $res->dfrn_id);
319                                 $challenge    = hex2bin((string) $res->challenge);
320
321                                 $final_dfrn_id = '';
322
323                                 if(($contact['duplex']) && strlen($contact['prvkey'])) {
324                                         openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
325                                         openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']);
326                                 }
327                                 else {
328                                         openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']);
329                                         openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']);
330                                 }
331
332                                 $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
333
334                                 if(strpos($final_dfrn_id,':') == 1)
335                                         $final_dfrn_id = substr($final_dfrn_id,2);
336
337                                 if($final_dfrn_id != $orig_id) {
338                                         logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);    
339                                         // did not decode properly - cannot trust this site 
340                                         continue;
341                                 }
342
343                                 $postvars['dfrn_id'] = $idtosend;
344                                 $postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION;
345                                 $postvars['perm'] = 'rw';
346
347                                 $xml = post_url($contact['poll'],$postvars);
348                         }
349                         elseif(($contact['network'] === NETWORK_OSTATUS) 
350                                 || ($contact['network'] === NETWORK_DIASPORA)
351                                 || ($contact['network'] === NETWORK_FEED) ) {
352
353                                 // Upgrading DB fields from an older Friendica version
354                                 // Will only do this once per notify-enabled OStatus contact
355                                 // or if relationship changes
356
357                                 $stat_writeable = ((($contact['notify']) && ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['rel'] == CONTACT_IS_FRIEND)) ? 1 : 0);
358
359                                 if($stat_writeable != $contact['writable']) {
360                                         q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1",
361                                                 intval($stat_writeable),
362                                                 intval($contact['id'])
363                                         );
364                                 }
365
366                                 // Are we allowed to import from this person?
367
368                                 if($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly'])
369                                         continue;
370
371                                 $xml = fetch_url($contact['poll']);
372                         }
373                         elseif($contact['network'] === NETWORK_MAIL || $contact['network'] === NETWORK_MAIL2) {
374
375                                 logger("Mail: Fetching");
376
377                                 $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
378                                 if($mail_disabled)
379                                         continue;
380
381                                 logger("Mail: Enabled");
382
383                                 $mbox = null;
384                                 $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1",
385                                         intval($importer_uid)
386                                 );
387                                 $mailconf = q("SELECT * FROM `mailacct` WHERE `server` != '' AND `uid` = %d LIMIT 1",
388                                         intval($importer_uid)
389                                 );
390                                 if(count($x) && count($mailconf)) {
391                                     $mailbox = construct_mailbox_name($mailconf[0]);
392                                         $password = '';
393                                         openssl_private_decrypt(hex2bin($mailconf[0]['pass']),$password,$x[0]['prvkey']);
394                                         $mbox = email_connect($mailbox,$mailconf[0]['user'],$password);
395                                         unset($password);
396                                         logger("Mail: Connect");
397                                         if($mbox) {
398                                                 q("UPDATE `mailacct` SET `last_check` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
399                                                         dbesc(datetime_convert()),
400                                                         intval($mailconf[0]['id']),
401                                                         intval($importer_uid)
402                                                 );
403                                         }
404                                 }
405                                 if($mbox) {
406                                         logger("Mail: mbox");
407
408                                         $msgs = email_poll($mbox,$contact['addr']);
409
410                                         if(count($msgs)) {
411                                                 logger("Mail: Parsing ".count($msgs)." mails.");
412
413                                                 foreach($msgs as $msg_uid) {
414                                                         logger("Mail: Parsing mail ".$msg_uid);
415
416                                                         $datarray = array();
417                                                         $meta = email_msg_meta($mbox,$msg_uid);
418                                                         $headers = email_msg_headers($mbox,$msg_uid);
419
420                                                         // look for a 'references' header and try and match with a parent item we have locally.
421
422                                                         $raw_refs = ((x($headers,'references')) ? str_replace("\t",'',$headers['references']) : '');
423                                                         $datarray['uri'] = msgid2iri(trim($meta->message_id,'<>'));
424
425                                                         if($raw_refs) {
426                                                                 $refs_arr = explode(' ', $raw_refs);
427                                                                 if(count($refs_arr)) {
428                                                                         for($x = 0; $x < count($refs_arr); $x ++)
429                                                                                 $refs_arr[$x] = "'" . msgid2iri(str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x]))) . "'";
430                                                                 }
431                                                                 $qstr = implode(',',$refs_arr);
432                                                                 $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `uri` IN ( $qstr ) AND `uid` = %d LIMIT 1",
433                                                                         intval($importer_uid)
434                                                                 );
435                                                                 if(count($r))
436                                                                         $datarray['parent-uri'] = $r[0]['uri'];
437                                                         }
438
439
440                                                         if(! x($datarray,'parent-uri'))
441                                                                 $datarray['parent-uri'] = $datarray['uri'];
442
443                                                         // Have we seen it before?
444                                                         $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
445                                                                 intval($importer_uid),
446                                                                 dbesc($datarray['uri'])
447                                                         );
448
449                                                         if(count($r)) {
450                                                                 logger("Mail: Seen before ".$msg_uid);
451                                                                 if($meta->deleted && ! $r[0]['deleted']) {
452                                                                         q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
453                                                                                 dbesc(datetime_convert()),
454                                                                                 intval($r[0]['id'])
455                                                                         );
456                                                                 }
457                                                                 //logger("Mail: Deleting ".$msg_uid);
458                                                                 //imap_delete($mbox, $msg_uid, FT_UID);
459                                                                 imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID);
460                                                                 logger("Mail: Moving ".$msg_uid);
461                                                                 imap_mail_move($mbox, $msg_uid, "Archiv", FT_UID);
462                                                                 continue;
463                                                         }
464
465                                                         // Decoding the header
466                                                         $subject = imap_mime_header_decode($meta->subject);
467                                                         $datarray['title'] = "";
468                                                         foreach($subject as $subpart)
469                                                                 if ($subpart->charset != "default")
470                                                                         $datarray['title'] .= iconv($subpart->charset, 'UTF-8//IGNORE', $subpart->text);
471                                                                 else
472                                                                         $datarray['title'] .= $subpart->text;
473
474                                                         $datarray['title'] = notags(trim($datarray['title']));
475
476                                                         //$datarray['title'] = notags(trim($meta->subject));
477                                                         $datarray['created'] = datetime_convert('UTC','UTC',$meta->date);
478
479                                                         $r = email_get_msg($mbox,$msg_uid);
480                                                         if(! $r) {
481                                                                 logger("Mail: can't fetch msg ".$msg_uid);
482                                                                 continue;
483                                                         }
484                                                         $datarray['body'] = escape_tags(convertquote($r['body'], false));
485
486                                                         logger("Mail: Importing ".$msg_uid);
487
488                                                         // some mailing lists have the original author as 'from' - add this sender info to msg body.
489                                                         // todo: adding a gravatar for the original author would be cool
490
491                                                         if(! stristr($meta->from,$contact['addr'])) {
492                                                                 $from = imap_mime_header_decode($meta->from);
493                                                                 $fromdecoded = "";
494                                                                 foreach($from as $frompart)
495                                                                         if ($frompart->charset != "default")
496                                                                                 $fromdecoded .= iconv($frompart->charset, 'UTF-8//IGNORE', $frompart->text);
497                                                                         else
498                                                                                 $fromdecoded .= $frompart->text;
499
500                                                                 $datarray['body'] = "[b]".t('From: ') . escape_tags($fromdecoded) . "[/b]\n\n" . $datarray['body'];
501                                                         }
502
503                                                         $datarray['uid'] = $importer_uid;
504                                                         $datarray['contact-id'] = $contact['id'];
505                                                         if($datarray['parent-uri'] === $datarray['uri'])
506                                                                 $datarray['private'] = 1;
507                                                         if(($contact['network'] === NETWORK_MAIL) && (! get_pconfig($importer_uid,'system','allow_public_email_replies'))) {
508                                                                 $datarray['private'] = 1;
509                                                                 $datarray['allow_cid'] = '<' . $contact['id'] . '>';
510                                                         }
511                                                         $datarray['author-name'] = $contact['name'];
512                                                         $datarray['author-link'] = 'mailbox';
513                                                         $datarray['author-avatar'] = $contact['photo'];
514
515                                                         $stored_item = item_store($datarray);
516                                                         q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d",
517                                                                 dbesc($datarray['parent-uri']),
518                                                                 intval($importer_uid)
519                                                         );
520                                                         q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
521                                                                 intval($stored_item)
522                                                         );
523                                                         //logger("Mail: Deleting ".$msg_uid);
524                                                         //imap_delete($mbox, $msg_uid, FT_UID);
525                                                         imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID);
526                                                         logger("Mail: Moving ".$msg_uid);
527                                                         imap_mail_move($mbox, $msg_uid, "Archiv", FT_UID);
528                                                 }
529                                         }
530
531                                         imap_close($mbox);
532                                 }
533                         }
534                         elseif($contact['network'] === NETWORK_FACEBOOK) {
535                                 // This is picked up by the Facebook plugin on a cron hook.
536                                 // Ignored here.
537                         }
538
539                         if($xml) {
540                                 logger('poller: received xml : ' . $xml, LOGGER_DATA);
541
542                                 if(! strstr($xml,'<?xml')) {
543                                         logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
544                                         $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
545                                                 dbesc(datetime_convert()),
546                                                 intval($contact['id'])
547                                         );
548                                         continue;
549                                 }
550
551
552                                 consume_feed($xml,$importer,$contact,$hub,1,1);
553
554                                 // do it twice. Ensures that children of parents which may be later in the stream aren't tossed
555         
556                                 consume_feed($xml,$importer,$contact,$hub,1,2);
557
558                                 $hubmode = 'subscribe';
559                                 if($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
560                                         $hubmode = 'unsubscribe';
561
562                                 if((strlen($hub)) && ($hub_update) && ($contact['rel'] != CONTACT_IS_FOLLOWER)) {
563                                         logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
564                                         $hubs = explode(',', $hub);
565                                         if(count($hubs)) {
566                                                 foreach($hubs as $h) {
567                                                         $h = trim($h);
568                                                         if(! strlen($h))
569                                                                 continue;
570                                                         subscribe_to_hub($h,$importer,$contact,$hubmode);
571                                                 }
572                                         }
573                                 }
574                         }
575
576
577                         $updated = datetime_convert();
578
579                         $r = q("UPDATE `contact` SET `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d LIMIT 1",
580                                 dbesc($updated),
581                                 dbesc($updated),
582                                 intval($contact['id'])
583                         );
584
585
586                         // load current friends if possible.
587
588                         if($contact['poco']) {  
589                                 $r = q("SELECT count(*) as total from glink 
590                                         where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
591                                         intval($contact['id'])
592                                 );
593                         }
594                         if(count($r)) {
595                                 if(! $r[0]['total']) {
596                                         poco_load($contact['id'],$importer_uid,$contact['poco']);
597                                 }
598                         }
599
600                         // loop - next contact
601                 }
602         }
603
604                 
605         return;
606 }
607
608 if (array_search(__file__,get_included_files())===0){
609   poller_run($argv,$argc);
610   killme();
611 }