|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('bbcode.php');
|
|
|
|
|
|
|
|
function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) {
|
|
|
|
|
|
|
|
|
|
|
|
// default permissions - anonymous user
|
|
|
|
|
|
|
|
$sql_extra = "
|
|
|
|
AND `allow_cid` = ''
|
|
|
|
AND `allow_gid` = ''
|
|
|
|
AND `deny_cid` = ''
|
|
|
|
AND `deny_gid` = ''
|
|
|
|
";
|
|
|
|
|
|
|
|
if(strlen($owner_id) && ! intval($owner_id)) {
|
|
|
|
$r = q("SELECT `uid`, `nickname` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
|
|
|
|
dbesc($owner_id)
|
|
|
|
);
|
|
|
|
if(count($r)) {
|
|
|
|
$owner_id = $r[0]['uid'];
|
|
|
|
$owner_nick = $r[0]['nickname'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
|
|
|
intval($owner_id)
|
|
|
|
);
|
|
|
|
if(count($r)) {
|
|
|
|
$owner = $r[0];
|
|
|
|
$owner['nickname'] = $owner_nick;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
killme();
|
|
|
|
|
|
|
|
if($dfrn_id && $dfrn_id != '*') {
|
|
|
|
|
|
|
|
$sql_extra = '';
|
|
|
|
switch($direction) {
|
|
|
|
case (-1):
|
|
|
|
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
|
|
|
|
$my_id = $dfrn_id;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
|
|
|
|
$my_id = '1:' . $dfrn_id;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
|
|
|
|
$my_id = '0:' . $dfrn_id;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break; // NOTREACHED
|
|
|
|
}
|
|
|
|
|
|
|
|
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `contact`.`uid` = %d $sql_extra LIMIT 1",
|
|
|
|
intval($owner_id)
|
|
|
|
);
|
|
|
|
|
|
|
|
if(! count($r))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
$contact = $r[0];
|
|
|
|
$groups = init_groups_visitor($contact['id']);
|
|
|
|
|
|
|
|
if(count($groups)) {
|
|
|
|
for($x = 0; $x < count($groups); $x ++)
|
|
|
|
$groups[$x] = '<' . intval($groups[$x]) . '>' ;
|
|
|
|
$gs = implode('|', $groups);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$gs = '<<>>' ; // Impossible to match
|
|
|
|
|
|
|
|
$sql_extra = sprintf("
|
|
|
|
AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
|
|
|
|
AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
|
|
|
|
AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
|
|
|
|
AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s')
|
|
|
|
",
|
|
|
|
intval($contact['id']),
|
|
|
|
intval($contact['id']),
|
|
|
|
dbesc($gs),
|
|
|
|
dbesc($gs)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($dfrn_id === '' || $dfrn_id === '*')
|
|
|
|
$sort = 'DESC';
|
|
|
|
else
|
|
|
|
$sort = 'ASC';
|
|
|
|
|
|
|
|
if(! strlen($last_update))
|
|
|
|
$last_update = 'now -30 days';
|
|
|
|
|
|
|
|
$check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
|
|
|
|
|
|
|
|
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
|
|
|
`contact`.`name`, `contact`.`photo`, `contact`.`url`,
|
|
|
|
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
|
|
|
|
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
|
|
|
`contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`
|
|
|
|
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
|
|
|
WHERE `item`.`uid` = %d AND `item`.`visible` = 1
|
|
|
|
AND `item`.`wall` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
|
|
|
AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
|
|
|
|
$sql_extra
|
|
|
|
ORDER BY `parent` %s, `created` ASC LIMIT 0, 300",
|
|
|
|
intval($owner_id),
|
|
|
|
dbesc($check_date),
|
|
|
|
dbesc($check_date),
|
|
|
|
dbesc($sort)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Will check further below if this actually returned results.
|
|
|
|
// We will provide an empty feed in any case.
|
|
|
|
|
|
|
|
$items = $r;
|
|
|
|
|
|
|
|
$feed_template = load_view_file('view/atom_feed.tpl');
|
|
|
|
|
|
|
|
$atom = '';
|
|
|
|
|
|
|
|
$hub = get_config('system','huburl');
|
|
|
|
|
|
|
|
$hubxml = '';
|
|
|
|
if(strlen($hub)) {
|
|
|
|
$hubs = explode(',', $hub);
|
|
|
|
if(count($hubs)) {
|
|
|
|
foreach($hubs as $h) {
|
|
|
|
$h = trim($h);
|
|
|
|
if(! strlen($h))
|
|
|
|
continue;
|
|
|
|
$hubxml .= '<link rel="hub" href="' . xmlify($h) . '" />' . "\n" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$salmon = '<link rel="salmon" href="' . xmlify($a->get_baseurl() . '/salmon/' . $owner_nick) . '" />' . "\n" ;
|
|
|
|
$salmon .= '<link rel="http://salmon-protocol.org/ns/salmon-replies" href="' . xmlify($a->get_baseurl() . '/salmon/' . $owner_nick) . '" />' . "\n" ;
|
|
|
|
$salmon .= '<link rel="http://salmon-protocol.org/ns/salmon-mention" href="' . xmlify($a->get_baseurl() . '/salmon/' . $owner_nick) . '" />' . "\n" ;
|
|
|
|
|
|
|
|
|
|
|
|
$atom .= replace_macros($feed_template, array(
|
|
|
|
'$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner_nick),
|
|
|
|
'$feed_title' => xmlify($owner['name']),
|
|
|
|
'$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now' , ATOM_TIME)) ,
|
|
|
|
'$hub' => $hubxml,
|
|
|
|
'$salmon' => $salmon,
|
|
|
|
'$name' => xmlify($owner['name']),
|
|
|
|
'$profile_page' => xmlify($owner['url']),
|
|
|
|
'$photo' => xmlify($owner['photo']),
|
|
|
|
'$thumb' => xmlify($owner['thumb']),
|
|
|
|
'$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
|
|
|
|
'$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) ,
|
|
|
|
'$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME))
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
call_hooks('atom_feed', $atom);
|
|
|
|
|
|
|
|
if(! count($items)) {
|
|
|
|
|
|
|
|
call_hooks('atom_feed_end', $atom);
|
|
|
|
|
|
|
|
$atom .= '</feed>' . "\r\n";
|
|
|
|
return $atom;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($items as $item) {
|
|
|
|
|
|
|
|
// public feeds get html, our own nodes use bbcode
|
|
|
|
|
|
|
|
if($dfrn_id === '*') {
|
|
|
|
$type = 'html';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$type = 'text';
|
|
|
|
}
|
|
|
|
|
|
|
|
$atom .= atom_entry($item,$type,null,$owner,true);
|
|
|
|
}
|
|
|
|
|
|
|
|
call_hooks('atom_feed_end', $atom);
|
|
|
|
|
|
|
|
$atom .= '</feed>' . "\r\n";
|
|
|
|
return $atom;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function construct_verb($item) {
|
|
|
|
if($item['verb'])
|
|
|
|
return $item['verb'];
|
|
|
|
return ACTIVITY_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
function construct_activity_object($item) {
|
|
|
|
|
|
|
|
if($item['object']) {
|
|
|
|
$o = '<as:object>' . "\r\n";
|
|
|
|
$r = @simplexml_load_string($item['object']);
|
|
|
|
if($r->type)
|
|
|
|
$o .= '<as:object-type>' . xmlify($r->type) . '</as:object-type>' . "\r\n";
|
|
|
|
if($r->id)
|
|
|
|
$o .= '<id>' . xmlify($r->id) . '</id>' . "\r\n";
|
|
|
|
if($r->title)
|
|
|
|
$o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
|
|
|
|
if($r->link) {
|
|
|
|
if(substr($r->link,0,1) === '<')
|
|
|
|
$o .= $r->link;
|
|
|
|
else
|
|
|
|
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
|
|
|
|
}
|
|
|
|
if($r->content)
|
|
|
|
$o .= '<content type="html" >' . xmlify(bbcode($r->content)) . '</content>' . "\r\n";
|
|
|
|
$o .= '</as:object>' . "\r\n";
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
function construct_activity_target($item) {
|
|
|
|
|
|
|
|
if($item['target']) {
|
|
|
|
$o = '<as:target>' . "\r\n";
|
|
|
|
$r = @simplexml_load_string($item['target']);
|
|
|
|
if($r->type)
|
|
|
|
$o .= '<as:object-type>' . xmlify($r->type) . '</as:object-type>' . "\r\n";
|
|
|
|
if($r->id)
|
|
|
|
$o .= '<id>' . xmlify($r->id) . '</id>' . "\r\n";
|
|
|
|
if($r->title)
|
|
|
|
$o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
|
|
|
|
if($r->link) {
|
|
|
|
if(substr($r->link,0,1) === '<')
|
|
|
|
$o .= $r->link;
|
|
|
|
else
|
|
|
|
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
|
|
|
|
}
|
|
|
|
if($r->content)
|
|
|
|
$o .= '<content type="html" >' . xmlify(bbcode($r->content)) . '</content>' . "\r\n";
|
|
|
|
$o .= '</as:target>' . "\r\n";
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_atom_elements($feed,$item) {
|
|
|
|
|
|
|
|
require_once('library/HTMLPurifier.auto.php');
|
|
|
|
require_once('include/html2bbcode.php');
|
|
|
|
|
|
|
|
$best_photo = array();
|
|
|
|
|
|
|
|
$res = array();
|
|
|
|
|
|
|
|
$author = $item->get_author();
|
|
|
|
$res['author-name'] = unxmlify($author->get_name());
|
|
|
|
$res['author-link'] = unxmlify($author->get_link());
|
|
|
|
$res['uri'] = unxmlify($item->get_id());
|
|
|
|
$res['title'] = unxmlify($item->get_title());
|
|
|
|
$res['body'] = unxmlify($item->get_content());
|
|
|
|
|
|
|
|
|
|
|
|
// look for a photo. We should check media size and find the best one,
|
|
|
|
// but for now let's just find any author photo
|
|
|
|
|
|
|
|
$rawauthor = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'author');
|
|
|
|
|
|
|
|
if($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) {
|
|
|
|
$base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
|
|
|
|
foreach($base as $link) {
|
|
|
|
if(! $res['author-avatar']) {
|
|
|
|
if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar')
|
|
|
|
$res['author-avatar'] = unxmlify($link['attribs']['']['href']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$rawactor = $item->get_item_tags(NAMESPACE_ACTIVITY, 'actor');
|
|
|
|
|
|
|
|
if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'],ACTIVITY_OBJ_PERSON)) {
|
|
|
|
$base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
|
|
|
|
if($base && count($base)) {
|
|
|
|
foreach($base as $link) {
|
|
|
|
if($link['attribs']['']['rel'] === 'alternate' && (! $res['author-link']))
|
|
|
|
$res['author-link'] = unxmlify($link['attribs']['']['href']);
|
|
|
|
if(! $res['author-avatar']) {
|
|
|
|
if($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo')
|
|
|
|
$res['author-avatar'] = unxmlify($link['attribs']['']['href']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No photo/profile-link on the item - look at the feed level
|
|
|
|
|
|
|
|
if((! (x($res,'author-link'))) || (! (x($res,'author-avatar')))) {
|
|
|
|
$rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'author');
|
|
|
|
if($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) {
|
|
|
|
$base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
|
|
|
|
foreach($base as $link) {
|
|
|
|
if($link['attribs']['']['rel'] === 'alternate' && (! $res['author-link']))
|
|
|
|
$res['author-link'] = unxmlify($link['attribs']['']['href']);
|
|
|
|
if(! $res['author-avatar']) {
|
|
|
|
if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar')
|
|
|
|
$res['author-avatar'] = unxmlify($link['attribs']['']['href']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$rawactor = $feed->get_feed_tags(NAMESPACE_ACTIVITY, 'subject');
|
|
|
|
|
|
|
|
if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'],ACTIVITY_OBJ_PERSON)) {
|
|
|
|
$base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
|
|
|
|
|
|
|
|
if($base && count($base)) {
|
|
|
|
foreach($base as $link) {
|
|
|
|
if($link['attribs']['']['rel'] === 'alternate' && (! $res['author-link']))
|
|
|
|
$res['author-link'] = unxmlify($link['attribs']['']['href']);
|
|
|
|
if(! (x($res,'author-avatar'))) {
|
|
|
|
if($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo')
|
|
|
|
$res['author-avatar'] = unxmlify($link['attribs']['']['href']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$maxlen = get_max_import_size();
|
|
|
|
if($maxlen && (strlen($res['body']) > $maxlen))
|
|
|
|
$res['body'] = substr($res['body'],0, $maxlen);
|
|
|
|
|
|
|
|
// It isn't certain at this point whether our content is plaintext or html and we'd be foolish to trust
|
|
|
|
// the content type. Our own network only emits text normally, though it might have been converted to
|
|
|
|
// html if we used a pubsubhubbub transport. But if we see even one html open tag in our text, we will
|
|
|
|
// have to assume it is all html and needs to be purified.
|
|
|
|
|
|
|
|
// It doesn't matter all that much security wise - because before this content is used anywhere, we are
|
|
|
|
// going to escape any tags we find regardless, but this lets us import a limited subset of html from
|
|
|
|
// the wild, by sanitising it and converting supported tags to bbcode before we rip out any remaining
|
|
|
|
// html.
|
|
|
|
|
|
|
|
|
|
|
|
if(strpos($res['body'],'<')) {
|
|
|
|
|
|
|
|
$res['body'] = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
|
|
|
|
'[youtube]$1[/youtube]', $res['body']);
|
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
$config->set('Cache.DefinitionImpl', null);
|
|
|
|
|
|
|
|
// we shouldn't need a whitelist, because the bbcode converter
|
|
|
|
// will strip out any unsupported tags.
|
|
|
|
// $config->set('HTML.Allowed', 'p,b,a[href],i');
|
|
|
|
|
|
|
|
$purifier = new HTMLPurifier($config);
|
|
|
|
$res['body'] = $purifier->purify($res['body']);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$res['body'] = html2bbcode($res['body']);
|
|
|
|
|
|
|
|
|
|
|
|
$allow = $item->get_item_tags(NAMESPACE_DFRN,'comment-allow');
|
|
|
|
if($allow && $allow[0]['data'] == 1)
|
|
|
|
$res['last-child'] = 1;
|
|
|
|
else
|
|
|
|
$res['last-child'] = 0;
|
|
|
|
|
|
|
|
$private = $item->get_item_tags(NAMESPACE_DFRN,'private');
|
|
|
|
if($private && $private[0]['data'] == 1)
|
|
|
|
$res['private'] = 1;
|
|
|
|
else
|
|
|
|
$res['private'] = 0;
|
|
|
|
|
|
|
|
$rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published');
|
|
|
|
if($rawcreated)
|
|
|
|
$res['created'] = unxmlify($rawcreated[0]['data']);
|
|
|
|
|
|
|
|
$rawlocation = $item->get_item_tags(NAMESPACE_DFRN, 'location');
|
|
|
|
if($rawlocation)
|
|
|
|
$res['location'] = unxmlify($rawlocation[0]['data']);
|
|
|
|
|
|
|
|
|
|
|
|
$rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'updated');
|
|
|
|
if($rawedited)
|
|
|
|
$res['edited'] = unxmlify($rawcreated[0]['data']);
|
|
|
|
|
|
|
|
$rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner');
|
|
|
|
if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])
|
|
|
|
$res['owner-name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']);
|
|
|
|
elseif($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data'])
|
|
|
|
$res['owner-name'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']);
|
|
|
|
if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])
|
|
|
|
$res['owner-link'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']);
|
|
|
|
elseif($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data'])
|
|
|
|
$res['owner-link'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']);
|
|
|
|
|
|
|
|
if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) {
|
|
|
|
$base = $rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
|
|
|
|
|
|
|
|
foreach($base as $link) {
|
|
|
|
if(! $res['owner-avatar']) {
|
|
|
|
if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar')
|
|
|
|
$res['owner-avatar'] = unxmlify($link['attribs']['']['href']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$rawgeo = $item->get_item_tags(NAMESPACE_GEORSS,'point');
|
|
|
|
if($rawgeo)
|
|
|
|
$res['coord'] = unxmlify($rawgeo[0]['data']);
|
|
|
|
|
|
|
|
|
|
|
|
$rawverb = $item->get_item_tags(NAMESPACE_ACTIVITY, 'verb');
|
|
|
|
// select between supported verbs
|
|
|
|
if($rawverb)
|
|
|
|
$res['verb'] = unxmlify($rawverb[0]['data']);
|
|
|
|
|
|
|
|
$rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object');
|
|
|
|
|
|
|
|
if($rawobj) {
|
|
|
|
$res['object'] = '<object>' . "\n";
|
|
|
|
if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
|
|
|
|
$res['object-type'] = $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'];
|
|
|
|
$res['object'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
|
|
|
|
}
|
|
|
|
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
|
|
|
|
$res['object'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
|
|
|
|
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
|
|
|
|
$res['object'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
|
|
|
|
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
|
|
|
|
$res['object'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
|
|
|
|
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
|
|
|
|
$body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
|
|
|
|
if(! $body)
|
|
|
|
$body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
|
|
|
|
if(strpos($body,'<')) {
|
|
|
|
|
|
|
|
$body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
|
|
|
|
'[youtube]$1[/youtube]', $body);
|
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
$config->set('Cache.DefinitionImpl', null);
|
|
|
|
|
|
|
|
$purifier = new HTMLPurifier($config);
|
|
|
|
$body = $purifier->purify($body);
|
|
|
|
}
|
|
|
|
|
|
|
|
$body = html2bbcode($body);
|
|
|
|
$res['object'] .= '<content>' . $body . '</content>' . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$res['object'] .= '</object>' . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'target');
|
|
|
|
|
|
|
|
if($rawobj) {
|
|
|
|
$res['target'] = '<target>' . "\n";
|
|
|
|
if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
|
|
|
|
$res['target'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
|
|
|
|
}
|
|
|
|
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
|
|
|
|
$res['target'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
|
|
|
|
|
|
|
|
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
|
|
|
|
$res['target'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
|
|
|
|
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
|
|
|
|
$res['target'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
|
|
|
|
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
|
|
|
|
$body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
|
|
|
|
if(! $body)
|
|
|
|
$body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
|
|
|
|
if(strpos($body,'<')) {
|
|
|
|
|
|
|
|
$body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
|
|
|
|
'[youtube]$1[/youtube]', $body);
|
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
$config->set('Cache.DefinitionImpl', null);
|
|
|
|
|
|
|
|
$purifier = new HTMLPurifier($config);
|
|
|
|
$body = $purifier->purify($body);
|
|
|
|
}
|
|
|
|
|
|
|
|
$body = html2bbcode($body);
|
|
|
|
$res['target'] .= '<content>' . $body . '</content>' . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$res['target'] .= '</target>' . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
call_hooks('parse_atom', array('feed' => $feed, 'item' => $item, 'result' => $res));
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
function encode_rel_links($links) {
|
|
|
|
$o = '';
|
|
|
|
if(! ((is_array($links)) && (count($links))))
|
|
|
|
return $o;
|
|
|
|
foreach($links as $link) {
|
|
|
|
$o .= '<link ';
|
|
|
|
if($link['attribs']['']['rel'])
|
|
|
|
$o .= 'rel="' . $link['attribs']['']['rel'] . '" ';
|
|
|
|
if($link['attribs']['']['type'])
|
|
|
|
$o .= 'type="' . $link['attribs']['']['type'] . '" ';
|
|
|
|
if($link['attribs']['']['href'])
|
|
|
|
$o .= 'type="' . $link['attribs']['']['href'] . '" ';
|
|
|
|
if( (x($link['attribs'],NAMESPACE_MEDIA)) && $link['attribs'][NAMESPACE_MEDIA]['width'])
|
|
|
|
$o .= 'media:width="' . $link['attribs'][NAMESPACE_MEDIA]['width'] . '" ';
|
|
|
|
if( (x($link['attribs'],NAMESPACE_MEDIA)) && $link['attribs'][NAMESPACE_MEDIA]['height'])
|
|
|
|
$o .= 'media:height="' . $link['attribs'][NAMESPACE_MEDIA]['height'] . '" ';
|
|
|
|
$o .= ' />' . "\n" ;
|
|
|
|
}
|
|
|
|
return xmlify($o);
|
|
|
|
}
|
|
|
|
|
|
|
|
function item_store($arr) {
|
|
|
|
|
|
|
|
if($arr['gravity'])
|
|
|
|
$arr['gravity'] = intval($arr['gravity']);
|
|
|
|
elseif($arr['parent-uri'] == $arr['uri'])
|
|
|
|
$arr['gravity'] = 0;
|
|
|
|
elseif(activity_match($arr['verb'],ACTIVITY_POST))
|
|
|
|
$arr['gravity'] = 6;
|
|
|
|
else
|
|
|
|
$arr['gravity'] = 6; // extensible catchall
|
|
|
|
|
|
|
|
if(! x($arr,'type'))
|
|
|
|
$arr['type'] = 'remote';
|
|
|
|
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
|
|
|
|
$arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string());
|
|
|
|
$arr['author-name'] = ((x($arr,'author-name')) ? notags(trim($arr['author-name'])) : '');
|
|
|
|
$arr['author-link'] = ((x($arr,'author-link')) ? notags(trim($arr['author-link'])) : '');
|
|
|
|
$arr['author-avatar'] = ((x($arr,'author-avatar')) ? notags(trim($arr['author-avatar'])) : '');
|
|
|
|
$arr['owner-name'] = ((x($arr,'owner-name')) ? notags(trim($arr['owner-name'])) : '');
|
|
|
|
$arr['owner-link'] = ((x($arr,'owner-link')) ? notags(trim($arr['owner-link'])) : '');
|
|
|
|
$arr['owner-avatar'] = ((x($arr,'owner-avatar')) ? notags(trim($arr['owner-avatar'])) : '');
|
|
|
|
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
|
|
|
|
$arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert());
|
|
|
|
$arr['changed'] = datetime_convert();
|
|
|
|
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
|
|
|
|
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : '');
|
|
|
|
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : '');
|
|
|
|
$arr['last-child'] = ((x($arr,'last-child')) ? intval($arr['last-child']) : 0 );
|
|
|
|
$arr['visible'] = ((x($arr,'visible') !== false) ? intval($arr['visible']) : 1 );
|
|
|
|
$arr['deleted'] = 0;
|
|
|
|
$arr['parent-uri'] = ((x($arr,'parent-uri')) ? notags(trim($arr['parent-uri'])) : '');
|
|
|
|
$arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : '');
|
|
|
|
$arr['object-type'] = ((x($arr,'object-type')) ? notags(trim($arr['object-type'])) : '');
|
|
|
|
$arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : '');
|
|
|
|
$arr['target-type'] = ((x($arr,'target-type')) ? notags(trim($arr['target-type'])) : '');
|
|
|
|
$arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : '');
|
|
|
|
$arr['allow_cid'] = ((x($arr,'allow_cid')) ? trim($arr['allow_cid']) : '');
|
|
|
|
$arr['allow_gid'] = ((x($arr,'allow_gid')) ? trim($arr['allow_gid']) : '');
|
|
|
|
$arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : '');
|
|
|
|
$arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : '');
|
|
|
|
$arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0 );
|
|
|
|
$arr['body'] = ((x($arr,'body')) ? escape_tags(trim($arr['body'])) : '');
|
|
|
|
|
|
|
|
// The content body has been through a lot of filtering and transport escaping by now.
|
|
|
|
// We don't want to skip any filters, however a side effect of all this filtering
|
|
|
|
// is that ampersands and <> may have been double encoded, depending on which filter chain
|
|
|
|
// they came through.
|
|
|
|
|
|
|
|
$arr['body'] = str_replace(
|
|
|
|
array('&amp;','&gt;','&lt;'),
|
|
|
|
array('&' ,'>' ,'<'),
|
|
|
|
$arr['body']
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($arr['parent-uri'] === $arr['uri']) {
|
|
|
|
$parent_id = 0;
|
|
|
|
$allow_cid = $arr['allow_cid'];
|
|
|
|
$allow_gid = $arr['allow_gid'];
|
|
|
|
$deny_cid = $arr['deny_cid'];
|
|
|
|
$deny_gid = $arr['deny_gid'];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
// find the parent and snarf the item id and ACL's
|
|
|
|
|
|
|
|
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
|
|
|
dbesc($arr['parent-uri']),
|
|
|
|
intval($arr['uid'])
|
|
|
|
);
|
|
|
|
|
|
|
|
if(count($r)) {
|
|
|
|
|
|
|
|
// is the new message multi-level threaded?
|
|
|
|
// even though we don't support it now, preserve the info
|
|
|
|
// and re-attach to the conversation parent.
|
|
|
|
|
|
|
|
if($r[0]['uri'] != $r[0]['parent-uri']) {
|
|
|
|
$arr['thr-parent'] = $arr['parent-uri'];
|
|
|
|
$arr['parent-uri'] = $r[0]['parent-uri'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$parent_id = $r[0]['id'];
|
|
|
|
$allow_cid = $r[0]['allow_cid'];
|
|
|
|
$allow_gid = $r[0]['allow_gid'];
|
|
|
|
$deny_cid = $r[0]['deny_cid'];
|
|
|
|
$deny_gid = $r[0]['deny_gid'];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
logger('item_store: item parent was not found - ignoring item');
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
call_hooks('post_remote',$arr);
|
|
|
|
|
|
|
|
dbesc_array($arr);
|
|
|
|
|
|
|
|
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
|
|
|
|
|
|
|
|
$r = dbq("INSERT INTO `item` (`"
|
|
|
|
. implode("`, `", array_keys($arr))
|
|
|
|
. "`) VALUES ('"
|
|
|
|
. implode("', '", array_values($arr))
|
|
|
|
. "')" );
|
|
|
|
|
|
|
|
// find the item we just created
|
|
|
|
|
|
|
|
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
|
|
|
$arr['uri'], // already dbesc'd
|
|
|
|
intval($arr['uid'])
|
|
|
|
);
|
|
|
|
if(count($r)) {
|
|
|
|
$current_post = $r[0]['id'];
|
|
|
|
logger('item_store: created item ' . $current_post);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
logger('item_store: could not locate created item');
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($arr['parent-uri'] === $arr['uri'])
|
|
|
|
$parent_id = $current_post;
|
|
|
|
|
|
|
|
if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid))
|
|
|
|
$private = 1;
|
|
|
|
else
|
|
|
|
$private = $arr['private'];
|
|
|
|
|
|
|
|
// Set parent id - and also make sure to inherit the parent's ACL's.
|
|
|
|
|
|
|
|
$r = q("UPDATE `item` SET `parent` = %d, `allow_cid` = '%s', `allow_gid` = '%s',
|
|
|
|
`deny_cid` = '%s', `deny_gid` = '%s', `private` = %d WHERE `id` = %d LIMIT 1",
|
|
|
|
intval($parent_id),
|
|
|
|
dbesc($allow_cid),
|
|
|
|
dbesc($allow_gid),
|
|
|
|
dbesc($deny_cid),
|
|
|
|
dbesc($deny_gid),
|
|
|
|
intval($private),
|
|
|
|
intval($current_post)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $current_post;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_item_contact($item,$contacts) {
|
|
|
|
if(! count($contacts) || (! is_array($item)))
|
|
|
|
return false;
|
|
|
|
foreach($contacts as $contact) {
|
|
|
|
if($contact['id'] == $item['contact-id']) {
|
|
|
|
return $contact;
|
|
|
|
break; // NOTREACHED
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function dfrn_deliver($owner,$contact,$atom) {
|
|
|
|
|
|
|
|
$a = get_app();
|
|
|
|
|
|
|
|
if((! strlen($contact['dfrn-id'])) && (! $contact['duplex']) && (! ($owner['page-flags'] == PAGE_COMMUNITY)))
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
|
|
|
|
|
|
|
|
if($contact['duplex'] && $contact['dfrn-id'])
|
|
|
|
$idtosend = '0:' . $orig_id;
|
|
|
|
if($contact['duplex'] && $contact['issued-id'])
|
|
|
|
$idtosend = '1:' . $orig_id;
|
|
|
|
|
|
|
|
$rino = ((function_exists('mcrypt_encrypt')) ? 1 : 0);
|
|
|
|
|
|
|
|
$rino_enable = get_config('system','rino_encrypt');
|
|
|
|
|
|
|
|
if(! $rino_enable)
|
|
|
|
$rino = 0;
|
|
|
|
|
|
|
|
$url = $contact['notify'] . '?dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : '');
|
|
|
|
|
|
|
|
logger('dfrn_deliver: ' . $url);
|
|
|
|
|
|
|
|
$xml = fetch_url($url);
|
|
|
|
|
|
|
|
$curl_stat = $a->get_curl_code();
|
|
|
|
if(! $curl_stat)
|
|
|
|
return(-1); // timed out
|
|
|
|
|
|
|
|
logger('dfrn_deliver: ' . $xml);
|
|
|
|
|
|
|
|
if(! $xml)
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
$res = simplexml_load_string($xml);
|
|
|
|
|
|
|
|
if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id)))
|
|
|
|
return (($res->status) ? $res->status : 3);
|
|
|
|
|
|
|
|
$postvars = array();
|
|
|
|
$sent_dfrn_id = hex2bin($res->dfrn_id);
|
|
|
|
$challenge = hex2bin($res->challenge);
|
|
|
|
$rino_allowed = ((intval($res->rino) === 1) ? 1 : 0);
|
|
|
|
|
|
|
|
$final_dfrn_id = '';
|
|
|
|
|
|
|
|
|
|
|
|
if(($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
|
|
|
|
openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
|
|
|
|
openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']);
|
|
|
|
openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
|
|
|
|
|
|
|
|
if(strpos($final_dfrn_id,':') == 1)
|
|
|
|
$final_dfrn_id = substr($final_dfrn_id,2);
|
|
|
|
|
|
|
|
if($final_dfrn_id != $orig_id) {
|
|
|
|
logger('dfrn_deliver: wrong dfrn_id.');
|
|
|
|
// did not decode properly - cannot trust this site
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
$postvars['dfrn_id'] = $idtosend;
|
|
|
|
$postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION;
|
|
|
|
|
|
|
|
if(($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked']) && (! $contact['readonly'])) {
|
|
|
|
$postvars['data'] = $atom;
|
|
|
|
}
|
|
|
|
elseif($owner['page-flags'] == PAGE_COMMUNITY) {
|
|
|
|
$postvars['data'] = $atom;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$postvars['data'] = str_replace('<dfrn:comment-allow>1','<dfrn:comment-allow>0',$atom);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($rino && $rino_allowed) {
|
|
|
|
$key = substr(random_string(),0,16);
|
|
|
|
$data = bin2hex(aes_encrypt($postvars['data'],$key));
|
|
|
|
$postvars['data'] = $data;
|
|
|
|
logger('rino: sent key = ' . $key);
|
|
|
|
|
|
|
|
if(($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
|
|
|
|
openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']);
|
|
|
|
}
|
|
|
|
|
|
|
|
logger('md5 rawkey ' . md5($postvars['key']));
|
|
|
|
|
|
|
|
$postvars['key'] = bin2hex($postvars['key']);
|
|
|
|
}
|
|
|
|
|
|
|
|
logger('dfrn_deliver: ' . "SENDING: " . print_r($postvars,true), LOGGER_DATA);
|
|
|
|
|
|
|
|
$xml = post_url($contact['notify'],$postvars);
|
|
|
|
|
|
|
|
logger('dfrn_deliver: ' . "RECEIVED: " . $xml, LOGGER_DATA);
|
|
|
|
|
|
|
|
$curl_stat = $a->get_curl_code();
|
|
|
|
if((! $curl_stat) || (! strlen($xml)))
|
|
|
|
return(-1); // timed out
|
|
|
|
|
|
|
|
$res = simplexml_load_string($xml);
|
|
|
|
|
|
|
|
return $res->status;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* consume_feed - process atom feed and update anything/everything we might need to update
|
|
|
|
*
|
|
|
|
* $xml = the (atom) feed to consume - no RSS spoken here, it might partially work since simplepie
|
|
|
|
* handles both, but we don't claim it will work well, and are reasonably certain it won't.
|
|
|
|
* $importer = the contact_record (joined to user_record) of the local user who owns this relationship.
|
|
|
|
* It is this person's stuff that is going to be updated.
|
|
|
|
* $contact = the person who is sending us stuff. If not set, we MAY be processing a "follow" activity
|
|
|
|
* from an external network and MAY create an appropriate contact record. Otherwise, we MUST
|
|
|
|
* have a contact record.
|
|
|
|
* $hub = should we find a hub declation in the feed, pass it back to our calling process, who might (or
|
|
|
|
* might not) try and subscribe to it.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
function consume_feed($xml,$importer,$contact, &$hub, $datedir = 0) {
|
|
|
|
|
|
|
|
require_once('simplepie/simplepie.inc');
|
|
|
|
|
|
|
|
$feed = new SimplePie();
|
|
|
|
$feed->set_raw_data($xml);
|
|
|
|
if($datedir)
|
|
|
|
$feed->enable_order_by_date(true);
|
|
|
|
else
|
|
|
|
$feed->enable_order_by_date(false);
|
|
|
|
$feed->init();
|
|
|
|
|
|
|
|
// Check at the feed level for updated contact name and/or photo
|
|
|
|
|
|
|
|
$name_updated = '';
|
|
|
|
$new_name = '';
|
|
|
|
$photo_timestamp = '';
|
|
|
|
$photo_url = '';
|
|
|
|
|
|
|
|
|
|
|
|
$hubs = $feed->get_links('hub');
|
|
|
|
|
|
|
|
if(count($hubs))
|
|
|
|
$hub = implode(',', $hubs);
|
|
|
|
|
|
|
|
$rawtags = $feed->get_feed_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
|
|
|
|
if($rawtags) {
|
|
|
|
$elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
|
|
|
|
if($elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated']) {
|
|
|
|