$o .= conversation($a, $conversation_items, 'display', $update_uid, false, 'commented', local_user());
// Preparing the meta header
- $description = trim(HTML::toPlaintext(BBCode::convert($items["body"], false), 0, true));
- $title = trim(HTML::toPlaintext(BBCode::convert($items["title"], false), 0, true));
- $author_name = $items["author-name"];
+ $description = trim(HTML::toPlaintext(BBCode::convert($items[0]["body"], false), 0, true));
+ $title = trim(HTML::toPlaintext(BBCode::convert($items[0]["title"], false), 0, true));
+ $author_name = $items[0]["author-name"];
- $image = $a->remove_baseurl($items["author-thumb"]);
+ $image = $a->remove_baseurl($items[0]["author-avatar"]);
if ($title == "") {
$title = $author_name;
$a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
- $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$items["plink"].'" />'."\n";
+ $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$items[0]["plink"].'" />'."\n";
// Dublin Core
$a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
- $a->page['htmlhead'] .= '<meta property="og:url" content="'.$items["plink"].'" />'."\n";
+ $a->page['htmlhead'] .= '<meta property="og:url" content="'.$items[0]["plink"].'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";
// article:tag
private static function fetchAuthor($xpath, $context, $importer, &$contact, $onlyfetch)
{
$author = [];
- $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"] = XML::getFirstNodeValue($xpath, 'atom:author/atom:uri/text()', $context);
+ $author["author-name"] = XML::getFirstNodeValue($xpath, 'atom:author/atom:name/text()', $context);
+ $addr = XML::getFirstNodeValue($xpath, 'atom:author/atom:email/text()', $context);
$aliaslink = $author["author-link"];
$author["author-avatar"] = Probe::fixAvatar(current($avatarlist), $author["author-link"]);
}
- $displayname = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
+ $displayname = XML::getFirstNodeValue($xpath, 'atom:author/poco:displayName/text()', $context);
if ($displayname != "") {
$author["author-name"] = $displayname;
}
$contact['url'] = $author["author-link"];
$contact['nurl'] = normalise_link($contact['url']);
- $value = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
+ $value = XML::getFirstNodeValue($xpath, 'atom:author/atom:uri/text()', $context);
if ($value != "") {
$contact["alias"] = $value;
}
- $value = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
+ $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:displayName/text()', $context);
if ($value != "") {
$contact["name"] = $value;
}
- $value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
+ $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:preferredUsername/text()', $context);
if ($value != "") {
$contact["nick"] = $value;
}
- $value = $xpath->evaluate('atom:author/poco:note/text()', $context)->item(0)->nodeValue;
+ $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:note/text()', $context);
if ($value != "") {
$contact["about"] = HTML::toBBCode($value);
}
- $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
+ $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:address/poco:formatted/text()', $context);
if ($value != "") {
$contact["location"] = $value;
}
$author = self::fetchAuthor($xpath, $entry, $importer, $contact, $stored);
}
- $value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $entry)->item(0)->nodeValue;
+ $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:preferredUsername/text()', $context);
if ($value != "") {
$nickname = $value;
} else {
$item = array_merge($header, $author);
- $item["uri"] = $xpath->query('atom:id/text()', $entry)->item(0)->nodeValue;
+ $item["uri"] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry);
- $item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
+ $item["verb"] = XML::getFirstNodeValue($xpath, 'activity:verb/text()', $entry);
// Delete a message
if (in_array($item["verb"], ['qvitter-delete-notice', ACTIVITY_DELETE, 'delete'])) {
*/
private static function processPost($xpath, $entry, &$item, $importer)
{
- $item["body"] = HTML::toBBCode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue);
- $item["object-type"] = $xpath->query('activity:object-type/text()', $entry)->item(0)->nodeValue;
+ $item["body"] = HTML::toBBCode(XML::getFirstNodeValue($xpath, 'atom:content/text()', $entry));
+ $item["object-type"] = XML::getFirstNodeValue($xpath, 'activity:object-type/text()', $entry);
if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) || ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
- $item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
- $item["body"] = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
+ $item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
+ $item["body"] = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry);
} elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) {
- $item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
+ $item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
}
- $item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
- $item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
- $conversation = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
- $item['conversation-uri'] = $conversation;
+ $item["created"] = XML::getFirstNodeValue($xpath, 'atom:published/text()', $entry);
+ $item["edited"] = XML::getFirstNodeValue($xpath, 'atom:updated/text()', $entry);
+ $item['conversation-uri'] = XML::getFirstNodeValue($xpath, 'ostatus:conversation/text()', $entry);
$conv = $xpath->query('ostatus:conversation', $entry);
if (is_object($conv->item(0))) {
// Mastodon Content Warning
if (($item["verb"] == ACTIVITY_POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
- $clear_text = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
+ $clear_text = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry);
if (!empty($clear_text)) {
$item['content-warning'] = HTML::toBBCode($clear_text);
}
$conv_data['protocol'] = PROTOCOL_SPLITTED_CONV;
$conv_data['network'] = NETWORK_OSTATUS;
- $conv_data['uri'] = $xpath->query('atom:id/text()', $entry)->item(0)->nodeValue;
+ $conv_data['uri'] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry);
$inreplyto = $xpath->query('thr:in-reply-to', $entry);
if (is_object($inreplyto->item(0))) {
}
}
- $conv = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
- $conv_data['conversation-uri'] = $conv;
+ $conv_data['conversation-uri'] = XML::getFirstNodeValue($xpath, 'ostatus:conversation/text()', $entry);
$conv = $xpath->query('ostatus:conversation', $entry);
if (is_object($conv->item(0))) {
$link_data = [];
- $orig_uri = $xpath->query('atom:id/text()', $activityobjects)->item(0)->nodeValue;
+ $orig_uri = XML::getFirstNodeValue($xpath, 'atom:id/text()', $activityobjects);
$links = $xpath->query("atom:link", $activityobjects);
if ($links) {
$matches = [];
$new_location_info = @parse_url($curl_info['redirect_url']);
$old_location_info = @parse_url($curl_info['url']);
-
+
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
$newurl = trim(array_pop($matches));
public static function stripTrackingQueryParams($url)
{
$urldata = parse_url($url);
- if (is_string($urldata["query"])) {
+ if (!empty($urldata["query"])) {
$query = $urldata["query"];
parse_str($query, $querydata);
return "";
}
+ if (empty($parts1["scheme"])) {
+ $parts1["scheme"] = '';
+ }
+ if (empty($parts2["scheme"])) {
+ $parts2["scheme"] = '';
+ }
+
if ($parts1["scheme"] != $parts2["scheme"]) {
return "";
}
+ if (empty($parts1["host"])) {
+ $parts1["host"] = '';
+ }
+ if (empty($parts2["host"])) {
+ $parts2["host"] = '';
+ }
+
if ($parts1["host"] != $parts2["host"]) {
return "";
}
+ if (empty($parts1["port"])) {
+ $parts1["port"] = '';
+ }
+ if (empty($parts2["port"])) {
+ $parts2["port"] = '';
+ }
+
if ($parts1["port"] != $parts2["port"]) {
return "";
}
$match .= ":".$parts1["port"];
}
+ if (empty($parts1["path"])) {
+ $parts1["path"] = '';
+ }
+ if (empty($parts2["path"])) {
+ $parts2["path"] = '';
+ }
+
$pathparts1 = explode("/", $parts1["path"]);
$pathparts2 = explode("/", $parts2["path"]);