X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=include%2Fitems.php;h=7931b8c3d4119ae61060ff6ccea24fc6766b8b06;hb=fe5705e5473c358359e6c78d596d4ad3d866cc26;hp=eff13668992a6c47a03ae9a021ae643b23c3a326;hpb=307beb47fd4930c665cb7d3032ca4405900af43d;p=friendica.git diff --git a/include/items.php b/include/items.php index eff1366899..7931b8c3d4 100644 --- a/include/items.php +++ b/include/items.php @@ -19,7 +19,7 @@ require_once('mod/share.php'); require_once('library/defuse/php-encryption-1.2.1/Crypto.php'); -function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0, $forpubsub = false) { +function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) { $sitefeed = ((strlen($owner_nick)) ? false : true); // not yet implemented, need to rewrite huge chunks of following logic @@ -120,18 +120,8 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0, else $sort = 'ASC'; - // Include answers to status.net posts in pubsub feeds - if($forpubsub) { - $sql_post_table = "INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent` - LEFT JOIN `item` AS `thritem` ON `thritem`.`uri`=`item`.`thr-parent` AND `thritem`.`uid`=`item`.`uid`"; - $visibility = sprintf("AND (`item`.`parent` = `item`.`id`) OR (`item`.`network` = '%s' AND ((`thread`.`network`='%s') OR (`thritem`.`network` = '%s')))", - dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS)); - $date_field = "`received`"; - $sql_order = "`item`.`received` DESC"; - } else { - $date_field = "`changed`"; - $sql_order = "`item`.`parent` ".$sort.", `item`.`created` ASC"; - } + $date_field = "`changed`"; + $sql_order = "`item`.`parent` ".$sort.", `item`.`created` ASC"; if(! strlen($last_update)) $last_update = 'now -30 days'; @@ -955,8 +945,9 @@ function add_page_info_data($data) { $a = get_app(); $hashtags = "\n"; foreach ($data["keywords"] AS $keyword) { - $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"), - array("","", "", "", "", ""), $keyword); + /// @todo make a positive list of allowed characters + $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"), + array("","", "", "", "", "", "", "", "", "", "", ""), $keyword); $hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] "; } } @@ -967,12 +958,7 @@ function add_page_info_data($data) { function query_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") { require_once("mod/parse_url.php"); - $data = Cache::get("parse_url:".$url); - if (is_null($data)){ - $data = parseurl_getsiteinfo($url, true); - Cache::set("parse_url:".$url,serialize($data), CACHE_DAY); - } else - $data = unserialize($data); + $data = parseurl_getsiteinfo_cached($url, true); if ($photo != "") $data["images"][0]["src"] = $photo; @@ -1097,10 +1083,13 @@ function add_guid($item) { dbesc($item["uri"]), dbesc($item["network"])); } -// Adds a "lang" specification in a "postopts" element of given $arr, -// if possible and not already present. -// Expects "body" element to exist in $arr. -// TODO: add a parameter to request forcing override +/** + * Adds a "lang" specification in a "postopts" element of given $arr, + * if possible and not already present. + * Expects "body" element to exist in $arr. + * + * @todo Add a parameter to request forcing override + */ function item_add_language_opt(&$arr) { if (version_compare(PHP_VERSION, '5.3.0', '<')) return; // LanguageDetect.php not available ? @@ -1110,7 +1099,7 @@ function item_add_language_opt(&$arr) { if ( strstr($arr['postopts'], 'lang=') ) { // do not override - // TODO: add parameter to request overriding + /// @TODO Add parameter to request overriding return; } $postopts = $arr['postopts']; @@ -1335,6 +1324,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa logger("item_store: Set network to ".$arr["network"]." for ".$arr["uri"], LOGGER_DEBUG); } + if ($arr["gcontact-id"] == 0) + $arr["gcontact-id"] = get_gcontact_id(array("url" => $arr['author-link'], "network" => $arr['network'], + "photo" => $arr['author-avatar'], "name" => $arr['author-name'])); + if ($arr['guid'] != "") { // Checking if there is already an item with the same guid logger('checking for an item for user '.$arr['uid'].' on network '.$arr['network'].' with the guid '.$arr['guid'], LOGGER_DEBUG); @@ -1606,6 +1599,14 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa ); if($dsprsig) { + + // Friendica servers lower than 3.4.3-2 had double encoded the signature ... + // We can check for this condition when we decode and encode the stuff again. + if (base64_encode(base64_decode(base64_decode($dsprsig->signature))) == base64_decode($dsprsig->signature)) { + $dsprsig->signature = base64_decode($dsprsig->signature); + logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG); + } + q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", intval($current_post), dbesc($dsprsig->signed_text), @@ -2640,7 +2641,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) logger('consume_feed: feed item count = ' . $feed->get_item_quantity()); - // in inverse date order + // in inverse date order if ($datedir) $items = array_reverse($feed->get_items()); else @@ -2765,20 +2766,20 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['gravity'] = GRAVITY_LIKE; // only one like or dislike per person // splitted into two queries for performance issues - $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent-uri` = '%s') limit 1", + $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1", intval($datarray['uid']), - intval($datarray['contact-id']), + dbesc($datarray['author-link']), dbesc($datarray['verb']), - dbesc($parent_uri) + dbesc($datarray['parent-uri']) ); if($r && count($r)) continue; - $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`thr-parent` = '%s') limit 1", + $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1", intval($datarray['uid']), - intval($datarray['contact-id']), + dbesc($datarray['author-link']), dbesc($datarray['verb']), - dbesc($parent_uri) + dbesc($datarray['parent-uri']) ); if($r && count($r)) continue; @@ -3228,11 +3229,11 @@ function local_delivery($importer,$data) { return 1; } - // TODO - // merge with current record, current contents have priority - // update record, set url-updated - // update profile photos - // schedule a scan? + /// @TODO + /// merge with current record, current contents have priority + /// update record, set url-updated + /// update profile photos + /// schedule a scan? return 0; } @@ -3714,7 +3715,7 @@ function local_delivery($importer,$data) { $datarray['owner-avatar'] = $own[0]['thumb']; $datarray['contact-id'] = $importer['id']; - if(($datarray['verb'] === ACTIVITY_LIKE) + if(($datarray['verb'] === ACTIVITY_LIKE) || ($datarray['verb'] === ACTIVITY_DISLIKE) || ($datarray['verb'] === ACTIVITY_ATTEND) || ($datarray['verb'] === ACTIVITY_ATTENDNO) @@ -3725,19 +3726,18 @@ function local_delivery($importer,$data) { $datarray['last-child'] = 0; // only one like or dislike per person // splitted into two queries for performance issues - $r = q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`parent-uri` = '%s') and deleted = 0 limit 1", + $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1", intval($datarray['uid']), - intval($datarray['contact-id']), + dbesc($datarray['author-link']), dbesc($datarray['verb']), dbesc($datarray['parent-uri']) - ); if($r && count($r)) continue; - $r = q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`thr-parent` = '%s') and deleted = 0 limit 1", + $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1", intval($datarray['uid']), - intval($datarray['contact-id']), + dbesc($datarray['author-link']), dbesc($datarray['verb']), dbesc($datarray['parent-uri']) @@ -3907,7 +3907,7 @@ function local_delivery($importer,$data) { $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['importer_uid']; $datarray['contact-id'] = $importer['id']; - if(($datarray['verb'] === ACTIVITY_LIKE) + if(($datarray['verb'] === ACTIVITY_LIKE) || ($datarray['verb'] === ACTIVITY_DISLIKE) || ($datarray['verb'] === ACTIVITY_ATTEND) || ($datarray['verb'] === ACTIVITY_ATTENDNO) @@ -3916,20 +3916,20 @@ function local_delivery($importer,$data) { $datarray['gravity'] = GRAVITY_LIKE; // only one like or dislike per person // splitted into two queries for performance issues - $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent-uri` = '%s') limit 1", + $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1", intval($datarray['uid']), - intval($datarray['contact-id']), + dbesc($datarray['author-link']), dbesc($datarray['verb']), - dbesc($parent_uri) + dbesc($datarray['parent-uri']) ); if($r && count($r)) continue; - $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`thr-parent` = '%s') limit 1", + $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1", intval($datarray['uid']), - intval($datarray['contact-id']), + dbesc($datarray['author-link']), dbesc($datarray['verb']), - dbesc($parent_uri) + dbesc($datarray['parent-uri']) ); if($r && count($r)) continue; @@ -4515,11 +4515,11 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $o .= '' . "\r\n"; } - // To-Do: - // To support these elements, the API needs to be enhanced - //$o .= ''."\r\n"; - //$o .= "\t".''."\r\n"; - //$o .= "\t".''."\r\n"; + /// @TODO + /// To support these elements, the API needs to be enhanced + /// $o .= ''."\r\n"; + /// $o .= "\t".''."\r\n"; + /// $o .= "\t".''."\r\n"; // Deactivated since it was meant only for OStatus //$o .= item_get_attachment($item);