3 require_once('library/HTML5/Parser.php');
4 require_once('include/crypto.php');
5 require_once('include/feed.php');
7 if(! function_exists('scrape_dfrn')) {
8 function scrape_dfrn($url, $dont_probe = false) {
14 logger('scrape_dfrn: url=' . $url);
16 // Try to fetch the data from noscrape. This is faster than parsing the HTML
17 $noscrape = str_replace("/hcard/", "/noscrape/", $url);
18 $noscrapejson = fetch_url($noscrape);
19 $noscrapedata = array();
21 $noscrapedata = json_decode($noscrapejson, true);
23 if (is_array($noscrapedata)) {
24 if ($noscrapedata["nick"] != "")
25 return($noscrapedata);
27 $noscrapedata = array();
36 $probe = probe_url($url);
38 if (isset($probe["addr"]))
39 $ret["addr"] = $probe["addr"];
42 $headers = $a->get_curl_headers();
43 logger('scrape_dfrn: headers=' . $headers, LOGGER_DEBUG);
46 $lines = explode("\n",$headers);
48 foreach($lines as $line) {
49 // don't try and run feeds through the html5 parser
50 if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml'))))
56 $dom = HTML5_Parser::parse($s);
57 } catch (DOMException $e) {
58 logger('scrape_dfrn: parse error: ' . $e);
64 $items = $dom->getElementsByTagName('link');
66 // get DFRN link elements
68 foreach($items as $item) {
69 $x = $item->getAttribute('rel');
70 if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml'))
71 $ret['feed_atom'] = $item->getAttribute('href');
72 if(substr($x,0,5) == "dfrn-") {
73 $ret[$x] = $item->getAttribute('href');
76 $decoded = urldecode($item->getAttribute('href'));
77 if(preg_match('/acct:([^@]*)@/',$decoded,$matches))
78 $ret['nick'] = $matches[1];
82 // Pull out hCard profile elements
86 $items = $dom->getElementsByTagName('*');
87 foreach($items as $item) {
88 if(attribute_contains($item->getAttribute('class'), 'vcard')) {
89 $level2 = $item->getElementsByTagName('*');
90 foreach($level2 as $x) {
91 if(attribute_contains($x->getAttribute('class'),'fn')) {
92 $ret['fn'] = $x->textContent;
94 if((attribute_contains($x->getAttribute('class'),'photo'))
95 || (attribute_contains($x->getAttribute('class'),'avatar'))) {
96 $size = intval($x->getAttribute('width'));
97 // dfrn prefers 175, so if we find this, we set largest_size so it can't be topped.
98 if(($size > $largest_photo) || ($size == 175) || (! $largest_photo)) {
99 $ret['photo'] = $x->getAttribute('src');
100 $largest_photo = (($size == 175) ? 9999 : $size);
103 if(attribute_contains($x->getAttribute('class'),'key')) {
104 $ret['key'] = $x->textContent;
109 return array_merge($ret, $noscrapedata);
117 if(! function_exists('validate_dfrn')) {
118 function validate_dfrn($a) {
122 if(! x($a,'dfrn-request'))
124 if(! x($a,'dfrn-confirm'))
126 if(! x($a,'dfrn-notify'))
128 if(! x($a,'dfrn-poll'))
133 if(! function_exists('scrape_meta')) {
134 function scrape_meta($url) {
140 logger('scrape_meta: url=' . $url);
142 $s = fetch_url($url);
147 $headers = $a->get_curl_headers();
148 logger('scrape_meta: headers=' . $headers, LOGGER_DEBUG);
150 $lines = explode("\n",$headers);
152 foreach($lines as $line) {
153 // don't try and run feeds through the html5 parser
154 if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml'))))
160 $dom = HTML5_Parser::parse($s);
161 } catch (DOMException $e) {
162 logger('scrape_meta: parse error: ' . $e);
168 $items = $dom->getElementsByTagName('meta');
170 // get DFRN link elements
172 foreach($items as $item) {
173 $x = $item->getAttribute('name');
174 if(substr($x,0,5) == "dfrn-")
175 $ret[$x] = $item->getAttribute('content');
182 if(! function_exists('scrape_vcard')) {
183 function scrape_vcard($url) {
189 logger('scrape_vcard: url=' . $url);
191 $s = fetch_url($url);
196 $headers = $a->get_curl_headers();
197 $lines = explode("\n",$headers);
199 foreach($lines as $line) {
200 // don't try and run feeds through the html5 parser
201 if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml'))))
207 $dom = HTML5_Parser::parse($s);
208 } catch (DOMException $e) {
209 logger('scrape_vcard: parse error: ' . $e);
215 // Pull out hCard profile elements
219 $items = $dom->getElementsByTagName('*');
220 foreach($items as $item) {
221 if(attribute_contains($item->getAttribute('class'), 'vcard')) {
222 $level2 = $item->getElementsByTagName('*');
223 foreach($level2 as $x) {
224 if(attribute_contains($x->getAttribute('class'),'fn'))
225 $ret['fn'] = $x->textContent;
226 if((attribute_contains($x->getAttribute('class'),'photo'))
227 || (attribute_contains($x->getAttribute('class'),'avatar'))) {
228 $size = intval($x->getAttribute('width'));
229 if(($size > $largest_photo) || (! $largest_photo)) {
230 $ret['photo'] = $x->getAttribute('src');
231 $largest_photo = $size;
234 if((attribute_contains($x->getAttribute('class'),'nickname'))
235 || (attribute_contains($x->getAttribute('class'),'uid'))) {
236 $ret['nick'] = $x->textContent;
246 if(! function_exists('scrape_feed')) {
247 function scrape_feed($url) {
252 $cookiejar = tempnam(get_temppath(), 'cookiejar-scrape-feed-');
253 $s = fetch_url($url, false, $redirects, 0, Null, $cookiejar);
256 $headers = $a->get_curl_headers();
257 $code = $a->get_curl_code();
259 logger('scrape_feed: returns: ' . $code . ' headers=' . $headers, LOGGER_DEBUG);
262 logger('scrape_feed: no data returned for ' . $url);
267 $lines = explode("\n",$headers);
269 foreach($lines as $line) {
270 if(stristr($line,'content-type:')) {
271 if(stristr($line,'application/atom+xml') || stristr($s,'<feed')) {
272 $ret['feed_atom'] = $url;
275 if(stristr($line,'application/rss+xml') || stristr($s,'<rss')) {
276 $ret['feed_rss'] = $url;
281 // perhaps an RSS version 1 feed with a generic or incorrect content-type?
282 if(stristr($s,'</item>')) {
283 $ret['feed_rss'] = $url;
288 $basename = implode('/', array_slice(explode('/',$url),0,3)) . '/';
290 $doc = new DOMDocument();
292 $xpath = new DomXPath($doc);
294 $base = $xpath->query("//base");
295 foreach ($base as $node) {
298 if ($node->attributes->length)
299 foreach ($node->attributes as $attribute)
300 $attr[$attribute->name] = $attribute->value;
302 if ($attr["href"] != "")
303 $basename = $attr["href"] ;
306 $list = $xpath->query("//link");
307 foreach ($list as $node) {
310 if ($node->attributes->length)
311 foreach ($node->attributes as $attribute)
312 $attr[$attribute->name] = $attribute->value;
314 if (($attr["rel"] == "alternate") AND ($attr["type"] == "application/atom+xml"))
315 $ret["feed_atom"] = $attr["href"];
317 if (($attr["rel"] == "alternate") AND ($attr["type"] == "application/rss+xml"))
318 $ret["feed_rss"] = $attr["href"];
321 // Drupal and perhaps others only provide relative URLs. Turn them into absolute.
323 if(x($ret,'feed_atom') && (! strstr($ret['feed_atom'],'://')))
324 $ret['feed_atom'] = $basename . $ret['feed_atom'];
325 if(x($ret,'feed_rss') && (! strstr($ret['feed_rss'],'://')))
326 $ret['feed_rss'] = $basename . $ret['feed_rss'];
334 * Probe a network address to discover what kind of protocols we need to communicate with it.
336 * Warning: this function is a bit touchy and there are some subtle dependencies within the logic flow.
343 * PROBE_DIASPORA has a bias towards returning Diaspora information
344 * while PROBE_NORMAL has a bias towards dfrn/zot - in the case where
345 * an address (such as a Friendica address) supports more than one type
351 define ( 'PROBE_NORMAL', 0);
352 define ( 'PROBE_DIASPORA', 1);
354 function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
355 require_once('include/email.php');
362 $result = Cache::get("probe_url:".$mode.":".$url);
363 if (!is_null($result)) {
364 $result = unserialize($result);
374 $email_conversant = false;
375 $connectornetworks = false;
378 if (strpos($url,'twitter.com')) {
379 $connectornetworks = true;
380 $network = NETWORK_TWITTER;
383 $lastfm = ((strpos($url,'last.fm/user') !== false) ? true : false);
385 $at_addr = ((strpos($url,'@') !== false) ? true : false);
387 if((!$appnet) && (!$lastfm) && !$connectornetworks) {
389 if(strpos($url,'mailto:') !== false && $at_addr) {
390 $url = str_replace('mailto:','',$url);
399 logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA);
400 foreach($links as $link) {
401 if($link['@attributes']['rel'] === NAMESPACE_ZOT)
402 $zot = unamp($link['@attributes']['href']);
403 if($link['@attributes']['rel'] === NAMESPACE_DFRN)
404 $dfrn = unamp($link['@attributes']['href']);
405 if($link['@attributes']['rel'] === 'salmon')
406 $notify = unamp($link['@attributes']['href']);
407 if($link['@attributes']['rel'] === NAMESPACE_FEED)
408 $poll = unamp($link['@attributes']['href']);
409 if($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard')
410 $hcard = unamp($link['@attributes']['href']);
411 if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
412 $profile = unamp($link['@attributes']['href']);
413 if($link['@attributes']['rel'] === 'http://portablecontacts.net/spec/1.0')
414 $poco = unamp($link['@attributes']['href']);
415 if($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') {
416 $diaspora_base = unamp($link['@attributes']['href']);
419 if($link['@attributes']['rel'] === 'http://joindiaspora.com/guid') {
420 $diaspora_guid = unamp($link['@attributes']['href']);
423 if($link['@attributes']['rel'] === 'diaspora-public-key') {
424 $diaspora_key = base64_decode(unamp($link['@attributes']['href']));
425 if(strstr($diaspora_key,'RSA '))
426 $pubkey = rsatopem($diaspora_key);
428 $pubkey = $diaspora_key;
431 if(($link['@attributes']['rel'] === 'http://ostatus.org/schema/1.0/subscribe') AND ($mode == PROBE_NORMAL)) {
436 // Status.Net can have more than one profile URL. We need to match the profile URL
437 // to a contact on incoming messages to prevent spam, and we won't know which one
438 // to match. So in case of two, one of them is stored as an alias. Only store URL's
439 // and not webfinger user@host aliases. If they've got more than two non-email style
440 // aliases, let's hope we're lucky and get one that matches the feed author-uri because
441 // otherwise we're screwed.
443 foreach($links as $link) {
444 if($link['@attributes']['rel'] === 'alias') {
445 if(strpos($link['@attributes']['href'],'@') === false) {
446 if(isset($profile)) {
447 if($link['@attributes']['href'] !== $profile)
448 $alias = unamp($link['@attributes']['href']);
451 $profile = unamp($link['@attributes']['href']);
456 // If the profile is different from the url then the url is abviously an alias
457 if (($alias == "") AND ($profile != "") AND !$at_addr AND (normalise_link($profile) != normalise_link($url)))
460 elseif($mode == PROBE_NORMAL) {
465 if((strpos($orig_url,'@')) && validate_email($orig_url)) {
466 $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1",
469 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
472 if(count($x) && count($r)) {
473 $mailbox = construct_mailbox_name($r[0]);
475 openssl_private_decrypt(hex2bin($r[0]['pass']),$password,$x[0]['prvkey']);
476 $mbox = email_connect($mailbox,$r[0]['user'],$password);
478 logger('probe_url: email_connect failed.');
482 $msgs = email_poll($mbox,$orig_url);
483 logger('probe_url: searching ' . $orig_url . ', ' . count($msgs) . ' messages found.', LOGGER_DEBUG);
486 $network = NETWORK_MAIL;
487 $name = substr($url,0,strpos($url,'@'));
488 $phost = substr($url,strpos($url,'@')+1);
489 $profile = 'http://' . $phost;
490 // fix nick character range
491 $vcard = array('fn' => $name, 'nick' => $name, 'photo' => avatar_img($url));
492 $notify = 'smtp ' . random_string();
493 $poll = 'email ' . random_string();
495 $x = email_msg_meta($mbox,$msgs[0]);
496 if(stristr($x[0]->from,$orig_url))
497 $adr = imap_rfc822_parse_adrlist($x[0]->from,'');
498 elseif(stristr($x[0]->to,$orig_url))
499 $adr = imap_rfc822_parse_adrlist($x[0]->to,'');
501 foreach($adr as $feadr) {
502 if((strcasecmp($feadr->mailbox,$name) == 0)
503 &&(strcasecmp($feadr->host,$phost) == 0)
504 && (strlen($feadr->personal))) {
506 $personal = imap_mime_header_decode($feadr->personal);
508 foreach($personal as $perspart)
509 if ($perspart->charset != "default")
510 $vcard['fn'] .= iconv($perspart->charset, 'UTF-8//IGNORE', $perspart->text);
512 $vcard['fn'] .= $perspart->text;
514 $vcard['fn'] = notags($vcard['fn']);
525 if($mode == PROBE_NORMAL) {
528 $s = fetch_url($zot);
530 $j = json_decode($s);
532 $network = NETWORK_ZOT;
534 'fn' => $j->fullname,
535 'nick' => $j->nickname,
540 $pubkey = $j->pubkey;
548 $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn, true);
549 if(is_array($ret) && x($ret,'dfrn-request')) {
550 $network = NETWORK_DFRN;
551 $request = $ret['dfrn-request'];
552 $confirm = $ret['dfrn-confirm'];
553 $notify = $ret['dfrn-notify'];
554 $poll = $ret['dfrn-poll'];
557 $vcard['fn'] = $ret['fn'];
558 $vcard['nick'] = $ret['nick'];
559 $vcard['photo'] = $ret['photo'];
564 // Scrape the public key from the hcard.
565 // Diaspora will remove it from the webfinger somewhere in the future.
566 if (($hcard != "") AND ($pubkey == "")) {
567 $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn, true);
568 if (isset($ret["key"])) {
569 $hcard_key = $ret["key"];
570 if(strstr($hcard_key,'RSA '))
571 $pubkey = rsatopem($hcard_key);
573 $pubkey = $hcard_key;
576 if($diaspora && $diaspora_base && $diaspora_guid) {
577 $diaspora_notify = $diaspora_base.'receive/users/'.$diaspora_guid;
579 if($mode == PROBE_DIASPORA || ! $notify || ($notify == $diaspora_notify)) {
580 $notify = $diaspora_notify;
581 $batch = $diaspora_base . 'receive/public' ;
584 $addr = str_replace('acct:', '', $url);
587 if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
589 $network = NETWORK_DIASPORA;
590 elseif($has_lrdd AND ($notify))
591 $network = NETWORK_OSTATUS;
594 $addr = str_replace('acct:', '', $url);
598 if($hcard && ! $vcard) {
599 $vcard = scrape_vcard($hcard);
601 // Google doesn't use absolute url in profile photos
603 if((x($vcard,'photo')) && substr($vcard['photo'],0,1) == '/') {
604 $h = @parse_url($hcard);
606 $vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo'];
609 logger('probe_url: scrape_vcard: ' . print_r($vcard,true), LOGGER_DATA);
612 if($diaspora && $addr) {
613 // Diaspora returns the name as the nick. As the nick will never be updated,
614 // let's use the Diaspora nickname (the first part of the handle) as the nick instead
615 $addr_parts = explode('@', $addr);
616 $vcard['nick'] = $addr_parts[0];
621 $poll = str_replace(array('www.','last.fm/'),array('','ws.audioscrobbler.com/1.0/'),$url) . '/recenttracks.rss';
622 $vcard['nick'] = basename($url);
623 $vcard['fn'] = $vcard['nick'] . t(' on Last.fm');
624 $network = NETWORK_FEED;
629 $vcard['fn'] = $vcard['nick'];
633 if(stristr($url,'tumblr.com') && (! stristr($url,'/rss'))) {
634 $poll = $url . '/rss';
636 // Will leave it to others to figure out how to grab the avatar, which is on the $url page in the open graph meta links
639 if($appnet || ! $poll)
641 if((! isset($vcard)) || (! x($vcard,'fn')) || (! $profile))
643 if(($at_addr) && (! count($links)))
646 if ($connectornetworks)
651 $feedret = scrape_feed(($poll) ? $poll : $url);
653 logger('probe_url: scrape_feed ' . (($poll)? $poll : $url) . ' returns: ' . print_r($feedret,true), LOGGER_DATA);
654 if(count($feedret) && ($feedret['feed_atom'] || $feedret['feed_rss'])) {
655 $poll = ((x($feedret,'feed_atom')) ? unamp($feedret['feed_atom']) : unamp($feedret['feed_rss']));
660 if(x($feedret,'photo') && (! x($vcard,'photo')))
661 $vcard['photo'] = $feedret['photo'];
663 $cookiejar = tempnam(get_temppath(), 'cookiejar-scrape-feed-');
664 $xml = fetch_url($poll, false, $redirects, 0, Null, $cookiejar);
667 logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA);
670 logger("scrape_feed: XML is empty for feed ".$poll);
671 $network = NETWORK_PHANTOM;
673 $data = feed_import($xml,$dummy1,$dummy2, $dummy3, true);
675 if (!is_array($data)) {
676 logger("scrape_feed: This doesn't seem to be a feed: ".$poll);
677 $network = NETWORK_PHANTOM;
679 if (($vcard["photo"] == "") AND ($data["header"]["author-avatar"] != ""))
680 $vcard["photo"] = $data["header"]["author-avatar"];
682 if (($vcard["fn"] == "") AND ($data["header"]["author-name"] != ""))
683 $vcard["fn"] = $data["header"]["author-name"];
685 if (($vcard["nick"] == "") AND ($data["header"]["author-nick"] != ""))
686 $vcard["nick"] = $data["header"]["author-nick"];
688 if(!$profile AND ($data["header"]["author-link"] != "") AND !in_array($network, array("", NETWORK_FEED)))
689 $profile = $data["header"]["author-link"];
693 // Workaround for misconfigured Friendica servers
694 if (($network == "") AND (strstr($url, "/profile/"))) {
695 $noscrape = str_replace("/profile/", "/noscrape/", $url);
696 $noscrapejson = fetch_url($noscrape);
699 $network = NETWORK_DFRN;
701 $poco = str_replace("/profile/", "/poco/", $url);
703 $noscrapedata = json_decode($noscrapejson, true);
705 if (isset($noscrapedata["addr"]))
706 $addr = $noscrapedata["addr"];
708 if (isset($noscrapedata["fn"]))
709 $vcard["fn"] = $noscrapedata["fn"];
711 if (isset($noscrapedata["key"]))
712 $pubkey = $noscrapedata["key"];
714 if (isset($noscrapedata["photo"]))
715 $vcard["photo"] = $noscrapedata["photo"];
717 if (isset($noscrapedata["dfrn-request"]))
718 $request = $noscrapedata["dfrn-request"];
720 if (isset($noscrapedata["dfrn-confirm"]))
721 $confirm = $noscrapedata["dfrn-confirm"];
723 if (isset($noscrapedata["dfrn-notify"]))
724 $notify = $noscrapedata["dfrn-notify"];
726 if (isset($noscrapedata["dfrn-poll"]))
727 $poll = $noscrapedata["dfrn-poll"];
733 $network = NETWORK_FEED;
735 if(! x($vcard,'nick')) {
736 $vcard['nick'] = strtolower(notags(unxmlify($vcard['fn'])));
737 if(strpos($vcard['nick'],' '))
738 $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' ')));
745 if(! x($vcard,'photo')) {
747 $vcard['photo'] = App::get_baseurl() . '/images/person-175.jpg' ;
753 // No human could be associated with this link, use the URL as the contact name
755 if(($network === NETWORK_FEED) && ($poll) && (! x($vcard,'fn')))
758 if (($notify != "") AND ($poll != "")) {
759 $baseurl = matching_url(normalise_link($notify), normalise_link($poll));
761 $baseurl2 = matching_url($baseurl, normalise_link($profile));
763 $baseurl = $baseurl2;
766 if (($baseurl == "") AND ($notify != ""))
767 $baseurl = matching_url(normalise_link($profile), normalise_link($notify));
769 if (($baseurl == "") AND ($poll != ""))
770 $baseurl = matching_url(normalise_link($profile), normalise_link($poll));
772 $baseurl = rtrim($baseurl, "/");
774 if(strpos($url,'@') AND ($addr == "") AND ($network == NETWORK_DFRN))
775 $addr = str_replace('acct:', '', $url);
777 $vcard['fn'] = notags($vcard['fn']);
778 $vcard['nick'] = str_replace(' ','',notags($vcard['nick']));
780 $result['name'] = $vcard['fn'];
781 $result['nick'] = $vcard['nick'];
782 $result['url'] = $profile;
783 $result['addr'] = $addr;
784 $result['batch'] = $batch;
785 $result['notify'] = $notify;
786 $result['poll'] = $poll;
787 $result['request'] = $request;
788 $result['confirm'] = $confirm;
789 $result['poco'] = $poco;
790 $result['photo'] = $vcard['photo'];
791 $result['priority'] = $priority;
792 $result['network'] = $network;
793 $result['alias'] = $alias;
794 $result['pubkey'] = $pubkey;
795 $result['baseurl'] = $baseurl;
797 logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);
800 // Trying if it maybe a diaspora account
801 if (($result['network'] == NETWORK_FEED) OR ($result['addr'] == "")) {
802 require_once('include/bbcode.php');
803 $address = GetProfileUsername($url, "", true);
804 $result2 = probe_url($address, $mode, ++$level);
805 if ($result2['network'] != "")
809 // Maybe it's some non standard GNU Social installation (Single user, subfolder or no uri rewrite)
810 if (($result['network'] == NETWORK_FEED) AND ($result['baseurl'] != "") AND ($result['nick'] != "")) {
811 $addr = $result['nick'].'@'.str_replace("http://", "", $result['baseurl']);
812 $result2 = probe_url($addr, $mode, ++$level);
813 if (($result2['network'] != "") AND ($result2['network'] != NETWORK_FEED))
818 // Only store into the cache if the value seems to be valid
819 if ($result['network'] != NETWORK_PHANTOM)
820 Cache::set("probe_url:".$mode.":".$url,serialize($result), CACHE_DAY);
826 * @brief Find the matching part between two url
828 * @param string $url1
829 * @param string $url2
830 * @return string The matching part
832 function matching_url($url1, $url2) {
834 if (($url1 == "") OR ($url2 == ""))
837 $url1 = normalise_link($url1);
838 $url2 = normalise_link($url2);
840 $parts1 = parse_url($url1);
841 $parts2 = parse_url($url2);
843 if (!isset($parts1["host"]) OR !isset($parts2["host"]))
846 if ($parts1["scheme"] != $parts2["scheme"])
849 if ($parts1["host"] != $parts2["host"])
852 if ($parts1["port"] != $parts2["port"])
855 $match = $parts1["scheme"]."://".$parts1["host"];
858 $match .= ":".$parts1["port"];
860 $pathparts1 = explode("/", $parts1["path"]);
861 $pathparts2 = explode("/", $parts2["path"]);
866 $path1 = $pathparts1[$i];
867 $path2 = $pathparts2[$i];
869 if ($path1 == $path2)
872 } while (($path1 == $path2) AND ($i++ <= count($pathparts1)));
876 return normalise_link($match);