From e76990ae7bffdcc5f1c54146f54fc11729c537b7 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 1 Aug 2011 16:15:37 -0700 Subject: bug #111 - don't parse an @ address as a feed --- include/Scrape.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/Scrape.php') diff --git a/include/Scrape.php b/include/Scrape.php index 6726d0b15..9bf89a49e 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -294,6 +294,8 @@ function probe_url($url) { $twitter = ((strpos($url,'twitter.com') !== false) ? true : false); + $at_addr = ((strpos($url,'@') !== false) ? true : false); + if(! $twitter) { $links = lrdd($url); @@ -452,7 +454,7 @@ function probe_url($url) { $vcard['fn'] = $vcard['nick']; - if(((! isset($vcard)) && (! $poll)) || ($twitter)) { + if(((! isset($vcard)) && (! $poll) && (! $at_addr)) || ($twitter)) { $feedret = scrape_feed($url); logger('probe_url: scrape_feed returns: ' . print_r($feedret,true), LOGGER_DATA); -- cgit v1.2.3 From cbfb40c43fd63d149ed3d4aa1b056bccb437cc32 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 9 Aug 2011 22:11:01 -0700 Subject: use mailto: to specify a new email contact and over-rider webfinger --- include/Scrape.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include/Scrape.php') diff --git a/include/Scrape.php b/include/Scrape.php index 9bf89a49e..ef5d7dcae 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -297,7 +297,13 @@ function probe_url($url) { $at_addr = ((strpos($url,'@') !== false) ? true : false); if(! $twitter) { - $links = lrdd($url); + + if(strpos($url,'mailto:') !== false && $at_addr) { + $url = str_replace('mailto:','',$url); + $links = array(); + } + else + $links = lrdd($url); if(count($links)) { logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA); -- cgit v1.2.3 From aefc6209a3d07d70835422e690f624c72075c410 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 12 Aug 2011 03:01:11 -0700 Subject: improved diaspora discovery --- include/Scrape.php | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'include/Scrape.php') diff --git a/include/Scrape.php b/include/Scrape.php index ef5d7dcae..c4882243d 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -1,6 +1,7 @@ getElementsByTagName('*'); foreach($items as $item) { if(attribute_contains($item->getAttribute('class'), 'vcard')) { @@ -179,8 +182,13 @@ function scrape_vcard($url) { if(attribute_contains($x->getAttribute('class'),'fn')) $ret['fn'] = $x->textContent; if((attribute_contains($x->getAttribute('class'),'photo')) - || (attribute_contains($x->getAttribute('class'),'avatar'))) - $ret['photo'] = $x->getAttribute('src'); + || (attribute_contains($x->getAttribute('class'),'avatar'))) { + $size = intval($x->getAttribute('width')); + if(($size > $largest_photo) || (! $largest_photo)) { + $ret['photo'] = $x->getAttribute('src'); + $largest_photo = $size; + } + } if((attribute_contains($x->getAttribute('class'),'nickname')) || (attribute_contains($x->getAttribute('class'),'uid'))) $ret['nick'] = $x->textContent; @@ -289,7 +297,10 @@ function probe_url($url) { if(! $url) return $result; - $diaspora = false; + $diaspora = false; + $diaspora_base = ''; + $diaspora_guid = ''; + $diaspora_key = ''; $email_conversant = false; $twitter = ((strpos($url,'twitter.com') !== false) ? true : false); @@ -320,8 +331,19 @@ function probe_url($url) { $hcard = unamp($link['@attributes']['href']); if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') $profile = unamp($link['@attributes']['href']); - if($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') + if($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') { + $diaspora_base = unamp($link['@attributes']['href']); + $diaspora = true; + } + if($link['@attributes']['rel'] === 'http://joindiaspora.com/guid') { + $diaspora_guid = unamp($link['@attributes']['href']); $diaspora = true; + } + if($link['@attributes']['rel'] === 'diaspora-public-key') { + $diaspora_key = base64_decode(unamp($link['@attributes']['href'])); + $pubkey = rsatopem($diaspora_key); + $diaspora = true; + } } // Status.Net can have more than one profile URL. We need to match the profile URL @@ -419,8 +441,17 @@ function probe_url($url) { } } + if($diaspora && $diaspora_base && $diaspora_guid) { + $notify = $diaspora_base . 'receive/post/' . $diaspora_guid; + if(strpos($url,'@')) + $addr = str_replace('acct:', '', $url); + } + if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) { - $network = NETWORK_OSTATUS; + if($diaspora) + $network = NETWORK_DIASPORA; + else + $network = NETWORK_OSTATUS; $priority = 0; if($hcard) { -- cgit v1.2.3 From 79529612226dc89b90df33ba066a530d0e716a69 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 14 Aug 2011 18:13:52 -0700 Subject: diaspora probe/scrape changes --- include/Scrape.php | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'include/Scrape.php') diff --git a/include/Scrape.php b/include/Scrape.php index c4882243d..b32d7283e 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -468,13 +468,6 @@ function probe_url($url) { logger('probe_url: scrape_vcard: ' . print_r($vcard,true), LOGGER_DATA); } - if(! $profile) { - if($diaspora) - $profile = $hcard; - else - $profile = $url; - } - if($twitter) { logger('twitter: setup'); $tid = basename($url); @@ -490,8 +483,16 @@ function probe_url($url) { if(x($vcard,'nick')) $vcard['fn'] = $vcard['nick']; - - if(((! isset($vcard)) && (! $poll) && (! $at_addr)) || ($twitter)) { + $check_feed = false; + + if($twitter || ! $poll) + $check_feed = true; + if((! isset($vcard)) || (! $profile)) + $check_feed = true; + if(($at_addr) && (! count($links))) + $check_feed = false; + + if($check_feed) { $feedret = scrape_feed($url); logger('probe_url: scrape_feed returns: ' . print_r($feedret,true), LOGGER_DATA); @@ -527,6 +528,8 @@ function probe_url($url) { if(strpos($vcard['fn'],'@') !== false) $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@')); $email = unxmlify($author->get_email()); + if(! $profile && $author->get_link()) + $profile = trim(unxmlify($author->get_link())); if(! $vcard['photo']) { $rawtags = $feed->get_feed_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if($rawtags) { @@ -547,6 +550,8 @@ function probe_url($url) { if(strpos($vcard['fn'],'@') !== false) $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@')); $email = unxmlify($author->get_email()); + if(! $profile && $author->get_link()) + $profile = trim(unxmlify($author->get_link())); } if(! $vcard['photo']) { $rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/','thumbnail'); @@ -584,8 +589,10 @@ function probe_url($url) { if(strpos($vcard['nick'],' ')) $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' '))); } - $network = 'feed'; - $priority = 2; + if(! $network) + $network = 'feed'; + if(! $priority) + $priority = 2; } } @@ -593,8 +600,12 @@ function probe_url($url) { $a = get_app(); $vcard['photo'] = $a->get_baseurl() . '/images/default-profile.jpg' ; } + + if(! $profile) + $profile = $url; + $vcard['fn'] = notags($vcard['fn']); - $vcard['nick'] = notags($vcard['nick']); + $vcard['nick'] = str_replace(' ','',notags($vcard['nick'])); $result['name'] = $vcard['fn']; -- cgit v1.2.3 From 5d6155a9685202b055744549a2cb84e3d8195fd2 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 15 Aug 2011 05:27:24 -0700 Subject: fixes share from diaspora --- include/Scrape.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Scrape.php') diff --git a/include/Scrape.php b/include/Scrape.php index b32d7283e..bfe795e19 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -494,7 +494,7 @@ function probe_url($url) { if($check_feed) { - $feedret = scrape_feed($url); + $feedret = scrape_feed(($poll) ? $poll : $url); logger('probe_url: scrape_feed returns: ' . print_r($feedret,true), LOGGER_DATA); if(count($feedret) && ($feedret['feed_atom'] || $feedret['feed_rss'])) { $poll = ((x($feedret,'feed_atom')) ? unamp($feedret['feed_atom']) : unamp($feedret['feed_rss'])); -- cgit v1.2.3