Some more places ...

This commit is contained in:
Michael 2018-07-08 12:58:43 +00:00
parent 8a2230bc4c
commit 1d745c25a7
6 changed files with 73 additions and 42 deletions

View file

@ -356,11 +356,11 @@ function display_content(App $a, $update = false, $update_uid = 0)
$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;
@ -392,7 +392,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$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";
@ -402,7 +402,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$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

View file

@ -31,7 +31,7 @@ function poco_init(App $a) {
$system_mode = true;
}
$format = (($_GET['format']) ? $_GET['format'] : 'json');
$format = defaults($_GET, 'format', 'json');
$justme = false;
$global = false;
@ -76,11 +76,11 @@ function poco_init(App $a) {
if ($justme) {
$sql_extra = " AND `contact`.`self` = 1 ";
} else {
$sql_extra = "";
}
// else
// $sql_extra = " AND `contact`.`self` = 0 ";
if ($cid) {
if (!empty($cid)) {
$sql_extra = sprintf(" AND `contact`.`id` = %d ", intval($cid));
}
if (x($_GET, 'updatedSince')) {
@ -112,8 +112,9 @@ function poco_init(App $a) {
} else {
$totalResults = 0;
}
$startIndex = intval($_GET['startIndex']);
if (! $startIndex) {
if (!empty($_GET['startIndex'])) {
$startIndex = intval($_GET['startIndex']);
} else {
$startIndex = 0;
}
$itemsPerPage = ((x($_GET, 'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
@ -204,6 +205,10 @@ function poco_init(App $a) {
if (is_array($contacts)) {
if (DBM::is_result($contacts)) {
foreach ($contacts as $contact) {
if (!isset($contact['updated'])) {
$contact['updated'] = '';
}
if (! isset($contact['generation'])) {
if ($global) {
$contact['generation'] = 3;

View file

@ -112,7 +112,7 @@ class Profile
}
}
$pdata = self::getByNickname($nickname, $user[0]['uid'], $profile);
$pdata = self::getByNickname($nickname, $user['uid'], $profile);
if (empty($pdata) && empty($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);

View file

@ -2746,7 +2746,7 @@ class DFRN
}
$condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]];
$item = Item::selectFirst(['id', 'parent', 'contact-id', 'file'], $condition);
$item = Item::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted'], $condition);
if (!DBM::is_result($item)) {
logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG);
return;

View file

@ -55,9 +55,9 @@ class OStatus
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"];
@ -126,7 +126,7 @@ class OStatus
$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;
}
@ -155,27 +155,27 @@ class OStatus
$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;
}
@ -390,7 +390,7 @@ class OStatus
$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 {
@ -399,9 +399,9 @@ class OStatus
$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'])) {
@ -561,19 +561,18 @@ class OStatus
*/
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))) {
@ -661,7 +660,7 @@ class OStatus
// 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);
}
@ -787,7 +786,7 @@ class OStatus
$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))) {
@ -798,8 +797,7 @@ class OStatus
}
}
$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))) {
@ -1003,7 +1001,7 @@ class OStatus
$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) {

View file

@ -410,7 +410,7 @@ class Network
$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));
@ -654,7 +654,7 @@ class Network
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);
@ -838,14 +838,35 @@ class Network
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 "";
}
@ -856,6 +877,13 @@ class Network
$match .= ":".$parts1["port"];
}
if (empty($parts1["path"])) {
$parts1["path"] = '';
}
if (empty($parts2["path"])) {
$parts2["path"] = '';
}
$pathparts1 = explode("/", $parts1["path"]);
$pathparts2 = explode("/", $parts2["path"]);