]> git.mxchange.org Git - friendica.git/blob - include/Scrape.php
fix typo
[friendica.git] / include / Scrape.php
1 <?php
2
3 require_once('library/HTML5/Parser.php');
4 require_once('include/crypto.php');
5
6 if(! function_exists('scrape_dfrn')) {
7 function scrape_dfrn($url) {
8
9         $a = get_app();
10
11         $ret = array();
12
13         logger('scrape_dfrn: url=' . $url);
14
15         $s = fetch_url($url);
16
17         if(! $s) 
18                 return $ret;
19
20         $headers = $a->get_curl_headers();
21         logger('scrape_dfrn: headers=' . $headers, LOGGER_DEBUG);
22
23
24         $lines = explode("\n",$headers);
25         if(count($lines)) {
26                 foreach($lines as $line) {                              
27                         // don't try and run feeds through the html5 parser
28                         if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml'))))
29                                 return ret;
30                 }
31         }
32
33
34         $dom = HTML5_Parser::parse($s);
35
36         if(! $dom)
37                 return $ret;
38
39         $items = $dom->getElementsByTagName('link');
40
41         // get DFRN link elements
42
43         foreach($items as $item) {
44                 $x = $item->getAttribute('rel');
45                 if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml'))
46                         $ret['feed_atom'] = $item->getAttribute('href');
47                 if(substr($x,0,5) == "dfrn-") {
48                         $ret[$x] = $item->getAttribute('href');
49                 }
50                 if($x === 'lrdd') {
51                         $decoded = urldecode($item->getAttribute('href'));
52                         if(preg_match('/acct:([^@]*)@/',$decoded,$matches))
53                                 $ret['nick'] = $matches[1];
54                 }
55         }
56
57         // Pull out hCard profile elements
58
59         $largest_photo = 0;
60
61         $items = $dom->getElementsByTagName('*');
62         foreach($items as $item) {
63                 if(attribute_contains($item->getAttribute('class'), 'vcard')) {
64                         $level2 = $item->getElementsByTagName('*');
65                         foreach($level2 as $x) {
66                                 if(attribute_contains($x->getAttribute('class'),'fn')) {
67                                         $ret['fn'] = $x->textContent;
68                                 }
69                                 if((attribute_contains($x->getAttribute('class'),'photo'))
70                                         || (attribute_contains($x->getAttribute('class'),'avatar'))) {
71                                         $size = intval($x->getAttribute('width'));
72                                         // dfrn prefers 175, so if we find this, we set largest_size so it can't be topped.
73                                         if(($size > $largest_photo) || ($size == 175) || (! $largest_photo)) {
74                                                 $ret['photo'] = $x->getAttribute('src');
75                                                 $largest_photo = (($size == 175) ? 9999 : $size);
76                                         }
77                                 }
78                                 if(attribute_contains($x->getAttribute('class'),'key')) {
79                                         $ret['key'] = $x->textContent;
80                                 }
81                         }
82                 }
83         }
84
85         return $ret;
86 }}
87
88
89
90
91
92
93 if(! function_exists('validate_dfrn')) {
94 function validate_dfrn($a) {
95         $errors = 0;
96         if(! x($a,'key'))
97                 $errors ++;
98         if(! x($a,'dfrn-request'))
99                 $errors ++;
100         if(! x($a,'dfrn-confirm'))
101                 $errors ++;
102         if(! x($a,'dfrn-notify'))
103                 $errors ++;
104         if(! x($a,'dfrn-poll'))
105                 $errors ++;
106         return $errors;
107 }}
108
109 if(! function_exists('scrape_meta')) {
110 function scrape_meta($url) {
111
112         $a = get_app();
113
114         $ret = array();
115
116         logger('scrape_meta: url=' . $url);
117
118         $s = fetch_url($url);
119
120         if(! $s) 
121                 return $ret;
122
123         $headers = $a->get_curl_headers();
124         logger('scrape_meta: headers=' . $headers, LOGGER_DEBUG);
125
126         $lines = explode("\n",$headers);
127         if(count($lines)) {
128                 foreach($lines as $line) {                              
129                         // don't try and run feeds through the html5 parser
130                         if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml'))))
131                                 return ret;
132                 }
133         }
134
135
136
137         $dom = HTML5_Parser::parse($s);
138
139         if(! $dom)
140                 return $ret;
141
142         $items = $dom->getElementsByTagName('meta');
143
144         // get DFRN link elements
145
146         foreach($items as $item) {
147                 $x = $item->getAttribute('name');
148                 if(substr($x,0,5) == "dfrn-")
149                         $ret[$x] = $item->getAttribute('content');
150         }
151
152         return $ret;
153 }}
154
155
156 if(! function_exists('scrape_vcard')) {
157 function scrape_vcard($url) {
158
159         $a = get_app();
160
161         $ret = array();
162
163         logger('scrape_vcard: url=' . $url);
164
165         $s = fetch_url($url);
166
167         if(! $s) 
168                 return $ret;
169
170         $headers = $a->get_curl_headers();
171         $lines = explode("\n",$headers);
172         if(count($lines)) {
173                 foreach($lines as $line) {                              
174                         // don't try and run feeds through the html5 parser
175                         if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml'))))
176                                 return ret;
177                 }
178         }
179
180         $dom = HTML5_Parser::parse($s);
181
182         if(! $dom)
183                 return $ret;
184
185         // Pull out hCard profile elements
186
187         $largest_photo = 0;
188
189         $items = $dom->getElementsByTagName('*');
190         foreach($items as $item) {
191                 if(attribute_contains($item->getAttribute('class'), 'vcard')) {
192                         $level2 = $item->getElementsByTagName('*');
193                         foreach($level2 as $x) {
194                                 if(attribute_contains($x->getAttribute('class'),'fn'))
195                                         $ret['fn'] = $x->textContent;
196                                 if((attribute_contains($x->getAttribute('class'),'photo'))
197                                         || (attribute_contains($x->getAttribute('class'),'avatar'))) {
198                                         $size = intval($x->getAttribute('width'));
199                                         if(($size > $largest_photo) || (! $largest_photo)) {
200                                                 $ret['photo'] = $x->getAttribute('src');
201                                                 $largest_photo = $size;
202                                         }
203                                 }
204                                 if((attribute_contains($x->getAttribute('class'),'nickname'))
205                                         || (attribute_contains($x->getAttribute('class'),'uid'))) {
206                                         $ret['nick'] = $x->textContent;
207                                 }
208                         }
209                 }
210         }
211
212         return $ret;
213 }}
214
215
216 if(! function_exists('scrape_feed')) {
217 function scrape_feed($url) {
218
219         $a = get_app();
220
221         $ret = array();
222         $s = fetch_url($url);
223
224         if(! $s) 
225                 return $ret;
226
227         $headers = $a->get_curl_headers();
228         logger('scrape_feed: headers=' . $headers, LOGGER_DEBUG);
229
230         $lines = explode("\n",$headers);
231         if(count($lines)) {
232                 foreach($lines as $line) {                              
233                         if(stristr($line,'content-type:')) {
234                                 if(stristr($line,'application/atom+xml') || stristr($s,'<feed')) {
235                                         $ret['feed_atom'] = $url;
236                                         return $ret;
237                                 }
238                                 if(stristr($line,'application/rss+xml') || stristr($s,'<rss')) {
239                                         $ret['feed_rss'] = $url;
240                                         return $ret;
241                                 }
242                         }
243                 }
244         }
245
246         $dom = HTML5_Parser::parse($s);
247
248         if(! $dom)
249                 return $ret;
250
251
252         $head = $dom->getElementsByTagName('base');
253         if($head) {
254                 foreach($head as $head0) {
255                         $basename = $head0->getAttribute('href');
256                         break;
257                 }
258         }
259         if(! $basename)
260                 $basename = substr($url,0,strrpos($url,'/')) . '/';
261
262         $items = $dom->getElementsByTagName('link');
263
264         // get Atom/RSS link elements, take the first one of either.
265
266         if($items) {
267                 foreach($items as $item) {
268                         $x = $item->getAttribute('rel');
269                         if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml')) {
270                                 if(! x($ret,'feed_atom'))
271                                         $ret['feed_atom'] = $item->getAttribute('href');
272                         }
273                         if(($x === 'alternate') && ($item->getAttribute('type') === 'application/rss+xml')) {
274                                 if(! x($ret,'feed_rss'))
275                                         $ret['feed_rss'] = $item->getAttribute('href');
276                         }
277                 }       
278         }
279
280         // Drupal and perhaps others only provide relative URL's. Turn them into absolute.
281
282         if(x($ret,'feed_atom') && (! strstr($ret['feed_atom'],'://')))
283                 $ret['feed_atom'] = $basename . $ret['feed_atom'];
284         if(x($ret,'feed_rss') && (! strstr($ret['feed_rss'],'://')))
285                 $ret['feed_rss'] = $basename . $ret['feed_rss'];
286
287         return $ret;
288 }}
289
290
291 /**
292  *
293  * Probe a network address to discover what kind of protocols we need to communicate with it.
294  *
295  * Warning: this function is a bit touchy and there are some subtle dependencies within the logic flow.
296  * Edit with care.
297  *
298  */
299
300 /**
301  *
302  * PROBE_DIASPORA has a bias towards returning Diaspora information
303  * while PROBE_NORMAL has a bias towards dfrn/zot - in the case where
304  * an address (such as a Friendika address) supports more than one type
305  * of network. 
306  *
307  */
308
309
310 define ( 'PROBE_NORMAL',   0);
311 define ( 'PROBE_DIASPORA', 1);
312
313 function probe_url($url, $mode = PROBE_NORMAL) {
314         require_once('include/email.php');
315
316         $result = array();
317
318         if(! $url)
319                 return $result;
320
321         $network = null;
322         $diaspora = false;
323         $diaspora_base = '';
324         $diaspora_guid = '';    
325         $diaspora_key = '';
326         $has_lrdd = false;
327         $email_conversant = false;
328
329         $twitter = ((strpos($url,'twitter.com') !== false) ? true : false);
330
331         $at_addr = ((strpos($url,'@') !== false) ? true : false);
332
333         if(! $twitter) {
334
335                 if(strpos($url,'mailto:') !== false && $at_addr) {
336                         $url = str_replace('mailto:','',$url);
337                         $links = array();
338                 }
339                 else
340                         $links = lrdd($url);
341
342                 if(count($links)) {
343                         $has_lrdd = true;
344
345                         logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA);
346                         foreach($links as $link) {
347                                 if($link['@attributes']['rel'] === NAMESPACE_ZOT)
348                                         $zot = unamp($link['@attributes']['href']);
349                                 if($link['@attributes']['rel'] === NAMESPACE_DFRN)
350                                         $dfrn = unamp($link['@attributes']['href']);
351                                 if($link['@attributes']['rel'] === 'salmon')
352                                         $notify = unamp($link['@attributes']['href']);
353                                 if($link['@attributes']['rel'] === NAMESPACE_FEED)
354                                         $poll = unamp($link['@attributes']['href']);
355                                 if($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard')
356                                         $hcard = unamp($link['@attributes']['href']);
357                                 if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
358                                         $profile = unamp($link['@attributes']['href']);
359                                 if($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') {
360                                         $diaspora_base = unamp($link['@attributes']['href']);
361                                         $diaspora = true;
362                                 }
363                                 if($link['@attributes']['rel'] === 'http://joindiaspora.com/guid') {
364                                         $diaspora_guid = unamp($link['@attributes']['href']);
365                                         $diaspora = true;
366                                 }
367                                 if($link['@attributes']['rel'] === 'diaspora-public-key') {
368                                         $diaspora_key = base64_decode(unamp($link['@attributes']['href']));
369                                         $pubkey = rsatopem($diaspora_key);
370                                         $diaspora = true;
371                                 }
372                         }
373
374                         // Status.Net can have more than one profile URL. We need to match the profile URL
375                         // to a contact on incoming messages to prevent spam, and we won't know which one
376                         // to match. So in case of two, one of them is stored as an alias. Only store URL's
377                         // and not webfinger user@host aliases. If they've got more than two non-email style
378                         // aliases, let's hope we're lucky and get one that matches the feed author-uri because 
379                         // otherwise we're screwed.
380
381                         foreach($links as $link) {
382                                 if($link['@attributes']['rel'] === 'alias') {
383                                         if(strpos($link['@attributes']['href'],'@') === false) {
384                                                 if(isset($profile)) {
385                                                         if($link['@attributes']['href'] !== $profile)
386                                                                 $alias = unamp($link['@attributes']['href']);
387                                                 }
388                                                 else
389                                                         $profile = unamp($link['@attributes']['href']);
390                                         }
391                                 }
392                         }
393                 }
394                 elseif($mode == PROBE_NORMAL) {
395
396                         // Check email
397
398                         $orig_url = $url;
399                         if((strpos($orig_url,'@')) && validate_email($orig_url)) {
400                                 $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1",
401                                         intval(local_user())
402                                 );
403                                 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
404                                         intval(local_user())
405                                 );
406                                 if(count($x) && count($r)) {
407                                     $mailbox = construct_mailbox_name($r[0]);
408                                         $password = '';
409                                         openssl_private_decrypt(hex2bin($r[0]['pass']),$password,$x[0]['prvkey']);
410                                         $mbox = email_connect($mailbox,$r[0]['user'],$password);
411                                         unset($password);
412                                 }
413                                 if($mbox) {
414                                         $msgs = email_poll($mbox,$orig_url);
415                                         if(count($msgs)) {
416                                                 $addr = $orig_url;
417                                                 $network = NETWORK_MAIL;
418                                                 $name = substr($url,0,strpos($url,'@'));
419                                                 $phost = substr($url,strpos($url,'@')+1);
420                                                 $profile = 'http://' . $phost;
421                                                 // fix nick character range
422                                                 $vcard = array('fn' => $name, 'nick' => $name, 'photo' => gravatar_img($url));
423                                                 $notify = 'smtp ' . random_string();
424                                                 $poll = 'email ' . random_string();
425                                                 $priority = 0;
426                                                 $x = email_msg_meta($mbox,$msgs[0]);
427                                                 if(stristr($x->from,$orig_url))
428                                                         $adr = imap_rfc822_parse_adrlist($x->from,'');
429                                                 elseif(stristr($x->to,$orig_url))
430                                                         $adr = imap_rfc822_parse_adrlist($x->to,'');
431                                                 if(isset($adr)) {
432                                                         foreach($adr as $feadr) {
433                                                                 if((strcasecmp($feadr->mailbox,$name) == 0) 
434                                                                         &&(strcasecmp($feadr->host,$phost) == 0) 
435                                                                         && (strlen($feadr->personal))) {
436                                                                         $vcard['fn'] = notags($feadr->personal);
437                                                                 }
438                                                         }
439                                                 }
440                                         }
441                                         imap_close($mbox);
442                                 }
443                         }
444                 }
445         }       
446
447         if($mode == PROBE_NORMAL) {
448                 if(strlen($zot)) {
449                         $s = fetch_url($zot);
450                         if($s) {
451                                 $j = json_decode($s);
452                                 if($j) {
453                                         $network = NETWORK_ZOT;
454                                         $vcard   = array(
455                                                 'fn'    => $j->fullname, 
456                                                 'nick'  => $j->nickname, 
457                                                 'photo' => $j->photo
458                                         );
459                                         $profile  = $j->url;
460                                         $notify   = $j->post;
461                                         $pubkey   = $j->pubkey;
462                                         $poll     = 'N/A';
463                                 }
464                         }
465                 }
466
467                 if(strlen($dfrn)) {
468                         $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn);
469                         if(is_array($ret) && x($ret,'dfrn-request')) {
470                                 $network = NETWORK_DFRN;
471                                 $request = $ret['dfrn-request'];
472                                 $confirm = $ret['dfrn-confirm'];
473                                 $notify  = $ret['dfrn-notify'];
474                                 $poll    = $ret['dfrn-poll'];
475
476                                 $vcard = array();
477                                 $vcard['fn'] = $ret['fn'];
478                                 $vcard['nick'] = $ret['nick'];
479                                 $vcard['photo'] = $ret['photo'];
480                         }
481                 }
482         }
483
484         if($diaspora && $diaspora_base && $diaspora_guid) {
485                 if($mode == PROBE_DIASPORA || ! $notify) {
486                         $notify = $diaspora_base . 'receive/users/' . $diaspora_guid;
487                         $batch  = $diaspora_base . 'receive/public' ;
488                 }
489                 if(strpos($url,'@'))
490                         $addr = str_replace('acct:', '', $url);
491         }                       
492
493         if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
494                 if($diaspora)
495                         $network = NETWORK_DIASPORA;
496                 elseif($has_lrdd)
497                         $network  = NETWORK_OSTATUS;
498                 $priority = 0;
499
500                 if($hcard && ! $vcard) {
501                         $vcard = scrape_vcard($hcard);
502
503                         // Google doesn't use absolute url in profile photos
504         
505                         if((x($vcard,'photo')) && substr($vcard['photo'],0,1) == '/') {
506                                 $h = @parse_url($hcard);
507                                 if($h)
508                                         $vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo'];
509                         }
510                 
511                         logger('probe_url: scrape_vcard: ' . print_r($vcard,true), LOGGER_DATA);
512                 }
513
514                 if($twitter) {          
515                         logger('twitter: setup');
516                         $tid = basename($url);
517                         $tapi = 'https://api.twitter.com/1/statuses/user_timeline.rss';
518                         if(intval($tid))
519                                 $poll = $tapi . '?user_id=' . $tid;
520                         else
521                                 $poll = $tapi . '?screen_name=' . $tid;
522                         $profile = 'http://twitter.com/#!/' . $tid;
523                         $vcard['photo'] = 'https://api.twitter.com/1/users/profile_image/' . $tid;
524                         $vcard['nick'] = $tid;
525                         $vcard['fn'] = $tid . '@twitter';
526                 }
527
528                 if(! x($vcard,'fn'))
529                         if(x($vcard,'nick'))
530                                 $vcard['fn'] = $vcard['nick'];
531
532                 $check_feed = false;
533
534                 if($twitter || ! $poll)
535                         $check_feed = true;
536                 if((! isset($vcard)) || (! x($vcard,'fn')) || (! $profile))
537                         $check_feed = true;
538                 if(($at_addr) && (! count($links)))
539                         $check_feed = false;
540
541                 if($check_feed) {
542
543                         $feedret = scrape_feed(($poll) ? $poll : $url);
544                         logger('probe_url: scrape_feed returns: ' . print_r($feedret,true), LOGGER_DATA);
545                         if(count($feedret) && ($feedret['feed_atom'] || $feedret['feed_rss'])) {
546                                 $poll = ((x($feedret,'feed_atom')) ? unamp($feedret['feed_atom']) : unamp($feedret['feed_rss']));
547                                 if(! x($vcard)) 
548                                         $vcard = array();
549                         }
550
551                         if(x($feedret,'photo') && (! x($vcard,'photo')))
552                                 $vcard['photo'] = $feedret['photo'];
553                         require_once('library/simplepie/simplepie.inc');
554                     $feed = new SimplePie();
555                         $xml = fetch_url($poll);
556
557                         logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA);
558                         $a = get_app();
559
560                         logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), $LOGGER_DATA);
561
562                         $feed->set_raw_data($xml);
563
564                     $feed->init();
565                         if($feed->error())
566                                 logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error());
567
568
569                         if(! x($vcard,'photo'))
570                                 $vcard['photo'] = $feed->get_image_url();
571                         $author = $feed->get_author();
572
573                         if($author) {                   
574                                 $vcard['fn'] = unxmlify(trim($author->get_name()));
575                                 if(! $vcard['fn'])
576                                         $vcard['fn'] = trim(unxmlify($author->get_email()));
577                                 if(strpos($vcard['fn'],'@') !== false)
578                                         $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@'));
579                                 $email = unxmlify($author->get_email());
580                                 if(! $profile && $author->get_link())
581                                         $profile = trim(unxmlify($author->get_link()));
582                                 if(! $vcard['photo']) {
583                                         $rawtags = $feed->get_feed_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
584                                 if($rawtags) {
585                                                 $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
586                                                 if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo'))
587                                                         $vcard['photo'] = $elems['link'][0]['attribs']['']['href'];
588                                 }
589                                 }
590                         }
591                         else {
592                                 $item = $feed->get_item(0);
593                                 if($item) {
594                                         $author = $item->get_author();
595                                         if($author) {                   
596                                                 $vcard['fn'] = trim(unxmlify($author->get_name()));
597                                                 if(! $vcard['fn'])
598                                                         $vcard['fn'] = trim(unxmlify($author->get_email()));
599                                                 if(strpos($vcard['fn'],'@') !== false)
600                                                         $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@'));
601                                                 $email = unxmlify($author->get_email());
602                                                 if(! $profile && $author->get_link())
603                                                         $profile = trim(unxmlify($author->get_link()));
604                                         }
605                                         if(! $vcard['photo']) {
606                                                 $rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/','thumbnail');
607                                                 if($rawmedia && $rawmedia[0]['attribs']['']['url'])
608                                                         $vcard['photo'] = unxmlify($rawmedia[0]['attribs']['']['url']);
609                                         }
610                                         if(! $vcard['photo']) {
611                                                 $rawtags = $item->get_item_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
612                                         if($rawtags) {
613                                                         $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
614                                                         if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo'))
615                                                                 $vcard['photo'] = $elems['link'][0]['attribs']['']['href'];
616                                         }
617                                         }
618                                 }
619                         }
620
621                         if((! $vcard['photo']) && strlen($email))
622                                 $vcard['photo'] = gravatar_img($email);
623                         if($poll === $profile)
624                                 $lnk = $feed->get_permalink();
625                         if(isset($lnk) && strlen($lnk))
626                                 $profile = $lnk;        
627
628                         if(! (x($vcard,'fn')))
629                                 $vcard['fn'] = notags($feed->get_title());
630                         if(! (x($vcard,'fn')))
631                                 $vcard['fn'] = notags($feed->get_description());
632
633                         if(strpos($vcard['fn'],'Twitter / ') !== false) {
634                                 $vcard['fn'] = substr($vcard['fn'],strpos($vcard['fn'],'/')+1);
635                                 $vcard['fn'] = trim($vcard['fn']);
636                         }
637                         if(! x($vcard,'nick')) {
638                                 $vcard['nick'] = strtolower(notags(unxmlify($vcard['fn'])));
639                                 if(strpos($vcard['nick'],' '))
640                                         $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' ')));
641                         }
642                         if(! $network)
643                                 $network = NETWORK_FEED;
644                         if(! $priority)
645                                 $priority = 2;
646                 }
647         }
648
649         if(! x($vcard,'photo')) {
650                 $a = get_app();
651                 $vcard['photo'] = $a->get_baseurl() . '/images/default-profile.jpg' ; 
652         }
653
654         if(! $profile)
655                 $profile = $url;
656
657         // No human could be associated with this link, use the URL as the contact name
658
659         if(($network === NETWORK_FEED) && ($poll) && (! x($vcard,'fn')))
660                 $vcard['fn'] = $url;
661
662         $vcard['fn'] = notags($vcard['fn']);
663         $vcard['nick'] = str_replace(' ','',notags($vcard['nick']));
664                 
665         $result['name'] = $vcard['fn'];
666         $result['nick'] = $vcard['nick'];
667         $result['url'] = $profile;
668         $result['addr'] = $addr;
669         $result['batch'] = $batch;
670         $result['notify'] = $notify;
671         $result['poll'] = $poll;
672         $result['request'] = $request;
673         $result['confirm'] = $confirm;
674         $result['photo'] = $vcard['photo'];
675         $result['priority'] = $priority;
676         $result['network'] = $network;
677         $result['alias'] = $alias;
678         $result['pubkey'] = $pubkey;
679
680         logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);
681
682         return $result;
683 }