diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/conversation.php | 3 | ||||
-rw-r--r-- | include/diaspora.php | 4 | ||||
-rw-r--r-- | include/items.php | 15 | ||||
-rw-r--r-- | include/network.php | 14 | ||||
-rw-r--r-- | include/oembed.php | 34 |
5 files changed, 44 insertions, 26 deletions
diff --git a/include/conversation.php b/include/conversation.php index 7f9627a7d..9ac251e46 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -112,10 +112,9 @@ function localize_item(&$item){ $parsedobj = parse_xml_string($xmlhead.$item['object']); - $tag = sprintf('#[url=%s]%s[/url]', $parsedobj->link, $parsedobj->content); + $tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content); $item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag ); - } } diff --git a/include/diaspora.php b/include/diaspora.php index ff0c0c0d7..36457655e 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -455,7 +455,9 @@ function diaspora_request($importer,$xml) { intval($importer['uid']) ); - if(count($self)) { + // they are not CONTACT_IS_FOLLOWER anymore but that's what we have in the array + + if(count($self) && $contact['rel'] == CONTACT_IS_FOLLOWER) { $arr = array(); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $importer['uid']); diff --git a/include/items.php b/include/items.php index 7ab7eeaa4..72c1a8b32 100644 --- a/include/items.php +++ b/include/items.php @@ -1529,10 +1529,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) continue; // extract tag, if not duplicate, add to parent item - if($xo->content) { - if(! (stristr($r[0]['tag'],trim($xo->content)))) { + if($xo->id && $xo->content) { + $newtag = '#[url=' . $xo->id . ']'. $xo->content . '[/url]'; + if(! (stristr($r[0]['tag'],$newtag))) { q("UPDATE item SET tag = '%s' WHERE id = %d LIMIT 1", - dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'), + dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag), intval($r[0]['id']) ); } @@ -2084,15 +2085,17 @@ dbg(0); if(($xt->type == ACTIVITY_OBJ_NOTE) && ($xt->id == $r[0]['uri'])) { // extract tag, if not duplicate, and this user allows tags, add to parent item - if($xo->content) { - if(! (stristr($r[0]['tag'],trim($xo->content)))) { + if($xo->id && $xo->content) { + $newtag = '#[url=' . $xo->id . ']'. $xo->content . '[/url]'; + + if(! (stristr($r[0]['tag'],$newtag))) { $i = q("SELECT `blocktags` FROM `user` where `uid` = %d LIMIT 1", intval($importer['importer_uid']) ); if(count($i) && ! ($i[0]['blocktags'])) { q("UPDATE item SET tag = '%s' WHERE id = %d LIMIT 1", - dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'), + dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag), intval($r[0]['id']) ); } diff --git a/include/network.php b/include/network.php index a9ee3f0a5..78ed24074 100644 --- a/include/network.php +++ b/include/network.php @@ -5,7 +5,7 @@ // results. if(! function_exists('fetch_url')) { -function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) { +function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_content=Null) { $a = get_app(); @@ -14,8 +14,16 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) { return false; @curl_setopt($ch, CURLOPT_HEADER, true); + + if (!is_null($accept_content)){ + curl_setopt($ch,CURLOPT_HTTPHEADER, array ( + "Accept: "+$accept_content + )); + } + @curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); - @curl_setopt($ch, CURLOPT_USERAGENT, "Friendika"); + @curl_setopt($ch, CURLOPT_USERAGENT, "Friendica"); + if(intval($timeout)) { @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); @@ -97,7 +105,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$params); - curl_setopt($ch, CURLOPT_USERAGENT, "Friendika"); + curl_setopt($ch, CURLOPT_USERAGENT, "Friendica"); if(intval($timeout)) { curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); diff --git a/include/oembed.php b/include/oembed.php index 7c0da4594..118f7fa4a 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -13,24 +13,30 @@ function oembed_replacecb($matches){ function oembed_fetch_url($embedurl){ $txt = Cache::get($embedurl); + + $noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm"); + $ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION); + if(is_null($txt)){ $txt = ""; - // try oembed autodiscovery - $redirects = 0; - $html_text = fetch_url($embedurl, false, $redirects, 15); - if($html_text){ - $dom = @DOMDocument::loadHTML($html_text); - if ($dom){ - $xpath = new DOMXPath($dom); - $attr = "oembed"; - - $xattr = oe_build_xpath("class","oembed"); - $entries = $xpath->query("//link[@type='application/json+oembed']"); - foreach($entries as $e){ - $href = $e->getAttributeNode("href")->nodeValue; - $txt = fetch_url($href); + if (!in_array($ext, $noexts)){ + // try oembed autodiscovery + $redirects = 0; + $html_text = fetch_url($embedurl, false, $redirects, 15, "text/*"); + if($html_text){ + $dom = @DOMDocument::loadHTML($html_text); + if ($dom){ + $xpath = new DOMXPath($dom); + $attr = "oembed"; + + $xattr = oe_build_xpath("class","oembed"); + $entries = $xpath->query("//link[@type='application/json+oembed']"); + foreach($entries as $e){ + $href = $e->getAttributeNode("href")->nodeValue; + $txt = fetch_url($href); + } } } } |