X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fitem.php;h=2cc2b9eb2cd9a1564cc8cedbb7e0224283a550c3;hb=b87ddbd58aa2739521282f44a463be53c6397231;hp=f964e7737db2ab4f87ffaebf35aa2c3d090160f8;hpb=950e5f6693907c76821b4da99cd4e3b080c4ae23;p=friendica.git diff --git a/mod/item.php b/mod/item.php index f964e7737d..2cc2b9eb2c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -1,11 +1,17 @@ get_baseurl() . "/" . $_POST['return'] ); } $parent_item = $r[0]; + if($parent_item['contact-id'] && $uid) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($parent_item['contact-id']), + intval($uid) + ); + if(count($r)) + $parent_contact = $r[0]; + } } $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0); @@ -71,6 +88,7 @@ function item_post(&$a) { $location = notags(trim($_POST['location'])); $coord = notags(trim($_POST['coord'])); $verb = notags(trim($_POST['verb'])); + $emailcc = notags(trim($_POST['emailcc'])); if(! strlen($body)) { notice( t('Empty post discarded.') . EOL ); @@ -165,7 +183,11 @@ function item_post(&$a) { } } + /** + * Fold multi-line [code] sequences + */ + $body = preg_replace('/\[\/code\]\s*\[code\]/m',"\n",$body); /** * Look for any tags and linkify them @@ -174,8 +196,13 @@ function item_post(&$a) { $str_tags = ''; $inform = ''; + $tags = get_tags($body); + if(($parent_contact) && ($parent_contact['network'] === 'stat') && ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) { + $body = '@' . $parent_contact['nick'] . ' ' . $body; + $tags[] = '@' . $parent_contact['nick']; + } if(count($tags)) { foreach($tags as $tag) { @@ -188,6 +215,7 @@ function item_post(&$a) { continue; } if(strpos($tag,'@') === 0) { + $stat = false; $name = substr($tag,1); if((strpos($name,'@')) || (strpos($name,'http://'))) { $newname = $name; @@ -221,7 +249,12 @@ function item_post(&$a) { } if(count($r)) { $profile = $r[0]['url']; - $newname = $r[0]['name']; + if($r[0]['network'] === 'stat') { + $newname = $r[0]['nick']; + $stat = true; + } + else + $newname = $r[0]['name']; if(strlen($inform)) $inform .= ','; $inform .= 'cid:' . $r[0]['id']; @@ -238,6 +271,8 @@ function item_post(&$a) { } } + + $wall = 0; if($post_type === 'wall' || $post_type === 'wall-comment') $wall = 1; @@ -412,21 +447,56 @@ function item_post(&$a) { ); } } + else { + logger('mod_item: unable to retrieve post that was just stored.'); + notify( t('System error. Post not saved.')); + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + // NOTREACHED + } $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); logger('mod_item: notifier invoked: ' . "\"$php_path\" \"include/notifier.php\" \"$notify_type\" \"$post_id\" &"); - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$notify_type\" \"$post_id\" &", - array(),$foo)); + proc_run($php_path, "include/notifier.php", $notify_type, "$post_id"); $datarray['id'] = $post_id; call_hooks('post_local_end', $datarray); - - goaway($a->get_baseurl() . "/" . $_POST['return'] ); - return; // NOTREACHED + if(strlen($emailcc) && $profile_uid == local_user()) { + $erecips = explode(',', $emailcc); + if(count($erecips)) { + foreach($erecips as $recip) { + $addr = trim($recip); + if(! strlen($addr)) + continue; + $disclaimer = '
' . t('This message was sent to you by ') . $a->user['username'] + . t(', a member of the Friendika social network.') . '
'; + $disclaimer .= t('You may visit them online at') . ' ' + . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '
'; + $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . '
'; + + $subject = '[Friendika]' . ' ' . $a->user['username'] . ' ' . t('posted an update.'); + $headers = 'From: ' . $a->user['username'] . ' <' . $a->user['email'] . '>' . "\n"; + $headers .= 'MIME-Version: 1.0' . "\n"; + $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n"; + $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n"; + $link = '' . $a->user['username'] . '

'; + $html = prepare_body($datarray); + $message = '' . $link . $html . $disclaimer . ''; + @mail($addr, $subject, $message, $headers); + } + } + } + + if((x($_POST,'return')) && strlen($_POST['return'])) + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + + $json = array('success' => 1); + echo json_encode($json); + killme(); + // NOTREACHED } @@ -516,11 +586,11 @@ function item_content(&$a) { // send the notification upstream/downstream as the case may be - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" &", - array(), $foo)); + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" &", array(), $foo)); + proc_run($php_path,"include/notifier.php","drop","$drop_id"); goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); - return; //NOTREACHED + //NOTREACHED } else { notice( t('Permission denied.') . EOL);