$ret = scrape_dfrn($dfrn);
if(is_array($ret) && x($ret,'dfrn-request')) {
if(strlen($a->path))
- $myaddr = urlencode($a->get_baseurl() . '/profile/' . $a->user['nickname']);
+ $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
else
- $myaddr = urlencode($a->user['nickname'] . '@' . $a->get_hostname());
+ $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
- goaway($ret['dfrn-request'] . "&address=$myaddr");
+ goaway($ret['dfrn-request'] . "&addr=$myaddr");
// NOTREACHED
}
}
+ $network = 'stat';
+
if($hcard) {
$vcard = scrape_vcard($hcard);
+
+ // Google doesn't use absolute url in profile photos
+
+ if((x($vcard,'photo')) && substr($vcard['photo'],0,1) == '/') {
+ $h = parse_url($hcard);
+ if($h)
+ $vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo'];
+ }
}
if(! $profile)
$profile = $url;
- // do we have enough information?
if(! x($vcard,'fn'))
if(x($vcard,'nick'))
$vcard['fn'] = $vcard['nick'];
- if(! ((x($vcard['fn'])) && ($poll) && ($notify) && ($profile))) {
+ if((! isset($vcard)) && (! $poll)) {
+
+ $ret = scrape_feed($url);
+
+ if(count($ret) && $ret['feed_atom']) {
+ $poll = $ret['feed_atom'];
+ $vcard = array();
+ require_once('simplepie/simplepie.inc');
+ $feed = new SimplePie();
+ $xml = fetch_url($poll);
+
+ $feed->set_raw_data($xml);
+
+ $feed->init();
+
+ $vcard['photo'] = $feed->get_image_url();
+ $author = $feed->get_author();
+ if($author) {
+ $vcard['fn'] = trim($author->get_name());
+ $vcard['nick'] = strtolower($vcard['fn']);
+ if(strpos($vcard['nick'],' '))
+ $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' ')));
+ $email = $author->get_email();
+ }
+ else {
+ $item = $feed->get_item(0);
+ if($item) {
+ $author = $item->get_author();
+ if($author) {
+ $vcard['fn'] = trim($author->get_name());
+ $vcard['nick'] = strtolower($vcard['fn']);
+ if(strpos($vcard['nick'],' '))
+ $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' ')));
+ $email = $author->get_email();
+ }
+ }
+ }
+ if((! $vcard['photo']) && strlen($email))
+ $vcard['photo'] = gravatar_img($email);
+ $network = 'feed';
+ }
+ }
+
+ logger('follow: poll=' . $poll . ' notify=' . $notify . ' profile=' . $profile . ' vcard=' . print_r($vcard,true));
+
+
+ // do we have enough information?
+
+ if(! ((x($vcard['fn'])) && ($poll) && ($profile))) {
notice( t('The profile address specified does not provide adequate information.') . EOL);
goaway($_SESSION['return_url']);
- }
+ }
+
+ if(! $notify) {
+ notice( t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL);
+ }
if(! x($vcard,'photo'))
$vcard['photo'] = $a->get_baseurl() . '/images/default-profile.jpg' ;
// check if we already have a contact
+ // the poll url is more reliable than the profile url, as we may have
+ // indirect links or webfinger links
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` = '%s' LIMIT 1",
intval(local_user()),
dbesc($poll)
);
- if($r) {
+
+ if(count($r)) {
// update contact
if($r[0]['rel'] == REL_VIP) {
- q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ q("UPDATE `contact` SET `rel` = %d , `readonly` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval(REL_BUD),
intval($r[0]['id']),
intval(local_user())
dbesc($vcard['fn']),
dbesc($vcard['nick']),
dbesc($vcard['photo']),
- dbesc('stat'),
+ dbesc($network),
intval(REL_FAN)
);
}
+
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
dbesc($profile),
intval(local_user())
);
+
if(! count($r)) {
notice( t('Unable to retrieve contact information.') . EOL);
goaway($_SESSION['return_url']);
require_once("Photo.php");
- $photo_failure = false;
-
- $filename = basename($vcard['photo']);
- $img_str = fetch_url($vcard['photo'],true);
- $img = new Photo($img_str);
- if($img->is_valid()) {
-
- $img->scaleImageSquare(175);
-
- $hash = photo_new_resource();
-
- $r = $img->store(local_user(), $contact_id, $hash, $filename, t('Contact Photos'), 4 );
-
- if($r === false)
- $photo_failure = true;
-
- $img->scaleImage(80);
-
- $r = $img->store(local_user(), $contact_id, $hash, $filename, t('Contact Photos'), 5 );
-
- if($r === false)
- $photo_failure = true;
-
- $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg';
- $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg';
- }
- else
- $photo_failure = true;
-
- if($photo_failure) {
- $photo = $a->get_baseurl() . '/images/default-profile.jpg';
- $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg';
- }
+ $photos = import_profile_photo($vcard['photo'],local_user(),$contact_id);
$r = q("UPDATE `contact` SET `photo` = '%s',
- `thumb` = '%s',
+ `thumb` = '%s',
+ `micro` = '%s',
`name-date` = '%s',
`uri-date` = '%s',
`avatar-date` = '%s'
WHERE `id` = %d LIMIT 1
",
- dbesc($photo),
- dbesc($thumb),
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
// pull feed and consume it, which should subscribe to the hub.
+ $php_path = ((x($a->config,'php_path') && strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
+ proc_close(proc_open("\"$php_path\" \"include/poller.php\" \"$contact_id\" &", array(), $foo));
+
// create a follow slap
'$type' => 'text',
'$content' => t('following'),
'$nick' => $a->user['nickname'],
- '$verb' => ACTIVITY_FOLLOW
+ '$verb' => ACTIVITY_FOLLOW,
+ '$ostat_follow' => ''
));
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
intval(local_user())
);
- require_once('include/salmon.php');
- slapper($r[0],$contact,$slap);
+
+ if((count($r)) && (x($contact,'notify')) && (strlen($contact['notify']))) {
+ require_once('include/salmon.php');
+ slapper($r[0],$contact['notify'],$slap);
+ }
goaway($_SESSION['return_url']);
// NOTREACHED