// Remove the abstract element. It is only locally important.
$body = BBCode::stripAbstract($body);
+ $htmlbody = '';
if ($type == 'html') {
$htmlbody = $body;
$author["name"] = $xpath->evaluate($element."/atom:name/text()", $context)->item(0)->nodeValue;
$author["link"] = $xpath->evaluate($element."/atom:uri/text()", $context)->item(0)->nodeValue;
- $r = q(
- "SELECT `id`, `uid`, `url`, `network`, `avatar-date`, `name-date`, `uri-date`, `addr`,
+ $contact_old = dba::fetch_first("SELECT `id`, `uid`, `url`, `network`, `avatar-date`, `name-date`, `uri-date`, `addr`,
`name`, `nick`, `about`, `location`, `keywords`, `xmpp`, `bdyear`, `bd`, `hidden`, `contact-type`
- FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
- intval($importer["uid"]),
- dbesc(normalise_link($author["link"])),
- dbesc(NETWORK_STATUSNET)
+ FROM `contact` WHERE `uid` = ? AND `nurl` = ? AND `network` != ?",
+ $importer["uid"],
+ normalise_link($author["link"]),
+ NETWORK_STATUSNET
);
- if (DBM::is_result($r)) {
- $contact = $r[0];
- $author["contact-id"] = $r[0]["id"];
- $author["network"] = $r[0]["network"];
+ if (DBM::is_result($contact_old)) {
+ $author["contact-id"] = $contact_old["id"];
+ $author["network"] = $contact_old["network"];
} else {
if (!$onlyfetch) {
logger("Contact ".$author["link"]." wasn't found for user ".$importer["uid"]." XML: ".$xml, LOGGER_DEBUG);
$width = $attributes->textContent;
}
if ($attributes->name == "updated") {
- $contact["avatar-date"] = $attributes->textContent;
+ $contact_old["avatar-date"] = $attributes->textContent;
}
}
if (($width > 0) && ($href != "")) {
$author["avatar"] = current($avatarlist);
}
- if (DBM::is_result($r) && !$onlyfetch) {
- logger("Check if contact details for contact " . $r[0]["id"] . " (" . $r[0]["nick"] . ") have to be updated.", LOGGER_DEBUG);
+ if (DBM::is_result($contact_old) && !$onlyfetch) {
+ logger("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated.", LOGGER_DEBUG);
- $poco = ["url" => $contact["url"]];
+ $poco = ["url" => $contact_old["url"]];
// When was the last change to name or uri?
$name_element = $xpath->query($element . "/atom:name", $context)->item(0);
// If the "hide" element is present then the profile isn't searchable.
$hide = intval($xpath->evaluate($element . "/dfrn:hide/text()", $context)->item(0)->nodeValue == "true");
- logger("Hidden status for contact " . $contact["url"] . ": " . $hide, LOGGER_DEBUG);
+ logger("Hidden status for contact " . $contact_old["url"] . ": " . $hide, LOGGER_DEBUG);
// If the contact isn't searchable then set the contact to "hidden".
// Problem: This can be manually overridden by the user.
if ($hide) {
- $contact["hidden"] = true;
+ $contact_old["hidden"] = true;
}
// Save the keywords into the contact table
}
// "dfrn:birthday" contains the birthday converted to UTC
- $old_bdyear = $contact["bdyear"];
-
$birthday = $xpath->evaluate($element . "/dfrn:birthday/text()", $context)->item(0)->nodeValue;
if (strtotime($birthday) > time()) {
$poco["bd"] = $value;
}
- $contact = array_merge($contact, $poco);
+ $contact = array_merge($contact_old, $poco);
- if ($old_bdyear != $contact["bdyear"]) {
+ if ($contact_old["bdyear"] != $contact["bdyear"]) {
self::birthdayEvent($contact, $birthday);
}
// Get all field names
$fields = [];
- foreach ($r[0] as $field => $data) {
+ foreach ($contact_old as $field => $data) {
$fields[$field] = $data;
}
unset($fields["name-date"]);
unset($fields["uri-date"]);
+ $update = false;
// Update check for this field has to be done differently
$datefields = ["name-date", "uri-date"];
foreach ($datefields as $field) {
- if (strtotime($contact[$field]) > strtotime($r[0][$field])) {
- logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $r[0][$field] . "'", LOGGER_DEBUG);
+ if (strtotime($contact[$field]) > strtotime($contact_old[$field])) {
+ logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG);
$update = true;
}
}
foreach ($fields as $field => $data) {
- if ($contact[$field] != $r[0][$field]) {
- logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $r[0][$field] . "'", LOGGER_DEBUG);
+ if ($contact[$field] != $contact_old[$field]) {
+ logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG);
$update = true;
}
}
$author["avatar"],
$importer["uid"],
$contact["id"],
- (strtotime($contact["avatar-date"]) > strtotime($r[0]["avatar-date"]))
+ (strtotime($contact["avatar-date"]) > strtotime($contact_old["avatar-date"]))
);
/*
$item["edited"] = $xpath->query("atom:updated/text()", $entry)->item(0)->nodeValue;
- $current = q(
- "SELECT `id`, `uid`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($item["uri"]),
- intval($importer["importer_uid"])
+ $current = dba::selectFirst('item',
+ ['id', 'uid', 'edited', 'body'],
+ ['uri' => $item["uri"], 'uid' => $importer["importer_uid"]]
);
-
// Is there an existing item?
- if (DBM::is_result($current) && !self::isEditedTimestampNewer($current[0], $item)) {
+ if (DBM::is_result($current) && !self::isEditedTimestampNewer($current, $item)) {
logger("Item ".$item["uri"]." (".$item['edited'].") already existed.", LOGGER_DEBUG);
return;
}
// Update content if 'updated' changes
if (DBM::is_result($current)) {
- if (self::updateContent($r[0], $item, $importer, $entrytype)) {
+ if (self::updateContent($current, $item, $importer, $entrytype)) {
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
} else {
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
private static function processDeletion($xpath, $deletion, $importer)
{
logger("Processing deletions");
-
+ $uri = null;
foreach ($deletion->attributes as $attributes) {
if ($attributes->name == "ref") {
$uri = $attributes->textContent;
}
$children = $basedom->children('https://joindiaspora.com/protocol');
+ $inner_aes_key = null;
+ $inner_iv = null;
+
if ($children->header) {
$public = true;
$author_link = str_replace('acct:', '', $children->header->author_id);
// figure out where in the DOM tree our data is hiding
+ $base = null;
if ($dom->provenance->data) {
$base = $dom->provenance;
} elseif ($dom->env->data) {
return false;
}
- $first_child = $data->getName();
-
// Is this the new or the old version?
if ($data->getName() == "XML") {
$oldXML = true;
$fields = new SimpleXMLElement("<".$type."/>");
$signed_data = "";
+ $author_signature = null;
+ $parent_author_signature = null;
foreach ($element->children() as $fieldname => $entry) {
if ($oldXML) {
*/
public static function personByHandle($handle)
{
- $r = q(
- "SELECT * FROM `fcontact` WHERE `network` = '%s' AND `addr` = '%s' LIMIT 1",
- dbesc(NETWORK_DIASPORA),
- dbesc($handle)
- );
- if ($r) {
- $person = $r[0];
- logger("In cache " . print_r($r, true), LOGGER_DEBUG);
+ $update = false;
+
+ $person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
+ if (DBM::is_result($person)) {
+ logger("In cache " . print_r($person, true), LOGGER_DEBUG);
// update record occasionally so it doesn't get stale
$d = strtotime($person["updated"]." +00:00");
}
}
- if (!$person || $update) {
+ if (!DBM::is_result($person) || $update) {
logger("create or refresh", LOGGER_DEBUG);
$r = Probe::uri($handle, NETWORK_DIASPORA);
$person = $r;
}
}
+
return $person;
}
$parent = $p[0];
$target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
+ $positive = null;
if ($item['verb'] === ACTIVITY_LIKE) {
$positive = "true";
} elseif ($item['verb'] === ACTIVITY_DISLIKE) {
$small = System::baseUrl().'/photo/custom/50/' .$profile['uid'].'.jpg';
$searchable = (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false');
+ $dob = null;
+ $about = null;
+ $location = null;
+ $tags = null;
if ($searchable === 'true') {
$dob = '';
$currline = $arrbody[$i];
while ($previousquote < $quotelevel) {
- if ($sender != '') {
- $quote = "[quote title=$sender]";
- $sender = '';
- } else
- $quote = "[quote]";
-
+ $quote = "[quote]";
$arrbody[$i] = $quote.$arrbody[$i];
$previousquote++;
}
$xpath->registerNamespace('poco', NAMESPACE_POCO);
$author = [];
+ $entries = null;
// Is it RDF?
if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) {
$item["title"] = '';
}
+ $preview = '';
if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) {
- $preview = "";
-
// Handle enclosures and treat them as preview picture
foreach ($attachments AS $attachment) {
if ($attachment["type"] == "image/jpeg") {
if (!empty($tags)) {
$item["tag"] = $tags;
} else {
+ // @todo $preview is never set in this case, is it intended? - @MrPetovan 2018-02-13
$item["tag"] = add_page_keywords($item["plink"], $preview, true, $contact["ffi_keyword_blacklist"]);
}
$item["body"] .= "\n".$item['tag'];
}
$author["contact-id"] = $contact["id"];
- $found = false;
-
+ $contact = null;
if ($aliaslink != '') {
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ?",
$importer["uid"], $aliaslink, NETWORK_STATUSNET];
- $r = dba::selectFirst('contact', [], $condition);
-
- if (DBM::is_result($r)) {
- $found = true;
- if ($r['blocked']) {
- $r['id'] = -1;
- }
- $contact = $r;
- $author["contact-id"] = $r["id"];
- }
+ $contact = dba::selectFirst('contact', [], $condition);
}
- if (!$found && ($author["author-link"] != "")) {
+ if (!DBM::is_result($contact) && $author["author-link"] != '') {
if ($aliaslink == "") {
$aliaslink = $author["author-link"];
}
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET];
- $r = dba::selectFirst('contact', [], $condition);
-
- if (DBM::is_result($r)) {
- $found = true;
- if ($r['blocked']) {
- $r['id'] = -1;
- }
- $contact = $r;
- $author["contact-id"] = $r["id"];
- }
+ $contact = dba::selectFirst('contact', [], $condition);
}
- if (!$found && ($addr != "")) {
+ if (!DBM::is_result($contact) && ($addr != '')) {
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ?",
$importer["uid"], $addr, NETWORK_STATUSNET];
- $r = dba::selectFirst('contact', [], $condition);
+ $contact = dba::selectFirst('contact', [], $condition);
+ }
- if (DBM::is_result($r)) {
- $found = true;
- if ($r['blocked']) {
- $r['id'] = -1;
- }
- $contact = $r;
- $author["contact-id"] = $r["id"];
+ if (DBM::is_result($contact)) {
+ if ($contact['blocked']) {
+ $contact['id'] = -1;
}
+ $author["contact-id"] = $contact["id"];
}
$avatarlist = [];
$author["owner-avatar"] = $author["author-avatar"];
// Only update the contacts if it is an OStatus contact
- if ($r && ($r['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
+ if (DBM::is_result($contact) && ($contact['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
// Update contact data
$current = $contact;
$links = $xpath->query('//link');
if ($links) {
+ $file = '';
foreach ($links as $link) {
$attribute = self::readAttributes($link);
if (($attribute['rel'] == 'alternate') && ($attribute['type'] == 'application/atom+xml')) {
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
+ $title = '';
switch ($filter) {
case 'activity': $title = L10n::t('%s\'s timeline', $owner['name']); break;
case 'posts' : $title = L10n::t('%s\'s posts' , $owner['name']); break;
*/
private static function addAuthor($doc, $owner)
{
- $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);
$author->appendChild($element);
}
- 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", "", ["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)
{
+ $xml = null;
+
$repeated_guid = self::getResharedGuid($item);
if ($repeated_guid != "") {
$xml = self::reshareEntry($doc, $item, $owner, $repeated_guid, $toplevel);
$contact['created'] = DateTimeFormat::utcNow();
}
+ $server_url = '';
if ($force) {
$server_url = normalise_link(self::detectServer($profile));
}