set_time_limit(0);
-define ( 'BUILD_ID', 1013 );
+define ( 'BUILD_ID', 1014 );
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
define ( 'EOL', "<br />\r\n" );
define ( 'NAMESPACE_TOMB' , 'http://purl.org/atompub/tombstones/1.0' );
define ( 'NAMESPACE_ACTIVITY', 'http://activitystrea.ms/spec/1.0/' );
define ( 'NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/' );
+define ( 'NAMESPACE_MEDIA', 'http://purl.org/syndication/atommedia' );
define ( 'NAMESPACE_SALMON_ME', 'http://salmon-protocol.org/ns/magic-env' );
define ( 'NAMESPACE_OSTATUSSUB', 'http://ostatus.org/schema/1.0/subscribe' );
define ( 'NAMESPACE_GEORSS', 'http://www.georss.org/georss' );
return ACTIVITY_POST;
}
-function construct_activity($item) {
+function construct_activity_object($item) {
if($item['object']) {
$o = '<as:object>' . "\r\n";
$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->link)
- $o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
+ if($r->link) {
+ if(substr($r->link,0,1) === '&')
+ $o .= unxmlify($r->link);
+ else
+ $o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
+ }
if($r->title)
$o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
if($r->content)
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->link) {
+ if(substr($r->link,0,1) === '&')
+ $o .= unxmlify($r->link);
+ else
+ $o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
+ }
+ if($r->title)
+ $o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
+ if($r->content)
+ $o .= '<content type="html" >' . xmlify(bbcode($r->content)) . '</content>' . "\r\n";
+ $o .= '</as:target>' . "\r\n";
+ return $o;
+ }
+
+ return '';
+}
+
}
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'][0]['attribs']['']['rel'] === 'alternate')
- $res['object'] .= '<link>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['href'] . '</link>' . "\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['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']) {
$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";
+ }
+
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($link['attribs'][NAMESPACE_MEDIA]['width'])
+ $o .= 'media:width="' . $link['attribs'][NAMESPACE_MEDIA]['width'] . '" ';
+ if($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'])
$verb = construct_verb($item);
$o .= '<as:verb>' . xmlify($verb) . '</as:verb>' . "\r\n";
- $actobj = construct_activity($item);
+ $actobj = construct_activity_object($item);
if(strlen($actobj))
$o .= $actobj;
+ $actarg = construct_activity_target($item);
+ if(strlen($actarg))
+ $o .= $actarg;
$mentioned = get_mentions($item);
if($mentioned)
if($x !== '@' && $x !== '#')
$rawtags = '#' . $rawtags;
+ $taginfo = array();
$tags = get_tags($rawtags);
if(count($tags)) {
if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
$profile = $link['@attributes']['href'];
if($link['@attributes']['rel'] === 'salmon') {
+ $salmon = '$url:' . str_replace(',','%sc',$link['@attributes']['href']);
if(strlen($inform))
$inform .= ',';
- $inform .= 'url:' . str_replace(',','%2c',$link['@attributes']['href']);
+ $inform .= $salmon;
}
}
}
+ $taginfo[] = array($newname,$profile,$salmon);
}
else {
$newname = $name;
}
if(count($r)) {
$profile = $r[0]['url'];
+ $notify = 'cid:' . $r[0]['id'];
if(strlen($inform))
$inform .= ',';
- $inform .= 'cid:' . $r[0]['id'];
+ $inform .= $notify;
}
}
if($profile) {
+ $taginfo[] = array($newname,$profile,$notify);
if(strlen($str_tags))
$str_tags .= ',';
$profile = str_replace(',','%2c',$profile);
intval($item_id),
intval(local_user())
);
+
+ if(count($taginfo)) {
+ foreach($taginfo as $tagged) {
+// $slap = create_photo_tag(local_user(),$item_id, $tagged);
+
+
+//
+ }
+ // call notifier on new tag activity
+ }
+
+// $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
+
+// $proc_debug = get_config('system','proc_debug');
+
+ // send the notification upstream/downstream as the case may be
+
+// if($i[0]['visible'])
+// proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" $proc_debug & ",
+// array(),$foo));
+
+
+
}
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
return; // NOTREACHED
}
-
+ // default post action - upload a photo
if(! x($_FILES,'userfile'))
killme();