X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FScrape.php;h=cd88aceb7cfb691bb30445fcf0f50f74c3587dc2;hb=3d6c49d5b3d4447ad91a5a4f4123c9fd9d4584cf;hp=141c90dcfd6a92bbb5246ee78fc61a040ba06a05;hpb=93ffba58cc10fc793821ba16de88cdfb271ea5b8;p=friendica.git diff --git a/include/Scrape.php b/include/Scrape.php index 141c90dcfd..cd88aceb7c 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -282,7 +282,7 @@ function scrape_feed($url) { } } if(! $basename) - $basename = substr($url,0,strrpos($url,'/')) . '/'; + $basename = implode('/', array_slice(explode('/',$url),0,3)) . '/'; $items = $dom->getElementsByTagName('link'); @@ -352,10 +352,11 @@ function probe_url($url, $mode = PROBE_NORMAL) { $email_conversant = false; $twitter = ((strpos($url,'twitter.com') !== false) ? true : false); + $lastfm = ((strpos($url,'last.fm/user') !== false) ? true : false); $at_addr = ((strpos($url,'@') !== false) ? true : false); - if(! $twitter) { + if((! $twitter) && (! $lastfm)) { if(strpos($url,'mailto:') !== false && $at_addr) { $url = str_replace('mailto:','',$url); @@ -393,7 +394,10 @@ function probe_url($url, $mode = PROBE_NORMAL) { } if($link['@attributes']['rel'] === 'diaspora-public-key') { $diaspora_key = base64_decode(unamp($link['@attributes']['href'])); - $pubkey = rsatopem($diaspora_key); + if(strstr($diaspora_key,'RSA ')) + $pubkey = rsatopem($diaspora_key); + else + $pubkey = $diaspora_key; $diaspora = true; } } @@ -431,14 +435,17 @@ function probe_url($url, $mode = PROBE_NORMAL) { intval(local_user()) ); if(count($x) && count($r)) { - $mailbox = construct_mailbox_name($r[0]); + $mailbox = construct_mailbox_name($r[0]); $password = ''; openssl_private_decrypt(hex2bin($r[0]['pass']),$password,$x[0]['prvkey']); $mbox = email_connect($mailbox,$r[0]['user'],$password); + if(! $mbox) + logger('probe_url: email_connect failed.'); unset($password); } if($mbox) { $msgs = email_poll($mbox,$orig_url); + logger('probe_url: searching ' . $orig_url . ', ' . count($msgs) . ' messages found.', LOGGER_DEBUG); if(count($msgs)) { $addr = $orig_url; $network = NETWORK_MAIL; @@ -556,9 +563,18 @@ function probe_url($url, $mode = PROBE_NORMAL) { else $poll = $tapi . '?screen_name=' . $tid; $profile = 'http://twitter.com/#!/' . $tid; - $vcard['photo'] = 'https://api.twitter.com/1/users/profile_image/' . $tid; + //$vcard['photo'] = 'https://api.twitter.com/1/users/profile_image/' . $tid; + $vcard['photo'] = 'https://api.twitter.com/1/users/profile_image?screen_name=' . $tid . '&size=bigger'; $vcard['nick'] = $tid; - $vcard['fn'] = $tid . '@twitter'; + $vcard['fn'] = $tid; + } + + if($lastfm) { + $profile = $url; + $poll = str_replace(array('www.','last.fm/'),array('','ws.audioscrobbler.com/1.0/'),$url) . '/recenttracks.rss'; + $vcard['nick'] = basename($url); + $vcard['fn'] = $vcard['nick'] . t(' on Last.fm'); + $network = NETWORK_FEED; } if(! x($vcard,'fn')) @@ -593,7 +609,7 @@ function probe_url($url, $mode = PROBE_NORMAL) { logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA); $a = get_app(); - logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), $LOGGER_DATA); + logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), LOGGER_DATA); $feed->set_raw_data($xml);