Several more warnings ... (#5340)

* Some more warnings removed

* Even more warnings ...

* Will it ever end? ;-)

* Avoid warning in dbstructure

* Origin and OStatus ...

* There are more warnings solved ... yeah!

* And again ...

* We are not done yet

* And more ...

* And some new places ...

* And more in the feeds

* Avoid some more

* And some backend stuff

* Notifications cleared

* Some more stuff

* and again ...

* It's getting fewer ...

* Some warnings had been hidden in the notifications

* Fix the fix

* And another missing one ...

* We need the owner here, not the user

* Forgotten user

* And more ...

* And some more warnings disappeared ...

* Some more frontend warnings

* Some backend warnings removed

* Fixed sidebar for "vier"

* And more ...

* Some more ...

* And something for "remote self"

* Am I stuck in an endless loop?

* Fix: Clear tag and file field on update

* Preset page content
This commit is contained in:
Michael Vogel 2018-07-10 14:27:56 +02:00 committed by Hypolite Petovan
parent 32ef5623ab
commit 0360f7197a
48 changed files with 415 additions and 267 deletions

View file

@ -866,7 +866,7 @@ function goaway($path)
*/ */
function local_user() function local_user()
{ {
if (x($_SESSION, 'authenticated') && x($_SESSION, 'uid')) { if (!empty($_SESSION['authenticated']) && !empty($_SESSION['uid'])) {
return intval($_SESSION['uid']); return intval($_SESSION['uid']);
} }
return false; return false;
@ -909,6 +909,11 @@ function remote_user()
// if (local_user()) { // if (local_user()) {
// return false; // return false;
// } // }
if (empty($_SESSION)) {
return false;
}
if (x($_SESSION, 'authenticated') && x($_SESSION, 'visitor_id')) { if (x($_SESSION, 'authenticated') && x($_SESSION, 'visitor_id')) {
return intval($_SESSION['visitor_id']); return intval($_SESSION['visitor_id']);
} }

View file

@ -169,7 +169,8 @@ function api_login(App $a)
$oauth1 = new FKOAuth1(); $oauth1 = new FKOAuth1();
// login with oauth // login with oauth
try { try {
list($consumer, $token) = $oauth1->verify_request(OAuthRequest::from_request()); $request = OAuthRequest::from_request();
list($consumer, $token) = $oauth1->verify_request($request);
if (!is_null($token)) { if (!is_null($token)) {
$oauth1->loginUser($token->uid); $oauth1->loginUser($token->uid);
Addon::callHooks('logged_in', $a->user); Addon::callHooks('logged_in', $a->user);

View file

@ -349,7 +349,10 @@ function localize_item(&$item)
// add sparkle links to appropriate permalinks // add sparkle links to appropriate permalinks
$author = ['uid' => 0, 'id' => $item['author-id'], $author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']]; 'network' => $item['author-network'], 'url' => $item['author-link']];
$item['plink'] = Contact::magicLinkbyContact($author, $item['plink']);
if (!empty($item['plink'])) {
$item['plink'] = Contact::magicLinkbyContact($author, $item['plink']);
}
} }
/** /**
@ -482,7 +485,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
$profile_owner = $a->profile['uid']; $profile_owner = $a->profile['uid'];
if (!$update) { if (!$update) {
$live_update_div = '<div id="live-display"></div>' . "\r\n" $live_update_div = '<div id="live-display"></div>' . "\r\n"
. "<script> var profile_uid = " . $_SESSION['uid'] . ";" . "<script> var profile_uid = " . defaults($_SESSION, 'uid', 0) . ";"
. " var profile_page = 1; </script>"; . " var profile_page = 1; </script>";
} }
} elseif ($mode === 'community') { } elseif ($mode === 'community') {
@ -631,8 +634,8 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
$tmp_item = [ $tmp_item = [
'template' => $tpl, 'template' => $tpl,
'id' => (($preview) ? 'P0' : $item['item_id']), 'id' => ($preview ? 'P0' : $item['id']),
'guid' => (($preview) ? 'Q0' : $item['guid']), 'guid' => ($preview ? 'Q0' : $item['guid']),
'network' => $item['network'], 'network' => $item['network'],
'network_name' => ContactSelector::networkToName($item['network'], $profile_link), 'network_name' => ContactSelector::networkToName($item['network'], $profile_link),
'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']), 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
@ -679,7 +682,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
$arr = ['item' => $item, 'output' => $tmp_item]; $arr = ['item' => $item, 'output' => $tmp_item];
Addon::callHooks('display_item', $arr); Addon::callHooks('display_item', $arr);
$threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['id'] = $item['id'];
$threads[$threadsid]['network'] = $item['network']; $threads[$threadsid]['network'] = $item['network'];
$threads[$threadsid]['items'] = [$arr['output']]; $threads[$threadsid]['items'] = [$arr['output']];

View file

@ -34,7 +34,7 @@ function notification($params)
$siteurl = System::baseUrl(true); $siteurl = System::baseUrl(true);
$thanks = L10n::t('Thank You,'); $thanks = L10n::t('Thank You,');
$sitename = $a->config['sitename']; $sitename = $a->config['sitename'];
if (!x($a->config['admin_name'])) { if (empty($a->config['admin_name'])) {
$site_admin = L10n::t('%s Administrator', $sitename); $site_admin = L10n::t('%s Administrator', $sitename);
} else { } else {
$site_admin = L10n::t('%1$s, %2$s Administrator', $a->config['admin_name'], $sitename); $site_admin = L10n::t('%1$s, %2$s Administrator', $a->config['admin_name'], $sitename);
@ -93,6 +93,8 @@ function notification($params)
} }
if ($params['type'] == NOTIFY_MAIL) { if ($params['type'] == NOTIFY_MAIL) {
$itemlink = $siteurl.'/message/'.$params['item']['id'];
$subject = L10n::t('[Friendica:Notify] New mail received at %s', $sitename); $subject = L10n::t('[Friendica:Notify] New mail received at %s', $sitename);
$preamble = L10n::t('%1$s sent you a new private message at %2$s.', $params['source_name'], $sitename); $preamble = L10n::t('%1$s sent you a new private message at %2$s.', $params['source_name'], $sitename);
@ -101,7 +103,6 @@ function notification($params)
$sitelink = L10n::t('Please visit %s to view and/or reply to your private messages.'); $sitelink = L10n::t('Please visit %s to view and/or reply to your private messages.');
$tsitelink = sprintf($sitelink, $siteurl.'/message/'.$params['item']['id']); $tsitelink = sprintf($sitelink, $siteurl.'/message/'.$params['item']['id']);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'/message/'.$params['item']['id'].'">'.$sitename.'</a>'); $hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'/message/'.$params['item']['id'].'">'.$sitename.'</a>');
$itemlink = $siteurl.'/message/'.$params['item']['id'];
} }
if ($params['type'] == NOTIFY_COMMENT) { if ($params['type'] == NOTIFY_COMMENT) {
@ -130,10 +131,11 @@ function notification($params)
$item = null; $item = null;
if ($params['otype'] === 'item' && $parent_id) { if ($params['otype'] === 'item' && $parent_id) {
$item = Item::selectFirstForUser($params['uid'], [], ['id' => $parent_id]); $item = Item::selectFirstForUser($params['uid'], Item::ITEM_FIELDLIST, ['id' => $parent_id]);
} }
$item_post_type = item_post_type($item); $item_post_type = item_post_type($item);
$itemlink = $item['plink'];
// "a post" // "a post"
$dest_str = L10n::t('%1$s commented on [url=%2$s]a %3$s[/url]', $dest_str = L10n::t('%1$s commented on [url=%2$s]a %3$s[/url]',
@ -242,6 +244,7 @@ function notification($params)
} }
if ($params['type'] == NOTIFY_TAGSHARE) { if ($params['type'] == NOTIFY_TAGSHARE) {
$itemlink = $params['link'];
$subject = L10n::t('[Friendica:Notify] %s tagged your post', $params['source_name']); $subject = L10n::t('[Friendica:Notify] %s tagged your post', $params['source_name']);
$preamble = L10n::t('%1$s tagged your post at %2$s', $params['source_name'], $sitename); $preamble = L10n::t('%1$s tagged your post at %2$s', $params['source_name'], $sitename);
@ -253,10 +256,10 @@ function notification($params)
$sitelink = L10n::t('Please visit %s to view and/or reply to the conversation.'); $sitelink = L10n::t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf($sitelink, $siteurl); $tsitelink = sprintf($sitelink, $siteurl);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>'); $hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
$itemlink = $params['link'];
} }
if ($params['type'] == NOTIFY_INTRO) { if ($params['type'] == NOTIFY_INTRO) {
$itemlink = $params['link'];
$subject = L10n::t('[Friendica:Notify] Introduction received'); $subject = L10n::t('[Friendica:Notify] Introduction received');
$preamble = L10n::t('You\'ve received an introduction from \'%1$s\' at %2$s', $params['source_name'], $sitename); $preamble = L10n::t('You\'ve received an introduction from \'%1$s\' at %2$s', $params['source_name'], $sitename);
@ -270,7 +273,6 @@ function notification($params)
$sitelink = L10n::t('Please visit %s to approve or reject the introduction.'); $sitelink = L10n::t('Please visit %s to approve or reject the introduction.');
$tsitelink = sprintf($sitelink, $siteurl); $tsitelink = sprintf($sitelink, $siteurl);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>'); $hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
$itemlink = $params['link'];
switch ($params['verb']) { switch ($params['verb']) {
case ACTIVITY_FRIEND: case ACTIVITY_FRIEND:
@ -300,6 +302,7 @@ function notification($params)
} }
if ($params['type'] == NOTIFY_SUGGEST) { if ($params['type'] == NOTIFY_SUGGEST) {
$itemlink = $params['link'];
$subject = L10n::t('[Friendica:Notify] Friend suggestion received'); $subject = L10n::t('[Friendica:Notify] Friend suggestion received');
$preamble = L10n::t('You\'ve received a friend suggestion from \'%1$s\' at %2$s', $params['source_name'], $sitename); $preamble = L10n::t('You\'ve received a friend suggestion from \'%1$s\' at %2$s', $params['source_name'], $sitename);
@ -316,11 +319,11 @@ function notification($params)
$sitelink = L10n::t('Please visit %s to approve or reject the suggestion.'); $sitelink = L10n::t('Please visit %s to approve or reject the suggestion.');
$tsitelink = sprintf($sitelink, $siteurl); $tsitelink = sprintf($sitelink, $siteurl);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>'); $hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
$itemlink = $params['link'];
} }
if ($params['type'] == NOTIFY_CONFIRM) { if ($params['type'] == NOTIFY_CONFIRM) {
if ($params['verb'] == ACTIVITY_FRIEND) { // mutual connection if ($params['verb'] == ACTIVITY_FRIEND) { // mutual connection
$itemlink = $params['link'];
$subject = L10n::t('[Friendica:Notify] Connection accepted'); $subject = L10n::t('[Friendica:Notify] Connection accepted');
$preamble = L10n::t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename); $preamble = L10n::t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
@ -334,8 +337,8 @@ function notification($params)
$sitelink = L10n::t('Please visit %s if you wish to make any changes to this relationship.'); $sitelink = L10n::t('Please visit %s if you wish to make any changes to this relationship.');
$tsitelink = sprintf($sitelink, $siteurl); $tsitelink = sprintf($sitelink, $siteurl);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>'); $hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
$itemlink = $params['link'];
} else { // ACTIVITY_FOLLOW } else { // ACTIVITY_FOLLOW
$itemlink = $params['link'];
$subject = L10n::t('[Friendica:Notify] Connection accepted'); $subject = L10n::t('[Friendica:Notify] Connection accepted');
$preamble = L10n::t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename); $preamble = L10n::t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
@ -351,13 +354,13 @@ function notification($params)
$sitelink = L10n::t('Please visit %s if you wish to make any changes to this relationship.'); $sitelink = L10n::t('Please visit %s if you wish to make any changes to this relationship.');
$tsitelink = sprintf($sitelink, $siteurl); $tsitelink = sprintf($sitelink, $siteurl);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>'); $hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
$itemlink = $params['link'];
} }
} }
if ($params['type'] == NOTIFY_SYSTEM) { if ($params['type'] == NOTIFY_SYSTEM) {
switch($params['event']) { switch($params['event']) {
case "SYSTEM_REGISTER_REQUEST": case "SYSTEM_REGISTER_REQUEST":
$itemlink = $params['link'];
$subject = L10n::t('[Friendica System Notify]') . ' ' . L10n::t('registration request'); $subject = L10n::t('[Friendica System Notify]') . ' ' . L10n::t('registration request');
$preamble = L10n::t('You\'ve received a registration request from \'%1$s\' at %2$s', $params['source_name'], $sitename); $preamble = L10n::t('You\'ve received a registration request from \'%1$s\' at %2$s', $params['source_name'], $sitename);
@ -375,7 +378,6 @@ function notification($params)
$sitelink = L10n::t('Please visit %s to approve or reject the request.'); $sitelink = L10n::t('Please visit %s to approve or reject the request.');
$tsitelink = sprintf($sitelink, $params['link']); $tsitelink = sprintf($sitelink, $params['link']);
$hsitelink = sprintf($sitelink, '<a href="'.$params['link'].'">'.$sitename.'</a><br><br>'); $hsitelink = sprintf($sitelink, '<a href="'.$params['link'].'">'.$sitename.'</a><br><br>');
$itemlink = $params['link'];
break; break;
case "SYSTEM_DB_UPDATE_FAIL": case "SYSTEM_DB_UPDATE_FAIL":
break; break;
@ -572,7 +574,7 @@ function notification($params)
$datarray['sitename'] = $sitename; $datarray['sitename'] = $sitename;
$datarray['siteurl'] = $siteurl; $datarray['siteurl'] = $siteurl;
$datarray['type'] = $params['type']; $datarray['type'] = $params['type'];
$datarray['parent'] = $params['parent']; $datarray['parent'] = $parent_id;
$datarray['source_name'] = $params['source_name']; $datarray['source_name'] = $params['source_name'];
$datarray['source_link'] = $params['source_link']; $datarray['source_link'] = $params['source_link'];
$datarray['source_photo'] = $params['source_photo']; $datarray['source_photo'] = $params['source_photo'];
@ -607,7 +609,7 @@ function notification($params)
'$source_name' => $datarray['source_name'], '$source_name' => $datarray['source_name'],
'$source_link' => $datarray['source_link'], '$source_link' => $datarray['source_link'],
'$source_photo' => $datarray['source_photo'], '$source_photo' => $datarray['source_photo'],
'$username' => $datarray['to_name'], '$username' => $datarray['username'],
'$hsitelink' => $datarray['hsitelink'], '$hsitelink' => $datarray['hsitelink'],
'$hitemlink' => $datarray['hitemlink'], '$hitemlink' => $datarray['hitemlink'],
'$thanks' => $datarray['thanks'], '$thanks' => $datarray['thanks'],
@ -628,7 +630,7 @@ function notification($params)
'$source_name' => $datarray['source_name'], '$source_name' => $datarray['source_name'],
'$source_link' => $datarray['source_link'], '$source_link' => $datarray['source_link'],
'$source_photo' => $datarray['source_photo'], '$source_photo' => $datarray['source_photo'],
'$username' => $datarray['to_name'], '$username' => $datarray['username'],
'$tsitelink' => $datarray['tsitelink'], '$tsitelink' => $datarray['tsitelink'],
'$titemlink' => $datarray['titemlink'], '$titemlink' => $datarray['titemlink'],
'$thanks' => $datarray['thanks'], '$thanks' => $datarray['thanks'],

View file

@ -33,6 +33,8 @@ function add_page_info_data($data, $no_photos = false) {
$data["type"] = "link"; $data["type"] = "link";
} }
$data["title"] = defaults($data, "title", "");
if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) { if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) {
return ""; return "";
} }
@ -47,19 +49,19 @@ function add_page_info_data($data, $no_photos = false) {
$text = "[attachment type='".$data["type"]."'"; $text = "[attachment type='".$data["type"]."'";
if ($data["text"] == "") { if (empty($data["text"])) {
$data["text"] = $data["title"]; $data["text"] = $data["title"];
} }
if ($data["text"] == "") { if (empty($data["text"])) {
$data["text"] = $data["url"]; $data["text"] = $data["url"];
} }
if ($data["url"] != "") { if (!empty($data["url"])) {
$text .= " url='".$data["url"]."'"; $text .= " url='".$data["url"]."'";
} }
if ($data["title"] != "") { if (!empty($data["title"])) {
$text .= " title='".$data["title"]."'"; $text .= " title='".$data["title"]."'";
} }
@ -427,7 +429,7 @@ function list_post_dates($uid, $wall) {
$start_month = DateTimeFormat::utc($dstart, 'Y-m-d'); $start_month = DateTimeFormat::utc($dstart, 'Y-m-d');
$end_month = DateTimeFormat::utc($dend, 'Y-m-d'); $end_month = DateTimeFormat::utc($dend, 'Y-m-d');
$str = day_translate(DateTimeFormat::utc($dnow, 'F')); $str = day_translate(DateTimeFormat::utc($dnow, 'F'));
if (!$ret[$dyear]) { if (empty($ret[$dyear])) {
$ret[$dyear] = []; $ret[$dyear] = [];
} }
$ret[$dyear][] = [$str, $end_month, $start_month]; $ret[$dyear][] = [$str, $end_month, $start_month];

View file

@ -643,13 +643,20 @@ function logger($msg, $level = 0) {
} }
$callers = debug_backtrace(); $callers = debug_backtrace();
if (count($callers) > 1) {
$function = $callers[1]['function'];
} else {
$function = '';
}
$logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
DateTimeFormat::utcNow(DateTimeFormat::ATOM), DateTimeFormat::utcNow(DateTimeFormat::ATOM),
$process_id, $process_id,
$LOGGER_LEVELS[$level], $LOGGER_LEVELS[$level],
basename($callers[0]['file']), basename($callers[0]['file']),
$callers[0]['line'], $callers[0]['line'],
$callers[1]['function'], $function,
$msg $msg
); );
@ -1280,7 +1287,8 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
]); ]);
} }
$id = end(explode('/', $the_url)); $url_parts = explode('/', $the_url);
$id = end($url_parts);
$as .= replace_macros(get_markup_template('video_top.tpl'), [ $as .= replace_macros(get_markup_template('video_top.tpl'), [
'$video' => [ '$video' => [
'id' => $id, 'id' => $id,
@ -1710,11 +1718,11 @@ function reltoabs($text, $base) {
* @return string * @return string
*/ */
function item_post_type($item) { function item_post_type($item) {
if (intval($item['event-id'])) { if (!empty($item['event-id'])) {
return L10n::t('event'); return L10n::t('event');
} elseif (strlen($item['resource-id'])) { } elseif (!empty($item['resource-id'])) {
return L10n::t('photo'); return L10n::t('photo');
} elseif (strlen($item['verb']) && $item['verb'] !== ACTIVITY_POST) { } elseif (!empty($item['verb']) && $item['verb'] !== ACTIVITY_POST) {
return L10n::t('activity'); return L10n::t('activity');
} elseif ($item['id'] != $item['parent']) { } elseif ($item['id'] != $item['parent']) {
return L10n::t('comment'); return L10n::t('comment');

View file

@ -128,7 +128,7 @@ if ((x($_GET,'zrl')) && $a->mode == App::MODE_NORMAL) {
// Valid profile links contain a path with "/profile/" and no query parameters // Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") && if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") &&
strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) { strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) {
if ($_SESSION["visitor_home"] != $_GET["zrl"]) { if (defaults($_SESSION, "visitor_home", "") != $_GET["zrl"]) {
$_SESSION['my_url'] = $_GET['zrl']; $_SESSION['my_url'] = $_GET['zrl'];
$_SESSION['authenticated'] = 0; $_SESSION['authenticated'] = 0;
} }

View file

@ -156,7 +156,7 @@ class ASN_BASE {
if (($length & ASN_LONG_LEN)==ASN_LONG_LEN){ if (($length & ASN_LONG_LEN)==ASN_LONG_LEN){
$tempLength = 0; $tempLength = 0;
for ($x=0; $x<($length & (ASN_LONG_LEN-1)); $x++){ for ($x=0; $x<($length & (ASN_LONG_LEN-1)); $x++){
$tempLength = ord($string[$p++]) + ($tempLength * 256); $tempLength = @ord($string[$p++]) + ($tempLength * 256);
} }
$length = $tempLength; $length = $tempLength;
} }

View file

@ -265,6 +265,8 @@ function dfrn_dispatch_private($user, $postdata)
// Set the user id. This is important if this is a public contact // Set the user id. This is important if this is a public contact
$importer['importer_uid'] = $user['uid']; $importer['importer_uid'] = $user['uid'];
$importer = array_merge($importer, $user);
logger('Importing post from ' . $msg['author'] . ' to ' . $user['nickname'] . ' with the private envelope.', LOGGER_DEBUG); logger('Importing post from ' . $msg['author'] . ' to ' . $user['nickname'] . ' with the private envelope.', LOGGER_DEBUG);
// Now we should be able to import it // Now we should be able to import it
@ -333,7 +335,8 @@ function dfrn_notify_content(App $a) {
); );
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
$status = 1; logger('No user data found for ' . $a->argv[1] . ' - SQL: ' . $sql_extra);
killme();
} }
logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DATA); logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DATA);

View file

@ -185,7 +185,7 @@ function dirfind_content(App $a, $prefix = "") {
$a->set_pager_itemspage($j->items_page); $a->set_pager_itemspage($j->items_page);
} }
if (count($j->results)) { if (!empty($j->results)) {
$id = 0; $id = 0;

View file

@ -140,29 +140,29 @@ function display_fetchauthor($a, $item)
if (!$skip) { if (!$skip) {
$author = ""; $author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches); preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
} }
preg_match('/author="(.*?)"/ism', $attributes, $matches); preg_match('/author="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
} }
$profile = ""; $profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches); preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$profiledata["url"] = $matches[1]; $profiledata["url"] = $matches[1];
} }
preg_match('/profile="(.*?)"/ism', $attributes, $matches); preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$profiledata["url"] = $matches[1]; $profiledata["url"] = $matches[1];
} }
$avatar = ""; $avatar = "";
preg_match("/avatar='(.*?)'/ism", $attributes, $matches); preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$profiledata["photo"] = $matches[1]; $profiledata["photo"] = $matches[1];
} }
preg_match('/avatar="(.*?)"/ism', $attributes, $matches); preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$profiledata["photo"] = $matches[1]; $profiledata["photo"] = $matches[1];
} }
$profiledata["nickname"] = $profiledata["name"]; $profiledata["nickname"] = $profiledata["name"];
@ -212,6 +212,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$item_parent_uri = $item['parent-uri']; $item_parent_uri = $item['parent-uri'];
} else { } else {
$item_id = (($a->argc > 2) ? $a->argv[2] : 0); $item_id = (($a->argc > 2) ? $a->argv[2] : 0);
$item_parent = $item_id;
if ($a->argc == 2) { if ($a->argc == 2) {
$item_parent = 0; $item_parent = 0;

View file

@ -23,7 +23,8 @@ function fetch_init(App $a)
$guid = $a->argv[2]; $guid = $a->argv[2];
// Fetch the item // Fetch the item
$fields = ['uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'app', 'location', 'coord', 'network']; $fields = ['uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'app', 'location', 'coord', 'network',
'event-id', 'resource-id', 'author-link', 'owner-link', 'attach'];
$condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]]; $condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
$item = Item::selectFirst($fields, $condition); $item = Item::selectFirst($fields, $condition);
if (!DBM::is_result($item)) { if (!DBM::is_result($item)) {

View file

@ -219,10 +219,10 @@ function item_post(App $a) {
$str_contact_deny = $user['deny_cid']; $str_contact_deny = $user['deny_cid'];
} else { } else {
// use the posted permissions // use the posted permissions
$str_group_allow = perms2str($_REQUEST['group_allow']); $str_group_allow = perms2str(defaults($_REQUEST, 'group_allow', ''));
$str_contact_allow = perms2str($_REQUEST['contact_allow']); $str_contact_allow = perms2str(defaults($_REQUEST, 'contact_allow', ''));
$str_group_deny = perms2str($_REQUEST['group_deny']); $str_group_deny = perms2str(defaults($_REQUEST, 'group_deny', ''));
$str_contact_deny = perms2str($_REQUEST['contact_deny']); $str_contact_deny = perms2str(defaults($_REQUEST, 'contact_deny', ''));
} }
$title = notags(trim(defaults($_REQUEST, 'title' , ''))); $title = notags(trim(defaults($_REQUEST, 'title' , '')));
@ -245,7 +245,6 @@ function item_post(App $a) {
// If this is a comment, set the permissions from the parent. // If this is a comment, set the permissions from the parent.
if ($parent_item) { if ($parent_item) {
// for non native networks use the network of the original post as network of the item // for non native networks use the network of the original post as network of the item
if (($parent_item['network'] != NETWORK_DIASPORA) if (($parent_item['network'] != NETWORK_DIASPORA)
&& ($parent_item['network'] != NETWORK_OSTATUS) && ($parent_item['network'] != NETWORK_OSTATUS)
@ -651,16 +650,18 @@ function item_post(App $a) {
$conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]); $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]);
if (DBM::is_result($conversation)) { if (DBM::is_result($conversation)) {
if ($r['conversation-uri'] != '') { if ($conversation['conversation-uri'] != '') {
$datarray['conversation-uri'] = $conversation['conversation-uri']; $datarray['conversation-uri'] = $conversation['conversation-uri'];
} }
if ($r['conversation-href'] != '') { if ($conversation['conversation-href'] != '') {
$datarray['conversation-href'] = $conversation['conversation-href']; $datarray['conversation-href'] = $conversation['conversation-href'];
} }
} }
if ($orig_post) { if ($orig_post) {
$datarray['edit'] = true; $datarray['edit'] = true;
} else {
$datarray['edit'] = false;
} }
// Check for hashtags in the body and repair or add hashtag links // Check for hashtags in the body and repair or add hashtag links
@ -674,6 +675,9 @@ function item_post(App $a) {
// We set the datarray ID to -1 because in preview mode the dataray // We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID. // doesn't have an ID.
$datarray["id"] = -1; $datarray["id"] = -1;
$datarray["item_id"] = -1;
$datarray["author-network"] = NETWORK_DFRN;
$o = conversation($a,[array_merge($contact_record,$datarray)],'search', false, true); $o = conversation($a,[array_merge($contact_record,$datarray)],'search', false, true);
logger('preview: ' . $o); logger('preview: ' . $o);
echo json_encode(['preview' => $o]); echo json_encode(['preview' => $o]);

View file

@ -118,7 +118,7 @@ function message_content(App $a)
} }
// Check if we should do HTML-based delete confirmation // Check if we should do HTML-based delete confirmation
if ($_REQUEST['confirm']) { if (!empty($_REQUEST['confirm'])) {
// <form> can't take arguments in its "action" parameter // <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs // so add any arguments as hidden inputs
$query = explode_querystring($a->query_string); $query = explode_querystring($a->query_string);
@ -143,7 +143,7 @@ function message_content(App $a)
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if ($_REQUEST['canceled']) { if (!empty($_REQUEST['canceled'])) {
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
} }
@ -308,8 +308,10 @@ function message_content(App $a)
WHERE `mail`.`uid` = %d $sql_extra ORDER BY `mail`.`created` ASC", WHERE `mail`.`uid` = %d $sql_extra ORDER BY `mail`.`created` ASC",
intval(local_user()) intval(local_user())
); );
} else {
$messages = false;
} }
if (!count($messages)) { if (!DBM::is_result($messages)) {
notice(L10n::t('Message not available.') . EOL); notice(L10n::t('Message not available.') . EOL);
return $o; return $o;
} }

View file

@ -833,7 +833,7 @@ function networkThreadedView(App $a, $update, $parent)
$top_limit = DateTimeFormat::utcNow(); $top_limit = DateTimeFormat::utcNow();
} }
$items = dba::p("SELECT `item`.`parent-uri` AS `uri`, 0 AS `item_id`, `item`.$ordering AS `order_date` FROM `item` $items = dba::p("SELECT `item`.`parent-uri` AS `uri`, 0 AS `item_id`, `item`.$ordering AS `order_date`, `author`.`url` AS `author-link` FROM `item`
STRAIGHT_JOIN (SELECT `oid` FROM `term` WHERE `term` IN STRAIGHT_JOIN (SELECT `oid` FROM `term` WHERE `term` IN
(SELECT SUBSTR(`term`, 2) FROM `search` WHERE `uid` = ? AND `term` LIKE '#%') AND `otype` = ? AND `type` = ? AND `uid` = 0) AS `term` (SELECT SUBSTR(`term`, 2) FROM `search` WHERE `uid` = ? AND `term` LIKE '#%') AND `otype` = ? AND `type` = ? AND `uid` = 0) AS `term`
ON `item`.`id` = `term`.`oid` ON `item`.`id` = `term`.`oid`

View file

@ -79,6 +79,7 @@ function notifications_content(App $a)
// Get the nav tabs for the notification pages // Get the nav tabs for the notification pages
$tabs = $nm->getTabs(); $tabs = $nm->getTabs();
$notif_content = []; $notif_content = [];
$notif_nocontent = '';
// Notification results per page // Notification results per page
$perpage = 20; $perpage = 20;
@ -184,7 +185,11 @@ function notifications_content(App $a)
$dfrn_tpl = get_markup_template('netfriend.tpl'); $dfrn_tpl = get_markup_template('netfriend.tpl');
$knowyou = ''; $knowyou = '';
$lbl_knowyou = '';
$dfrn_text = ''; $dfrn_text = '';
$helptext = '';
$helptext2 = '';
$helptext3 = '';
if ($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) { if ($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
if ($it['network'] === NETWORK_DFRN) { if ($it['network'] === NETWORK_DFRN) {

View file

@ -39,7 +39,9 @@ function photo_init(App $a)
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header('HTTP/1.1 304 Not Modified'); header('HTTP/1.1 304 Not Modified');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']); if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']);
}
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT"); header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
header("Cache-Control: max-age=31536000"); header("Cache-Control: max-age=31536000");
if (function_exists('header_remove')) { if (function_exists('header_remove')) {

View file

@ -101,6 +101,8 @@ function photos_init(App $a) {
if (local_user() && $a->data['user']['uid'] == local_user()) { if (local_user() && $a->data['user']['uid'] == local_user()) {
$can_post = true; $can_post = true;
} else {
$can_post = false;
} }
if ($ret['success']) { if ($ret['success']) {
@ -950,6 +952,7 @@ function photos_content(App $a)
$contact = null; $contact = null;
$remote_contact = false; $remote_contact = false;
$contact_id = 0; $contact_id = 0;
$edit = false;
$owner_uid = $a->data['user']['uid']; $owner_uid = $a->data['user']['uid'];

View file

@ -278,6 +278,7 @@ function ping_init(App $a)
if (DBM::is_result($intros)) { if (DBM::is_result($intros)) {
foreach ($intros as $intro) { foreach ($intros as $intro) {
$notif = [ $notif = [
'id' => 0,
'href' => System::baseUrl() . '/notifications/intros/' . $intro['id'], 'href' => System::baseUrl() . '/notifications/intros/' . $intro['id'],
'name' => $intro['name'], 'name' => $intro['name'],
'url' => $intro['url'], 'url' => $intro['url'],
@ -293,6 +294,7 @@ function ping_init(App $a)
if (DBM::is_result($mails)) { if (DBM::is_result($mails)) {
foreach ($mails as $mail) { foreach ($mails as $mail) {
$notif = [ $notif = [
'id' => 0,
'href' => System::baseUrl() . '/message/' . $mail['id'], 'href' => System::baseUrl() . '/message/' . $mail['id'],
'name' => $mail['from-name'], 'name' => $mail['from-name'],
'url' => $mail['from-url'], 'url' => $mail['from-url'],
@ -308,6 +310,7 @@ function ping_init(App $a)
if (DBM::is_result($regs)) { if (DBM::is_result($regs)) {
foreach ($regs as $reg) { foreach ($regs as $reg) {
$notif = [ $notif = [
'id' => 0,
'href' => System::baseUrl() . '/admin/users/', 'href' => System::baseUrl() . '/admin/users/',
'name' => $reg['name'], 'name' => $reg['name'],
'url' => $reg['url'], 'url' => $reg['url'],

View file

@ -23,9 +23,9 @@ function poco_init(App $a) {
if ($a->argc > 1) { if ($a->argc > 1) {
$user = notags(trim($a->argv[1])); $user = notags(trim($a->argv[1]));
} }
if (! x($user)) { if (empty($user)) {
$c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1"); $c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
if (! DBM::is_result($c)) { if (!DBM::is_result($c)) {
System::httpExit(401); System::httpExit(401);
} }
$system_mode = true; $system_mode = true;

View file

@ -282,6 +282,8 @@ function profile_content(App $a, $update = 0)
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
$sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id']))); $sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
} else {
$sql_extra3 = "";
} }
// check if we serve a mobile device and get the user settings // check if we serve a mobile device and get the user settings

View file

@ -74,6 +74,11 @@ function search_init(App $a) {
dba::delete('search', ['uid' => local_user(), 'term' => $search]); dba::delete('search', ['uid' => local_user(), 'term' => $search]);
} }
/// @todo Check if there is a case at all that "aside" is prefilled here
if (!isset($a->page['aside'])) {
$a->page['aside'] = '';
}
$a->page['aside'] .= search_saved_searches(); $a->page['aside'] .= search_saved_searches();
} else { } else {

View file

@ -12,14 +12,14 @@ function xrd_init(App $a)
{ {
if ($a->argv[0] == 'xrd') { if ($a->argv[0] == 'xrd') {
$uri = urldecode(notags(trim($_GET['uri']))); $uri = urldecode(notags(trim($_GET['uri'])));
if ($_SERVER['HTTP_ACCEPT'] == 'application/jrd+json') { if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/jrd+json') {
$mode = 'json'; $mode = 'json';
} else { } else {
$mode = 'xml'; $mode = 'xml';
} }
} else { } else {
$uri = urldecode(notags(trim($_GET['resource']))); $uri = urldecode(notags(trim($_GET['resource'])));
if ($_SERVER['HTTP_ACCEPT'] == 'application/xrd+xml') { if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/xrd+xml') {
$mode = 'xml'; $mode = 'xml';
} else { } else {
$mode = 'json'; $mode = 'json';

View file

@ -174,7 +174,21 @@ class App
$this->callstack['parser'] = []; $this->callstack['parser'] = [];
$this->config = []; $this->config = [];
$this->page = [];
$this->page = [
'aside' => '',
'bottom' => '',
'content' => '',
'end' => '',
'footer' => '',
'htmlhead' => '',
'nav' => '',
'page_title' => '',
'right_aside' => '',
'template' => '',
'title' => ''
];
$this->pager = []; $this->pager = [];
$this->query_string = ''; $this->query_string = '';
@ -1154,7 +1168,12 @@ class App
} }
} }
$user_theme = defaults($_SESSION, 'theme', $system_theme); if (!empty($_SESSION)) {
$user_theme = defaults($_SESSION, 'theme', $system_theme);
} else {
$user_theme = $system_theme;
}
// Specific mobile theme override // Specific mobile theme override
if (($this->is_mobile || $this->is_tablet) && defaults($_SESSION, 'show-mobile', true)) { if (($this->is_mobile || $this->is_tablet) && defaults($_SESSION, 'show-mobile', true)) {
$system_mobile_theme = Config::get('system', 'mobile-theme'); $system_mobile_theme = Config::get('system', 'mobile-theme');

View file

@ -108,7 +108,7 @@ class OEmbed
$txt = '{"type":"error"}'; $txt = '{"type":"error"}';
} else { //save in cache } else { //save in cache
$j = json_decode($txt); $j = json_decode($txt);
if ($j->type != "error") { if (!empty($j->type) && $j->type != "error") {
dba::insert('oembed', [ dba::insert('oembed', [
'url' => normalise_link($embedurl), 'url' => normalise_link($embedurl),
'maxwidth' => $a->videowidth, 'maxwidth' => $a->videowidth,

View file

@ -540,7 +540,7 @@ class BBCode extends BaseObject
private static function convertAttachment($return, $simplehtml = false, $tryoembed = true) private static function convertAttachment($return, $simplehtml = false, $tryoembed = true)
{ {
$data = self::getAttachmentData($return); $data = self::getAttachmentData($return);
if (!$data) { if (empty($data) || empty($data["url"])) {
return $return; return $return;
} }
@ -549,7 +549,7 @@ class BBCode extends BaseObject
$data["title"] = str_replace(["http://", "https://"], "", $data["title"]); $data["title"] = str_replace(["http://", "https://"], "", $data["title"]);
} }
if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && ($data["image"] != "")) { if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && !empty($data["image"])) {
$data["preview"] = $data["image"]; $data["preview"] = $data["image"];
$data["image"] = ""; $data["image"] = "";
} }
@ -567,6 +567,8 @@ class BBCode extends BaseObject
throw new Exception('OEmbed is disabled for this attachment.'); throw new Exception('OEmbed is disabled for this attachment.');
} }
} catch (Exception $e) { } catch (Exception $e) {
$data["title"] = defaults($data, 'title', $data['url']);
if ($simplehtml != 4) { if ($simplehtml != 4) {
$return = sprintf('<div class="type-%s">', $data["type"]); $return = sprintf('<div class="type-%s">', $data["type"]);
} }

View file

@ -264,7 +264,7 @@ class Widget
$cid = $zcid = 0; $cid = $zcid = 0;
if (is_array($_SESSION['remote'])) { if (!empty($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $visitor) { foreach ($_SESSION['remote'] as $visitor) {
if ($visitor['uid'] == $profile_uid) { if ($visitor['uid'] == $profile_uid) {
$cid = $visitor['cid']; $cid = $visitor['cid'];

View file

@ -409,7 +409,7 @@ class DBStructure
// Compare the field structure field by field // Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) { foreach ($structure["fields"] AS $fieldname => $parameters) {
// Compare the field definition // Compare the field definition
$field_definition = $database[$name]["fields"][$fieldname]; $field_definition = defaults($database[$name]["fields"], $fieldname, ['Collation' => '']);
// Define the default collation if not given // Define the default collation if not given
if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) { if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) {

View file

@ -475,34 +475,34 @@ class Contact extends BaseObject
$profile = $default; $profile = $default;
} }
if (($profile["photo"] == "") && isset($default["photo"])) { if (empty($profile["photo"]) && isset($default["photo"])) {
$profile["photo"] = $default["photo"]; $profile["photo"] = $default["photo"];
} }
if (($profile["name"] == "") && isset($default["name"])) { if (empty($profile["name"]) && isset($default["name"])) {
$profile["name"] = $default["name"]; $profile["name"] = $default["name"];
} }
if (($profile["network"] == "") && isset($default["network"])) { if (empty($profile["network"]) && isset($default["network"])) {
$profile["network"] = $default["network"]; $profile["network"] = $default["network"];
} }
if (($profile["thumb"] == "") && isset($profile["photo"])) { if (empty($profile["thumb"]) && isset($profile["photo"])) {
$profile["thumb"] = $profile["photo"]; $profile["thumb"] = $profile["photo"];
} }
if (($profile["micro"] == "") && isset($profile["thumb"])) { if (empty($profile["micro"]) && isset($profile["thumb"])) {
$profile["micro"] = $profile["thumb"]; $profile["micro"] = $profile["thumb"];
} }
if ((($profile["addr"] == "") || ($profile["name"] == "")) && ($profile["gid"] != 0) if ((empty($profile["addr"]) || empty($profile["name"])) && (defaults($profile, "gid", 0) != 0)
&& in_array($profile["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && in_array($profile["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])
) { ) {
Worker::add(PRIORITY_LOW, "UpdateGContact", $profile["gid"]); Worker::add(PRIORITY_LOW, "UpdateGContact", $profile["gid"]);
} }
// Show contact details of Diaspora contacts only if connected // Show contact details of Diaspora contacts only if connected
if (($profile["cid"] == 0) && ($profile["network"] == NETWORK_DIASPORA)) { if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == NETWORK_DIASPORA)) {
$profile["location"] = ""; $profile["location"] = "";
$profile["about"] = ""; $profile["about"] = "";
$profile["gender"] = ""; $profile["gender"] = "";
@ -596,7 +596,7 @@ class Contact extends BaseObject
$uid = local_user(); $uid = local_user();
} }
if ($contact['uid'] != $uid) { if (empty($contact['uid']) || ($contact['uid'] != $uid)) {
if ($uid == 0) { if ($uid == 0) {
$profile_link = self::magicLink($contact['url']); $profile_link = self::magicLink($contact['url']);
$menu = ['profile' => [L10n::t('View Profile'), $profile_link, true]]; $menu = ['profile' => [L10n::t('View Profile'), $profile_link, true]];
@ -1533,8 +1533,12 @@ class Contact extends BaseObject
$contact_record = [ $contact_record = [
'id' => dba::lastInsertId(), 'id' => dba::lastInsertId(),
'network' => NETWORK_OSTATUS 'network' => NETWORK_OSTATUS,
'name' => $name,
'url' => $url,
'photo' => $photo
]; ];
Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true); Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true);
/// @TODO Encapsulate this into a function/method /// @TODO Encapsulate this into a function/method

View file

@ -787,11 +787,11 @@ class GContact
// Bugfix: We had an error in the storing of keywords which lead to the "0" // Bugfix: We had an error in the storing of keywords which lead to the "0"
// This value is still transmitted via poco. // This value is still transmitted via poco.
if ($contact["keywords"] == "0") { if (!empty($contact["keywords"]) && ($contact["keywords"] == "0")) {
unset($contact["keywords"]); unset($contact["keywords"]);
} }
if ($public_contact[0]["keywords"] == "0") { if (!empty($public_contact[0]["keywords"]) && ($public_contact[0]["keywords"] == "0")) {
$public_contact[0]["keywords"] = ""; $public_contact[0]["keywords"] = "";
} }
@ -996,7 +996,7 @@ class GContact
$statistics = json_decode($result["body"]); $statistics = json_decode($result["body"]);
if (is_object($statistics->config)) { if (!empty($statistics->config)) {
if ($statistics->config->instance_with_ssl) { if ($statistics->config->instance_with_ssl) {
$server = "https://"; $server = "https://";
} else { } else {
@ -1006,8 +1006,7 @@ class GContact
$server .= $statistics->config->instance_address; $server .= $statistics->config->instance_address;
$hostname = $statistics->config->instance_address; $hostname = $statistics->config->instance_address;
} else { } elseif (!empty($statistics)) {
/// @TODO is_object() above means here no object, still $statistics is being used as object
if ($statistics->instance_with_ssl) { if ($statistics->instance_with_ssl) {
$server = "https://"; $server = "https://";
} else { } else {
@ -1019,7 +1018,7 @@ class GContact
$hostname = $statistics->instance_address; $hostname = $statistics->instance_address;
} }
if (is_object($statistics->users)) { if (!empty($statistics->users)) {
foreach ($statistics->users as $nick => $user) { foreach ($statistics->users as $nick => $user) {
$profile_url = $server."/".$user->nickname; $profile_url = $server."/".$user->nickname;
@ -1027,9 +1026,13 @@ class GContact
"name" => $user->fullname, "name" => $user->fullname,
"addr" => $user->nickname."@".$hostname, "addr" => $user->nickname."@".$hostname,
"nick" => $user->nickname, "nick" => $user->nickname,
"about" => $user->bio,
"network" => NETWORK_OSTATUS, "network" => NETWORK_OSTATUS,
"photo" => System::baseUrl()."/images/person-175.jpg"]; "photo" => System::baseUrl()."/images/person-175.jpg"];
if (isset($user->bio)) {
$contact["about"] = $user->bio;
}
self::getId($contact); self::getId($contact);
} }
} }

View file

@ -726,21 +726,21 @@ class Item extends BaseObject
$author_owner_fields = ['author-name', 'author-avatar', 'author-link', 'owner-name', 'owner-avatar', 'owner-link']; $author_owner_fields = ['author-name', 'author-avatar', 'author-link', 'owner-name', 'owner-avatar', 'owner-link'];
foreach ($author_owner_fields as $field) { foreach ($author_owner_fields as $field) {
if (isset($fields[$field])) { if (array_key_exists($field, $fields)) {
$fields[$field] = null; $fields[$field] = null;
} }
} }
if (array_key_exists('tag', $fields)) { if (array_key_exists('tag', $fields)) {
$tags = $fields['tag']; $tags = $fields['tag'];
unset($fields['tag']); $fields['tag'] = null;
} else { } else {
$tags = ''; $tags = '';
} }
if (array_key_exists('file', $fields)) { if (array_key_exists('file', $fields)) {
$files = $fields['file']; $files = $fields['file'];
unset($fields['file']); $fields['file'] = null;
} else { } else {
$files = ''; $files = '';
} }
@ -1329,12 +1329,7 @@ class Item extends BaseObject
if ($item['network'] == NETWORK_PHANTOM) { if ($item['network'] == NETWORK_PHANTOM) {
logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG); logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG);
$contact = Contact::getDetailsByURL($item['author-link'], $item['uid']); $item['network'] = NETWORK_DFRN;
if (!empty($contact['network'])) {
$item['network'] = $contact["network"];
} else {
$item['network'] = NETWORK_DFRN;
}
logger("Set network to " . $item["network"] . " for " . $item["uri"], LOGGER_DEBUG); logger("Set network to " . $item["network"] . " for " . $item["uri"], LOGGER_DEBUG);
} }
@ -1505,7 +1500,11 @@ class Item extends BaseObject
put_item_in_cache($item); put_item_in_cache($item);
if ($notify) { if ($notify) {
$item['edit'] = false;
$item['parent'] = $parent_id;
Addon::callHooks('post_local', $item); Addon::callHooks('post_local', $item);
unset($item['edit']);
unset($item['parent']);
} else { } else {
Addon::callHooks('post_remote', $item); Addon::callHooks('post_remote', $item);
} }
@ -1896,6 +1895,8 @@ class Item extends BaseObject
return; return;
} }
$origin = $item['origin'];
unset($item['id']); unset($item['id']);
unset($item['parent']); unset($item['parent']);
unset($item['mention']); unset($item['mention']);
@ -1918,7 +1919,7 @@ class Item extends BaseObject
$parents = self::select(['uid', 'origin'], ["`uri` = ? AND `uid` != 0", $item['parent-uri']]); $parents = self::select(['uid', 'origin'], ["`uri` = ? AND `uid` != 0", $item['parent-uri']]);
while ($parent = dba::fetch($parents)) { while ($parent = dba::fetch($parents)) {
$users[$parent['uid']] = $parent['uid']; $users[$parent['uid']] = $parent['uid'];
if ($parent['origin'] && !$item['origin']) { if ($parent['origin'] && !$origin) {
$origin_uid = $parent['uid']; $origin_uid = $parent['uid'];
} }
} }
@ -2449,7 +2450,7 @@ class Item extends BaseObject
} }
// Prevent the forwarding of posts that are forwarded // Prevent the forwarding of posts that are forwarded
if ($datarray["extid"] == NETWORK_DFRN) { if (!empty($datarray["extid"]) && ($datarray["extid"] == NETWORK_DFRN)) {
logger('Already forwarded', LOGGER_DEBUG); logger('Already forwarded', LOGGER_DEBUG);
return false; return false;
} }
@ -2940,6 +2941,7 @@ class Item extends BaseObject
'type' => 'activity', 'type' => 'activity',
'wall' => $item['wall'], 'wall' => $item['wall'],
'origin' => 1, 'origin' => 1,
'network' => NETWORK_DFRN,
'gravity' => GRAVITY_ACTIVITY, 'gravity' => GRAVITY_ACTIVITY,
'parent' => $item['id'], 'parent' => $item['id'],
'parent-uri' => $item['uri'], 'parent-uri' => $item['uri'],

View file

@ -40,11 +40,11 @@ class Profile
{ {
$location = ''; $location = '';
if ($profile['locality']) { if (!empty($profile['locality'])) {
$location .= $profile['locality']; $location .= $profile['locality'];
} }
if ($profile['region'] && ($profile['locality'] != $profile['region'])) { if (!empty($profile['region']) && (defaults($profile, 'locality', '') != $profile['region'])) {
if ($location) { if ($location) {
$location .= ', '; $location .= ', ';
} }
@ -52,7 +52,7 @@ class Profile
$location .= $profile['region']; $location .= $profile['region'];
} }
if ($profile['country-name']) { if (!empty($profile['country-name'])) {
if ($location) { if ($location) {
$location .= ', '; $location .= ', ';
} }
@ -307,6 +307,8 @@ class Profile
$connect = false; $connect = false;
} }
$profile_url = '';
// Is the local user already connected to that user? // Is the local user already connected to that user?
if ($connect && local_user()) { if ($connect && local_user()) {
if (isset($profile['url'])) { if (isset($profile['url'])) {
@ -437,9 +439,9 @@ class Profile
'fullname' => $profile['name'], 'fullname' => $profile['name'],
'firstname' => $firstname, 'firstname' => $firstname,
'lastname' => $lastname, 'lastname' => $lastname,
'photo300' => $profile['contact_photo'], 'photo300' => defaults($profile, 'contact_photo', ''),
'photo100' => $profile['contact_thumb'], 'photo100' => defaults($profile, 'contact_thumb', ''),
'photo50' => $profile['contact_micro'], 'photo50' => defaults($profile, 'contact_micro', ''),
]; ];
} else { } else {
$diaspora = false; $diaspora = false;
@ -497,7 +499,7 @@ class Profile
$p['photo'] = proxy_url($p['photo'], false, PROXY_SIZE_SMALL); $p['photo'] = proxy_url($p['photo'], false, PROXY_SIZE_SMALL);
} }
$p['url'] = Contact::magicLink($p['url']); $p['url'] = Contact::magicLink(defaults($p, 'url', $profile_url));
$tpl = get_markup_template('profile_vcard.tpl'); $tpl = get_markup_template('profile_vcard.tpl');
$o .= replace_macros($tpl, [ $o .= replace_macros($tpl, [

View file

@ -248,7 +248,7 @@ class Login extends BaseModule
// Make sure to refresh the last login time for the user if the user // Make sure to refresh the last login time for the user if the user
// stays logged in for a long time, e.g. with "Remember Me" // stays logged in for a long time, e.g. with "Remember Me"
$login_refresh = false; $login_refresh = false;
if (!x($_SESSION['last_login_date'])) { if (empty($_SESSION['last_login_date'])) {
$_SESSION['last_login_date'] = DateTimeFormat::utcNow(); $_SESSION['last_login_date'] = DateTimeFormat::utcNow();
} }
if (strcmp(DateTimeFormat::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) { if (strcmp(DateTimeFormat::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) {

View file

@ -13,7 +13,7 @@ use dba;
/** /**
* Magic Auth (remote authentication) module. * Magic Auth (remote authentication) module.
* *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/Zotlabs/Module/Magic.php * Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/Zotlabs/Module/Magic.php
*/ */
class Magic extends BaseModule class Magic extends BaseModule
@ -31,7 +31,7 @@ class Magic extends BaseModule
$test = ((x($_REQUEST, 'test')) ? intval($_REQUEST['test']) : 0); $test = ((x($_REQUEST, 'test')) ? intval($_REQUEST['test']) : 0);
$owa = ((x($_REQUEST, 'owa')) ? intval($_REQUEST['owa']) : 0); $owa = ((x($_REQUEST, 'owa')) ? intval($_REQUEST['owa']) : 0);
// NOTE: I guess $dest isn't just the profile url (could be also // NOTE: I guess $dest isn't just the profile url (could be also
// other profile pages e.g. photo). We need to find a solution // other profile pages e.g. photo). We need to find a solution
// to be able to redirct to other pages than the contact profile. // to be able to redirct to other pages than the contact profile.
$cid = Contact::getIdForURL($dest); $cid = Contact::getIdForURL($dest);
@ -48,8 +48,8 @@ class Magic extends BaseModule
$contact = dba::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]); $contact = dba::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
// Redirect if the contact is already authenticated on this site. // Redirect if the contact is already authenticated on this site.
if (array_key_exists('id', $a->contact) && strpos($contact['nurl'], normalise_link(self::getApp()->get_baseurl())) !== false) { if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], normalise_link(self::getApp()->get_baseurl())) !== false) {
if($test) { if ($test) {
$ret['success'] = true; $ret['success'] = true;
$ret['message'] .= 'Local site - you are already authenticated.' . EOL; $ret['message'] .= 'Local site - you are already authenticated.' . EOL;
return $ret; return $ret;
@ -111,7 +111,7 @@ class Magic extends BaseModule
} }
} }
if($test) { if ($test) {
$ret['message'] = 'Not authenticated or invalid arguments' . EOL; $ret['message'] = 'Not authenticated or invalid arguments' . EOL;
return $ret; return $ret;
} }

View file

@ -697,6 +697,14 @@ class Probe
} }
} }
if (empty($result["network"])) {
$result["network"] = NETWORK_PHANTOM;
}
if (empty($result["url"])) {
$result["url"] = $uri;
}
logger($uri." is ".$result["network"], LOGGER_DEBUG); logger($uri." is ".$result["network"], LOGGER_DEBUG);
if (empty($result["baseurl"])) { if (empty($result["baseurl"])) {
@ -980,7 +988,7 @@ class Probe
} }
} }
if (is_array($webfinger["aliases"])) { if (!empty($webfinger["aliases"]) && is_array($webfinger["aliases"])) {
foreach ($webfinger["aliases"] as $alias) { foreach ($webfinger["aliases"] as $alias) {
if (normalise_link($alias) != normalise_link($data["url"]) && ! strstr($alias, "@")) { if (normalise_link($alias) != normalise_link($data["url"]) && ! strstr($alias, "@")) {
$data["alias"] = $alias; $data["alias"] = $alias;
@ -990,7 +998,7 @@ class Probe
} }
} }
if (substr($webfinger["subject"], 0, 5) == "acct:") { if (!empty($webfinger["subject"]) && (substr($webfinger["subject"], 0, 5) == "acct:")) {
$data["addr"] = substr($webfinger["subject"], 5); $data["addr"] = substr($webfinger["subject"], 5);
} }
@ -1049,13 +1057,17 @@ class Probe
return false; return false;
} }
if (!isset($data["baseurl"])) {
$data["baseurl"] = "";
}
if ($vcards->length > 0) { if ($vcards->length > 0) {
$vcard = $vcards->item(0); $vcard = $vcards->item(0);
// We have to discard the guid from the hcard in favour of the guid from lrdd // We have to discard the guid from the hcard in favour of the guid from lrdd
// Reason: Hubzilla doesn't use the value "uid" in the hcard like Diaspora does. // Reason: Hubzilla doesn't use the value "uid" in the hcard like Diaspora does.
$search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' uid ')]", $vcard); // */ $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' uid ')]", $vcard); // */
if (($search->length > 0) && ($data["guid"] == "")) { if (($search->length > 0) && empty($data["guid"])) {
$data["guid"] = $search->item(0)->nodeValue; $data["guid"] = $search->item(0)->nodeValue;
} }
@ -1089,21 +1101,23 @@ class Probe
} }
$avatar = []; $avatar = [];
$photos = $xpath->query("//*[contains(concat(' ', @class, ' '), ' photo ') or contains(concat(' ', @class, ' '), ' avatar ')]", $vcard); // */ if (!empty($vcard)) {
foreach ($photos as $photo) { $photos = $xpath->query("//*[contains(concat(' ', @class, ' '), ' photo ') or contains(concat(' ', @class, ' '), ' avatar ')]", $vcard); // */
$attr = []; foreach ($photos as $photo) {
foreach ($photo->attributes as $attribute) { $attr = [];
$attr[$attribute->name] = trim($attribute->value); foreach ($photo->attributes as $attribute) {
} $attr[$attribute->name] = trim($attribute->value);
}
if (isset($attr["src"]) && isset($attr["width"])) { if (isset($attr["src"]) && isset($attr["width"])) {
$avatar[$attr["width"]] = $attr["src"]; $avatar[$attr["width"]] = $attr["src"];
} }
// We don't have a width. So we just take everything that we got. // We don't have a width. So we just take everything that we got.
// This is a Hubzilla workaround which doesn't send a width. // This is a Hubzilla workaround which doesn't send a width.
if ((sizeof($avatar) == 0) && !empty($attr["src"])) { if ((sizeof($avatar) == 0) && !empty($attr["src"])) {
$avatar[] = $attr["src"]; $avatar[] = $attr["src"];
}
} }
} }
@ -1177,7 +1191,7 @@ class Probe
return false; return false;
} }
if (is_array($webfinger["aliases"])) { if (!empty($webfinger["aliases"]) && is_array($webfinger["aliases"])) {
foreach ($webfinger["aliases"] as $alias) { foreach ($webfinger["aliases"] as $alias) {
if (normalise_link($alias) != normalise_link($data["url"]) && ! strstr($alias, "@")) { if (normalise_link($alias) != normalise_link($data["url"]) && ! strstr($alias, "@")) {
$data["alias"] = $alias; $data["alias"] = $alias;
@ -1207,7 +1221,9 @@ class Probe
$data["network"] = NETWORK_DIASPORA; $data["network"] = NETWORK_DIASPORA;
// The Diaspora handle must always be lowercase // The Diaspora handle must always be lowercase
$data["addr"] = strtolower($data["addr"]); if (!empty($data["addr"])) {
$data["addr"] = strtolower($data["addr"]);
}
// We have to overwrite the detected value for "notify" since Hubzilla doesn't send it // We have to overwrite the detected value for "notify" since Hubzilla doesn't send it
$data["notify"] = $data["baseurl"] . "/receive/users/" . $data["guid"]; $data["notify"] = $data["baseurl"] . "/receive/users/" . $data["guid"];
@ -1231,7 +1247,7 @@ class Probe
{ {
$data = []; $data = [];
if (is_array($webfinger["aliases"])) { if (!empty($webfinger["aliases"]) && is_array($webfinger["aliases"])) {
foreach ($webfinger["aliases"] as $alias) { foreach ($webfinger["aliases"] as $alias) {
if (strstr($alias, "@") && !strstr(normalise_link($alias), "http://")) { if (strstr($alias, "@") && !strstr(normalise_link($alias), "http://")) {
$data["addr"] = str_replace('acct:', '', $alias); $data["addr"] = str_replace('acct:', '', $alias);
@ -1239,7 +1255,7 @@ class Probe
} }
} }
if (is_string($webfinger["subject"]) && strstr($webfinger["subject"], "@") if (!empty($webfinger["subject"]) && strstr($webfinger["subject"], "@")
&& !strstr(normalise_link($webfinger["subject"]), "http://") && !strstr(normalise_link($webfinger["subject"]), "http://")
) { ) {
$data["addr"] = str_replace('acct:', '', $webfinger["subject"]); $data["addr"] = str_replace('acct:', '', $webfinger["subject"]);
@ -1304,32 +1320,35 @@ class Probe
return false; return false;
} }
$feed = $ret['body']; $feed = $ret['body'];
$dummy1 = null;
$dummy2 = null;
$dummy2 = null;
$feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true); $feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true);
if (!$feed_data) { if (!$feed_data) {
return false; return false;
} }
if ($feed_data["header"]["author-name"] != "") { if (!empty($feed_data["header"]["author-name"])) {
$data["name"] = $feed_data["header"]["author-name"]; $data["name"] = $feed_data["header"]["author-name"];
} }
if ($feed_data["header"]["author-nick"] != "") { if (!empty($feed_data["header"]["author-nick"])) {
$data["nick"] = $feed_data["header"]["author-nick"]; $data["nick"] = $feed_data["header"]["author-nick"];
} }
if ($feed_data["header"]["author-avatar"] != "") { if (!empty($feed_data["header"]["author-avatar"])) {
$data["photo"] = self::fixAvatar($feed_data["header"]["author-avatar"], $data["url"]); $data["photo"] = self::fixAvatar($feed_data["header"]["author-avatar"], $data["url"]);
} }
if ($feed_data["header"]["author-id"] != "") { if (!empty($feed_data["header"]["author-id"])) {
$data["alias"] = $feed_data["header"]["author-id"]; $data["alias"] = $feed_data["header"]["author-id"];
} }
if ($feed_data["header"]["author-location"] != "") { if (!empty($feed_data["header"]["author-location"])) {
$data["location"] = $feed_data["header"]["author-location"]; $data["location"] = $feed_data["header"]["author-location"];
} }
if ($feed_data["header"]["author-about"] != "") { if (!empty($feed_data["header"]["author-about"])) {
$data["about"] = $feed_data["header"]["author-about"]; $data["about"] = $feed_data["header"]["author-about"];
} }
// OStatus has serious issues when the the url doesn't fit (ssl vs. non ssl) // OStatus has serious issues when the the url doesn't fit (ssl vs. non ssl)
// So we take the value that we just fetched, although the other one worked as well // So we take the value that we just fetched, although the other one worked as well
if ($feed_data["header"]["author-link"] != "") { if (!empty($feed_data["header"]["author-link"])) {
$data["url"] = $feed_data["header"]["author-link"]; $data["url"] = $feed_data["header"]["author-link"];
} }
@ -1528,26 +1547,26 @@ class Probe
return self::feed($feed_url, false); return self::feed($feed_url, false);
} }
if ($feed_data["header"]["author-name"] != "") { if (!empty($feed_data["header"]["author-name"])) {
$data["name"] = $feed_data["header"]["author-name"]; $data["name"] = $feed_data["header"]["author-name"];
} }
if ($feed_data["header"]["author-nick"] != "") { if (!empty($feed_data["header"]["author-nick"])) {
$data["nick"] = $feed_data["header"]["author-nick"]; $data["nick"] = $feed_data["header"]["author-nick"];
} }
if ($feed_data["header"]["author-avatar"] != "") { if (!empty($feed_data["header"]["author-avatar"])) {
$data["photo"] = $feed_data["header"]["author-avatar"]; $data["photo"] = $feed_data["header"]["author-avatar"];
} }
if ($feed_data["header"]["author-id"] != "") { if (!empty($feed_data["header"]["author-id"])) {
$data["alias"] = $feed_data["header"]["author-id"]; $data["alias"] = $feed_data["header"]["author-id"];
} }
$data["url"] = $url; $data["url"] = $url;
$data["poll"] = $url; $data["poll"] = $url;
if ($feed_data["header"]["author-link"] != "") { if (!empty($feed_data["header"]["author-link"])) {
$data["baseurl"] = $feed_data["header"]["author-link"]; $data["baseurl"] = $feed_data["header"]["author-link"];
} else { } else {
$data["baseurl"] = $data["url"]; $data["baseurl"] = $data["url"];

View file

@ -731,8 +731,11 @@ class Image
$headers=[]; $headers=[];
$h = explode("\n", $a->get_curl_headers()); $h = explode("\n", $a->get_curl_headers());
foreach ($h as $l) { foreach ($h as $l) {
list($k,$v) = array_map("trim", explode(":", trim($l), 2)); $data = array_map("trim", explode(":", trim($l), 2));
$headers[$k] = $v; if (count($data) > 1) {
list($k,$v) = $data;
$headers[$k] = $v;
}
} }
if (array_key_exists('Content-Type', $headers)) if (array_key_exists('Content-Type', $headers))
$type = $headers['Content-Type']; $type = $headers['Content-Type'];

View file

@ -77,6 +77,11 @@ class DFRN
} }
foreach ($items as $item) { foreach ($items as $item) {
// These values aren't sent when sending from the queue.
/// @todo Check if we can set these values from the queue or if they are needed at all.
$item["entry:comment-allow"] = defaults($item, "entry:comment-allow", true);
$item["entry:cid"] = defaults($item, "entry:cid", 0);
$entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]); $entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
$root->appendChild($entry); $root->appendChild($entry);
} }

View file

@ -3352,12 +3352,12 @@ class Diaspora
$guid = ""; $guid = "";
preg_match("/guid='(.*?)'/ism", $attributes, $matches); preg_match("/guid='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$guid = $matches[1]; $guid = $matches[1];
} }
preg_match('/guid="(.*?)"/ism', $attributes, $matches); preg_match('/guid="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$guid = $matches[1]; $guid = $matches[1];
} }
@ -3382,12 +3382,12 @@ class Diaspora
$profile = ""; $profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches); preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$profile = $matches[1]; $profile = $matches[1];
} }
preg_match('/profile="(.*?)"/ism', $attributes, $matches); preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$profile = $matches[1]; $profile = $matches[1];
} }

View file

@ -45,7 +45,7 @@ class Feed {
} else { } else {
logger("Test Atom/RSS feed", LOGGER_DEBUG); logger("Test Atom/RSS feed", LOGGER_DEBUG);
} }
if ($xml == "") { if (empty($xml)) {
logger('XML is empty.', LOGGER_DEBUG); logger('XML is empty.', LOGGER_DEBUG);
return; return;
} }
@ -74,18 +74,18 @@ class Feed {
// Is it RDF? // Is it RDF?
if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) { if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) {
$author["author-link"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:link/text()')->item(0)->nodeValue; $author["author-link"] = XML::getFirstNodeValue($xpath, '/rdf:RDF/rss:channel/rss:link/text()');
$author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:title/text()')->item(0)->nodeValue; $author["author-name"] = XML::getFirstNodeValue($xpath, '/rdf:RDF/rss:channel/rss:title/text()');
if ($author["author-name"] == "") { if (empty($author["author-name"])) {
$author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:description/text()')->item(0)->nodeValue; $author["author-name"] = XML::getFirstNodeValue($xpath, '/rdf:RDF/rss:channel/rss:description/text()');
} }
$entries = $xpath->query('/rdf:RDF/rss:item'); $entries = $xpath->query('/rdf:RDF/rss:item');
} }
// Is it Atom? // Is it Atom?
if ($xpath->query('/atom:feed')->length > 0) { if ($xpath->query('/atom:feed')->length > 0) {
$alternate = $xpath->query("atom:link[@rel='alternate']")->item(0)->attributes; $alternate = XML::getFirstAttributes($xpath, "atom:link[@rel='alternate']");
if (is_object($alternate)) { if (is_object($alternate)) {
foreach ($alternate AS $attribute) { foreach ($alternate AS $attribute) {
if ($attribute->name == "href") { if ($attribute->name == "href") {
@ -94,11 +94,8 @@ class Feed {
} }
} }
if ($author["author-link"] == "") { if (empty($author["author-link"])) {
$author["author-link"] = $author["author-id"]; $self = XML::getFirstAttributes($xpath, "atom:link[@rel='self']");
}
if ($author["author-link"] == "") {
$self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes;
if (is_object($self)) { if (is_object($self)) {
foreach ($self AS $attribute) { foreach ($self AS $attribute) {
if ($attribute->name == "href") { if ($attribute->name == "href") {
@ -108,27 +105,27 @@ class Feed {
} }
} }
if ($author["author-link"] == "") { if (empty($author["author-link"])) {
$author["author-link"] = $xpath->evaluate('/atom:feed/atom:id/text()')->item(0)->nodeValue; $author["author-link"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:id/text()');
} }
$author["author-avatar"] = $xpath->evaluate('/atom:feed/atom:logo/text()')->item(0)->nodeValue; $author["author-avatar"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:logo/text()');
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:title/text()')->item(0)->nodeValue; $author["author-name"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:title/text()');
if ($author["author-name"] == "") { if (empty($author["author-name"])) {
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:subtitle/text()')->item(0)->nodeValue; $author["author-name"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:subtitle/text()');
} }
if ($author["author-name"] == "") { if (empty($author["author-name"])) {
$author["author-name"] = $xpath->evaluate('/atom:feed/atom:author/atom:name/text()')->item(0)->nodeValue; $author["author-name"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:author/atom:name/text()');
} }
$value = $xpath->evaluate('atom:author/poco:displayName/text()')->item(0)->nodeValue; $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:displayName/text()');
if ($value != "") { if ($value != "") {
$author["author-name"] = $value; $author["author-name"] = $value;
} }
if ($simulate) { if ($simulate) {
$author["author-id"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue; $author["author-id"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:author/atom:uri/text()');
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()')->item(0)->nodeValue; $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:preferredUsername/text()');
if ($value != "") { if ($value != "") {
$author["author-nick"] = $value; $author["author-nick"] = $value;
} }
@ -140,7 +137,7 @@ class Feed {
if ($value != "") { if ($value != "") {
$author["author-about"] = $value; $author["author-about"] = $value;
} }
$avatar = $xpath->evaluate("atom:author/atom:link[@rel='avatar']")->item(0)->attributes; $avatar = XML::getFirstAttributes($xpath, "atom:author/atom:link[@rel='avatar']");
if (is_object($avatar)) { if (is_object($avatar)) {
foreach ($avatar AS $attribute) { foreach ($avatar AS $attribute) {
if ($attribute->name == "href") { if ($attribute->name == "href") {
@ -159,20 +156,20 @@ class Feed {
// Is it RSS? // Is it RSS?
if ($xpath->query('/rss/channel')->length > 0) { if ($xpath->query('/rss/channel')->length > 0) {
$author["author-link"] = $xpath->evaluate('/rss/channel/link/text()')->item(0)->nodeValue; $author["author-link"] = XML::getFirstNodeValue($xpath, '/rss/channel/link/text()');
$author["author-name"] = $xpath->evaluate('/rss/channel/title/text()')->item(0)->nodeValue; $author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/title/text()');
$author["author-avatar"] = $xpath->evaluate('/rss/channel/image/url/text()')->item(0)->nodeValue; $author["author-avatar"] = XML::getFirstNodeValue($xpath, '/rss/channel/image/url/text()');
if ($author["author-name"] == "") { if (empty($author["author-name"])) {
$author["author-name"] = $xpath->evaluate('/rss/channel/copyright/text()')->item(0)->nodeValue; $author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/copyright/text()');
} }
if ($author["author-name"] == "") { if (empty($author["author-name"])) {
$author["author-name"] = $xpath->evaluate('/rss/channel/description/text()')->item(0)->nodeValue; $author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/description/text()');
} }
$author["edited"] = $author["created"] = $xpath->query('/rss/channel/pubDate/text()')->item(0)->nodeValue; $author["edited"] = $author["created"] = XML::getFirstNodeValue($xpath, '/rss/channel/pubDate/text()');
$author["app"] = $xpath->evaluate('/rss/channel/generator/text()')->item(0)->nodeValue; $author["app"] = XML::getFirstNodeValue($xpath, '/rss/channel/generator/text()');
$entries = $xpath->query('/rss/channel/item'); $entries = $xpath->query('/rss/channel/item');
} }
@ -180,7 +177,7 @@ class Feed {
if (!$simulate) { if (!$simulate) {
$author["author-link"] = $contact["url"]; $author["author-link"] = $contact["url"];
if ($author["author-name"] == "") { if (empty($author["author-name"])) {
$author["author-name"] = $contact["name"]; $author["author-name"] = $contact["name"];
} }
$author["author-avatar"] = $contact["thumb"]; $author["author-avatar"] = $contact["thumb"];
@ -215,9 +212,9 @@ class Feed {
$item = array_merge($header, $author); $item = array_merge($header, $author);
$alternate = $xpath->query("atom:link[@rel='alternate']", $entry)->item(0)->attributes; $alternate = XML::getFirstAttributes($xpath, "atom:link[@rel='alternate']", $entry);
if (!is_object($alternate)) { if (!is_object($alternate)) {
$alternate = $xpath->query("atom:link", $entry)->item(0)->attributes; $alternate = XML::getFirstAttributes($xpath, "atom:link", $entry);
} }
if (is_object($alternate)) { if (is_object($alternate)) {
foreach ($alternate AS $attribute) { foreach ($alternate AS $attribute) {
@ -226,19 +223,19 @@ class Feed {
} }
} }
} }
if ($item["plink"] == "") { if (empty($item["plink"])) {
$item["plink"] = XML::getFirstNodeValue($xpath, 'link/text()', $entry); $item["plink"] = XML::getFirstNodeValue($xpath, 'link/text()', $entry);
} }
if ($item["plink"] == "") { if (empty($item["plink"])) {
$item["plink"] = XML::getFirstNodeValue($xpath, 'rss:link/text()', $entry); $item["plink"] = XML::getFirstNodeValue($xpath, 'rss:link/text()', $entry);
} }
$item["uri"] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry); $item["uri"] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry);
if ($item["uri"] == "") { if (empty($item["uri"])) {
$item["uri"] = XML::getFirstNodeValue($xpath, 'guid/text()', $entry); $item["uri"] = XML::getFirstNodeValue($xpath, 'guid/text()', $entry);
} }
if ($item["uri"] == "") { if (empty($item["uri"])) {
$item["uri"] = $item["plink"]; $item["uri"] = $item["plink"];
} }
@ -260,23 +257,23 @@ class Feed {
$item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry); $item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
if ($item["title"] == "") { if (empty($item["title"])) {
$item["title"] = XML::getFirstNodeValue($xpath, 'title/text()', $entry); $item["title"] = XML::getFirstNodeValue($xpath, 'title/text()', $entry);
} }
if ($item["title"] == "") { if (empty($item["title"])) {
$item["title"] = XML::getFirstNodeValue($xpath, 'rss:title/text()', $entry); $item["title"] = XML::getFirstNodeValue($xpath, 'rss:title/text()', $entry);
} }
$published = XML::getFirstNodeValue($xpath, 'atom:published/text()', $entry); $published = XML::getFirstNodeValue($xpath, 'atom:published/text()', $entry);
if ($published == "") { if (empty($published)) {
$published = XML::getFirstNodeValue($xpath, 'pubDate/text()', $entry); $published = XML::getFirstNodeValue($xpath, 'pubDate/text()', $entry);
} }
if ($published == "") { if (empty($published)) {
$published = XML::getFirstNodeValue($xpath, 'dc:date/text()', $entry); $published = XML::getFirstNodeValue($xpath, 'dc:date/text()', $entry);
} }
$updated = XML::getFirstNodeValue($xpath, 'atom:updated/text()', $entry); $updated = XML::getFirstNodeValue($xpath, 'atom:updated/text()', $entry);
if ($updated == "") { if (empty($updated)) {
$updated = $published; $updated = $published;
} }
if ($published != "") { if ($published != "") {
@ -287,10 +284,10 @@ class Feed {
} }
$creator = XML::getFirstNodeValue($xpath, 'author/text()', $entry); $creator = XML::getFirstNodeValue($xpath, 'author/text()', $entry);
if ($creator == "") { if (empty($creator)) {
$creator = XML::getFirstNodeValue($xpath, 'atom:author/atom:name/text()', $entry); $creator = XML::getFirstNodeValue($xpath, 'atom:author/atom:name/text()', $entry);
} }
if ($creator == "") { if (empty($creator)) {
$creator = XML::getFirstNodeValue($xpath, 'dc:creator/text()', $entry); $creator = XML::getFirstNodeValue($xpath, 'dc:creator/text()', $entry);
} }
if ($creator != "") { if ($creator != "") {
@ -324,8 +321,10 @@ class Feed {
$type = $attribute->textContent; $type = $attribute->textContent;
} }
} }
if (strlen($item["attach"])) { if (!empty($item["attach"])) {
$item["attach"] .= ','; $item["attach"] .= ',';
} else {
$item["attach"] = '';
} }
$attachments[] = ["link" => $href, "type" => $type, "length" => $length]; $attachments[] = ["link" => $href, "type" => $type, "length" => $length];
@ -345,16 +344,16 @@ class Feed {
$tags .= $taglink; $tags .= $taglink;
} }
$body = trim($xpath->evaluate('atom:content/text()', $entry)->item(0)->nodeValue); $body = trim(XML::getFirstNodeValue($xpath, 'atom:content/text()', $entry));
if ($body == "") { if (empty($body)) {
$body = trim($xpath->evaluate('content:encoded/text()', $entry)->item(0)->nodeValue); $body = trim(XML::getFirstNodeValue($xpath, 'content:encoded/text()', $entry));
} }
if ($body == "") { if (empty($body)) {
$body = trim($xpath->evaluate('description/text()', $entry)->item(0)->nodeValue); $body = trim(XML::getFirstNodeValue($xpath, 'description/text()', $entry));
} }
if ($body == "") { if (empty($body)) {
$body = trim($xpath->evaluate('atom:summary/text()', $entry)->item(0)->nodeValue); $body = trim(XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry));
} }
// remove the content of the title if it is identically to the body // remove the content of the title if it is identically to the body

View file

@ -61,14 +61,16 @@ class OStatus
$aliaslink = $author["author-link"]; $aliaslink = $author["author-link"];
$alternate = $xpath->query("atom:author/atom:link[@rel='alternate']", $context)->item(0)->attributes; $alternate_item = $xpath->query("atom:author/atom:link[@rel='alternate']", $context)->item(0);
if (is_object($alternate)) { if (is_object($alternate_item)) {
foreach ($alternate as $attributes) { foreach ($alternate_item->attributes as $attributes) {
if (($attributes->name == "href") && ($attributes->textContent != "")) { if (($attributes->name == "href") && ($attributes->textContent != "")) {
$author["author-link"] = $attributes->textContent; $author["author-link"] = $attributes->textContent;
} }
} }
} }
$author["author-id"] = Contact::getIdForURL($author["author-link"]);
$author["contact-id"] = $contact["id"]; $author["contact-id"] = $contact["id"];
$contact = null; $contact = null;
@ -131,9 +133,7 @@ class OStatus
$author["author-name"] = $displayname; $author["author-name"] = $displayname;
} }
$author["owner-name"] = $author["author-name"]; $author["owner-id"] = $author["author-id"];
$author["owner-link"] = $author["author-link"];
$author["owner-avatar"] = $author["author-avatar"];
// Only update the contacts if it is an OStatus contact // Only update the contacts if it is an OStatus contact
if (DBM::is_result($contact) && ($contact['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) { if (DBM::is_result($contact) && ($contact['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
@ -206,12 +206,16 @@ class OStatus
dba::update('contact', $fields, ['id' => $cid], $old_contact); dba::update('contact', $fields, ['id' => $cid], $old_contact);
// Update the avatar // Update the avatar
Contact::updateAvatar($author["author-avatar"], 0, $cid); if (!empty($author["author-avatar"])) {
Contact::updateAvatar($author["author-avatar"], 0, $cid);
}
} }
$contact["generation"] = 2; $contact["generation"] = 2;
$contact["hide"] = false; // OStatus contacts are never hidden $contact["hide"] = false; // OStatus contacts are never hidden
$contact["photo"] = $author["author-avatar"]; if (!empty($author["author-avatar"])) {
$contact["photo"] = $author["author-avatar"];
}
$gcid = GContact::update($contact); $gcid = GContact::update($contact);
GContact::link($gcid, $contact["uid"], $contact["id"]); GContact::link($gcid, $contact["uid"], $contact["id"]);
@ -325,12 +329,15 @@ class OStatus
$xpath->registerNamespace('statusnet', NAMESPACE_STATUSNET); $xpath->registerNamespace('statusnet', NAMESPACE_STATUSNET);
$hub = ""; $hub = "";
$hub_attributes = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0)->attributes; $hub_items = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0);
if (is_object($hub_attributes)) { if (is_object($hub_items)) {
foreach ($hub_attributes as $hub_attribute) { $hub_attributes = $hub_items->attributes;
if ($hub_attribute->name == "href") { if (is_object($hub_attributes)) {
$hub = $hub_attribute->textContent; foreach ($hub_attributes as $hub_attribute) {
logger("Found hub ".$hub, LOGGER_DEBUG); if ($hub_attribute->name == "href") {
$hub = $hub_attribute->textContent;
logger("Found hub ".$hub, LOGGER_DEBUG);
}
} }
} }
} }
@ -390,7 +397,7 @@ class OStatus
$author = self::fetchAuthor($xpath, $entry, $importer, $contact, $stored); $author = self::fetchAuthor($xpath, $entry, $importer, $contact, $stored);
} }
$value = XML::getFirstNodeValue($xpath, 'atom:author/poco:preferredUsername/text()', $context); $value = XML::getFirstNodeValue($xpath, 'atom:author/poco:preferredUsername/text()', $entry);
if ($value != "") { if ($value != "") {
$nickname = $value; $nickname = $value;
} else { } else {
@ -441,6 +448,7 @@ class OStatus
} }
if ($item["verb"] == NAMESPACE_OSTATUS."/unfollow") { if ($item["verb"] == NAMESPACE_OSTATUS."/unfollow") {
$dummy = null;
Contact::removeFollower($importer, $contact, $item, $dummy); Contact::removeFollower($importer, $contact, $item, $dummy);
continue; continue;
} }
@ -611,9 +619,12 @@ class OStatus
foreach ($category->attributes as $attributes) { foreach ($category->attributes as $attributes) {
if ($attributes->name == "term") { if ($attributes->name == "term") {
$term = $attributes->textContent; $term = $attributes->textContent;
if (strlen($item["tag"])) { if (!empty($item["tag"])) {
$item["tag"] .= ','; $item["tag"] .= ',';
} else {
$item["tag"] = '';
} }
$item["tag"] .= "#[url=".System::baseUrl()."/search?tag=".$term."]".$term."[/url]"; $item["tag"] .= "#[url=".System::baseUrl()."/search?tag=".$term."]".$term."[/url]";
} }
} }
@ -1008,15 +1019,15 @@ class OStatus
$link_data = self::processLinks($links, $item); $link_data = self::processLinks($links, $item);
} }
$orig_body = $xpath->query('atom:content/text()', $activityobjects)->item(0)->nodeValue; $orig_body = XML::getFirstNodeValue($xpath, 'atom:content/text()', $activityobjects);
$orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue; $orig_created = XML::getFirstNodeValue($xpath, 'atom:published/text()', $activityobjects);
$orig_edited = $xpath->query('atom:updated/text()', $activityobjects)->item(0)->nodeValue; $orig_edited = XML::getFirstNodeValue($xpath, 'atom:updated/text()', $activityobjects);
$orig_author = self::fetchAuthor($xpath, $activityobjects, $importer, $dummy, false); $orig_author = self::fetchAuthor($xpath, $activityobjects, $importer, $dummy, false);
$item["author-name"] = $orig_author["author-name"]; $item["author-name"] = $orig_author["author-name"];
$item["author-link"] = $orig_author["author-link"]; $item["author-link"] = $orig_author["author-link"];
$item["author-avatar"] = $orig_author["author-avatar"]; $item["author-id"] = $orig_author["author-id"];
$item["body"] = HTML::toBBCode($orig_body); $item["body"] = HTML::toBBCode($orig_body);
$item["created"] = $orig_created; $item["created"] = $orig_created;
@ -1024,9 +1035,9 @@ class OStatus
$item["uri"] = $orig_uri; $item["uri"] = $orig_uri;
$item["verb"] = $xpath->query('activity:verb/text()', $activityobjects)->item(0)->nodeValue; $item["verb"] = XML::getFirstNodeValue($xpath, 'activity:verb/text()', $activityobjects);
$item["object-type"] = $xpath->query('activity:object-type/text()', $activityobjects)->item(0)->nodeValue; $item["object-type"] = XML::getFirstNodeValue($xpath, 'activity:object-type/text()', $activityobjects);
$inreplyto = $xpath->query('thr:in-reply-to', $activityobjects); $inreplyto = $xpath->query('thr:in-reply-to', $activityobjects);
if (is_object($inreplyto->item(0))) { if (is_object($inreplyto->item(0))) {
@ -1055,7 +1066,7 @@ class OStatus
foreach ($links as $link) { foreach ($links as $link) {
$attribute = self::readAttributes($link); $attribute = self::readAttributes($link);
if (($attribute['rel'] != "") && ($attribute['href'] != "")) { if (!empty($attribute['rel']) && !empty($attribute['href'])) {
switch ($attribute['rel']) { switch ($attribute['rel']) {
case "alternate": case "alternate":
$item["plink"] = $attribute['href']; $item["plink"] = $attribute['href'];
@ -1077,13 +1088,15 @@ class OStatus
if ($filetype == 'image') { if ($filetype == 'image') {
$link_data['add_body'] .= "\n[img]".$attribute['href'].'[/img]'; $link_data['add_body'] .= "\n[img]".$attribute['href'].'[/img]';
} else { } else {
if (strlen($item["attach"])) { if (!empty($item["attach"])) {
$item["attach"] .= ','; $item["attach"] .= ',';
} else {
$item["attach"] = '';
} }
if (!isset($attribute['length'])) { if (!isset($attribute['length'])) {
$attribute['length'] = "0"; $attribute['length'] = "0";
} }
$item["attach"] .= '[attach]href="'.$attribute['href'].'" length="'.$attribute['length'].'" type="'.$attribute['type'].'" title="'.$attribute['title'].'"[/attach]'; $item["attach"] .= '[attach]href="'.$attribute['href'].'" length="'.$attribute['length'].'" type="'.$attribute['type'].'" title="'.defaults($attribute, 'title', '').'"[/attach]';
} }
break; break;
case "related": case "related":
@ -1097,7 +1110,7 @@ class OStatus
} }
break; break;
case "self": case "self":
if ($item["plink"] == '') { if (empty($item["plink"])) {
$item["plink"] = $attribute['href']; $item["plink"] = $attribute['href'];
} }
$link_data['self'] = $attribute['href']; $link_data['self'] = $attribute['href'];
@ -1627,6 +1640,7 @@ class OStatus
} }
$contact = self::contactEntry($repeated_item['author-link'], $owner); $contact = self::contactEntry($repeated_item['author-link'], $owner);
$contact['account-type'] = $contact['contact-type'];
$title = $owner["nick"]." repeated a notice by ".$contact["nick"]; $title = $owner["nick"]." repeated a notice by ".$contact["nick"];
@ -1972,10 +1986,10 @@ class OStatus
if (isset($parent_item)) { if (isset($parent_item)) {
$conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]); $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);
if (DBM::is_result($conversation)) { if (DBM::is_result($conversation)) {
if ($r['conversation-uri'] != '') { if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri']; $conversation_uri = $conversation['conversation-uri'];
} }
if ($r['conversation-href'] != '') { if ($conversation['conversation-href'] != '') {
$conversation_href = $conversation['conversation-href']; $conversation_href = $conversation['conversation-href'];
} }
} }

View file

@ -120,7 +120,9 @@ class PortableContact
$contact_type = -1; $contact_type = -1;
$generation = 0; $generation = 0;
$name = $entry->displayName; if (!empty($entry->displayName)) {
$name = $entry->displayName;
}
if (isset($entry->urls)) { if (isset($entry->urls)) {
foreach ($entry->urls as $url) { foreach ($entry->urls as $url) {
@ -419,7 +421,7 @@ class PortableContact
GContact::update($contact); GContact::update($contact);
if (trim($noscrape["updated"]) != "") { if (!empty($noscrape["updated"])) {
$fields = ['last_contact' => DateTimeFormat::utcNow()]; $fields = ['last_contact' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
@ -1027,7 +1029,7 @@ class PortableContact
if (!$serverret["success"] || ($serverret["body"] == "") || empty($xmlobj) || !is_object($xmlobj)) { if (!$serverret["success"] || ($serverret["body"] == "") || empty($xmlobj) || !is_object($xmlobj)) {
// Workaround for bad configured servers (known nginx problem) // Workaround for bad configured servers (known nginx problem)
if (!in_array($serverret["debug"]["http_code"], ["403", "404"])) { if (!empty($serverret["debug"]) && !in_array($serverret["debug"]["http_code"], ["403", "404"])) {
$failure = true; $failure = true;
} }
$possible_failure = true; $possible_failure = true;
@ -1174,17 +1176,19 @@ class PortableContact
if (!empty($data->channels_total)) { if (!empty($data->channels_total)) {
$registered_users = $data->channels_total; $registered_users = $data->channels_total;
} }
switch ($data->register_policy) { if (!empty($data->register_policy)) {
case "REGISTER_OPEN": switch ($data->register_policy) {
$register_policy = REGISTER_OPEN; case "REGISTER_OPEN":
break; $register_policy = REGISTER_OPEN;
case "REGISTER_APPROVE": break;
$register_policy = REGISTER_APPROVE; case "REGISTER_APPROVE":
break; $register_policy = REGISTER_APPROVE;
case "REGISTER_CLOSED": break;
default: case "REGISTER_CLOSED":
$register_policy = REGISTER_CLOSED; default:
break; $register_policy = REGISTER_CLOSED;
break;
}
} }
} else { } else {
// Test for Hubzilla, Redmatrix or Friendica // Test for Hubzilla, Redmatrix or Friendica
@ -1266,7 +1270,7 @@ class PortableContact
$network = NETWORK_DIASPORA; $network = NETWORK_DIASPORA;
} }
if ($data->registrations_open) { if (!empty($data->registrations_open) && $data->registrations_open) {
$register_policy = REGISTER_OPEN; $register_policy = REGISTER_OPEN;
} else { } else {
$register_policy = REGISTER_CLOSED; $register_policy = REGISTER_CLOSED;
@ -1317,7 +1321,9 @@ class PortableContact
if (isset($data->version)) { if (isset($data->version)) {
$network = NETWORK_DFRN; $network = NETWORK_DFRN;
$noscrape = defaults($data->no_scrape_url, ''); if (!empty($data->no_scrape_url)) {
$noscrape = $data->no_scrape_url;
}
$version = $data->version; $version = $data->version;
$site_name = $data->site_name; $site_name = $data->site_name;
$info = $data->info; $info = $data->info;
@ -1515,7 +1521,7 @@ class PortableContact
if ($serverdata) { if ($serverdata) {
$servers = json_decode($serverdata); $servers = json_decode($serverdata);
if (is_array($servers->pods)) { if (!empty($servers->pods)) {
foreach ($servers->pods as $server) { foreach ($servers->pods as $server) {
Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", "https://".$server->host); Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", "https://".$server->host);
} }

View file

@ -101,7 +101,7 @@ class Network
$a = get_app(); $a = get_app();
$parts = parse_url($url); $parts = parse_url($url);
$path_parts = explode('/', $parts['path']); $path_parts = explode('/', defaults($parts, 'path', ''));
foreach ($path_parts as $part) { foreach ($path_parts as $part) {
if (strlen($part) <> mb_strlen($part)) { if (strlen($part) <> mb_strlen($part)) {
$parts2[] = rawurlencode($part); $parts2[] = rawurlencode($part);
@ -250,7 +250,7 @@ class Network
$newurl = $curl_info['redirect_url']; $newurl = $curl_info['redirect_url'];
if (($new_location_info['path'] == '') && ($new_location_info['host'] != '')) { if (empty($new_location_info['path']) && !empty($new_location_info['host'])) {
$newurl = $new_location_info['scheme'] . '://' . $new_location_info['host'] . $old_location_info['path']; $newurl = $new_location_info['scheme'] . '://' . $new_location_info['host'] . $old_location_info['path'];
} }
@ -890,8 +890,8 @@ class Network
$i = 0; $i = 0;
$path = ""; $path = "";
do { do {
$path1 = $pathparts1[$i]; $path1 = defaults($pathparts1, $i, '');
$path2 = $pathparts2[$i]; $path2 = defaults($pathparts2, $i, '');
if ($path1 == $path2) { if ($path1 == $path2) {
$path .= $path1."/"; $path .= $path1."/";

View file

@ -159,19 +159,21 @@ class ParseUrl
if ($do_oembed) { if ($do_oembed) {
$oembed_data = OEmbed::fetchURL($url); $oembed_data = OEmbed::fetchURL($url);
if (!in_array($oembed_data->type, ["error", "rich", ""])) { if (!empty($oembed_data->type)) {
$siteinfo["type"] = $oembed_data->type; if (!in_array($oembed_data->type, ["error", "rich", ""])) {
} $siteinfo["type"] = $oembed_data->type;
}
if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) { if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) {
if (isset($oembed_data->title)) { if (isset($oembed_data->title)) {
$siteinfo["title"] = trim($oembed_data->title); $siteinfo["title"] = trim($oembed_data->title);
} }
if (isset($oembed_data->description)) { if (isset($oembed_data->description)) {
$siteinfo["text"] = trim($oembed_data->description); $siteinfo["text"] = trim($oembed_data->description);
} }
if (isset($oembed_data->thumbnail_url)) { if (isset($oembed_data->thumbnail_url)) {
$siteinfo["image"] = $oembed_data->thumbnail_url; $siteinfo["image"] = $oembed_data->thumbnail_url;
}
} }
} }
} }
@ -251,9 +253,9 @@ class ParseUrl
} }
} }
$attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8")); if (!empty($attr["content"])) {
$attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
if ($attr["content"] != "") {
switch (strtolower($attr["name"])) { switch (strtolower($attr["name"])) {
case "fulltitle": case "fulltitle":
$siteinfo["title"] = trim($attr["content"]); $siteinfo["title"] = trim($attr["content"]);
@ -319,9 +321,9 @@ class ParseUrl
} }
} }
$attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8")); if (!empty($attr["content"])) {
$attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
if ($attr["content"] != "") {
switch (strtolower($attr["property"])) { switch (strtolower($attr["property"])) {
case "og:image": case "og:image":
$siteinfo["image"] = $attr["content"]; $siteinfo["image"] = $attr["content"];
@ -363,7 +365,7 @@ class ParseUrl
"height" => $photodata[1]]; "height" => $photodata[1]];
} }
} }
} elseif ($siteinfo["image"] != "") { } elseif (!empty($siteinfo["image"])) {
$src = self::completeUrl($siteinfo["image"], $url); $src = self::completeUrl($siteinfo["image"], $url);
unset($siteinfo["image"]); unset($siteinfo["image"]);

View file

@ -446,4 +446,19 @@ class XML
return $first_item->nodeValue; return $first_item->nodeValue;
} }
public static function getFirstAttributes($xpath, $element, $context = null)
{
$result = $xpath->query($element, $context);
if (!is_object($result)) {
return false;
}
$first_item = $result->item(0);
if (!is_object($first_item)) {
return false;
}
return $first_item->attributes;
}
} }

View file

@ -61,7 +61,7 @@ class Delivery extends BaseObject
$condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false]; $condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false];
$params = ['order' => ['id']]; $params = ['order' => ['id']];
$itemdata = Item::select(Item::ITEM_FIELDLIST, $condition, $params); $itemdata = Item::select([], $condition, $params);
$items = []; $items = [];
while ($item = Item::fetch($itemdata)) { while ($item = Item::fetch($itemdata)) {

View file

@ -11,6 +11,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Queue as QueueModel; use Friendica\Model\Queue as QueueModel;
use Friendica\Model\PushSubscriber; use Friendica\Model\PushSubscriber;
use Friendica\Model\User;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
@ -106,7 +107,7 @@ class Queue
$data = $q_item['content']; $data = $q_item['content'];
$public = $q_item['batch']; $public = $q_item['batch'];
$owner = $user; $owner = User::getOwnerDataById($user['uid']);
$deliver_status = 0; $deliver_status = 0;

View file

@ -21,8 +21,8 @@ if (!isset($minimal)) {
?> ?>
<html> <html>
<head> <head>
<title><?php if (x($page, 'title')) echo $page['title'] ?></title> <title><?php if (!empty($page['title'])) echo $page['title'] ?></title>
<meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?>"> <meta request="<?php echo htmlspecialchars(defaults($_REQUEST, 'pagename', '')) ?>">
<script type="text/javascript">var baseurl = "<?php echo System::baseUrl(); ?>";</script> <script type="text/javascript">var baseurl = "<?php echo System::baseUrl(); ?>";</script>
<script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script> <script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script>
<?php <?php

View file

@ -29,8 +29,8 @@ function vier_init(App $a)
$a->set_template_engine('smarty3'); $a->set_template_engine('smarty3');
if (!empty($a->argv[0]) && !empty($a->argv[1])) { if (!empty($a->argv[0])) {
if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) { if ($a->argv[0] . defaults($a->argv, 1, '') === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
vier_community_info(); vier_community_info();
$a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n"; $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";