X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fitem.php;h=ffb486a7dbb194358ccb85dd95f763fba9d524e9;hb=fd8df4c4d6688e5ffd6bc78e14062aa064102715;hp=f8f2e0fafe49f04a42f5f20c4cfd55e6907c9c52;hpb=0c67c89715df801e0c887be50c9739db3bae7ca3;p=friendica.git diff --git a/mod/item.php b/mod/item.php index f8f2e0fafe..ffb486a7db 100644 --- a/mod/item.php +++ b/mod/item.php @@ -24,8 +24,8 @@ require_once('include/threads.php'); require_once('include/text.php'); require_once('include/items.php'); require_once('include/Scrape.php'); +require_once('include/diaspora.php'); -if(! function_exists('item_post')) { function item_post(&$a) { if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter'))) @@ -161,6 +161,9 @@ function item_post(&$a) { logger('no contact found: '.print_r($thrparent, true), LOGGER_DEBUG); } else logger('parent contact: '.print_r($parent_contact, true), LOGGER_DEBUG); + + if ($parent_contact["nick"] == "") + $parent_contact["nick"] = $parent_contact["name"]; } } @@ -845,9 +848,6 @@ function item_post(&$a) { // NOTREACHED } - // Store the guid and other relevant data - add_guid($datarray); - $post_id = $r[0]['id']; logger('mod_item: saved item ' . $post_id); @@ -901,7 +901,7 @@ function item_post(&$a) { // Store the comment signature information in case we need to relay to Diaspora - store_diaspora_comment_sig($datarray, $author, ($self ? $user['prvkey'] : false), $parent_item, $post_id); + diaspora::store_comment_signature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id); } else { $parent = $post_id; @@ -1018,9 +1018,7 @@ function item_post(&$a) { item_post_return($a->get_baseurl(), $api_source, $return_path); // NOTREACHED } -} -if(! function_exists('item_post_return')) { function item_post_return($baseurl, $api_source, $return_path) { // figure out how to return, depending on from whence we came @@ -1040,9 +1038,9 @@ function item_post_return($baseurl, $api_source, $return_path) { echo json_encode($json); killme(); } -} -if(! function_exists('item_content')) { + + function item_content(&$a) { if((! local_user()) && (! remote_user())) @@ -1061,21 +1059,20 @@ function item_content(&$a) { } return $o; } -} /** * This function removes the tag $tag from the text $body and replaces it with * the appropiate link. * * @param unknown_type $body the text to replace the tag in - * @param unknown_type $inform a comma-seperated string containing everybody to inform - * @param unknown_type $str_tags string to add the tag to - * @param unknown_type $profile_uid - * @param unknown_type $tag the tag to replace + * @param string $inform a comma-seperated string containing everybody to inform + * @param string $str_tags string to add the tag to + * @param integer $profile_uid + * @param string $tag the tag to replace + * @param string $network The network of the post * * @return boolean true if replaced, false if not replaced */ -if(! function_exists('handle_tag')) { function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "") { require_once("include/Scrape.php"); require_once("include/socgraph.php"); @@ -1180,7 +1177,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo //select someone from this user's contacts by name in the current network if (!$r AND ($network != "")) $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1", - dbesc($newname), + dbesc($name), dbesc($network), intval($profile_uid) ); @@ -1197,7 +1194,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo //select someone from this user's contacts by name if(!$r) $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", - dbesc($newname), + dbesc($name), intval($profile_uid) ); } @@ -1220,13 +1217,13 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo } //if there is an url for this persons profile - if(isset($profile)) { + if (isset($profile) AND ($newname != "")) { $replaced = true; //create profile link $profile = str_replace(',','%2c',$profile); - $newtag = '@[url=' . $profile . ']' . $newname . '[/url]'; - $body = str_replace('@' . $name, $newtag, $body); + $newtag = '@[url='.$profile.']'.$newname.'[/url]'; + $body = str_replace('@'.$name, $newtag, $body); //append tag to str_tags if(! stristr($str_tags,$newtag)) { if(strlen($str_tags)) @@ -1238,7 +1235,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo // subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both. if(strlen($alias)) { - $newtag = '@[url=' . $alias . ']' . $newname . '[/url]'; + $newtag = '@[url='.$alias.']'.$newname.'[/url]'; if(! stristr($str_tags,$newtag)) { if(strlen($str_tags)) $str_tags .= ','; @@ -1250,44 +1247,3 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo return array('replaced' => $replaced, 'contact' => $r[0]); } -} - -if(! function_exists('store_diaspora_comment_sig')) { -function store_diaspora_comment_sig($datarray, $author, $uprvkey, $parent_item, $post_id) { - // We won't be able to sign Diaspora comments for authenticated visitors - we don't have their private key - - $enabled = intval(get_config('system','diaspora_enabled')); - if(! $enabled) { - logger('mod_item: diaspora support disabled, not storing comment signature', LOGGER_DEBUG); - return; - } - - - logger('mod_item: storing diaspora comment signature'); - - require_once('include/bb2diaspora.php'); - $signed_body = html_entity_decode(bb2diaspora($datarray['body'])); - - // Only works for NETWORK_DFRN - $contact_baseurl_start = strpos($author['url'],'://') + 3; - $contact_baseurl_length = strpos($author['url'],'/profile') - $contact_baseurl_start; - $contact_baseurl = substr($author['url'], $contact_baseurl_start, $contact_baseurl_length); - $diaspora_handle = $author['nick'] . '@' . $contact_baseurl; - - $signed_text = $datarray['guid'] . ';' . $parent_item['guid'] . ';' . $signed_body . ';' . $diaspora_handle; - - if( $uprvkey !== false ) - $authorsig = rsa_sign($signed_text,$uprvkey,'sha256'); - else - $authorsig = ''; - - q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", - intval($post_id), - dbesc($signed_text), - dbesc(base64_encode($authorsig)), - dbesc($diaspora_handle) - ); - - return; -} -}