X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FScrape.php;h=ce18bb10333f5c5dddf573c609263512716a28e3;hb=26eceaacbe883b7ece20c0cfb5c724c8ba1a7d99;hp=c74fd879c2b1e30243d6a8c03f52fed4fa0f93d2;hpb=135869fd1c045bee2172384b789f400767859f5d;p=friendica.git diff --git a/include/Scrape.php b/include/Scrape.php index c74fd879c2..ce18bb1033 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -364,16 +364,6 @@ function probe_url($url, $mode = PROBE_NORMAL) { $network = NETWORK_TWITTER; } - if (strpos($url,'www.facebook.com')) { - $connectornetworks = true; - $network = NETWORK_FACEBOOK; - } - - if (strpos($url,'alpha.app.net')) { - $appnet = true; - $network = NETWORK_APPNET; - } - // Twitter is deactivated since twitter closed its old API //$twitter = ((strpos($url,'twitter.com') !== false) ? true : false); $lastfm = ((strpos($url,'last.fm/user') !== false) ? true : false); @@ -526,8 +516,8 @@ function probe_url($url, $mode = PROBE_NORMAL) { if($j) { $network = NETWORK_ZOT; $vcard = array( - 'fn' => $j->fullname, - 'nick' => $j->nickname, + 'fn' => $j->fullname, + 'nick' => $j->nickname, 'photo' => $j->photo ); $profile = $j->url; @@ -569,6 +559,10 @@ function probe_url($url, $mode = PROBE_NORMAL) { $network = NETWORK_DIASPORA; elseif($has_lrdd) $network = NETWORK_OSTATUS; + + if(strpos($url,'@')) + $addr = str_replace('acct:', '', $url); + $priority = 0; if($hcard && ! $vcard) { @@ -762,6 +756,22 @@ function probe_url($url, $mode = PROBE_NORMAL) { if(($network === NETWORK_FEED) && ($poll) && (! x($vcard,'fn'))) $vcard['fn'] = $url; + if (($notify != "") AND ($poll != "")) { + $baseurl = matching($notify, $poll); + + $baseurl2 = matching($baseurl, $profile); + if ($baseurl2 != "") + $baseurl = $baseurl2; + } + + if (($baseurl == "") AND ($notify != "")) + $baseurl = matching($profile, $notify); + + if (($baseurl == "") AND ($poll != "")) + $baseurl = matching($profile, $poll); + + $baseurl = rtrim($baseurl, "/"); + $vcard['fn'] = notags($vcard['fn']); $vcard['nick'] = str_replace(' ','',notags($vcard['nick'])); @@ -780,11 +790,12 @@ function probe_url($url, $mode = PROBE_NORMAL) { $result['network'] = $network; $result['alias'] = $alias; $result['pubkey'] = $pubkey; + $result['baseurl'] = $baseurl; logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG); // Trying if it maybe a diaspora account - if ($result['network'] == NETWORK_FEED) { + if (($result['network'] == NETWORK_FEED) OR ($result['addr'] == "")) { require_once('include/bbcode.php'); $address = GetProfileUsername($url, "", true); $result2 = probe_url($address, $mode); @@ -796,3 +807,20 @@ function probe_url($url, $mode = PROBE_NORMAL) { return $result; } + +function matching($part1, $part2) { + $len = min(strlen($part1), strlen($part2)); + + $match = ""; + $matching = true; + $i = 0; + while (($i <= $len) AND $matching) { + if (substr($part1, $i, 1) == substr($part2, $i, 1)) + $match .= substr($part1, $i, 1); + else + $matching = false; + + $i++; + } + return($match); +}