use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
require_once 'include/items.php';
require_once 'mod/share.php';
require_once 'include/enotify.php';
require_once 'include/items.php';
require_once 'mod/share.php';
require_once 'include/enotify.php';
*/
private static function fetchAuthor($xpath, $context, $importer, &$contact, $onlyfetch)
{
*/
private static function fetchAuthor($xpath, $context, $importer, &$contact, $onlyfetch)
{
$author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
$author["author-name"] = $xpath->evaluate('atom:author/atom:name/text()', $context)->item(0)->nodeValue;
$addr = $xpath->evaluate('atom:author/atom:email/text()', $context)->item(0)->nodeValue;
$author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
$author["author-name"] = $xpath->evaluate('atom:author/atom:name/text()', $context)->item(0)->nodeValue;
$addr = $xpath->evaluate('atom:author/atom:email/text()', $context)->item(0)->nodeValue;
- $condition = array("`uid` = ? AND `alias` = ? AND `network` != ?",
- $importer["uid"], $aliaslink, NETWORK_STATUSNET);
- $r = dba::select('contact', array(), $condition, array('limit' => 1));
-
- if (DBM::is_result($r)) {
- $found = true;
- if ($r['blocked']) {
- $r['id'] = -1;
- }
- $contact = $r;
- $author["contact-id"] = $r["id"];
- }
+ $condition = ["`uid` = ? AND `alias` = ? AND `network` != ?",
+ $importer["uid"], $aliaslink, NETWORK_STATUSNET];
+ $contact = dba::selectFirst('contact', [], $condition);
- $condition = array("`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
- normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET);
- $r = dba::select('contact', array(), $condition, array('limit' => 1));
-
- if (DBM::is_result($r)) {
- $found = true;
- if ($r['blocked']) {
- $r['id'] = -1;
- }
- $contact = $r;
- $author["contact-id"] = $r["id"];
- }
+ $condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
+ normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET];
+ $contact = dba::selectFirst('contact', [], $condition);
- if (!$found && ($addr != "")) {
- $condition = array("`uid` = ? AND `addr` = ? AND `network` != ?",
- $importer["uid"], $addr, NETWORK_STATUSNET);
- $r = dba::select('contact', array(), $condition, array('limit' => 1));
+ if (!DBM::is_result($contact) && ($addr != '')) {
+ $condition = ["`uid` = ? AND `addr` = ? AND `network` != ?",
+ $importer["uid"], $addr, NETWORK_STATUSNET];
+ $contact = dba::selectFirst('contact', [], $condition);
+ }
$avatars = $xpath->query("atom:author/atom:link[@rel='avatar']", $context);
foreach ($avatars as $avatar) {
$href = "";
$avatars = $xpath->query("atom:author/atom:link[@rel='avatar']", $context);
foreach ($avatars as $avatar) {
$href = "";
$author["owner-avatar"] = $author["author-avatar"];
// Only update the contacts if it is an OStatus contact
$author["owner-avatar"] = $author["author-avatar"];
// Only update the contacts if it is an OStatus contact
- dba::update('contact', $contact, array('id' => $contact["id"]), $current);
+ dba::update('contact', $contact, ['id' => $contact["id"]], $current);
if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
- $fields = array('url', 'nurl', 'name', 'nick', 'alias', 'about', 'location');
- $old_contact = dba::select('contact', $fields, array('id' => $cid), array('limit' => 1));
+ $fields = ['url', 'nurl', 'name', 'nick', 'alias', 'about', 'location'];
+ $old_contact = dba::selectFirst('contact', $fields, ['id' => $cid]);
'nurl' => normalise_link($author["author-link"]),
'nick' => $contact["nick"], 'alias' => $contact["alias"],
'about' => $contact["about"], 'location' => $contact["location"],
'nurl' => normalise_link($author["author-link"]),
'nick' => $contact["nick"], 'alias' => $contact["alias"],
'about' => $contact["about"], 'location' => $contact["location"],
- dba::update('contact', $fields, array('id' => $cid), $old_contact);
+ dba::update('contact', $fields, ['id' => $cid], $old_contact);
foreach ($element->attributes as $attributes) {
$attribute[$attributes->name] = $attributes->textContent;
foreach ($element->attributes as $attributes) {
$attribute[$attributes->name] = $attributes->textContent;
private static function process($xml, $importer, &$contact, &$hub, $stored = false, $initialize = true)
{
if ($initialize) {
private static function process($xml, $importer, &$contact, &$hub, $stored = false, $initialize = true)
{
if ($initialize) {
$header["uid"] = $importer["uid"];
$header["network"] = NETWORK_OSTATUS;
$header["type"] = "remote";
$header["uid"] = $importer["uid"];
$header["network"] = NETWORK_OSTATUS;
$header["type"] = "remote";
- if (in_array($item["verb"], array('qvitter-delete-notice', ACTIVITY_DELETE, 'delete'))) {
+ if (in_array($item["verb"], ['qvitter-delete-notice', ACTIVITY_DELETE, 'delete'])) {
// Ignore "Unfavorite" message
logger("Ignore unfavorite message ".print_r($item, true), LOGGER_DEBUG);
continue;
}
// Deletions come with the same uri, so we check for duplicates after processing deletions
// Ignore "Unfavorite" message
logger("Ignore unfavorite message ".print_r($item, true), LOGGER_DEBUG);
continue;
}
// Deletions come with the same uri, so we check for duplicates after processing deletions
- new_follower($importer, $contact, $item, $nickname);
+ Contact::addRelationship($importer, $contact, $item, $nickname);
- lose_follower($importer, $contact, $item, $dummy);
+ Contact::removeFollower($importer, $contact, $item, $dummy);
- if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE))) {
+ if (!in_array($item["verb"], [ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE])) {
if (!$valid) {
// If not, then it depends on this setting
$valid = !Config::get('system', 'ostatus_full_threads');
if (!$valid) {
// If not, then it depends on this setting
$valid = !Config::get('system', 'ostatus_full_threads');
foreach (self::$itemlist as $item) {
if (!empty($item['contact-id']) && in_array($item['verb'], $verbs)) {
$valid = true;
}
}
foreach (self::$itemlist as $item) {
if (!empty($item['contact-id']) && in_array($item['verb'], $verbs)) {
$valid = true;
}
}
- $valid = dba::exists('item', array('uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']));
+ $valid = dba::exists('item', ['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
+ if ($valid) {
+ logger("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", LOGGER_DEBUG);
+ }
if ($found) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG);
} elseif ($item['contact-id'] < 0) {
logger("Item with uri ".$item["uri"]." is from a blocked contact.", LOGGER_DEBUG);
} else {
// We are having duplicated entries. Hopefully this solves it.
if ($found) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG);
} elseif ($item['contact-id'] < 0) {
logger("Item with uri ".$item["uri"]." is from a blocked contact.", LOGGER_DEBUG);
} else {
// We are having duplicated entries. Hopefully this solves it.
- if (Lock::set('ostatus_process_item_store')) {
- $ret = item_store($item);
- Lock::remove('ostatus_process_item_store');
+ if (Lock::set('ostatus_process_item_insert')) {
+ $ret = Item::insert($item);
+ Lock::remove('ostatus_process_item_insert');
- $condition = array('uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']);
- $deleted = dba::select('item', array('id', 'parent-uri'), $condition, array('limit' => 1));
+ $condition = ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']];
+ $deleted = dba::selectFirst('item', ['id', 'parent-uri'], $condition);
if (!DBM::is_result($deleted)) {
logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it. ");
return;
}
if (!DBM::is_result($deleted)) {
logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it. ");
return;
}
- // Currently we don't have a central deletion function that we could use in this case
- // The function "item_drop" doesn't work for that case
- dba::update(
- 'item',
- array('deleted' => true, 'title' => '', 'body' => '',
- 'edited' => datetime_convert(), 'changed' => datetime_convert()),
- array('id' => $deleted["id"])
- );
-
- delete_thread($deleted["id"], $deleted["parent-uri"]);
+ Item::deleteById($deleted["id"]);
self::fetchRelated($related, $item["parent-uri"], $importer);
} else {
logger('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
self::fetchRelated($related, $item["parent-uri"], $importer);
} else {
logger('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
- $conversation_data = z_fetch_url($conversation, false, $redirects, array('accept_content' => 'application/atom+xml, text/html'));
+ $conversation_data = Network::curl($conversation, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']);
foreach ($links as $link) {
$attribute = self::readAttributes($link);
if (($attribute['rel'] == 'alternate') && ($attribute['type'] == 'application/atom+xml')) {
foreach ($links as $link) {
$attribute = self::readAttributes($link);
if (($attribute['rel'] == 'alternate') && ($attribute['type'] == 'application/atom+xml')) {
if (dba::exists('conversation', $condition)) {
logger('Delete deprecated entry for URI '.$conv_data['uri'], LOGGER_DEBUG);
if (dba::exists('conversation', $condition)) {
logger('Delete deprecated entry for URI '.$conv_data['uri'], LOGGER_DEBUG);
- $condition = array('`item-uri` = ? AND `protocol` IN (?, ?)', $self, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON);
+ $condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $self, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
if (dba::exists('conversation', $condition)) {
logger('Conversation '.$item['uri'].' is already stored.', LOGGER_DEBUG);
return;
}
if (dba::exists('conversation', $condition)) {
logger('Conversation '.$item['uri'].' is already stored.', LOGGER_DEBUG);
return;
}
- $condition = array('`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON);
- $conversation = dba::select('conversation', array('source', 'protocol'), $condition, array('limit' => 1));
+ $condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
+ $conversation = dba::selectFirst('conversation', ['source', 'protocol'], $condition);
}
if ($conversation['protocol'] == PROTOCOL_OSTATUS_SALMON) {
logger('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG);
}
if ($conversation['protocol'] == PROTOCOL_OSTATUS_SALMON) {
logger('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG);
- $related_data = z_fetch_url($related, false, $redirects, array('accept_content' => 'application/atom+xml, text/html'));
+ $related_data = Network::curl($related, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']);
if ($related_atom['success']) {
logger('Fetched XML for URI '.$related_uri, LOGGER_DEBUG);
if ($related_atom['success']) {
logger('Fetched XML for URI '.$related_uri, LOGGER_DEBUG);
// Workaround for older GNU Social servers
if (($xml == '') && strstr($related, '/notice/')) {
// Workaround for older GNU Social servers
if (($xml == '') && strstr($related, '/notice/')) {
if ($related_atom['success']) {
logger('GNU Social workaround to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
if ($related_atom['success']) {
logger('GNU Social workaround to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
// Even more worse workaround for GNU Social ;-)
if ($xml == '') {
$related_guess = OStatus::convertHref($related_uri);
// Even more worse workaround for GNU Social ;-)
if ($xml == '') {
$related_guess = OStatus::convertHref($related_uri);
- $related_atom = z_fetch_url(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom');
+ $related_atom = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom');
if ($related_atom['success']) {
logger('GNU Social workaround 2 to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
if ($related_atom['success']) {
logger('GNU Social workaround 2 to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
- $condition = array('item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV);
- $conversation = dba::select('conversation', array('source'), $condition, array('limit' => 1));
+ $condition = ['item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV];
+ $conversation = dba::selectFirst('conversation', ['source'], $condition);
if (DBM::is_result($conversation)) {
$stored = true;
logger('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG);
if (DBM::is_result($conversation)) {
$stored = true;
logger('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG);
$activityobjects = $xpath->query('activity:object', $entry)->item(0);
if (!is_object($activityobjects)) {
$activityobjects = $xpath->query('activity:object', $entry)->item(0);
if (!is_object($activityobjects)) {
$preview = proxy_url($preview, false, PROXY_SIZE_SMALL);
// Is it a local picture? Then make it smaller here
$preview = proxy_url($preview, false, PROXY_SIZE_SMALL);
// Is it a local picture? Then make it smaller here
- $preview = str_replace(array("-0.jpg", "-0.png"), array("-2.jpg", "-2.png"), $preview);
- $preview = str_replace(array("-1.jpg", "-1.png"), array("-2.jpg", "-2.png"), $preview);
+ $preview = str_replace(["-0.jpg", "-0.png"], ["-2.jpg", "-2.png"], $preview);
+ $preview = str_replace(["-1.jpg", "-1.png"], ["-2.jpg", "-2.png"], $preview);
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
- case 'activity': $title = t('%s\'s timeline', $owner['name']); break;
- case 'posts' : $title = t('%s\'s posts' , $owner['name']); break;
- case 'comments': $title = t('%s\'s comments', $owner['name']); break;
+ case 'activity': $title = L10n::t('%s\'s timeline', $owner['name']); break;
+ case 'posts' : $title = L10n::t('%s\'s posts' , $owner['name']); break;
+ case 'comments': $title = L10n::t('%s\'s comments', $owner['name']); break;
XML::addElement($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
XML::addElement($doc, $root, "id", System::baseUrl() . "/profile/" . $owner["nick"]);
XML::addElement($doc, $root, "title", $title);
XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
XML::addElement($doc, $root, "logo", $owner["photo"]);
XML::addElement($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
XML::addElement($doc, $root, "id", System::baseUrl() . "/profile/" . $owner["nick"]);
XML::addElement($doc, $root, "title", $title);
XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
XML::addElement($doc, $root, "logo", $owner["photo"]);
- XML::addElement($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
+ XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
$author = self::addAuthor($doc, $owner);
$root->appendChild($author);
$author = self::addAuthor($doc, $owner);
$root->appendChild($author);
XML::addElement($doc, $root, "link", "", $attributes);
/// @TODO We have to find out what this is
XML::addElement($doc, $root, "link", "", $attributes);
/// @TODO We have to find out what this is
XML::addElement($doc, $root, "link", "", $attributes);
XML::addElement($doc, $root, "link", "", $attributes);
XML::addElement($doc, $root, "link", "", $attributes);
XML::addElement($doc, $root, "link", "", $attributes);
XML::addElement($doc, $root, "link", "", $attributes);
XML::addElement($doc, $root, "link", "", $attributes);
- $attributes = array("href" => System::baseUrl() . "/api/statuses/user_timeline/" . $owner["nick"] . ".atom",
- "rel" => "self", "type" => "application/atom+xml");
+ $attributes = ["href" => System::baseUrl() . "/api/statuses/user_timeline/" . $owner["nick"] . ".atom",
+ "rel" => "self", "type" => "application/atom+xml"];
XML::addElement($doc, $root, "link", "", $attributes);
return $root;
XML::addElement($doc, $root, "link", "", $attributes);
return $root;
public static function hublinks($doc, $root, $nick)
{
$h = System::baseUrl() . '/pubsubhubbub/'.$nick;
public static function hublinks($doc, $root, $nick)
{
$h = System::baseUrl() . '/pubsubhubbub/'.$nick;
- XML::addElement($doc, $root, "link", "", array("href" => $h, "rel" => "hub"));
+ XML::addElement($doc, $root, "link", "", ["href" => $h, "rel" => "hub"]);
"href" => $siteinfo["image"],
"type" => $imgdata["mime"],
"href" => $siteinfo["image"],
"type" => $imgdata["mime"],
XML::addElement($doc, $root, "link", "", $attributes);
break;
case 'video':
XML::addElement($doc, $root, "link", "", $attributes);
break;
case 'video':
"href" => $siteinfo["url"],
"type" => "text/html; charset=UTF-8",
"length" => "",
"href" => $siteinfo["url"],
"type" => "text/html; charset=UTF-8",
"length" => "",
XML::addElement($doc, $root, "link", "", $attributes);
break;
default:
XML::addElement($doc, $root, "link", "", $attributes);
break;
default:
if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
$imgdata = Image::getInfoFromURL($siteinfo["image"]);
if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
$imgdata = Image::getInfoFromURL($siteinfo["image"]);
"href" => $siteinfo["image"],
"type" => $imgdata["mime"],
"href" => $siteinfo["image"],
"type" => $imgdata["mime"],
XML::addElement($doc, $root, "link", "", $attributes);
}
XML::addElement($doc, $root, "link", "", $attributes);
}
$matches = false;
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|', $r, $matches);
if ($cnt) {
$matches = false;
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|', $r, $matches);
if ($cnt) {
- $r = q("SELECT `homepage`, `publish` FROM `profile` WHERE `uid` = %d AND `is-default` LIMIT 1", intval($owner["uid"]));
- if (DBM::is_result($r)) {
- $profile = $r[0];
- }
+ $profile = dba::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]);
$author = $doc->createElement("author");
XML::addElement($doc, $author, "id", $owner["url"]);
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
XML::addElement($doc, $author, "uri", $owner["url"]);
XML::addElement($doc, $author, "name", $owner["nick"]);
XML::addElement($doc, $author, "email", $owner["addr"]);
$author = $doc->createElement("author");
XML::addElement($doc, $author, "id", $owner["url"]);
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
XML::addElement($doc, $author, "uri", $owner["url"]);
XML::addElement($doc, $author, "name", $owner["nick"]);
XML::addElement($doc, $author, "email", $owner["addr"]);
- XML::addElement($doc, $author, "summary", bbcode($owner["about"], false, false, 7));
+ XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, 7));
XML::addElement($doc, $author, "link", "", $attributes);
XML::addElement($doc, $author, "link", "", $attributes);
XML::addElement($doc, $author, "link", "", $attributes);
if (isset($owner["thumb"])) {
XML::addElement($doc, $author, "link", "", $attributes);
if (isset($owner["thumb"])) {
XML::addElement($doc, $author, "link", "", $attributes);
}
XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
XML::addElement($doc, $author, "link", "", $attributes);
}
XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
- XML::addElement($doc, $author, "poco:note", bbcode($owner["about"], false, false, 7));
+ XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, 7));
- if (trim($profile["homepage"]) != "") {
- $urls = $doc->createElement("poco:urls");
- XML::addElement($doc, $urls, "poco:type", "homepage");
- XML::addElement($doc, $urls, "poco:value", $profile["homepage"]);
- XML::addElement($doc, $urls, "poco:primary", "true");
- $author->appendChild($urls);
- }
+ if (DBM::is_result($profile)) {
+ if (trim($profile["homepage"]) != "") {
+ $urls = $doc->createElement("poco:urls");
+ XML::addElement($doc, $urls, "poco:type", "homepage");
+ XML::addElement($doc, $urls, "poco:value", $profile["homepage"]);
+ XML::addElement($doc, $urls, "poco:primary", "true");
+ $author->appendChild($urls);
+ }
- if (count($profile)) {
- XML::addElement($doc, $author, "followers", "", array("url" => System::baseUrl()."/viewcontacts/".$owner["nick"]));
- XML::addElement($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["uid"]));
+ XML::addElement($doc, $author, "followers", "", ["url" => System::baseUrl()."/viewcontacts/".$owner["nick"]]);
+ XML::addElement($doc, $author, "statusnet:profile_info", "", ["local_id" => $owner["uid"]]);
*/
private static function entry($doc, $item, $owner, $toplevel = false)
{
*/
private static function entry($doc, $item, $owner, $toplevel = false)
{
$repeated_guid = self::getResharedGuid($item);
if ($repeated_guid != "") {
$xml = self::reshareEntry($doc, $item, $owner, $repeated_guid, $toplevel);
$repeated_guid = self::getResharedGuid($item);
if ($repeated_guid != "") {
$xml = self::reshareEntry($doc, $item, $owner, $repeated_guid, $toplevel);
if ($item["verb"] == ACTIVITY_LIKE) {
return self::likeEntry($doc, $item, $owner, $toplevel);
if ($item["verb"] == ACTIVITY_LIKE) {
return self::likeEntry($doc, $item, $owner, $toplevel);
return self::followEntry($doc, $item, $owner, $toplevel);
} else {
return self::noteEntry($doc, $item, $owner, $toplevel);
return self::followEntry($doc, $item, $owner, $toplevel);
} else {
return self::noteEntry($doc, $item, $owner, $toplevel);
$source = $doc->createElement("source");
XML::addElement($doc, $source, "id", $contact["poll"]);
XML::addElement($doc, $source, "title", $contact["name"]);
$source = $doc->createElement("source");
XML::addElement($doc, $source, "id", $contact["poll"]);
XML::addElement($doc, $source, "title", $contact["name"]);
- XML::addElement($doc, $source, "link", "", array("rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]));
- XML::addElement($doc, $source, "link", "", array("rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]));
+ XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]);
+ XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]);
XML::addElement($doc, $source, "icon", $contact["photo"]);
XML::addElement($doc, $source, "icon", $contact["photo"]);
- XML::addElement($doc, $source, "updated", datetime_convert("UTC", "UTC", $contact["success_update"]."+00:00", ATOM_TIME));
+ XML::addElement($doc, $source, "updated", DateTimeFormat::utc($contact["success_update"]."+00:00", DateTimeFormat::ATOM));
XML::addElement($doc, $object, "id", $contact["alias"]);
XML::addElement($doc, $object, "title", $contact["nick"]);
XML::addElement($doc, $object, "id", $contact["alias"]);
XML::addElement($doc, $object, "title", $contact["nick"]);
XML::addElement($doc, $object, "link", "", $attributes);
XML::addElement($doc, $object, "link", "", $attributes);
XML::addElement($doc, $object, "link", "", $attributes);
XML::addElement($doc, $object, "poco:preferredUsername", $contact["nick"]);
XML::addElement($doc, $object, "link", "", $attributes);
XML::addElement($doc, $object, "poco:preferredUsername", $contact["nick"]);
- XML::addElement($doc, $entry, "content", $body, array("type" => "html"));
+ XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);
- XML::addElement($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
- "href" => System::baseUrl()."/display/".$item["guid"])
+ XML::addElement($doc, $entry, "link", "", ["rel" => "alternate", "type" => "text/html",
+ "href" => System::baseUrl()."/display/".$item["guid"]]
- XML::addElement($doc, $entry, "status_net", "", array("notice_id" => $item["id"]));
+ XML::addElement($doc, $entry, "status_net", "", ["notice_id" => $item["id"]]);
}
XML::addElement($doc, $entry, "activity:verb", $verb);
}
XML::addElement($doc, $entry, "activity:verb", $verb);
- XML::addElement($doc, $entry, "published", datetime_convert("UTC", "UTC", $item["created"]."+00:00", ATOM_TIME));
- XML::addElement($doc, $entry, "updated", datetime_convert("UTC", "UTC", $item["edited"]."+00:00", ATOM_TIME));
+ XML::addElement($doc, $entry, "published", DateTimeFormat::utc($item["created"]."+00:00", DateTimeFormat::ATOM));
+ XML::addElement($doc, $entry, "updated", DateTimeFormat::utc($item["edited"]."+00:00", DateTimeFormat::ATOM));
*/
private static function entryFooter($doc, $entry, $item, $owner, $complete = true)
{
*/
private static function entryFooter($doc, $entry, $item, $owner, $complete = true)
{
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
$parent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `id` = %d", intval($item["parent"]));
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
$parent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `id` = %d", intval($item["parent"]));
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
XML::addElement($doc, $entry, "link", "", $attributes);
}
XML::addElement($doc, $entry, "link", "", $attributes);
}
- XML::addElement($doc, $entry, "link", "", array("rel" => "ostatus:conversation", "href" => $conversation_href));
+ XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:conversation", "href" => $conversation_href]);
"href" => $conversation_href,
"local_id" => $item["parent"],
"href" => $conversation_href,
"local_id" => $item["parent"],
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
}
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
}
foreach ($mentioned as $mention) {
$newmentions[str_replace("http://", "https://", $mention)] = str_replace("http://", "https://", $mention);
$newmentions[str_replace("https://", "http://", $mention)] = str_replace("https://", "http://", $mention);
foreach ($mentioned as $mention) {
$newmentions[str_replace("http://", "https://", $mention)] = str_replace("http://", "https://", $mention);
$newmentions[str_replace("https://", "http://", $mention)] = str_replace("https://", "http://", $mention);
);
if ($r[0]["forum"] || $r[0]["prv"]) {
XML::addElement($doc, $entry, "link", "",
);
if ($r[0]["forum"] || $r[0]["prv"]) {
XML::addElement($doc, $entry, "link", "",
);
} else {
XML::addElement($doc, $entry, "link", "",
);
} else {
XML::addElement($doc, $entry, "link", "",
- XML::addElement($doc, $entry, "link", "", array("rel" => "ostatus:attention",
- "href" => "http://activityschema.org/collection/public"));
- XML::addElement($doc, $entry, "link", "", array("rel" => "mentioned",
+ XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:attention",
+ "href" => "http://activityschema.org/collection/public"]);
+ XML::addElement($doc, $entry, "link", "", ["rel" => "mentioned",
XML::addElement($doc, $entry, "mastodon:scope", "public");
}
if (count($tags)) {
foreach ($tags as $t) {
if ($t[0] != "@") {
XML::addElement($doc, $entry, "mastodon:scope", "public");
}
if (count($tags)) {
foreach ($tags as $t) {
if ($t[0] != "@") {
- XML::addElement($doc, $entry, "category", "", array("term" => $t[2]));
+ XML::addElement($doc, $entry, "category", "", ["term" => $t[2]]);
- $check_date = datetime_convert('UTC', 'UTC', $last_update, 'Y-m-d H:i:s');
- $authorid = Contact::getIdForURL($owner["url"], 0);
+ $check_date = DateTimeFormat::utc($last_update);
+ $authorid = Contact::getIdForURL($owner["url"], 0, true);
AND `thread`.`network` IN ('%s', '%s')
$sql_extra
ORDER BY `item`.`created` DESC LIMIT %d",
AND `thread`.`network` IN ('%s', '%s')
$sql_extra
ORDER BY `item`.`created` DESC LIMIT %d",
Cache::set($cachekey, $msg, CACHE_QUARTER_HOUR);
logger('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG);
Cache::set($cachekey, $msg, CACHE_QUARTER_HOUR);
logger('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG);