5 * This is the POST destination for most all locally posted
6 * text stuff. This function handles status, wall-to-wall status,
7 * local comments, and remote coments - that are posted on this site
8 * (as opposed to being delivered in a feed).
9 * Also processed here are posts and comments coming through the
10 * statusnet/twitter API.
11 * All of these become an "item" which is our basic unit of
13 * Posts that originate externally or do not fall into the above
14 * posting categories go through item_store() instead of this function.
18 function item_post(&$a) {
20 if((! local_user()) && (! remote_user()))
23 require_once('include/security.php');
27 if(x($_POST,'dropitems')) {
28 require_once('include/items.php');
29 $arr_drop = explode(',',$_POST['dropitems']);
30 drop_items($arr_drop);
31 $json = array('success' => 1);
32 echo json_encode($json);
36 call_hooks('post_local_start', $_POST);
38 $api_source = ((x($_POST,'api_source')) ? true : false);
41 * Is this a reply to something?
44 $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
45 $parent_uri = ((x($_POST,'parent_uri')) ? trim($_POST['parent_uri']) : '');
48 $parent_contact = null;
53 if($parent || $parent_uri) {
55 if(! x($_POST,'type'))
56 $_POST['type'] = 'net-comment';
59 $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
63 elseif($parent_uri && local_user()) {
64 // This is coming from an API source, and we are logged in
65 $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
70 // if this isn't the real parent of the conversation, find it
71 if($r !== false && count($r)) {
72 $parid = $r[0]['parent'];
73 if($r[0]['id'] != $r[0]['parent']) {
74 $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
80 if(($r === false) || (! count($r))) {
81 notice( t('Unable to locate original post.') . EOL);
82 if(x($_POST,'return'))
83 goaway($a->get_baseurl() . "/" . $_POST['return'] );
87 $parent = $r[0]['id'];
89 // multi-level threading - preserve the info but re-parent to our single level threading
90 if(($parid) && ($parid != $parent))
91 $thr_parent = $parent_uri;
93 if($parent_item['contact-id'] && $uid) {
94 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
95 intval($parent_item['contact-id']),
99 $parent_contact = $r[0];
103 if($parent) logger('mod_post: parent=' . $parent);
105 $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0);
106 $post_id = ((x($_POST['post_id'])) ? intval($_POST['post_id']) : 0);
107 $app = ((x($_POST['source'])) ? strip_tags($_POST['source']) : '');
109 if(! can_write_wall($a,$profile_uid)) {
110 notice( t('Permission denied.') . EOL) ;
111 if(x($_POST,'return'))
112 goaway($a->get_baseurl() . "/" . $_POST['return'] );
117 // is this an edited post?
122 $i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
123 intval($profile_uid),
133 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
140 $str_group_allow = $orig_post['allow_gid'];
141 $str_contact_allow = $orig_post['allow_cid'];
142 $str_group_deny = $orig_post['deny_gid'];
143 $str_contact_deny = $orig_post['deny_cid'];
144 $title = $orig_post['title'];
145 $location = $orig_post['location'];
146 $coord = $orig_post['coord'];
147 $verb = $orig_post['verb'];
148 $emailcc = $orig_post['emailcc'];
149 $app = $orig_post['app'];
151 $body = escape_tags(trim($_POST['body']));
152 $private = $orig_post['private'];
153 $pubmail_enable = $orig_post['pubmail'];
156 $str_group_allow = perms2str($_POST['group_allow']);
157 $str_contact_allow = perms2str($_POST['contact_allow']);
158 $str_group_deny = perms2str($_POST['group_deny']);
159 $str_contact_deny = perms2str($_POST['contact_deny']);
160 $title = notags(trim($_POST['title']));
161 $location = notags(trim($_POST['location']));
162 $coord = notags(trim($_POST['coord']));
163 $verb = notags(trim($_POST['verb']));
164 $emailcc = notags(trim($_POST['emailcc']));
166 $body = escape_tags(trim($_POST['body']));
167 $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
170 (($parent_item['private'])
171 || strlen($parent_item['allow_cid'])
172 || strlen($parent_item['allow_gid'])
173 || strlen($parent_item['deny_cid'])
174 || strlen($parent_item['deny_gid'])
179 $pubmail_enable = ((x($_POST,'pubmail_enable') && intval($_POST['pubmail_enable']) && (! $private)) ? 1 : 0);
181 if(! strlen($body)) {
182 info( t('Empty post discarded.') . EOL );
183 if(x($_POST,'return'))
184 goaway($a->get_baseurl() . "/" . $_POST['return'] );
189 // get contact info for poster
194 if(($_SESSION['uid']) && ($_SESSION['uid'] == $profile_uid)) {
196 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
197 intval($_SESSION['uid'])
201 if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id']))) {
202 $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
203 intval($_SESSION['visitor_id'])
210 $contact_id = $author['id'];
213 // get contact info for owner
215 if($profile_uid == $_SESSION['uid']) {
216 $contact_record = $author;
219 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
223 $contact_record = $r[0];
228 $post_type = notags(trim($_POST['type']));
230 if($post_type === 'net-comment') {
231 if($parent_item !== null) {
232 if($parent_item['wall'] == 1)
233 $post_type = 'wall-comment';
235 $post_type = 'remote-comment';
241 * When a photo was uploaded into the message using the (profile wall) ajax
242 * uploader, The permissions are initially set to disallow anybody but the
243 * owner from seeing it. This is because the permissions may not yet have been
244 * set for the post. If it's private, the photo permissions should be set
245 * appropriately. But we didn't know the final permissions on the post until
246 * now. So now we'll look for links of uploaded messages that are in the
247 * post and set them to the same permissions as the post itself.
253 if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
256 foreach($images as $image) {
257 if(! stristr($image,$a->get_baseurl() . '/photo/'))
259 $image_uri = substr($image,strrpos($image,'/') + 1);
260 $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
261 if(! strlen($image_uri))
263 $srch = '<' . intval($profile_uid) . '>';
264 $r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''
265 AND `resource-id` = '%s' AND `uid` = %d LIMIT 1",
274 $r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
275 WHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ",
276 dbesc($str_contact_allow),
277 dbesc($str_group_allow),
278 dbesc($str_contact_deny),
279 dbesc($str_group_deny),
281 intval($profile_uid),
282 dbesc( t('Wall Photos'))
291 * Next link in any attachment references we find in the post.
296 if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) {
297 $attaches = $match[1];
298 if(count($attaches)) {
299 foreach($attaches as $attach) {
300 $r = q("SELECT * FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
301 intval($profile_uid),
305 $r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
306 WHERE `uid` = %d AND `id` = %d LIMIT 1",
307 dbesc($str_contact_allow),
308 dbesc($str_group_allow),
309 dbesc($str_contact_deny),
310 dbesc($str_group_deny),
311 intval($profile_uid),
320 * Fold multi-line [code] sequences
323 $body = preg_replace('/\[\/code\]\s*\[code\]/m',"\n",$body);
326 * Look for any tags and linkify them
333 $tags = get_tags($body);
336 * add a statusnet style reply tag if the original post was from there
337 * and we are replying, and there isn't one already
340 if(($parent_contact) && ($parent_contact['network'] === 'stat')
341 && ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) {
342 $body = '@' . $parent_contact['nick'] . ' ' . $body;
343 $tags[] = '@' . $parent_contact['nick'];
347 foreach($tags as $tag) {
350 if(strpos($tag,'#') === 0) {
351 if(strpos($tag,'[url='))
353 $basetag = str_replace('_',' ',substr($tag,1));
354 $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
355 if(strlen($str_tags))
357 $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
360 if(strpos($tag,'@') === 0) {
361 if(strpos($tag,'[url='))
364 $name = substr($tag,1);
365 if((strpos($name,'@')) || (strpos($name,'http://'))) {
367 $links = @lrdd($name);
369 foreach($links as $link) {
370 if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
371 $profile = $link['@attributes']['href'];
372 if($link['@attributes']['rel'] === 'salmon') {
375 $inform .= 'url:' . str_replace(',','%2c',$link['@attributes']['href']);
383 if(strstr($name,'_') || strstr($name,' ')) {
384 $newname = str_replace('_',' ',$name);
385 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
391 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
397 $profile = $r[0]['url'];
398 if($r[0]['network'] === 'stat') {
399 $newname = $r[0]['nick'];
402 $alias = $r[0]['alias'];
405 $newname = $r[0]['name'];
408 $inform .= 'cid:' . $r[0]['id'];
412 $body = str_replace('@' . $name, '@' . '[url=' . $profile . ']' . $newname . '[/url]', $body);
413 $profile = str_replace(',','%2c',$profile);
414 if(strlen($str_tags))
416 $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]';
418 // Status.Net seems to require the numeric ID URL in a mention if the person isn't
419 // subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both.
422 if(strlen($str_tags))
424 $str_tags .= '@[url=' . $alias . ']' . $newname . '[/url]';
434 if(preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) {
435 foreach($match[2] as $mtch) {
436 $r = q("SELECT `id`,`filename`,`filesize`,`filetype` FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
437 intval($profile_uid),
441 if(strlen($attachments))
443 $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
445 $body = str_replace($match[1],'',$body);
451 if($post_type === 'wall' || $post_type === 'wall-comment')
455 $verb = ACTIVITY_POST ;
457 $gravity = (($parent) ? 6 : 0 );
459 $notify_type = (($parent) ? 'comment-new' : 'wall-new' );
461 $uri = item_new_uri($a->get_hostname(),$profile_uid);
464 $datarray['uid'] = $profile_uid;
465 $datarray['type'] = $post_type;
466 $datarray['wall'] = $wall;
467 $datarray['gravity'] = $gravity;
468 $datarray['contact-id'] = $contact_id;
469 $datarray['owner-name'] = $contact_record['name'];
470 $datarray['owner-link'] = $contact_record['url'];
471 $datarray['owner-avatar'] = $contact_record['thumb'];
472 $datarray['author-name'] = $author['name'];
473 $datarray['author-link'] = $author['url'];
474 $datarray['author-avatar'] = $author['thumb'];
475 $datarray['created'] = datetime_convert();
476 $datarray['edited'] = datetime_convert();
477 $datarray['received'] = datetime_convert();
478 $datarray['changed'] = datetime_convert();
479 $datarray['uri'] = $uri;
480 $datarray['title'] = $title;
481 $datarray['body'] = $body;
482 $datarray['app'] = $app;
483 $datarray['location'] = $location;
484 $datarray['coord'] = $coord;
485 $datarray['tag'] = $str_tags;
486 $datarray['inform'] = $inform;
487 $datarray['verb'] = $verb;
488 $datarray['allow_cid'] = $str_contact_allow;
489 $datarray['allow_gid'] = $str_group_allow;
490 $datarray['deny_cid'] = $str_contact_deny;
491 $datarray['deny_gid'] = $str_group_deny;
492 $datarray['private'] = $private;
493 $datarray['pubmail'] = $pubmail_enable;
494 $datarray['attach'] = $attachments;
495 $datarray['thr-parent'] = $thr_parent;
498 * These fields are for the convenience of plugins...
499 * 'self' if true indicates the owner is posting on their own wall
500 * If parent is 0 it is a top-level post.
503 $datarray['parent'] = $parent;
504 $datarray['self'] = $self;
505 $datarray['prvnets'] = $user['prvnets'];
508 $datarray['edit'] = true;
510 $datarray['guid'] = get_guid();
513 call_hooks('post_local',$datarray);
517 $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
519 dbesc(datetime_convert()),
524 proc_run('php', "include/notifier.php", 'edit_post', "$post_id");
525 if((x($_POST,'return')) && strlen($_POST['return'])) {
526 logger('return: ' . $_POST['return']);
527 goaway($a->get_baseurl() . "/" . $_POST['return'] );
535 $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
536 `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
537 `tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach` )
538 VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s' )",
539 intval($datarray['uid']),
540 dbesc($datarray['guid']),
541 dbesc($datarray['type']),
542 intval($datarray['wall']),
543 intval($datarray['gravity']),
544 intval($datarray['contact-id']),
545 dbesc($datarray['owner-name']),
546 dbesc($datarray['owner-link']),
547 dbesc($datarray['owner-avatar']),
548 dbesc($datarray['author-name']),
549 dbesc($datarray['author-link']),
550 dbesc($datarray['author-avatar']),
551 dbesc($datarray['created']),
552 dbesc($datarray['edited']),
553 dbesc($datarray['received']),
554 dbesc($datarray['changed']),
555 dbesc($datarray['uri']),
556 dbesc($datarray['thr-parent']),
557 dbesc($datarray['title']),
558 dbesc($datarray['body']),
559 dbesc($datarray['app']),
560 dbesc($datarray['location']),
561 dbesc($datarray['coord']),
562 dbesc($datarray['tag']),
563 dbesc($datarray['inform']),
564 dbesc($datarray['verb']),
565 dbesc($datarray['allow_cid']),
566 dbesc($datarray['allow_gid']),
567 dbesc($datarray['deny_cid']),
568 dbesc($datarray['deny_gid']),
569 intval($datarray['private']),
570 intval($datarray['pubmail']),
571 dbesc($datarray['attach'])
574 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
575 dbesc($datarray['uri']));
577 $post_id = $r[0]['id'];
578 logger('mod_item: saved item ' . $post_id);
582 // This item is the last leaf and gets the comment box, clear any ancestors
583 $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d ",
584 dbesc(datetime_convert()),
588 // Inherit ACL's from the parent item.
590 $r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d
591 WHERE `id` = %d LIMIT 1",
592 dbesc($parent_item['allow_cid']),
593 dbesc($parent_item['allow_gid']),
594 dbesc($parent_item['deny_cid']),
595 dbesc($parent_item['deny_gid']),
596 intval($parent_item['private']),
600 // Send a notification email to the conversation owner, unless the owner is me and I wrote this item
601 if(($user['notify-flags'] & NOTIFY_COMMENT) && ($contact_record != $author)) {
602 push_lang($user['language']);
603 require_once('bbcode.php');
604 $from = $author['name'];
606 // name of the automated email sender
607 $msg['notificationfromname'] = stripslashes($datarray['author-name']);;
608 // noreply address to send from
609 $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname();
612 // process the message body to display properly in text mode
614 = html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8');
617 // process the message body to display properly in text mode
619 = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$datarray['body']))));
621 // load the template for private message notifications
622 $tpl = get_intltext_template('cmnt_received_html_body_eml.tpl');
623 $email_html_body_tpl = replace_macros($tpl,array(
624 '$username' => $user['username'],
625 '$sitename' => $a->config['sitename'], // name of this site
626 '$siteurl' => $a->get_baseurl(), // descriptive url of this site
627 '$thumb' => $author['thumb'], // thumbnail url for sender icon
628 '$email' => $importer['email'], // email address to send to
629 '$url' => $author['url'], // full url for the site
630 '$from' => $from, // name of the person sending the message
631 '$body' => $msg['htmlversion'], // html version of the message
632 '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
635 // load the template for private message notifications
636 $tpl = get_intltext_template('cmnt_received_text_body_eml.tpl');
637 $email_text_body_tpl = replace_macros($tpl,array(
638 '$username' => $user['username'],
639 '$sitename' => $a->config['sitename'], // name of this site
640 '$siteurl' => $a->get_baseurl(), // descriptive url of this site
641 '$thumb' => $author['thumb'], // thumbnail url for sender icon
642 '$email' => $importer['email'], // email address to send to
643 '$url' => $author['url'], // profile url for the author
644 '$from' => $from, // name of the person sending the message
645 '$body' => $msg['textversion'], // text version of the message
646 '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
649 // use the EmailNotification library to send the message
650 require_once("include/EmailNotification.php");
651 EmailNotification::sendTextHtmlEmail(
652 $msg['notificationfromname'],
653 t("Administrator@") . $a->get_hostname(),
654 t("noreply") . '@' . $a->get_hostname(),
656 sprintf( t('%s commented on an item at %s'), $from , $a->config['sitename']),
657 $email_html_body_tpl,
667 // let me know if somebody did a wall-to-wall post on my profile
669 if(($user['notify-flags'] & NOTIFY_WALL) && ($contact_record != $author)) {
670 push_lang($user['language']);
671 require_once('bbcode.php');
672 $from = $author['name'];
674 // name of the automated email sender
675 $msg['notificationfromname'] = $from;
676 // noreply address to send from
677 $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname();
680 // process the message body to display properly in text mode
682 = html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8');
685 // process the message body to display properly in text mode
687 = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$datarray['body']))));
689 // load the template for private message notifications
690 $tpl = load_view_file('view/wall_received_html_body_eml.tpl');
691 $email_html_body_tpl = replace_macros($tpl,array(
692 '$username' => $user['username'],
693 '$sitename' => $a->config['sitename'], // name of this site
694 '$siteurl' => $a->get_baseurl(), // descriptive url of this site
695 '$thumb' => $author['thumb'], // thumbnail url for sender icon
696 '$url' => $author['url'], // full url for the site
697 '$from' => $from, // name of the person sending the message
698 '$body' => $msg['htmlversion'], // html version of the message
699 '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
702 // load the template for private message notifications
703 $tpl = load_view_file('view/wall_received_text_body_eml.tpl');
704 $email_text_body_tpl = replace_macros($tpl,array(
705 '$username' => $user['username'],
706 '$sitename' => $a->config['sitename'], // name of this site
707 '$siteurl' => $a->get_baseurl(), // descriptive url of this site
708 '$thumb' => $author['thumb'], // thumbnail url for sender icon
709 '$url' => $author['url'], // full url for the site
710 '$from' => $from, // name of the person sending the message
711 '$body' => $msg['textversion'], // text version of the message
712 '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
715 // use the EmailNotification library to send the message
716 require_once("include/EmailNotification.php");
717 EmailNotification::sendTextHtmlEmail(
718 $msg['notificationfromname'],
719 t("Administrator@") . $a->get_hostname(),
720 t("noreply") . '@' . $a->get_hostname(),
722 sprintf( t('%s posted to your profile wall at %s') , $from , $a->config['sitename']),
723 $email_html_body_tpl,
730 $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `plink` = '%s', `changed` = '%s', `last-child` = 1, `visible` = 1
731 WHERE `id` = %d LIMIT 1",
733 dbesc(($parent == $post_id) ? $uri : $parent_item['uri']),
734 dbesc($a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id),
735 dbesc(datetime_convert()),
739 // photo comments turn the corresponding item visible to the profile wall
740 // This way we don't see every picture in your new photo album posted to your wall at once.
741 // They will show up as people comment on them.
743 if(! $parent_item['visible']) {
744 $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d LIMIT 1",
745 intval($parent_item['id'])
750 logger('mod_item: unable to retrieve post that was just stored.');
751 notify( t('System error. Post not saved.'));
752 goaway($a->get_baseurl() . "/" . $_POST['return'] );
756 proc_run('php', "include/notifier.php", $notify_type, "$post_id");
758 $datarray['id'] = $post_id;
759 $datarray['plink'] = $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id;
761 call_hooks('post_local_end', $datarray);
763 if(strlen($emailcc) && $profile_uid == local_user()) {
764 $erecips = explode(',', $emailcc);
765 if(count($erecips)) {
766 foreach($erecips as $recip) {
767 $addr = trim($recip);
770 $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendika social network.'),$a->user['username'])
772 $disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
773 $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
775 $subject = '[Friendika]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']);
776 $headers = 'From: ' . $a->user['username'] . ' <' . $a->user['email'] . '>' . "\n";
777 $headers .= 'MIME-Version: 1.0' . "\n";
778 $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
779 $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
780 $link = '<a href="' . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
781 $html = prepare_body($datarray);
782 $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
783 @mail($addr, $subject, $message, $headers);
788 logger('post_complete');
790 // figure out how to return, depending on from whence we came
795 if((x($_POST,'return')) && strlen($_POST['return'])) {
796 logger('return: ' . $_POST['return']);
797 goaway($a->get_baseurl() . "/" . $_POST['return'] );
799 $json = array('success' => 1);
800 if(x($_POST,'jsreload') && strlen($_POST['jsreload']))
801 $json['reload'] = $a->get_baseurl() . '/' . $_POST['jsreload'];
803 logger('post_json: ' . print_r($json,true), LOGGER_DEBUG);
805 echo json_encode($json);
814 function item_content(&$a) {
816 if((! local_user()) && (! remote_user()))
819 require_once('include/security.php');
821 if(($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
822 require_once('include/items.php');
823 drop_item($a->argv[2]);