// $called_api is the API path exploded on / and is expected to have at least 2 elements
if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api);
- list($user, $null) = explode(".", $a->argv[$argid]);
+ if (!empty($a->argv[$argid])) {
+ list($user, $null) = explode(".", $a->argv[$argid]);
+ }
if (is_numeric($user)) {
$user = dbesc(api_unique_id_to_nurl(intval($user)));
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $a->argv[2], 'private' => false, 'uid' => 0]);
}
- if (!DBM::is_result($item) || $item['deleted']) {
+ if (!DBM::is_result($item)) {
$a->error = 404;
notice(L10n::t('Item not found.') . EOL);
return;
}
- if (strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
+ if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
logger('Directly serving XML for id '.$item["id"], LOGGER_DEBUG);
displayShowFeed($item["id"], false);
}
Item::update(['unseen' => false], $condition);
}
- $items = conv_sort(Item::inArray($items_obj), "`commented`");
+ $items = Item::inArray($items_obj);
+ $conversation_items = conv_sort($items, "`commented`");
if (!$update) {
$o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
}
- $o .= conversation($a, $items, 'display', $update_uid, false, 'commented', local_user());
+ $o .= conversation($a, $conversation_items, 'display', $update_uid, false, 'commented', local_user());
// Preparing the meta header
- $description = trim(HTML::toPlaintext(BBCode::convert($s[0]["body"], false), 0, true));
- $title = trim(HTML::toPlaintext(BBCode::convert($s[0]["title"], false), 0, true));
- $author_name = $s[0]["author-name"];
+ $description = trim(HTML::toPlaintext(BBCode::convert($items["body"], false), 0, true));
+ $title = trim(HTML::toPlaintext(BBCode::convert($items["title"], false), 0, true));
+ $author_name = $items["author-name"];
- $image = $a->remove_baseurl($s[0]["author-thumb"]);
+ $image = $a->remove_baseurl($items["author-thumb"]);
if ($title == "") {
$title = $author_name;
$a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
- $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$s[0]["plink"].'" />'."\n";
+ $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$items["plink"].'" />'."\n";
// Dublin Core
$a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
- $a->page['htmlhead'] .= '<meta property="og:url" content="'.$s[0]["plink"].'" />'."\n";
+ $a->page['htmlhead'] .= '<meta property="og:url" content="'.$items["plink"].'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";
// article:tag
function friendica_init(App $a)
{
- if ($a->argv[1] == "json") {
+ if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
$register_policy = ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'];
$sql_extra = '';
$order_mode = 'commented';
}
- if ($sql_order == '') {
- $sql_order = "$sql_table.$ordering";
- }
+ $sql_order = "$sql_table.$ordering";
if (x($_GET, 'offset')) {
$sql_range = sprintf(" AND $sql_order <= '%s'", dbesc($_GET['offset']));
$condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()];
$fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
- 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid'];
+ 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall'];
$params = ['order' => ['created' => true]];
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
if ($notification["visible"]
&& !$notification["deleted"]
- && !(x($result, $notification["parent"]) && is_array($result[$notification["parent"]]))
+ && !(x($result, $notification["parent"]) && !empty($result[$notification["parent"]]))
) {
// Should we condense the notifications or show them all?
if (PConfig::get(local_user(), 'system', 'detailed_notif')) {
logger('mod-diaspora: receiving post', LOGGER_DEBUG);
- $xml = urldecode($_POST['xml']);
-
- if (!$xml) {
+ if (empty($_POST['xml'])) {
$postdata = file_get_contents("php://input");
if ($postdata == '') {
System::httpExit(500);
logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
$msg = Diaspora::decodeRaw($importer, $postdata);
} else {
+ $xml = urldecode($_POST['xml']);
+
logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG);
$msg = Diaspora::decode($importer, $xml);
$return = sprintf('<div class="type-%s">', $data["type"]);
}
- if ($data["image"] != "") {
+ if (!empty($data["image"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
- } elseif ($data["preview"] != "") {
+ } elseif (!empty($data["preview"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
}
{
$a = get_app();
+ if (empty($s)) {
+ return '';
+ }
+
if (x($a->strings, $s)) {
$t = $a->strings[$s];
$s = is_array($t) ? $t[0] : $t;
if (isset($description["title"])) {
$tpl = get_markup_template('http_status.tpl');
- echo replace_macros(
- $tpl,
- [
- '$title' => $description["title"],
- '$description' => $description["description"]]
- );
+ echo replace_macros($tpl, ['$title' => $description["title"],
+ '$description' => defaults($description, 'description', '')]);
}
killme();
$last_failure_str = '';
$last_contact_str = '';
+ if (empty($contact["network"])) {
+ logger("Empty network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
+ return false;
+ }
+
if (in_array($contact["network"], [NETWORK_PHANTOM])) {
logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
return false;
private static function guid($item, $notify)
{
- $guid = notags(trim($item['guid']));
-
- if (!empty($guid)) {
- return $guid;
+ if (!empty($item['guid'])) {
+ return notags(trim($item['guid']));
}
if ($notify) {
'guid' => urlencode($item['guid']),
'isevent' => $isevent,
'attend' => $attend,
- 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, defaults($item, 'author-link', $item['url'])),
- 'olinktitle' => L10n::t('View %s\'s profile @ %s', htmlentities($this->getOwnerName()), defaults($item, 'owner-link', $item['url'])),
+ 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
+ 'olinktitle' => L10n::t('View %s\'s profile @ %s', htmlentities($this->getOwnerName()), $item['owner-link']),
'to' => L10n::t('to'),
'via' => L10n::t('via'),
'wall' => L10n::t('Wall-to-Wall'),
if (isset($parent_item)) {
$conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
if (DBM::is_result($conversation)) {
- if ($r['conversation-uri'] != '') {
+ if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri'];
}
- if ($r['conversation-href'] != '') {
+ if ($conversation['conversation-href'] != '') {
$conversation_href = $conversation['conversation-href'];
}
}
$author = "";
// Fetch the author - for the old and the new Diaspora version
- if ($source_xml->post->status_message->diaspora_handle) {
+ if ($source_xml->post->status_message && $source_xml->post->status_message->diaspora_handle) {
$author = (string)$source_xml->post->status_message->diaspora_handle;
} elseif ($source_xml->author && ($source_xml->getName() == "status_message")) {
$author = (string)$source_xml->author;
}
// Send all existing comments and likes to the requesting server
- $comments = Item::select(['id', 'verb', 'self'], ['parent' => $item['id']]);
+ $comments = Item::select(['id', 'parent', 'verb', 'self'], ['parent' => $item['id']]);
while ($comment = Item::fetch($comments)) {
if ($comment['id'] == $comment['parent']) {
continue;
$guid = "";
preg_match("/guid='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "") {
+ if (!empty($matches[1])) {
$guid = $matches[1];
}
preg_match('/guid="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "") {
+ if (!empty($matches[1])) {
$guid = $matches[1];
}
$condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false];
$params = ['order' => ['id']];
- $itemdata = Item::select([], $condition, $params);
+ $itemdata = Item::select(Item::ITEM_FIELDLIST, $condition, $params);
$items = [];
while ($item = Item::fetch($itemdata)) {
return;
}
+ $user = dba::selectFirst('user', [], ['uid' => $target_uid]);
+
+ $target_importer = array_merge($target_importer, $user);
+
// Set the user id. This is important if this is a public contact
$target_importer['importer_uid'] = $target_uid;
DFRN::import($atom, $target_importer);
$a->set_template_engine('smarty3');
- if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
- vier_community_info();
+ if (!empty($a->argv[0]) && !empty($a->argv[1])) {
+ if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
+ 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";
+ }
}
if ($a->is_mobile || $a->is_tablet) {
// Hide the left menu bar
/// @TODO maybe move this static array out where it should belong?
- if (($a->page['aside'] == "") && in_array($a->argv[0], ["community", "events", "help", "manage", "notifications",
+ if (empty($a->page['aside']) && in_array($a->argv[0], ["community", "events", "help", "manage", "notifications",
"probe", "webfinger", "login", "invite", "credits"])) {
$a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
}