]> git.mxchange.org Git - friendica.git/blob - include/notifier.php
Some more function calls changed to the new class
[friendica.git] / include / notifier.php
1 <?php
2 require_once("boot.php");
3 require_once('include/queue_fn.php');
4 require_once('include/html2plain.php');
5 require_once("include/Scrape.php");
6 require_once('include/diaspora.php');
7 require_once("include/ostatus.php");
8 require_once('include/salmon.php');
9
10 /*
11  * This file was at one time responsible for doing all deliveries, but this caused
12  * big problems when the process was killed or stalled during the delivery process.
13  * It now invokes separate queues that are delivering via delivery.php and pubsubpublish.php.
14  */
15
16 /*
17  * The notifier is typically called with:
18  *
19  *              proc_run('php', "include/notifier.php", COMMAND, ITEM_ID);
20  *
21  * where COMMAND is one of the following:
22  *
23  *              activity                                (in diaspora.php, dfrn_confirm.php, profiles.php)
24  *              comment-import                  (in diaspora.php, items.php)
25  *              comment-new                             (in item.php)
26  *              drop                                    (in diaspora.php, items.php, photos.php)
27  *              edit_post                               (in item.php)
28  *              event                                   (in events.php)
29  *              expire                                  (in items.php)
30  *              like                                    (in like.php, poke.php)
31  *              mail                                    (in message.php)
32  *              suggest                                 (in fsuggest.php)
33  *              tag                                             (in photos.php, poke.php, tagger.php)
34  *              tgroup                                  (in items.php)
35  *              wall-new                                (in photos.php, item.php)
36  *              removeme                                (in Contact.php)
37  *              relocate                                (in uimport.php)
38  *
39  * and ITEM_ID is the id of the item in the database that needs to be sent to others.
40  */
41
42
43 function notifier_run(&$argv, &$argc){
44         global $a, $db;
45
46         if(is_null($a)){
47                 $a = new App;
48         }
49
50         if(is_null($db)) {
51                 @include(".htconfig.php");
52                 require_once("include/dba.php");
53                 $db = new dba($db_host, $db_user, $db_pass, $db_data);
54                         unset($db_host, $db_user, $db_pass, $db_data);
55         }
56
57         require_once("include/session.php");
58         require_once("include/datetime.php");
59         require_once('include/items.php');
60         require_once('include/bbcode.php');
61         require_once('include/email.php');
62         load_config('config');
63         load_config('system');
64
65         load_hooks();
66
67         if($argc < 3)
68                 return;
69
70         $a->set_baseurl(get_config('system','url'));
71
72         logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
73
74         $cmd = $argv[1];
75
76         switch($cmd) {
77                 case 'mail':
78                 default:
79                         $item_id = intval($argv[2]);
80                         if(! $item_id){
81                                 return;
82                         }
83                         break;
84         }
85
86         $expire = false;
87         $mail = false;
88         $fsuggest = false;
89         $relocate = false;
90         $top_level = false;
91         $recipients = array();
92         $url_recipients = array();
93
94         $normal_mode = true;
95
96         if($cmd === 'mail') {
97                 $normal_mode = false;
98                 $mail = true;
99                 $message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1",
100                                 intval($item_id)
101                 );
102                 if(! count($message)){
103                         return;
104                 }
105                 $uid = $message[0]['uid'];
106                 $recipients[] = $message[0]['contact-id'];
107                 $item = $message[0];
108
109         }
110         elseif($cmd === 'expire') {
111                 $normal_mode = false;
112                 $expire = true;
113                 $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
114                         AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 10 MINUTE",
115                         intval($item_id)
116                 );
117                 $uid = $item_id;
118                 $item_id = 0;
119                 if(! count($items))
120                         return;
121         }
122         elseif($cmd === 'suggest') {
123                 $normal_mode = false;
124                 $fsuggest = true;
125
126                 $suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1",
127                         intval($item_id)
128                 );
129                 if(! count($suggest))
130                         return;
131                 $uid = $suggest[0]['uid'];
132                 $recipients[] = $suggest[0]['cid'];
133                 $item = $suggest[0];
134         } elseif($cmd === 'removeme') {
135                 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($item_id));
136                 if (! $r)
137                         return;
138
139                 $user = $r[0];
140                 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($item_id));
141                 if (! $r)
142                         return;
143
144                 $self = $r[0];
145                 $r = q("SELECT * FROM `contact` WHERE `self` = 0 AND `uid` = %d", intval($item_id));
146                 if(! $r)
147                         return;
148
149                 require_once('include/Contact.php');
150                 foreach($r as $contact) {
151                         terminate_friendship($user, $self, $contact);
152                 }
153                 return;
154         } elseif($cmd === 'relocate') {
155                 $normal_mode = false;
156                 $relocate = true;
157                 $uid = $item_id;
158
159                 $recipients_relocate = q("SELECT * FROM contact WHERE uid = %d  AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN);
160         } else {
161                 // find ancestors
162                 $r = q("SELECT * FROM `item` WHERE `id` = %d and visible = 1 and moderated = 0 LIMIT 1",
163                         intval($item_id)
164                 );
165
166                 if((! count($r)) || (! intval($r[0]['parent']))) {
167                         return;
168                 }
169
170                 $target_item = $r[0];
171                 $parent_id = intval($r[0]['parent']);
172                 $uid = $r[0]['uid'];
173                 $updated = $r[0]['edited'];
174
175                 $items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
176                         FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d and visible = 1 and moderated = 0 ORDER BY `id` ASC",
177                         intval($parent_id)
178                 );
179
180                 if(! count($items)) {
181                         return;
182                 }
183
184                 // avoid race condition with deleting entries
185
186                 if($items[0]['deleted']) {
187                         foreach($items as $item)
188                                 $item['deleted'] = 1;
189                 }
190
191                 if((count($items) == 1) && ($items[0]['id'] === $target_item['id']) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
192                         logger('notifier: top level post');
193                         $top_level = true;
194                 }
195
196         }
197
198         $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
199                 `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
200                 `user`.`page-flags`, `user`.`prvnets`
201                 FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
202                 WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
203                 intval($uid)
204         );
205
206         if(! count($r))
207                 return;
208
209         $owner = $r[0];
210
211         $walltowall = ((($top_level) && ($owner['id'] != $items[0]['contact-id'])) ? true : false);
212
213         $hub = get_config('system','huburl');
214
215         // If this is a public conversation, notify the feed hub
216         $public_message = true;
217
218         // Do a PuSH
219         $push_notify = false;
220
221         // fill this in with a single salmon slap if applicable
222         $slap = '';
223
224         if(! ($mail || $fsuggest || $relocate)) {
225
226                 $slap = ostatus_salmon($target_item,$owner);
227
228                 require_once('include/group.php');
229
230                 $parent = $items[0];
231
232                 $thr_parent = q("SELECT `network` FROM `item` WHERE `uri` = '%s' AND `uid` = %d",
233                         dbesc($target_item["thr-parent"]), intval($target_item["uid"]));
234
235                 logger('Parent is '.$parent['network'].'. Thread parent is '.$thr_parent[0]['network'], LOGGER_DEBUG);
236
237                 // This is IMPORTANT!!!!
238
239                 // We will only send a "notify owner to relay" or followup message if the referenced post
240                 // originated on our system by virtue of having our hostname somewhere
241                 // in the URI, AND it was a comment (not top_level) AND the parent originated elsewhere.
242
243                 // if $parent['wall'] == 1 we will already have the parent message in our array
244                 // and we will relay the whole lot.
245
246                 // expire sends an entire group of expire messages and cannot be forwarded.
247                 // However the conversation owner will be a part of the conversation and will
248                 // be notified during this run.
249                 // Other DFRN conversation members will be alerted during polled updates.
250
251
252
253                 // Diaspora members currently are not notified of expirations, and other networks have
254                 // either limited or no ability to process deletions. We should at least fix Diaspora
255                 // by stringing togther an array of retractions and sending them onward.
256
257
258                 $localhost = str_replace('www.','',$a->get_hostname());
259                 if(strpos($localhost,':'))
260                         $localhost = substr($localhost,0,strpos($localhost,':'));
261
262                 /**
263                  *
264                  * Be VERY CAREFUL if you make any changes to the following several lines. Seemingly innocuous changes
265                  * have been known to cause runaway conditions which affected several servers, along with
266                  * permissions issues.
267                  *
268                  */
269
270                 $relay_to_owner = false;
271
272                 if(!$top_level && ($parent['wall'] == 0) && !$expire && (stristr($target_item['uri'],$localhost))) {
273                         $relay_to_owner = true;
274                 }
275
276
277                 if(($cmd === 'uplink') && (intval($parent['forum_mode']) == 1) && !$top_level) {
278                         $relay_to_owner = true;
279                 }
280
281                 // until the 'origin' flag has been in use for several months
282                 // we will just use it as a fallback test
283                 // later we will be able to use it as the primary test of whether or not to relay.
284
285                 if(! $target_item['origin'])
286                         $relay_to_owner = false;
287
288                 if($parent['origin'])
289                         $relay_to_owner = false;
290
291                 if($relay_to_owner) {
292                         logger('notifier: followup '.$target_item["guid"], LOGGER_DEBUG);
293                         // local followup to remote post
294                         $followup = true;
295                         $public_message = false; // not public
296                         $conversant_str = dbesc($parent['contact-id']);
297                         $recipients = array($parent['contact-id']);
298                         $recipients_followup  = array($parent['contact-id']);
299
300                         //if (!$target_item['private'] AND $target_item['wall'] AND
301                         if (!$target_item['private'] AND
302                                 (strlen($target_item['allow_cid'].$target_item['allow_gid'].
303                                         $target_item['deny_cid'].$target_item['deny_gid']) == 0))
304                                 $push_notify = true;
305
306                         if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
307
308                                 $push_notify = true;
309
310                                 if ($parent["network"] == NETWORK_OSTATUS) {
311                                         // Distribute the message to the DFRN contacts as if this wasn't a followup since OStatus can't relay comments
312                                         // Currently it is work at progress
313                                         $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `network` = '%s' AND NOT `blocked` AND NOT `pending` AND NOT `archive`",
314                                                 intval($uid),
315                                                 dbesc(NETWORK_DFRN)
316                                         );
317                                         if(count($r))
318                                                 foreach($r as $rr)
319                                                         $recipients_followup[] = $rr['id'];
320                                 }
321                         }
322                         logger("Notify ".$target_item["guid"]." via PuSH: ".($push_notify?"Yes":"No"), LOGGER_DEBUG);
323                 } else {
324                         $followup = false;
325
326                         logger('Distributing directly '.$target_item["guid"], LOGGER_DEBUG);
327
328                         // don't send deletions onward for other people's stuff
329
330                         if($target_item['deleted'] && (! intval($target_item['wall']))) {
331                                 logger('notifier: ignoring delete notification for non-wall item');
332                                 return;
333                         }
334
335                         if((strlen($parent['allow_cid']))
336                                 || (strlen($parent['allow_gid']))
337                                 || (strlen($parent['deny_cid']))
338                                 || (strlen($parent['deny_gid']))) {
339                                 $public_message = false; // private recipients, not public
340                         }
341
342                         $allow_people = expand_acl($parent['allow_cid']);
343                         $allow_groups = expand_groups(expand_acl($parent['allow_gid']),true);
344                         $deny_people  = expand_acl($parent['deny_cid']);
345                         $deny_groups  = expand_groups(expand_acl($parent['deny_gid']));
346
347                         // if our parent is a public forum (forum_mode == 1), uplink to the origional author causing
348                         // a delivery fork. private groups (forum_mode == 2) do not uplink
349
350                         if((intval($parent['forum_mode']) == 1) && (! $top_level) && ($cmd !== 'uplink')) {
351                                 proc_run('php','include/notifier.php','uplink',$item_id);
352                         }
353
354                         $conversants = array();
355
356                         foreach($items as $item) {
357                                 $recipients[] = $item['contact-id'];
358                                 $conversants[] = $item['contact-id'];
359                                 // pull out additional tagged people to notify (if public message)
360                                 if($public_message && strlen($item['inform'])) {
361                                         $people = explode(',',$item['inform']);
362                                         foreach($people as $person) {
363                                                 if(substr($person,0,4) === 'cid:') {
364                                                         $recipients[] = intval(substr($person,4));
365                                                         $conversants[] = intval(substr($person,4));
366                                                 }
367                                                 else {
368                                                         $url_recipients[] = substr($person,4);
369                                                 }
370                                         }
371                                 }
372                         }
373
374                         if (count($url_recipients))
375                                 logger('notifier: '.$target_item["guid"].' url_recipients ' . print_r($url_recipients,true));
376
377                         $conversants = array_unique($conversants);
378
379
380                         $recipients = array_unique(array_merge($recipients,$allow_people,$allow_groups));
381                         $deny = array_unique(array_merge($deny_people,$deny_groups));
382                         $recipients = array_diff($recipients,$deny);
383
384                         $conversant_str = dbesc(implode(', ',$conversants));
385                 }
386
387                 // If the thread parent is OStatus then do some magic to distribute the messages.
388                 // We have not only to look at the parent, since it could be a Friendica thread.
389                 if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
390
391                         logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG);
392
393                         // Send a salmon notification to every person we mentioned in the post
394                         $arr = explode(',',$target_item['tag']);
395                         foreach($arr as $x) {
396                                 //logger('Checking tag '.$x, LOGGER_DEBUG);
397                                 $matches = null;
398                                 if(preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) {
399                                                 $probed_contact = probe_url($matches[1]);
400                                         if ($probed_contact["notify"] != "") {
401                                                 logger('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]);
402                                                 $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
403                                         }
404                                 }
405                         }
406
407                         // It only makes sense to distribute answers to OStatus messages to Friendica and OStatus - but not Diaspora
408                         $sql_extra = " AND `network` IN ('".NETWORK_OSTATUS."', '".NETWORK_DFRN."')";
409                 } else
410                         $sql_extra = " AND `network` IN ('".NETWORK_OSTATUS."', '".NETWORK_DFRN."', '".NETWORK_DIASPORA."', '".NETWORK_MAIL."', '".NETWORK_MAIL2."')";
411
412                 $r = q("SELECT * FROM `contact` WHERE `id` IN ($conversant_str) AND NOT `blocked` AND NOT `pending` AND NOT `archive`".$sql_extra);
413
414                 if(count($r))
415                         $contacts = $r;
416
417         } else
418                 $public_message = false;
419
420         // If this is a public message and pubmail is set on the parent, include all your email contacts
421
422         $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
423
424         if(! $mail_disabled) {
425                 if((! strlen($target_item['allow_cid'])) && (! strlen($target_item['allow_gid']))
426                         && (! strlen($target_item['deny_cid'])) && (! strlen($target_item['deny_gid']))
427                         && (intval($target_item['pubmail']))) {
428                         $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `network` = '%s'",
429                                 intval($uid),
430                                 dbesc(NETWORK_MAIL)
431                         );
432                         if(count($r)) {
433                                 foreach($r as $rr)
434                                         $recipients[] = $rr['id'];
435                         }
436                 }
437         }
438
439         if($followup)
440                 $recip_str = implode(', ', $recipients_followup);
441         else
442                 $recip_str = implode(', ', $recipients);
443
444         if ($relocate)
445                 $r = $recipients_relocate;
446         else
447                 $r = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND NOT `blocked` AND NOT `pending` AND NOT `archive`",
448                         dbesc($recip_str)
449                 );
450
451
452         $interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
453
454         // If we are using the worker we don't need a delivery interval
455         if (get_config("system", "worker"))
456                 $interval = false;
457
458         // delivery loop
459
460         if(count($r)) {
461
462                 foreach($r as $contact) {
463                         if(!$contact['self']) {
464                                 if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
465                                         continue;
466                                 q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)",
467                                         dbesc($cmd),
468                                         intval($item_id),
469                                         intval($contact['id'])
470                                 );
471                         }
472                 }
473
474
475                 // This controls the number of deliveries to execute with each separate delivery process.
476                 // By default we'll perform one delivery per process. Assuming a hostile shared hosting
477                 // provider, this provides the greatest chance of deliveries if processes start getting
478                 // killed. We can also space them out with the delivery_interval to also help avoid them
479                 // getting whacked.
480
481                 // If $deliveries_per_process > 1, we will chain this number of multiple deliveries
482                 // together into a single process. This will reduce the overall number of processes
483                 // spawned for each delivery, but they will run longer.
484
485                 // When using the workerqueue, we don't need this functionality.
486
487                 $deliveries_per_process = intval(get_config('system','delivery_batch_count'));
488                 if (($deliveries_per_process <= 0) OR get_config("system", "worker"))
489                         $deliveries_per_process = 1;
490
491                 $this_batch = array();
492
493                 for($x = 0; $x < count($r); $x ++) {
494                         $contact = $r[$x];
495
496                         if($contact['self'])
497                                 continue;
498
499                         logger("Deliver ".$target_item["guid"]." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG);
500
501                         // potentially more than one recipient. Start a new process and space them out a bit.
502                         // we will deliver single recipient types of message and email recipients here.
503
504                         $this_batch[] = $contact['id'];
505
506                         if(count($this_batch) >= $deliveries_per_process) {
507                                 proc_run('php','include/delivery.php',$cmd,$item_id,$this_batch);
508                                 $this_batch = array();
509                                 if($interval)
510                                         @time_sleep_until(microtime(true) + (float) $interval);
511                         }
512                         continue;
513                 }
514
515                 // be sure to pick up any stragglers
516                 if(count($this_batch))
517                         proc_run('php','include/delivery.php',$cmd,$item_id,$this_batch);
518         }
519
520         // send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
521         // They are especially used for notifications to OStatus users that don't follow us.
522
523         if($slap && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
524                 if(!get_config('system','dfrn_only')) {
525                         foreach($url_recipients as $url) {
526                                 if($url) {
527                                         logger('notifier: urldelivery: ' . $url);
528                                         $deliver_status = slapper($owner,$url,$slap);
529                                         /// @TODO Redeliver/queue these items on failure, though there is no contact record
530                                 }
531                         }
532                 }
533         }
534
535
536         if($public_message) {
537
538                 if (!$followup AND $top_level)
539                         $r0 = diaspora::relay_list();
540                 else
541                         $r0 = array();
542
543                 $r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s'
544                         AND `uid` = %d AND `rel` != %d group by `batch` ORDER BY rand() ",
545                         dbesc(NETWORK_DIASPORA),
546                         intval($owner['uid']),
547                         intval(CONTACT_IS_SHARING)
548                 );
549
550                 $r2 = q("SELECT `id`, `name`,`network` FROM `contact`
551                         WHERE `network` in ( '%s', '%s')  AND `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `archive`
552                         AND `rel` != %d order by rand() ",
553                         dbesc(NETWORK_DFRN),
554                         dbesc(NETWORK_MAIL2),
555                         intval($owner['uid']),
556                         intval(CONTACT_IS_SHARING)
557                 );
558
559                 $r = array_merge($r2,$r1,$r0);
560
561                 if(count($r)) {
562                         logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
563
564                         // throw everything into the queue in case we get killed
565
566                         foreach($r as $rr) {
567                                 if((! $mail) && (! $fsuggest) && (! $followup)) {
568                                         q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
569                                                 dbesc($cmd),
570                                                 intval($item_id),
571                                                 intval($rr['id'])
572                                         );
573                                 }
574                         }
575
576                         foreach($r as $rr) {
577
578                                 // except for Diaspora batch jobs
579                                 // Don't deliver to folks who have already been delivered to
580
581                                 if(($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'],$conversants))) {
582                                         logger('notifier: already delivered id=' . $rr['id']);
583                                         continue;
584                                 }
585
586                                 if((! $mail) && (! $fsuggest) && (! $followup)) {
587                                         logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
588                                         proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']);
589                                         if($interval)
590                                                 @time_sleep_until(microtime(true) + (float) $interval);
591                                 }
592                         }
593                 }
594
595                 $push_notify = true;
596
597         }
598
599         // Notify PuSH subscribers (Used for OStatus distribution of regular posts)
600         if($push_notify AND strlen($hub)) {
601                 $hubs = explode(',', $hub);
602                 if(count($hubs)) {
603                         foreach($hubs as $h) {
604                                 $h = trim($h);
605                                 if(! strlen($h))
606                                         continue;
607
608                                 if ($h === '[internal]') {
609                                         // Set push flag for PuSH subscribers to this topic,
610                                         // they will be notified in queue.php
611                                         q("UPDATE `push_subscriber` SET `push` = 1 " .
612                                           "WHERE `nickname` = '%s'", dbesc($owner['nickname']));
613
614                                         logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);
615
616                                 } else {
617
618                                         $params = 'hub.mode=publish&hub.url=' . urlencode( $a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
619                                         post_url($h,$params);
620                                         logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
621                                 }
622                                 if(count($hubs) > 1)
623                                         sleep(7);                               // try and avoid multiple hubs responding at precisely the same time
624                         }
625                 }
626
627                 // Handling the pubsubhubbub requests
628                 proc_run('php','include/pubsubpublish.php');
629         }
630
631         // If the item was deleted, clean up the `sign` table
632         /* if($target_item['deleted']) {
633                 $r = q("DELETE FROM sign where `retract_iid` = %d",
634                         intval($target_item['id'])
635                 );
636         } */
637
638         logger('notifier: calling hooks', LOGGER_DEBUG);
639
640         if($normal_mode)
641                 call_hooks('notifier_normal',$target_item);
642
643         call_hooks('notifier_end',$target_item);
644
645         return;
646 }
647
648
649 if (array_search(__file__,get_included_files())===0){
650         notifier_run($_SERVER["argv"],$_SERVER["argc"]);
651         killme();
652 }