Use short form array syntax everywhere

- Add short form array syntax to po2php.php generation
This commit is contained in:
Hypolite Petovan 2018-01-15 08:05:12 -05:00
parent 77dfbaa0bf
commit e36f2bb1fb
212 changed files with 5160 additions and 5160 deletions

View file

@ -475,7 +475,7 @@ class DFRN
WHERE `profile` = 1 AND `uid` = %d ORDER BY scale;",
$uid
);
$photos = array();
$photos = [];
$ext = Image::supportedTypes();
foreach ($rp as $p) {
@ -544,13 +544,13 @@ class DFRN
XML::addElement($doc, $root, "id", System::baseUrl()."/profile/".$owner["nick"]);
XML::addElement($doc, $root, "title", $owner["name"]);
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
$attributes = ["uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION];
XML::addElement($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
$attributes = array("rel" => "license", "href" => "http://creativecommons.org/licenses/by/3.0/");
$attributes = ["rel" => "license", "href" => "http://creativecommons.org/licenses/by/3.0/"];
XML::addElement($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $alternatelink);
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $alternatelink];
XML::addElement($doc, $root, "link", "", $attributes);
@ -558,13 +558,13 @@ class DFRN
// DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed.
OStatus::hublinks($doc, $root, $owner["nick"]);
$attributes = array("rel" => "salmon", "href" => System::baseUrl()."/salmon/".$owner["nick"]);
$attributes = ["rel" => "salmon", "href" => System::baseUrl()."/salmon/".$owner["nick"]];
XML::addElement($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => System::baseUrl()."/salmon/".$owner["nick"]);
$attributes = ["rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => System::baseUrl()."/salmon/".$owner["nick"]];
XML::addElement($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => System::baseUrl()."/salmon/".$owner["nick"]);
$attributes = ["rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => System::baseUrl()."/salmon/".$owner["nick"]];
XML::addElement($doc, $root, "link", "", $attributes);
}
@ -617,18 +617,18 @@ class DFRN
$uridate = datetime_convert('UTC', 'UTC', $owner['uri-date'].'+00:00', ATOM_TIME);
$picdate = datetime_convert('UTC', 'UTC', $owner['avatar-date'].'+00:00', ATOM_TIME);
$attributes = array();
$attributes = [];
if (!$public || !$hidewall) {
$attributes = array("dfrn:updated" => $namdate);
$attributes = ["dfrn:updated" => $namdate];
}
XML::addElement($doc, $author, "name", $owner["name"], $attributes);
XML::addElement($doc, $author, "uri", System::baseUrl().'/profile/'.$owner["nickname"], $attributes);
XML::addElement($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
$attributes = array("rel" => "photo", "type" => "image/jpeg",
"media:width" => 175, "media:height" => 175, "href" => $owner['photo']);
$attributes = ["rel" => "photo", "type" => "image/jpeg",
"media:width" => 175, "media:height" => 175, "href" => $owner['photo']];
if (!$public || !$hidewall) {
$attributes["dfrn:updated"] = $picdate;
@ -753,20 +753,20 @@ class DFRN
/// @Todo
/// - Check real image type and image size
/// - Check which of these boths elements we should use
$attributes = array(
$attributes = [
"rel" => "photo",
"type" => "image/jpeg",
"media:width" => 80,
"media:height" => 80,
"href" => $contact["photo"]);
"href" => $contact["photo"]];
XML::addElement($doc, $author, "link", "", $attributes);
$attributes = array(
$attributes = [
"rel" => "avatar",
"type" => "image/jpeg",
"media:width" => 80,
"media:height" => 80,
"href" => $contact["photo"]);
"href" => $contact["photo"]];
XML::addElement($doc, $author, "link", "", $attributes);
return $author;
@ -813,7 +813,7 @@ class DFRN
$data = parse_xml_string("<dummy>" . $r->link . "</dummy>", false);
if (is_object($data)) {
foreach ($data->link as $link) {
$attributes = array();
$attributes = [];
foreach ($link->attributes() as $parameter => $value) {
$attributes[$parameter] = $value;
}
@ -821,12 +821,12 @@ class DFRN
}
}
} else {
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $r->link);
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $r->link];
XML::addElement($doc, $entry, "link", "", $attributes);
}
}
if ($r->content) {
XML::addElement($doc, $entry, "content", bbcode($r->content), array("type" => "html"));
XML::addElement($doc, $entry, "content", bbcode($r->content), ["type" => "html"]);
}
return $entry;
@ -853,9 +853,9 @@ class DFRN
$matches = false;
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|', $r, $matches);
if ($cnt) {
$attributes = array("rel" => "enclosure",
$attributes = ["rel" => "enclosure",
"href" => $matches[1],
"type" => $matches[3]);
"type" => $matches[3]];
if (intval($matches[2])) {
$attributes["length"] = intval($matches[2]);
@ -887,14 +887,14 @@ class DFRN
*/
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0, $single = false)
{
$mentioned = array();
$mentioned = [];
if (!$item['parent']) {
return;
}
if ($item['deleted']) {
$attributes = array("ref" => $item['uri'], "when" => datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', ATOM_TIME));
$attributes = ["ref" => $item['uri'], "when" => datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', ATOM_TIME)];
return XML::createElement($doc, "at:deleted-entry", "", $attributes);
}
@ -943,9 +943,9 @@ class DFRN
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$parent = q("SELECT `guid`,`plink` FROM `item` WHERE `uri` = '%s' AND `uid` = %d", dbesc($parent_item), intval($item['uid']));
$attributes = array("ref" => $parent_item, "type" => "text/html",
$attributes = ["ref" => $parent_item, "type" => "text/html",
"href" => $parent[0]['plink'],
"dfrn:diaspora_guid" => $parent[0]['guid']);
"dfrn:diaspora_guid" => $parent[0]['guid']];
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
}
@ -965,9 +965,9 @@ class DFRN
}
}
$attributes = array(
$attributes = [
"href" => $conversation_href,
"ref" => $conversation_uri);
"ref" => $conversation_uri];
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
@ -982,7 +982,7 @@ class DFRN
// The "content" field is not read by the receiver. We could remove it when the type is "text"
// We keep it at the moment, maybe there is some old version that doesn't read "dfrn:env"
XML::addElement($doc, $entry, "content", (($type == 'html') ? $htmlbody : $body), array("type" => $type));
XML::addElement($doc, $entry, "content", (($type == 'html') ? $htmlbody : $body), ["type" => $type]);
// We save this value in "plink". Maybe we should read it from there as well?
XML::addElement(
@ -990,8 +990,8 @@ class DFRN
$entry,
"link",
"",
array("rel" => "alternate", "type" => "text/html",
"href" => System::baseUrl() . "/display/" . $item["guid"])
["rel" => "alternate", "type" => "text/html",
"href" => System::baseUrl() . "/display/" . $item["guid"]]
);
// "comment-allow" is some old fashioned stuff for old Friendica versions.
@ -1021,7 +1021,7 @@ class DFRN
}
if ($item['app']) {
XML::addElement($doc, $entry, "statusnet:notice_info", "", array("local_id" => $item['id'], "source" => $item['app']));
XML::addElement($doc, $entry, "statusnet:notice_info", "", ["local_id" => $item['id'], "source" => $item['app']]);
}
XML::addElement($doc, $entry, "dfrn:diaspora_guid", $item["guid"]);
@ -1029,7 +1029,7 @@ class DFRN
// The signed text contains the content in Markdown, the sender handle and the signatur for the content
// It is needed for relayed comments to Diaspora.
if ($item['signed_text']) {
$sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
$sign = base64_encode(json_encode(['signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer']]));
XML::addElement($doc, $entry, "dfrn:diaspora_signature", $sign);
}
@ -1058,7 +1058,7 @@ class DFRN
if (count($tags)) {
foreach ($tags as $t) {
if (($type != 'html') || ($t[0] != "@")) {
XML::addElement($doc, $entry, "category", "", array("scheme" => "X-DFRN:".$t[0].":".$t[1], "term" => $t[2]));
XML::addElement($doc, $entry, "category", "", ["scheme" => "X-DFRN:".$t[0].":".$t[1], "term" => $t[2]]);
}
}
}
@ -1084,9 +1084,9 @@ class DFRN
$entry,
"link",
"",
array("rel" => "mentioned",
["rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
"href" => $mention)
"href" => $mention]
);
} else {
XML::addElement(
@ -1094,9 +1094,9 @@ class DFRN
$entry,
"link",
"",
array("rel" => "mentioned",
["rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
"href" => $mention)
"href" => $mention]
);
}
}
@ -1212,7 +1212,7 @@ class DFRN
return (($res->status) ? $res->status : 3);
}
$postvars = array();
$postvars = [];
$sent_dfrn_id = hex2bin((string) $res->dfrn_id);
$challenge = hex2bin((string) $res->challenge);
$perm = (($res->perm) ? $res->perm : null);
@ -1447,7 +1447,7 @@ class DFRN
*/
private static function fetchauthor($xpath, $context, $importer, $element, $onlyfetch, $xml = "")
{
$author = array();
$author = [];
$author["name"] = $xpath->evaluate($element."/atom:name/text()", $context)->item(0)->nodeValue;
$author["link"] = $xpath->evaluate($element."/atom:uri/text()", $context)->item(0)->nodeValue;
@ -1475,7 +1475,7 @@ class DFRN
}
// Until now we aren't serving different sizes - but maybe later
$avatarlist = array();
$avatarlist = [];
/// @todo check if "avatar" or "photo" would be the best field in the specification
$avatars = $xpath->query($element."/atom:link[@rel='avatar']", $context);
foreach ($avatars as $avatar) {
@ -1505,7 +1505,7 @@ class DFRN
if (DBM::is_result($r) && !$onlyfetch) {
logger("Check if contact details for contact " . $r[0]["id"] . " (" . $r[0]["nick"] . ") have to be updated.", LOGGER_DEBUG);
$poco = array("url" => $contact["url"]);
$poco = ["url" => $contact["url"]];
// When was the last change to name or uri?
$name_element = $xpath->query($element . "/atom:name", $context)->item(0);
@ -1573,7 +1573,7 @@ class DFRN
}
// Save the keywords into the contact table
$tags = array();
$tags = [];
$tagelements = $xpath->evaluate($element . "/poco:tags/text()", $context);
foreach ($tagelements as $tag) {
$tags[$tag->nodeValue] = $tag->nodeValue;
@ -1597,7 +1597,7 @@ class DFRN
// "poco:birthday" is the birthday in the format "yyyy-mm-dd"
$value = $xpath->evaluate($element . "/poco:birthday/text()", $context)->item(0)->nodeValue;
if (!in_array($value, array("", "0000-00-00", "0001-01-01"))) {
if (!in_array($value, ["", "0000-00-00", "0001-01-01"])) {
$bdyear = date("Y");
$value = str_replace("0000", $bdyear, $value);
@ -1616,7 +1616,7 @@ class DFRN
}
// Get all field names
$fields = array();
$fields = [];
foreach ($r[0] as $field => $data) {
$fields[$field] = $data;
}
@ -1629,7 +1629,7 @@ class DFRN
unset($fields["uri-date"]);
// Update check for this field has to be done differently
$datefields = array("name-date", "uri-date");
$datefields = ["name-date", "uri-date"];
foreach ($datefields as $field) {
if (strtotime($contact[$field]) > strtotime($r[0][$field])) {
logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $r[0][$field] . "'", LOGGER_DEBUG);
@ -1755,7 +1755,7 @@ class DFRN
logger("Processing mails");
/// @TODO Rewrite this to one statement
$msg = array();
$msg = [];
$msg["uid"] = $importer["importer_uid"];
$msg["from-name"] = $xpath->query("dfrn:sender/dfrn:name/text()", $mail)->item(0)->nodeValue;
$msg["from-url"] = $xpath->query("dfrn:sender/dfrn:uri/text()", $mail)->item(0)->nodeValue;
@ -1773,7 +1773,7 @@ class DFRN
// send notifications.
/// @TODO Arange this mess
$notif_params = array(
$notif_params = [
"type" => NOTIFY_MAIL,
"notify_flags" => $importer["notify-flags"],
"language" => $importer["language"],
@ -1786,7 +1786,7 @@ class DFRN
"source_photo" => $importer["thumb"],
"verb" => ACTIVITY_POST,
"otype" => "mail"
);
];
notification($notif_params);
@ -1809,7 +1809,7 @@ class DFRN
logger("Processing suggestions");
/// @TODO Rewrite this to one statement
$suggest = array();
$suggest = [];
$suggest["uid"] = $importer["importer_uid"];
$suggest["cid"] = $importer["id"];
$suggest["url"] = $xpath->query("dfrn:url/text()", $suggestion)->item(0)->nodeValue;
@ -1910,7 +1910,7 @@ class DFRN
);
notification(
array(
[
"type" => NOTIFY_SUGGEST,
"notify_flags" => $importer["notify-flags"],
"language" => $importer["language"],
@ -1923,7 +1923,7 @@ class DFRN
"source_link" => $importer["url"],
"source_photo" => $importer["photo"],
"verb" => ACTIVITY_REQ_FRIEND,
"otype" => "intro")
"otype" => "intro"]
);
return true;
@ -1943,7 +1943,7 @@ class DFRN
logger("Processing relocations");
/// @TODO Rewrite this to one statement
$relocate = array();
$relocate = [];
$relocate["uid"] = $importer["importer_uid"];
$relocate["cid"] = $importer["id"];
$relocate["url"] = $xpath->query("dfrn:url/text()", $relocation)->item(0)->nodeValue;
@ -2043,12 +2043,12 @@ class DFRN
// update items
/// @todo This is an extreme performance killer
$fields = array(
'owner-link' => array($old["url"], $relocate["url"]),
'author-link' => array($old["url"], $relocate["url"]),
$fields = [
'owner-link' => [$old["url"], $relocate["url"]],
'author-link' => [$old["url"], $relocate["url"]],
//'owner-avatar' => array($old["photo"], $relocate["photo"]),
//'author-avatar' => array($old["photo"], $relocate["photo"]),
);
];
foreach ($fields as $n => $f) {
$r = q(
"SELECT `id` FROM `item` WHERE `%s` = '%s' AND `uid` = %d LIMIT 1",
@ -2101,11 +2101,11 @@ class DFRN
return false;
}
$fields = array('title' => $item["title"], 'body' => $item["body"],
$fields = ['title' => $item["title"], 'body' => $item["body"],
'tag' => $item["tag"], 'changed' => datetime_convert(),
'edited' => datetime_convert("UTC", "UTC", $item["edited"]));
'edited' => datetime_convert("UTC", "UTC", $item["edited"])];
$condition = array("`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]);
$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
dba::update('item', $fields, $condition);
create_tags_from_itemuri($item["uri"], $importer["importer_uid"]);
@ -2244,7 +2244,7 @@ class DFRN
if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
// send a notification
notification(
array(
[
"type" => NOTIFY_POKE,
"notify_flags" => $importer["notify-flags"],
"language" => $importer["language"],
@ -2260,7 +2260,7 @@ class DFRN
"verb" => $item["verb"],
"otype" => "person",
"activity" => $verb,
"parent" => $item["parent"])
"parent" => $item["parent"]]
);
}
}
@ -2491,7 +2491,7 @@ class DFRN
$item["created"] = $xpath->query("atom:published/text()", $entry)->item(0)->nodeValue;
$item["body"] = $xpath->query("dfrn:env/text()", $entry)->item(0)->nodeValue;
$item["body"] = str_replace(array(' ',"\t","\r","\n"), array('','','',''), $item["body"]);
$item["body"] = str_replace([' ',"\t","\r","\n"], ['','','',''], $item["body"]);
// make sure nobody is trying to sneak some html tags by us
$item["body"] = notags(base64url_decode($item["body"]));
@ -2643,7 +2643,7 @@ class DFRN
$entrytype = self::getEntryType($importer, $item);
// Now assign the rest of the values that depend on the type of the message
if (in_array($entrytype, array(DFRN_REPLY, DFRN_REPLY_RC))) {
if (in_array($entrytype, [DFRN_REPLY, DFRN_REPLY_RC])) {
if (!isset($item["object-type"])) {
$item["object-type"] = ACTIVITY_OBJ_COMMENT;
}
@ -2728,7 +2728,7 @@ class DFRN
return;
}
if (in_array($entrytype, array(DFRN_REPLY, DFRN_REPLY_RC))) {
if (in_array($entrytype, [DFRN_REPLY, DFRN_REPLY_RC])) {
$posted_id = item_store($item);
$parent = 0;
@ -2883,7 +2883,7 @@ class DFRN
}
if ($author_remove || $owner_remove) {
$tags = explode(',', $i[0]["tag"]);
$newtags = array();
$newtags = [];
if (count($tags)) {
foreach ($tags as $tag) {
if (trim($tag) !== trim($xo->body)) {
@ -2990,7 +2990,7 @@ class DFRN
$xpath->registerNamespace("ostatus", NAMESPACE_OSTATUS);
$xpath->registerNamespace("statusnet", NAMESPACE_STATUSNET);
$header = array();
$header = [];
$header["uid"] = $importer["uid"];
$header["network"] = NETWORK_DFRN;
$header["type"] = "remote";
@ -3017,7 +3017,7 @@ class DFRN
$accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()")->item(0)->nodeValue);
if ($accounttype != $importer["contact-type"]) {
dba::update('contact', array('contact-type' => $accounttype), array('id' => $importer["id"]));
dba::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
}
}
@ -3026,8 +3026,8 @@ class DFRN
$forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()")->item(0)->nodeValue);
if ($forum != $importer["forum"]) {
$condition = array('`forum` != ? AND `id` = ?', $forum, $importer["id"]);
dba::update('contact', array('forum' => $forum), $condition);
$condition = ['`forum` != ? AND `id` = ?', $forum, $importer["id"]];
dba::update('contact', ['forum' => $forum], $condition);
}
// We are processing relocations even if we are ignoring a contact
@ -3064,7 +3064,7 @@ class DFRN
self::processEntry($header, $xpath, $entry, $importer, $xml);
}
} else {
$newentries = array();
$newentries = [];
$entries = $xpath->query("/atom:feed/atom:entry");
foreach ($entries as $entry) {
$created = $xpath->query("atom:published/text()", $entry)->item(0)->nodeValue;

View file

@ -51,10 +51,10 @@ class Diaspora
{
$serverdata = Config::get("system", "relay_server");
if ($serverdata == "") {
return array();
return [];
}
$relay = array();
$relay = [];
$servers = explode(",", $serverdata);
@ -215,7 +215,7 @@ class Diaspora
}
$b64url_data = base64url_encode($data);
$msg = str_replace(array("\n", "\r", " ", "\t"), array("", "", "", ""), $b64url_data);
$msg = str_replace(["\n", "\r", " ", "\t"], ["", "", "", ""], $b64url_data);
$signable_data = $msg.".".base64url_encode($type).".".base64url_encode($encoding).".".base64url_encode($alg);
@ -305,7 +305,7 @@ class Diaspora
$base = $basedom->children(NAMESPACE_SALMON_ME);
// Not sure if this cleaning is needed
$data = str_replace(array(" ", "\t", "\r", "\n"), array("", "", "", ""), $base->data);
$data = str_replace([" ", "\t", "\r", "\n"], ["", "", "", ""], $base->data);
// Build the signed data
$type = $base->data[0]->attributes()->type[0];
@ -327,9 +327,9 @@ class Diaspora
http_status_exit(400);
}
return array('message' => (string)base64url_decode($base->data),
return ['message' => (string)base64url_decode($base->data),
'author' => unxmlify($author_addr),
'key' => (string)$key);
'key' => (string)$key];
}
/**
@ -412,7 +412,7 @@ class Diaspora
// unpack the data
// strip whitespace so our data element will return to one big base64 blob
$data = str_replace(array(" ", "\t", "\r", "\n"), array("", "", "", ""), $base->data);
$data = str_replace([" ", "\t", "\r", "\n"], ["", "", "", ""], $base->data);
// stash away some other stuff for later
@ -463,9 +463,9 @@ class Diaspora
logger('Message verified.');
return array('message' => (string)$inner_decrypted,
return ['message' => (string)$inner_decrypted,
'author' => unxmlify($author_link),
'key' => (string)$key);
'key' => (string)$key];
}
@ -504,11 +504,11 @@ class Diaspora
// Process item retractions. This has to be done separated from the other stuff,
// since retractions for comments could come even from non followers.
if (!empty($fields) && in_array($fields->getName(), array('retraction'))) {
if (!empty($fields) && in_array($fields->getName(), ['retraction'])) {
$target = notags(unxmlify($fields->target_type));
if (in_array($target, array("Comment", "Like", "Post", "Reshare", "StatusMessage"))) {
if (in_array($target, ["Comment", "Like", "Post", "Reshare", "StatusMessage"])) {
logger('processing retraction for '.$target, LOGGER_DEBUG);
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
$importer = ["uid" => 0, "page-flags" => PAGE_FREELOVE];
$message_id = self::dispatch($importer, $msg, $fields);
return $message_id;
}
@ -532,7 +532,7 @@ class Diaspora
logger("Unwanted message from ".$msg["author"]." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG);
} else {
// Use a dummy importer to import the data for the public copy
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
$importer = ["uid" => 0, "page-flags" => PAGE_FREELOVE];
$message_id = self::dispatch($importer, $msg, $fields);
}
@ -657,7 +657,7 @@ class Diaspora
// All retractions are handled identically from now on.
// In the new version there will only be "retraction".
if (in_array($type, array("signed_retraction", "relayable_retraction")))
if (in_array($type, ["signed_retraction", "relayable_retraction"]))
$type = "retraction";
if ($type == "request") {
@ -677,7 +677,7 @@ class Diaspora
if ($fieldname == "participant_handles") {
$fieldname = "participants";
}
if (in_array($type, array("like", "participation"))) {
if (in_array($type, ["like", "participation"])) {
if ($fieldname == "target_type") {
$fieldname = "parent_type";
}
@ -710,14 +710,14 @@ class Diaspora
$author_signature = base64_decode($entry);
} elseif (($fieldname == "parent_author_signature") && ($entry != "")) {
$parent_author_signature = base64_decode($entry);
} elseif (!in_array($fieldname, array("author_signature", "parent_author_signature", "target_author_signature"))) {
} elseif (!in_array($fieldname, ["author_signature", "parent_author_signature", "target_author_signature"])) {
if ($signed_data != "") {
$signed_data .= ";";
}
$signed_data .= $entry;
}
if (!in_array($fieldname, array("parent_author_signature", "target_author_signature"))
if (!in_array($fieldname, ["parent_author_signature", "target_author_signature"])
|| ($orig_type == "relayable_retraction")
) {
XML::copy($entry, $fields, $fieldname);
@ -725,7 +725,7 @@ class Diaspora
}
// This is something that shouldn't happen at all.
if (in_array($type, array("status_message", "reshare", "profile"))) {
if (in_array($type, ["status_message", "reshare", "profile"])) {
if ($msg["author"] != $fields->author) {
logger("Message handle is not the same as envelope sender. Quitting this message.");
return false;
@ -733,8 +733,8 @@ class Diaspora
}
// Only some message types have signatures. So we quit here for the other types.
if (!in_array($type, array("comment", "like"))) {
return array("fields" => $fields, "relayed" => false);
if (!in_array($type, ["comment", "like"])) {
return ["fields" => $fields, "relayed" => false];
}
// No author_signature? This is a must, so we quit.
if (!isset($author_signature)) {
@ -761,7 +761,7 @@ class Diaspora
logger("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG);
return false;
} else {
return array("fields" => $fields, "relayed" => $relayed);
return ["fields" => $fields, "relayed" => $relayed];
}
}
@ -1311,7 +1311,7 @@ class Diaspora
return false;
}
$msg = array("message" => $x, "author" => $author);
$msg = ["message" => $x, "author" => $author];
$msg["key"] = self::key($msg["author"]);
@ -1396,7 +1396,7 @@ class Diaspora
$network = NETWORK_DIASPORA;
}
return array("cid" => $cid, "network" => $network);
return ["cid" => $cid, "network" => $network];
}
/**
@ -1495,30 +1495,30 @@ class Diaspora
return false;
}
$fields = array('url' => $data['url'], 'nurl' => normalise_link($data['url']),
$fields = ['url' => $data['url'], 'nurl' => normalise_link($data['url']),
'name' => $data['name'], 'nick' => $data['nick'],
'addr' => $data['addr'], 'batch' => $data['batch'],
'notify' => $data['notify'], 'poll' => $data['poll'],
'network' => $data['network']);
'network' => $data['network']];
dba::update('contact', $fields, array('addr' => $old_handle));
dba::update('contact', $fields, ['addr' => $old_handle]);
$fields = array('url' => $data['url'], 'nurl' => normalise_link($data['url']),
$fields = ['url' => $data['url'], 'nurl' => normalise_link($data['url']),
'name' => $data['name'], 'nick' => $data['nick'],
'addr' => $data['addr'], 'connect' => $data['addr'],
'notify' => $data['notify'], 'photo' => $data['photo'],
'server_url' => $data['baseurl'], 'network' => $data['network']);
'server_url' => $data['baseurl'], 'network' => $data['network']];
dba::update('gcontact', $fields, array('addr' => $old_handle));
dba::update('gcontact', $fields, ['addr' => $old_handle]);
logger('Contacts are updated.');
// update items
/// @todo This is an extreme performance killer
$fields = array(
'owner-link' => array($contact["url"], $data["url"]),
'author-link' => array($contact["url"], $data["url"]),
);
$fields = [
'owner-link' => [$contact["url"], $data["url"]],
'author-link' => [$contact["url"], $data["url"]],
];
foreach ($fields as $n => $f) {
$r = q(
"SELECT `id` FROM `item` WHERE `%s` = '%s' AND `uid` = %d LIMIT 1",
@ -1687,7 +1687,7 @@ class Diaspora
// Fetch the contact id - if we know this contact
$author_contact = self::authorContactByUrl($contact, $person, $importer["uid"]);
$datarray = array();
$datarray = [];
$datarray["uid"] = $importer["uid"];
$datarray["contact-id"] = $author_contact["cid"];
@ -1743,7 +1743,7 @@ class Diaspora
if ($message_id && $parent_item["origin"]) {
// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($data)));
dba::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($data)]);
// notify others
Worker::add(PRIORITY_HIGH, "Notifier", "comment-import", $message_id);
@ -1828,22 +1828,22 @@ class Diaspora
dba::unlock();
dba::update('conv', array('updated' => datetime_convert()), array('id' => $conversation["id"]));
dba::update('conv', ['updated' => datetime_convert()], ['id' => $conversation["id"]]);
notification(
array(
[
"type" => NOTIFY_MAIL,
"notify_flags" => $importer["notify-flags"],
"language" => $importer["language"],
"to_name" => $importer["username"],
"to_email" => $importer["email"],
"uid" =>$importer["uid"],
"item" => array("subject" => $subject, "body" => $body),
"item" => ["subject" => $subject, "body" => $body],
"source_name" => $person["name"],
"source_link" => $person["url"],
"source_photo" => $person["thumb"],
"verb" => ACTIVITY_POST,
"otype" => "mail")
"otype" => "mail"]
);
return true;
}
@ -1956,12 +1956,12 @@ class Diaspora
$link = '<link rel="alternate" type="text/html" href="'.System::baseUrl()."/display/".$importer["nickname"]."/".$parent_item["id"].'" />';
$parent_body = $parent_item["body"];
$xmldata = array("object" => array("type" => $objtype,
$xmldata = ["object" => ["type" => $objtype,
"local" => "1",
"id" => $parent_item["uri"],
"link" => $link,
"title" => "",
"content" => $parent_body));
"content" => $parent_body]];
return XML::fromArray($xmldata, $xml, true);
}
@ -1985,7 +1985,7 @@ class Diaspora
// likes on comments aren't supported by Diaspora - only on posts
// But maybe this will be supported in the future, so we will accept it.
if (!in_array($parent_type, array("Post", "Comment"))) {
if (!in_array($parent_type, ["Post", "Comment"])) {
return false;
}
@ -2021,7 +2021,7 @@ class Diaspora
$verb = ACTIVITY_DISLIKE;
}
$datarray = array();
$datarray = [];
$datarray["protocol"] = PROTOCOL_DIASPORA;
@ -2072,7 +2072,7 @@ class Diaspora
if ($message_id && $origin) {
// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($data)));
dba::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($data)]);
// notify others
Worker::add(PRIORITY_HIGH, "Notifier", "comment-import", $message_id);
@ -2161,7 +2161,7 @@ class Diaspora
dba::unlock();
dba::update('conv', array('updated' => datetime_convert()), array('id' => $conversation["id"]));
dba::update('conv', ['updated' => datetime_convert()], ['id' => $conversation["id"]]);
return true;
}
@ -2284,7 +2284,7 @@ class Diaspora
$tags = explode("#", $tags);
$keywords = array();
$keywords = [];
foreach ($tags as $tag) {
$tag = trim(strtolower($tag));
if ($tag != "") {
@ -2338,11 +2338,11 @@ class Diaspora
intval($importer["uid"])
);
$gcontact = array("url" => $contact["url"], "network" => NETWORK_DIASPORA, "generation" => 2,
$gcontact = ["url" => $contact["url"], "network" => NETWORK_DIASPORA, "generation" => 2,
"photo" => $image_url, "name" => $name, "location" => $location,
"about" => $about, "birthday" => $birthday, "gender" => $gender,
"addr" => $author, "nick" => $nick, "keywords" => $keywords,
"hide" => !$searchable, "nsfw" => $nsfw);
"hide" => !$searchable, "nsfw" => $nsfw];
$gcid = GContact::update($gcontact);
@ -2367,8 +2367,8 @@ class Diaspora
if ($contact["rel"] == CONTACT_IS_SHARING) {
dba::update(
'contact',
array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
array('id' => $contact["id"], 'uid' => $importer["uid"])
['rel' => CONTACT_IS_FRIEND, 'writable' => true],
['id' => $contact["id"], 'uid' => $importer["uid"]]
);
}
// send notification
@ -2387,7 +2387,7 @@ class Diaspora
// they are not CONTACT_IS_FOLLOWER anymore but that's what we have in the array
if ($self && $contact["rel"] == CONTACT_IS_FOLLOWER) {
$arr = array();
$arr = [];
$arr["protocol"] = PROTOCOL_DIASPORA;
$arr["uri"] = $arr["parent-uri"] = item_new_uri($a->get_hostname(), $importer["uid"]);
$arr["uid"] = $importer["uid"];
@ -2439,10 +2439,10 @@ class Diaspora
$link = '<link rel="alternate" type="text/html" href="'.$contact["url"].'" />'."\n".
'<link rel="photo" type="image/jpeg" href="'.$contact["thumb"].'" />'."\n";
$xmldata = array("object" => array("type" => $objtype,
$xmldata = ["object" => ["type" => $objtype,
"title" => $contact["name"],
"id" => $contact["url"]."/".$contact["name"],
"link" => $link));
"link" => $link]];
return XML::fromArray($xmldata, $xml, true);
}
@ -2492,7 +2492,7 @@ class Diaspora
// If we are now friends, we are sending a share message.
// Normally we needn't to do so, but the first message could have been vanished.
if (in_array($contact["rel"], array(CONTACT_IS_FRIEND))) {
if (in_array($contact["rel"], [CONTACT_IS_FRIEND])) {
$u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
if ($u) {
logger("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG);
@ -2507,7 +2507,7 @@ class Diaspora
}
}
if (!$following && $sharing && in_array($importer["page-flags"], array(PAGE_SOAPBOX, PAGE_NORMAL))) {
if (!$following && $sharing && in_array($importer["page-flags"], [PAGE_SOAPBOX, PAGE_NORMAL])) {
logger("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", LOGGER_DEBUG);
return false;
} elseif (!$following && !$sharing) {
@ -2621,7 +2621,7 @@ class Diaspora
$ret = self::sendShare($u[0], $contact_record);
// Send the profile data, maybe it weren't transmitted before
self::sendProfile($importer["uid"], array($contact_record));
self::sendProfile($importer["uid"], [$contact_record]);
}
}
@ -2654,7 +2654,7 @@ class Diaspora
// Then refetch the content, if it is a reshare from a reshare.
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
if (self::isReshare($r[0]["body"], true)) {
$r = array();
$r = [];
} elseif (self::isReshare($r[0]["body"], false) || strstr($r[0]["body"], "[share")) {
$r[0]["body"] = diaspora2bb(bb2diaspora($r[0]["body"]));
@ -2738,7 +2738,7 @@ class Diaspora
$orig_url = System::baseUrl()."/display/".$original_item["guid"];
$datarray = array();
$datarray = [];
$datarray["uid"] = $importer["uid"];
$datarray["contact-id"] = $contact["id"];
@ -2819,13 +2819,13 @@ class Diaspora
}
// Fetch items that are about to be deleted
$fields = array('uid', 'id', 'parent', 'parent-uri', 'author-link');
$fields = ['uid', 'id', 'parent', 'parent-uri', 'author-link'];
// When we receive a public retraction, we delete every item that we find.
if ($importer['uid'] == 0) {
$condition = array("`guid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid);
$condition = ["`guid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid];
} else {
$condition = array("`guid` = ? AND `uid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid, $importer['uid']);
$condition = ["`guid` = ? AND `uid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid, $importer['uid']];
}
$r = dba::select('item', $fields, $condition);
if (!DBM::is_result($r)) {
@ -2847,13 +2847,13 @@ class Diaspora
// The function "item_drop" doesn't work for that case
dba::update(
'item',
array(
[
'deleted' => true,
'title' => '',
'body' => '',
'edited' => datetime_convert(),
'changed' => datetime_convert()),
array('id' => $item["id"])
'changed' => datetime_convert()],
['id' => $item["id"]]
);
// Delete the thread - if it is a starting post and not a comment
@ -2887,7 +2887,7 @@ class Diaspora
$target_type = notags(unxmlify($data->target_type));
$contact = self::contactByHandle($importer["uid"], $sender);
if (!$contact && (in_array($target_type, array("Contact", "Person")))) {
if (!$contact && (in_array($target_type, ["Contact", "Person"]))) {
logger("cannot find contact for sender: ".$sender." and user ".$importer["uid"]);
return false;
}
@ -2944,7 +2944,7 @@ class Diaspora
return true;
}
$address = array();
$address = [];
if ($data->location) {
foreach ($data->location->children() as $fieldname => $data) {
$address[$fieldname] = notags(unxmlify($data));
@ -2953,7 +2953,7 @@ class Diaspora
$body = diaspora2bb($text);
$datarray = array();
$datarray = [];
// Attach embedded pictures to the body
if ($data->photo) {
@ -3090,14 +3090,14 @@ class Diaspora
$ciphertext = self::aesEncrypt($aes_key, $iv, $msg);
$json = json_encode(array("iv" => $b_iv, "key" => $b_aes_key));
$json = json_encode(["iv" => $b_iv, "key" => $b_aes_key]);
$encrypted_key_bundle = "";
openssl_public_encrypt($json, $encrypted_key_bundle, $pubkey);
$json_object = json_encode(
array("aes_key" => base64_encode($encrypted_key_bundle),
"encrypted_magic_envelope" => base64_encode($ciphertext))
["aes_key" => base64_encode($encrypted_key_bundle),
"encrypted_magic_envelope" => base64_encode($ciphertext)]
);
return $json_object;
@ -3114,7 +3114,7 @@ class Diaspora
public static function buildMagicEnvelope($msg, $user)
{
$b64url_data = base64url_encode($msg);
$data = str_replace(array("\n", "\r", " ", "\t"), array("", "", "", ""), $b64url_data);
$data = str_replace(["\n", "\r", " ", "\t"], ["", "", "", ""], $b64url_data);
$key_id = base64url_encode(self::myHandle($user));
$type = "application/xml";
@ -3130,14 +3130,14 @@ class Diaspora
$signature = Crypto::rsaSign($signable_data, $user["uprvkey"]);
$sig = base64url_encode($signature);
$xmldata = array("me:env" => array("me:data" => $data,
"@attributes" => array("type" => $type),
$xmldata = ["me:env" => ["me:data" => $data,
"@attributes" => ["type" => $type],
"me:encoding" => $encoding,
"me:alg" => $alg,
"me:sig" => $sig,
"@attributes2" => array("key_id" => $key_id)));
"@attributes2" => ["key_id" => $key_id]]];
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
$namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
return XML::fromArray($xmldata, $xml, false, $namespaces);
}
@ -3230,7 +3230,7 @@ class Diaspora
if (!intval(Config::get("system", "diaspora_test"))) {
$content_type = (($public_batch) ? "application/magic-envelope+xml" : "application/json");
post_url($dest_url."/", $envelope, array("Content-Type: ".$content_type));
post_url($dest_url."/", $envelope, ["Content-Type: ".$content_type]);
$return_code = $a->get_curl_code();
} else {
logger("test_mode");
@ -3278,7 +3278,7 @@ class Diaspora
*/
public static function buildPostXml($type, $message)
{
$data = array($type => $message);
$data = [$type => $message];
return XML::fromArray($data, $xml);
}
@ -3357,10 +3357,10 @@ class Diaspora
$author = self::myHandle($owner);
$message = array("author" => $author,
$message = ["author" => $author,
"guid" => get_guid(32),
"parent_type" => "Post",
"parent_guid" => $item["guid"]);
"parent_guid" => $item["guid"]];
logger("Send participation for ".$item["guid"]." by ".$author, LOGGER_DEBUG);
@ -3387,9 +3387,9 @@ class Diaspora
$signed_text = 'AccountMigration:'.$old_handle.':'.$profile['author'];
$signature = base64_encode(Crypto::rsaSign($signed_text, $owner["uprvkey"], "sha256"));
$message = array("author" => $old_handle,
$message = ["author" => $old_handle,
"profile" => $profile,
"signature" => $signature);
"signature" => $signature];
logger("Send account migration ".print_r($message, true), LOGGER_DEBUG);
@ -3427,10 +3427,10 @@ class Diaspora
}
*/
$message = array("author" => self::myHandle($owner),
$message = ["author" => self::myHandle($owner),
"recipient" => $contact["addr"],
"following" => "true",
"sharing" => "true");
"sharing" => "true"];
logger("Send share ".print_r($message, true), LOGGER_DEBUG);
@ -3447,10 +3447,10 @@ class Diaspora
*/
public static function sendUnshare($owner, $contact)
{
$message = array("author" => self::myHandle($owner),
$message = ["author" => self::myHandle($owner),
"recipient" => $contact["addr"],
"following" => "false",
"sharing" => "false");
"sharing" => "false"];
logger("Send unshare ".print_r($message, true), LOGGER_DEBUG);
@ -3510,7 +3510,7 @@ class Diaspora
NETWORK_DIASPORA
);
if ($r) {
$ret= array();
$ret= [];
$ret["root_handle"] = self::handleFromContact($r[0]["contact-id"]);
$ret["root_guid"] = $guid;
return($ret);
@ -3528,7 +3528,7 @@ class Diaspora
$profile = $matches[1];
}
$ret= array();
$ret= [];
$ret["root_handle"] = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile);
if (($ret["root_handle"] == $profile) || ($ret["root_handle"] == "")) {
@ -3565,23 +3565,23 @@ class Diaspora
{
$r = q("SELECT `guid`, `uid`, `start`, `finish`, `nofinish`, `summary`, `desc`, `location`, `adjust` FROM `event` WHERE `id` = %d", intval($event_id));
if (!DBM::is_result($r)) {
return array();
return [];
}
$event = $r[0];
$eventdata = array();
$eventdata = [];
$r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d", intval($event['uid']));
if (!DBM::is_result($r)) {
return array();
return [];
}
$user = $r[0];
$r = q("SELECT `addr`, `nick` FROM `contact` WHERE `uid` = %d AND `self`", intval($event['uid']));
if (!DBM::is_result($r)) {
return array();
return [];
}
$owner = $r[0];
@ -3618,7 +3618,7 @@ class Diaspora
$eventdata['description'] = html_entity_decode(bb2diaspora($event['desc']));
}
if ($event['location']) {
$location = array();
$location = [];
$location["address"] = html_entity_decode(bb2diaspora($event['location']));
$location["lat"] = 0;
$location["lng"] = 0;
@ -3655,13 +3655,13 @@ class Diaspora
// Detect a share element and do a reshare
if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
$message = array("author" => $myaddr,
$message = ["author" => $myaddr,
"guid" => $item["guid"],
"created_at" => $created,
"root_author" => $ret["root_handle"],
"root_guid" => $ret["root_guid"],
"provider_display_name" => $item["app"],
"public" => $public);
"public" => $public];
$type = "reshare";
} else {
@ -3686,7 +3686,7 @@ class Diaspora
}
}
$location = array();
$location = [];
if ($item["location"] != "")
$location["address"] = $item["location"];
@ -3697,13 +3697,13 @@ class Diaspora
$location["lng"] = $coord[1];
}
$message = array("author" => $myaddr,
$message = ["author" => $myaddr,
"guid" => $item["guid"],
"created_at" => $created,
"public" => $public,
"text" => $body,
"provider_display_name" => $item["app"],
"location" => $location);
"location" => $location];
// Diaspora rejects messages when they contain a location without "lat" or "lng"
if (!isset($location["lat"]) || !isset($location["lng"])) {
@ -3723,7 +3723,7 @@ class Diaspora
$type = "status_message";
}
$msg = array("type" => $type, "message" => $message);
$msg = ["type" => $type, "message" => $message];
Cache::set($cachekey, $msg, CACHE_QUARTER_HOUR);
@ -3774,12 +3774,12 @@ class Diaspora
$positive = "false";
}
return(array("author" => self::myHandle($owner),
return(["author" => self::myHandle($owner),
"guid" => $item["guid"],
"parent_guid" => $parent["guid"],
"parent_type" => $target_type,
"positive" => $positive,
"author_signature" => ""));
"author_signature" => ""]);
}
/**
@ -3817,11 +3817,11 @@ class Diaspora
return false;
}
return(array("author" => self::myHandle($owner),
return(["author" => self::myHandle($owner),
"guid" => $item["guid"],
"parent_guid" => $parent["guid"],
"status" => $attend_answer,
"author_signature" => ""));
"author_signature" => ""]);
}
/**
@ -3856,12 +3856,12 @@ class Diaspora
$text = html_entity_decode(bb2diaspora($item["body"]));
$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
$comment = array("author" => self::myHandle($owner),
$comment = ["author" => self::myHandle($owner),
"guid" => $item["guid"],
"created_at" => $created,
"parent_guid" => $parent["guid"],
"text" => $text,
"author_signature" => "");
"author_signature" => ""];
// Send the thread parent guid only if it is a threaded comment
if ($item['thr-parent'] != $item['parent-uri']) {
@ -3885,10 +3885,10 @@ class Diaspora
*/
public static function sendFollowup($item, $owner, $contact, $public_batch = false)
{
if (in_array($item['verb'], array(ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE))) {
if (in_array($item['verb'], [ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE])) {
$message = self::constructAttend($item, $owner);
$type = "event_participation";
} elseif (in_array($item["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
$message = self::constructLike($item, $owner);
$type = "like";
} else {
@ -3919,17 +3919,17 @@ class Diaspora
$signed_parts = explode(";", $signature['signed_text']);
if ($item["deleted"]) {
$message = array("author" => $signature['signer'],
$message = ["author" => $signature['signer'],
"target_guid" => $signed_parts[0],
"target_type" => $signed_parts[1]);
} elseif (in_array($item["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
$message = array("author" => $signed_parts[4],
"target_type" => $signed_parts[1]];
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
$message = ["author" => $signed_parts[4],
"guid" => $signed_parts[1],
"parent_guid" => $signed_parts[3],
"parent_type" => $signed_parts[2],
"positive" => $signed_parts[0],
"author_signature" => $signature['signature'],
"parent_author_signature" => "");
"parent_author_signature" => ""];
} else {
// Remove the comment guid
$guid = array_shift($signed_parts);
@ -3943,12 +3943,12 @@ class Diaspora
// Glue the parts together
$text = implode(";", $signed_parts);
$message = array("author" => $handle,
$message = ["author" => $handle,
"guid" => $guid,
"parent_guid" => $parent_guid,
"text" => implode(";", $signed_parts),
"author_signature" => $signature['signature'],
"parent_author_signature" => "");
"parent_author_signature" => ""];
}
return $message;
}
@ -3967,7 +3967,7 @@ class Diaspora
{
if ($item["deleted"]) {
return self::sendRetraction($item, $owner, $contact, $public_batch, true);
} elseif (in_array($item["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
$type = "like";
} else {
$type = "comment";
@ -3996,7 +3996,7 @@ class Diaspora
} else {// New way
$msg = json_decode($signature['signed_text'], true);
$message = array();
$message = [];
if (is_array($msg)) {
foreach ($msg as $field => $data) {
if (!$item["deleted"]) {
@ -4041,15 +4041,15 @@ class Diaspora
if ($item['id'] == $item['parent']) {
$target_type = "Post";
} elseif (in_array($item["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
$target_type = "Like";
} else {
$target_type = "Comment";
}
$message = array("author" => $itemaddr,
$message = ["author" => $itemaddr,
"target_guid" => $item['guid'],
"target_type" => $target_type);
"target_type" => $target_type];
logger("Got message ".print_r($message, true), LOGGER_DEBUG);
@ -4081,36 +4081,36 @@ class Diaspora
}
$cnv = $r[0];
$conv = array(
$conv = [
"author" => $cnv["creator"],
"guid" => $cnv["guid"],
"subject" => $cnv["subject"],
"created_at" => datetime_convert("UTC", "UTC", $cnv['created'], 'Y-m-d\TH:i:s\Z'),
"participants" => $cnv["recips"]
);
];
$body = bb2diaspora($item["body"]);
$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
$msg = array(
$msg = [
"author" => $myaddr,
"guid" => $item["guid"],
"conversation_guid" => $cnv["guid"],
"text" => $body,
"created_at" => $created,
);
];
if ($item["reply"]) {
$message = $msg;
$type = "message";
} else {
$message = array(
$message = [
"author" => $cnv["creator"],
"guid" => $cnv["guid"],
"subject" => $cnv["subject"],
"created_at" => datetime_convert("UTC", "UTC", $cnv['created'], 'Y-m-d\TH:i:s\Z'),
"participants" => $cnv["recips"],
"message" => $msg);
"message" => $msg];
$type = "conversation";
}
@ -4193,7 +4193,7 @@ class Diaspora
);
if (!$r) {
return array();
return [];
}
$profile = $r[0];
@ -4235,7 +4235,7 @@ class Diaspora
$tags = trim($tags);
}
return array("author" => $handle,
return ["author" => $handle,
"first_name" => $first,
"last_name" => $last,
"image_url" => $large,
@ -4247,7 +4247,7 @@ class Diaspora
"location" => $location,
"searchable" => $searchable,
"nsfw" => "false",
"tag_string" => $tags);
"tag_string" => $tags];
}
/**
@ -4318,7 +4318,7 @@ class Diaspora
return false;
}
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
if (!in_array($r[0]["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
return false;
}
@ -4333,7 +4333,7 @@ class Diaspora
* Now store the signature more flexible to dynamically support new fields.
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
*/
dba::insert('sign', array('iid' => $post_id, 'signed_text' => json_encode($message)));
dba::insert('sign', ['iid' => $post_id, 'signed_text' => json_encode($message)]);
logger('Stored diaspora like signature');
return true;
@ -4369,7 +4369,7 @@ class Diaspora
* Now store the signature more flexible to dynamically support new fields.
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
*/
dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($message)));
dba::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($message)]);
logger('Stored diaspora comment signature');
return true;

View file

@ -36,26 +36,26 @@ class Email
public static function poll($mbox, $email_addr)
{
if (!$mbox || !$email_addr) {
return array();
return [];
}
$search1 = @imap_search($mbox, 'FROM "' . $email_addr . '"', SE_UID);
if (!$search1) {
$search1 = array();
$search1 = [];
} else {
logger("Found mails from ".$email_addr, LOGGER_DEBUG);
}
$search2 = @imap_search($mbox, 'TO "' . $email_addr . '"', SE_UID);
if (!$search2) {
$search2 = array();
$search2 = [];
} else {
logger("Found mails to ".$email_addr, LOGGER_DEBUG);
}
$search3 = @imap_search($mbox, 'CC "' . $email_addr . '"', SE_UID);
if (!$search3) {
$search3 = array();
$search3 = [];
} else {
logger("Found mails cc ".$email_addr, LOGGER_DEBUG);
}
@ -84,8 +84,8 @@ class Email
*/
public static function messageMeta($mbox, $uid)
{
$ret = (($mbox && $uid) ? @imap_fetch_overview($mbox, $uid, FT_UID) : array(array())); // POSSIBLE CLEANUP --> array(array()) is probably redundant now
return (count($ret)) ? $ret : array();
$ret = (($mbox && $uid) ? @imap_fetch_overview($mbox, $uid, FT_UID) : [[]]); // POSSIBLE CLEANUP --> array(array()) is probably redundant now
return (count($ret)) ? $ret : [];
}
/**
@ -96,7 +96,7 @@ class Email
*/
public static function getMessage($mbox, $uid, $reply)
{
$ret = array();
$ret = [];
$struc = (($mbox && $uid) ? @imap_fetchstructure($mbox, $uid, FT_UID) : null);
@ -179,7 +179,7 @@ class Email
// PARAMETERS
// get all parameters, like charset, filenames of attachments, etc.
$params = array();
$params = [];
if ($p->parameters) {
foreach ($p->parameters as $x) {
$params[strtolower($x->attribute)] = $x->value;
@ -388,7 +388,7 @@ class Email
private static function unifyAttributionLine($message)
{
$quotestr = array('quote', 'spoiler');
$quotestr = ['quote', 'spoiler'];
foreach ($quotestr as $quote) {
$message = self::saveReplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Cc: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
$message = self::saveReplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
@ -473,7 +473,7 @@ class Email
$cleaned = trim($result[1].$result[2].$result[3]);
$cleaned = str_replace(array("\n- --\n", "\n- -"), array("\n-- \n", "\n-"), $cleaned);
$cleaned = str_replace(["\n- --\n", "\n- -"], ["\n-- \n", "\n-"], $cleaned);
if ($cleaned == '') {
$cleaned = $message;
@ -496,7 +496,7 @@ class Email
// When the signature separator is inside a quote, we don't separate
if (($sigpos < $quotepos) && ($sigpos != 0)) {
return array('body' => $message, 'sig' => '');
return ['body' => $message, 'sig' => ''];
}
$pattern = '/(.*)[\r\n]-- [\r\n](.*)/is';
@ -511,14 +511,14 @@ class Email
$sig = '';
}
return array('body' => $cleaned, 'sig' => $sig);
return ['body' => $cleaned, 'sig' => $sig];
}
private static function removeLinebreak($message)
{
$arrbody = explode("\n", trim($message));
$lines = array();
$lines = [];
$lineno = 0;
foreach ($arrbody as $i => $line) {
@ -589,7 +589,7 @@ class Email
{
// Convert Quotes
$arrbody = explode("\n", trim($body));
$arrlevel = array();
$arrlevel = [];
for ($i = 0; $i < count($arrbody); $i++) {
$quotelevel = 0;
@ -609,7 +609,7 @@ class Email
$quotelevel = 0;
$previousquote = 0;
$arrbodyquoted = array();
$arrbodyquoted = [];
for ($i = 0; $i < count($arrbody); $i++) {
$previousquote = $quotelevel;
@ -662,7 +662,7 @@ class Email
$message = str_replace("[/quote][quote]", "", $message);
} while ($message != $oldmessage);
$quotes = array();
$quotes = [];
$startquotes = 0;

View file

@ -65,7 +65,7 @@ class Feed {
$xpath->registerNamespace('media', "http://search.yahoo.com/mrss/");
$xpath->registerNamespace('poco', NAMESPACE_POCO);
$author = array();
$author = [];
// Is it RDF?
if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) {
@ -185,7 +185,7 @@ class Feed {
$author["owner-avatar"] = $contact["thumb"];
}
$header = array();
$header = [];
$header["uid"] = $importer["uid"];
$header["network"] = NETWORK_FEED;
$header["type"] = "remote";
@ -208,9 +208,9 @@ class Feed {
return;
}
$items = array();
$items = [];
$entrylist = array();
$entrylist = [];
foreach ($entries AS $entry) {
$entrylist[] = $entry;
@ -309,7 +309,7 @@ class Feed {
// <category>Ausland</category>
// <media:thumbnail width="152" height="76" url="http://www.taz.de/picture/667875/192/14388767.jpg"/>
$attachments = array();
$attachments = [];
$enclosures = $xpath->query("enclosure", $entry);
foreach ($enclosures AS $enclosure) {
@ -331,7 +331,7 @@ class Feed {
$item["attach"] .= ',';
}
$attachments[] = array("link" => $href, "type" => $type, "length" => $length);
$attachments[] = ["link" => $href, "type" => $type, "length" => $length];
$item["attach"] .= '[attach]href="'.$href.'" length="'.$length.'" type="'.$type.'"[/attach]';
}
@ -448,7 +448,7 @@ class Feed {
}
if ($simulate) {
return array("header" => $author, "items" => $items);
return ["header" => $author, "items" => $items];
}
}
}

View file

@ -35,7 +35,7 @@ require_once 'mod/proxy.php';
class OStatus
{
private static $itemlist;
private static $conv_list = array();
private static $conv_list = [];
/**
* @brief Fetches author data
@ -50,7 +50,7 @@ class OStatus
*/
private static function fetchAuthor($xpath, $context, $importer, &$contact, $onlyfetch)
{
$author = array();
$author = [];
$author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
$author["author-name"] = $xpath->evaluate('atom:author/atom:name/text()', $context)->item(0)->nodeValue;
$addr = $xpath->evaluate('atom:author/atom:email/text()', $context)->item(0)->nodeValue;
@ -118,7 +118,7 @@ class OStatus
}
}
$avatarlist = array();
$avatarlist = [];
$avatars = $xpath->query("atom:author/atom:link[@rel='avatar']", $context);
foreach ($avatars as $avatar) {
$href = "";
@ -196,7 +196,7 @@ class OStatus
$contact['name-date'] = datetime_convert();
dba::update('contact', $contact, array('id' => $contact["id"]), $current);
dba::update('contact', $contact, ['id' => $contact["id"]], $current);
if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
@ -211,13 +211,13 @@ class OStatus
$old_contact = dba::selectFirst('contact', $fields, ['id' => $cid]);
// Update it with the current values
$fields = array('url' => $author["author-link"], 'name' => $contact["name"],
$fields = ['url' => $author["author-link"], 'name' => $contact["name"],
'nurl' => normalise_link($author["author-link"]),
'nick' => $contact["nick"], 'alias' => $contact["alias"],
'about' => $contact["about"], 'location' => $contact["location"],
'success_update' => datetime_convert(), 'last-update' => datetime_convert());
'success_update' => datetime_convert(), 'last-update' => datetime_convert()];
dba::update('contact', $fields, array('id' => $cid), $old_contact);
dba::update('contact', $fields, ['id' => $cid], $old_contact);
// Update the avatar
Contact::updateAvatar($author["author-avatar"], 0, $cid);
@ -279,7 +279,7 @@ class OStatus
*/
private static function readAttributes($element)
{
$attribute = array();
$attribute = [];
foreach ($element->attributes as $attributes) {
$attribute[$attributes->name] = $attributes->textContent;
@ -317,8 +317,8 @@ class OStatus
private static function process($xml, $importer, &$contact, &$hub, $stored = false, $initialize = true)
{
if ($initialize) {
self::$itemlist = array();
self::$conv_list = array();
self::$itemlist = [];
self::$conv_list = [];
}
logger("Import OStatus message", LOGGER_DEBUG);
@ -350,7 +350,7 @@ class OStatus
}
}
$header = array();
$header = [];
$header["uid"] = $importer["uid"];
$header["network"] = NETWORK_OSTATUS;
$header["type"] = "remote";
@ -387,7 +387,7 @@ class OStatus
$entry = $xpath->query('/atom:entry');
// Reverse the order of the entries
$entrylist = array();
$entrylist = [];
foreach ($entries as $entry) {
$entrylist[] = $entry;
@ -419,19 +419,19 @@ class OStatus
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
// Delete a message
if (in_array($item["verb"], array('qvitter-delete-notice', ACTIVITY_DELETE, 'delete'))) {
if (in_array($item["verb"], ['qvitter-delete-notice', ACTIVITY_DELETE, 'delete'])) {
self::deleteNotice($item);
continue;
}
if (in_array($item["verb"], array(NAMESPACE_OSTATUS."/unfavorite", ACTIVITY_UNFAVORITE))) {
if (in_array($item["verb"], [NAMESPACE_OSTATUS."/unfavorite", ACTIVITY_UNFAVORITE])) {
// Ignore "Unfavorite" message
logger("Ignore unfavorite message ".print_r($item, true), LOGGER_DEBUG);
continue;
}
// Deletions come with the same uri, so we check for duplicates after processing deletions
if (dba::exists('item', array('uid' => $importer["uid"], 'uri' => $item["uri"]))) {
if (dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item["uri"]])) {
logger('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
continue;
} else {
@ -470,7 +470,7 @@ class OStatus
}
// http://activitystrea.ms/schema/1.0/rsvp-yes
if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE))) {
if (!in_array($item["verb"], [ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE])) {
logger("Unhandled verb ".$item["verb"]." ".print_r($item, true), LOGGER_DEBUG);
}
@ -487,7 +487,7 @@ class OStatus
if ($valid) {
// Never post a thread when the only interaction by our contact was a like
$valid = false;
$verbs = array(ACTIVITY_POST, ACTIVITY_SHARE);
$verbs = [ACTIVITY_POST, ACTIVITY_SHARE];
foreach (self::$itemlist as $item) {
if (!empty($item['contact-id']) && in_array($item['verb'], $verbs)) {
$valid = true;
@ -496,7 +496,7 @@ class OStatus
}
} else {
// But we will only import complete threads
$valid = dba::exists('item', array('uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']));
$valid = dba::exists('item', ['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
}
if ($valid) {
@ -510,7 +510,7 @@ class OStatus
}
}
foreach (self::$itemlist as $item) {
$found = dba::exists('item', array('uid' => $importer["uid"], 'uri' => $item["uri"]));
$found = dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item["uri"]]);
if ($found) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG);
} elseif ($item['contact-id'] < 0) {
@ -528,7 +528,7 @@ class OStatus
}
}
}
self::$itemlist = array();
self::$itemlist = [];
}
logger('Processing done for post with URI '.$item["uri"].' for user '.$importer["uid"].'.', LOGGER_DEBUG);
}
@ -552,9 +552,9 @@ class OStatus
// The function "item_drop" doesn't work for that case
dba::update(
'item',
array('deleted' => true, 'title' => '', 'body' => '',
'edited' => datetime_convert(), 'changed' => datetime_convert()),
array('id' => $deleted["id"])
['deleted' => true, 'title' => '', 'body' => '',
'edited' => datetime_convert(), 'changed' => datetime_convert()],
['id' => $deleted["id"]]
);
delete_thread($deleted["id"], $deleted["parent-uri"]);
@ -687,7 +687,7 @@ class OStatus
}
if (isset($item["parent-uri"]) && ($related != '')) {
if (!dba::exists('item', array('uid' => $importer["uid"], 'uri' => $item['parent-uri']))) {
if (!dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item['parent-uri']])) {
self::fetchRelated($related, $item["parent-uri"], $importer);
} else {
logger('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
@ -722,7 +722,7 @@ class OStatus
self::$conv_list[$conversation] = true;
$conversation_data = z_fetch_url($conversation, false, $redirects, array('accept_content' => 'application/atom+xml, text/html'));
$conversation_data = z_fetch_url($conversation, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']);
if (!$conversation_data['success']) {
return;
@ -792,7 +792,7 @@ class OStatus
$doc2->preserveWhiteSpace = false;
$doc2->formatOutput = true;
$conv_data = array();
$conv_data = [];
$conv_data['protocol'] = PROTOCOL_SPLITTED_CONV;
$conv_data['network'] = NETWORK_OSTATUS;
@ -836,10 +836,10 @@ class OStatus
$conv_data['source'] = $doc2->saveXML();
$condition = array('item-uri' => $conv_data['uri'],'protocol' => PROTOCOL_OSTATUS_FEED);
$condition = ['item-uri' => $conv_data['uri'],'protocol' => PROTOCOL_OSTATUS_FEED];
if (dba::exists('conversation', $condition)) {
logger('Delete deprecated entry for URI '.$conv_data['uri'], LOGGER_DEBUG);
dba::delete('conversation', array('item-uri' => $conv_data['uri']));
dba::delete('conversation', ['item-uri' => $conv_data['uri']]);
}
logger('Store conversation data for uri '.$conv_data['uri'], LOGGER_DEBUG);
@ -860,7 +860,7 @@ class OStatus
*/
private static function fetchSelf($self, &$item)
{
$condition = array('`item-uri` = ? AND `protocol` IN (?, ?)', $self, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON);
$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $self, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
if (dba::exists('conversation', $condition)) {
logger('Conversation '.$item['uri'].' is already stored.', LOGGER_DEBUG);
return;
@ -906,12 +906,12 @@ class OStatus
}
if ($conversation['protocol'] == PROTOCOL_OSTATUS_SALMON) {
logger('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG);
dba::delete('conversation', array('item-uri' => $related_uri));
dba::delete('conversation', ['item-uri' => $related_uri]);
}
}
$stored = false;
$related_data = z_fetch_url($related, false, $redirects, array('accept_content' => 'application/atom+xml, text/html'));
$related_data = z_fetch_url($related, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']);
if (!$related_data['success']) {
return;
@ -1007,10 +1007,10 @@ class OStatus
$activityobjects = $xpath->query('activity:object', $entry)->item(0);
if (!is_object($activityobjects)) {
return array();
return [];
}
$link_data = array();
$link_data = [];
$orig_uri = $xpath->query('atom:id/text()', $activityobjects)->item(0)->nodeValue;
@ -1061,7 +1061,7 @@ class OStatus
*/
private static function processLinks($links, &$item)
{
$link_data = array('add_body' => '', 'self' => '');
$link_data = ['add_body' => '', 'self' => ''];
foreach ($links as $link) {
$attribute = self::readAttributes($link);
@ -1216,8 +1216,8 @@ class OStatus
$preview = proxy_url($preview, false, PROXY_SIZE_SMALL);
// Is it a local picture? Then make it smaller here
$preview = str_replace(array("-0.jpg", "-0.png"), array("-2.jpg", "-2.png"), $preview);
$preview = str_replace(array("-1.jpg", "-1.png"), array("-2.jpg", "-2.png"), $preview);
$preview = str_replace(["-0.jpg", "-0.png"], ["-2.jpg", "-2.png"], $preview);
$preview = str_replace(["-1.jpg", "-1.png"], ["-2.jpg", "-2.png"], $preview);
if (isset($siteinfo["url"])) {
$url = $siteinfo["url"];
@ -1262,7 +1262,7 @@ class OStatus
case 'comments': $title = t('%s\'s comments', $owner['name']); break;
}
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION);
$attributes = ["uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION];
XML::addElement($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
XML::addElement($doc, $root, "id", System::baseUrl() . "/profile/" . $owner["nick"]);
XML::addElement($doc, $root, "title", $title);
@ -1273,7 +1273,7 @@ class OStatus
$author = self::addAuthor($doc, $owner);
$root->appendChild($author);
$attributes = array("href" => $owner["url"], "rel" => "alternate", "type" => "text/html");
$attributes = ["href" => $owner["url"], "rel" => "alternate", "type" => "text/html"];
XML::addElement($doc, $root, "link", "", $attributes);
/// @TODO We have to find out what this is
@ -1284,17 +1284,17 @@ class OStatus
self::hublinks($doc, $root, $owner["nick"]);
$attributes = array("href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "salmon");
$attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "salmon"];
XML::addElement($doc, $root, "link", "", $attributes);
$attributes = array("href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-replies");
$attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-replies"];
XML::addElement($doc, $root, "link", "", $attributes);
$attributes = array("href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention");
$attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention"];
XML::addElement($doc, $root, "link", "", $attributes);
$attributes = array("href" => System::baseUrl() . "/api/statuses/user_timeline/" . $owner["nick"] . ".atom",
"rel" => "self", "type" => "application/atom+xml");
$attributes = ["href" => System::baseUrl() . "/api/statuses/user_timeline/" . $owner["nick"] . ".atom",
"rel" => "self", "type" => "application/atom+xml"];
XML::addElement($doc, $root, "link", "", $attributes);
return $root;
@ -1311,7 +1311,7 @@ class OStatus
public static function hublinks($doc, $root, $nick)
{
$h = System::baseUrl() . '/pubsubhubbub/'.$nick;
XML::addElement($doc, $root, "link", "", array("href" => $h, "rel" => "hub"));
XML::addElement($doc, $root, "link", "", ["href" => $h, "rel" => "hub"]);
}
/**
@ -1330,18 +1330,18 @@ class OStatus
switch ($siteinfo["type"]) {
case 'photo':
$imgdata = Image::getInfoFromURL($siteinfo["image"]);
$attributes = array("rel" => "enclosure",
$attributes = ["rel" => "enclosure",
"href" => $siteinfo["image"],
"type" => $imgdata["mime"],
"length" => intval($imgdata["size"]));
"length" => intval($imgdata["size"])];
XML::addElement($doc, $root, "link", "", $attributes);
break;
case 'video':
$attributes = array("rel" => "enclosure",
$attributes = ["rel" => "enclosure",
"href" => $siteinfo["url"],
"type" => "text/html; charset=UTF-8",
"length" => "",
"title" => $siteinfo["title"]);
"title" => $siteinfo["title"]];
XML::addElement($doc, $root, "link", "", $attributes);
break;
default:
@ -1350,10 +1350,10 @@ class OStatus
if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
$imgdata = Image::getInfoFromURL($siteinfo["image"]);
$attributes = array("rel" => "enclosure",
$attributes = ["rel" => "enclosure",
"href" => $siteinfo["image"],
"type" => $imgdata["mime"],
"length" => intval($imgdata["size"]));
"length" => intval($imgdata["size"])];
XML::addElement($doc, $root, "link", "", $attributes);
}
@ -1364,9 +1364,9 @@ class OStatus
$matches = false;
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|', $r, $matches);
if ($cnt) {
$attributes = array("rel" => "enclosure",
$attributes = ["rel" => "enclosure",
"href" => $matches[1],
"type" => $matches[3]);
"type" => $matches[3]];
if (intval($matches[2])) {
$attributes["length"] = intval($matches[2]);
@ -1402,24 +1402,24 @@ class OStatus
XML::addElement($doc, $author, "email", $owner["addr"]);
XML::addElement($doc, $author, "summary", bbcode($owner["about"], false, false, 7));
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $owner["url"]);
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
XML::addElement($doc, $author, "link", "", $attributes);
$attributes = array(
$attributes = [
"rel" => "avatar",
"type" => "image/jpeg", // To-Do?
"media:width" => 175,
"media:height" => 175,
"href" => $owner["photo"]);
"href" => $owner["photo"]];
XML::addElement($doc, $author, "link", "", $attributes);
if (isset($owner["thumb"])) {
$attributes = array(
$attributes = [
"rel" => "avatar",
"type" => "image/jpeg", // To-Do?
"media:width" => 80,
"media:height" => 80,
"href" => $owner["thumb"]);
"href" => $owner["thumb"]];
XML::addElement($doc, $author, "link", "", $attributes);
}
@ -1442,8 +1442,8 @@ class OStatus
}
if (count($profile)) {
XML::addElement($doc, $author, "followers", "", array("url" => System::baseUrl()."/viewcontacts/".$owner["nick"]));
XML::addElement($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["uid"]));
XML::addElement($doc, $author, "followers", "", ["url" => System::baseUrl()."/viewcontacts/".$owner["nick"]]);
XML::addElement($doc, $author, "statusnet:profile_info", "", ["local_id" => $owner["uid"]]);
}
if ($profile["publish"]) {
@ -1483,7 +1483,7 @@ class OStatus
*/
private static function constructObjecttype($item)
{
if (in_array($item['object-type'], array(ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT)))
if (in_array($item['object-type'], [ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT]))
return $item['object-type'];
return ACTIVITY_OBJ_NOTE;
}
@ -1511,7 +1511,7 @@ class OStatus
if ($item["verb"] == ACTIVITY_LIKE) {
return self::likeEntry($doc, $item, $owner, $toplevel);
} elseif (in_array($item["verb"], array(ACTIVITY_FOLLOW, NAMESPACE_OSTATUS."/unfollow"))) {
} elseif (in_array($item["verb"], [ACTIVITY_FOLLOW, NAMESPACE_OSTATUS."/unfollow"])) {
return self::followEntry($doc, $item, $owner, $toplevel);
} else {
return self::noteEntry($doc, $item, $owner, $toplevel);
@ -1531,8 +1531,8 @@ class OStatus
$source = $doc->createElement("source");
XML::addElement($doc, $source, "id", $contact["poll"]);
XML::addElement($doc, $source, "title", $contact["name"]);
XML::addElement($doc, $source, "link", "", array("rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]));
XML::addElement($doc, $source, "link", "", array("rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]));
XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]);
XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]);
XML::addElement($doc, $source, "icon", $contact["photo"]);
XML::addElement($doc, $source, "updated", datetime_convert("UTC", "UTC", $contact["success_update"]."+00:00", ATOM_TIME));
@ -1726,15 +1726,15 @@ class OStatus
XML::addElement($doc, $object, "id", $contact["alias"]);
XML::addElement($doc, $object, "title", $contact["nick"]);
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $contact["url"]);
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $contact["url"]];
XML::addElement($doc, $object, "link", "", $attributes);
$attributes = array(
$attributes = [
"rel" => "avatar",
"type" => "image/jpeg", // To-Do?
"media:width" => 175,
"media:height" => 175,
"href" => $contact["photo"]);
"href" => $contact["photo"]];
XML::addElement($doc, $object, "link", "", $attributes);
XML::addElement($doc, $object, "poco:preferredUsername", $contact["nick"]);
@ -1906,14 +1906,14 @@ class OStatus
$body = bbcode($body, false, false, 7);
XML::addElement($doc, $entry, "content", $body, array("type" => "html"));
XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);
XML::addElement($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
"href" => System::baseUrl()."/display/".$item["guid"])
XML::addElement($doc, $entry, "link", "", ["rel" => "alternate", "type" => "text/html",
"href" => System::baseUrl()."/display/".$item["guid"]]
);
if ($complete && ($item["id"] > 0)) {
XML::addElement($doc, $entry, "status_net", "", array("notice_id" => $item["id"]));
XML::addElement($doc, $entry, "status_net", "", ["notice_id" => $item["id"]]);
}
XML::addElement($doc, $entry, "activity:verb", $verb);
@ -1934,7 +1934,7 @@ class OStatus
*/
private static function entryFooter($doc, $entry, $item, $owner, $complete = true)
{
$mentioned = array();
$mentioned = [];
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
$parent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `id` = %d", intval($item["parent"]));
@ -1955,14 +1955,14 @@ class OStatus
$parent_plink = System::baseUrl()."/display/".$parent[0]["guid"];
}
$attributes = array(
$attributes = [
"ref" => $parent_item,
"href" => $parent_plink);
"href" => $parent_plink];
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
$attributes = array(
$attributes = [
"rel" => "related",
"href" => $parent_plink);
"href" => $parent_plink];
XML::addElement($doc, $entry, "link", "", $attributes);
}
@ -1982,12 +1982,12 @@ class OStatus
}
}
XML::addElement($doc, $entry, "link", "", array("rel" => "ostatus:conversation", "href" => $conversation_href));
XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:conversation", "href" => $conversation_href]);
$attributes = array(
$attributes = [
"href" => $conversation_href,
"local_id" => $item["parent"],
"ref" => $conversation_uri);
"ref" => $conversation_uri];
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
}
@ -2003,7 +2003,7 @@ class OStatus
}
// Make sure that mentions are accepted (GNU Social has problems with mixing HTTP and HTTPS)
$newmentions = array();
$newmentions = [];
foreach ($mentioned as $mention) {
$newmentions[str_replace("http://", "https://", $mention)] = str_replace("http://", "https://", $mention);
$newmentions[str_replace("https://", "http://", $mention)] = str_replace("https://", "http://", $mention);
@ -2018,34 +2018,34 @@ class OStatus
);
if ($r[0]["forum"] || $r[0]["prv"]) {
XML::addElement($doc, $entry, "link", "",
array(
[
"rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
"href" => $mention)
"href" => $mention]
);
} else {
XML::addElement($doc, $entry, "link", "",
array(
[
"rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
"href" => $mention)
"href" => $mention]
);
}
}
if (!$item["private"]) {
XML::addElement($doc, $entry, "link", "", array("rel" => "ostatus:attention",
"href" => "http://activityschema.org/collection/public"));
XML::addElement($doc, $entry, "link", "", array("rel" => "mentioned",
XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:attention",
"href" => "http://activityschema.org/collection/public"]);
XML::addElement($doc, $entry, "link", "", ["rel" => "mentioned",
"ostatus:object-type" => "http://activitystrea.ms/schema/1.0/collection",
"href" => "http://activityschema.org/collection/public"));
"href" => "http://activityschema.org/collection/public"]);
XML::addElement($doc, $entry, "mastodon:scope", "public");
}
if (count($tags)) {
foreach ($tags as $t) {
if ($t[0] != "@") {
XML::addElement($doc, $entry, "category", "", array("term" => $t[2]));
XML::addElement($doc, $entry, "category", "", ["term" => $t[2]]);
}
}
}
@ -2058,7 +2058,7 @@ class OStatus
$app = "web";
}
$attributes = array("local_id" => $item["id"], "source" => $app);
$attributes = ["local_id" => $item["id"], "source" => $app];
if (isset($parent["id"])) {
$attributes["repeat_of"] = $parent["id"];
@ -2174,7 +2174,7 @@ class OStatus
$feeddata = trim($doc->saveXML());
$msg = array('feed' => $feeddata, 'last_update' => $last_update);
$msg = ['feed' => $feeddata, 'last_update' => $last_update];
Cache::set($cachekey, $msg, CACHE_QUARTER_HOUR);
logger('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG);

View file

@ -176,7 +176,7 @@ class PortableContact
$contact_type = $entry->contactType;
}
$gcontact = array("url" => $profile_url,
$gcontact = ["url" => $profile_url,
"name" => $name,
"network" => $network,
"photo" => $profile_photo,
@ -187,7 +187,7 @@ class PortableContact
"connect" => $connect_url,
"updated" => $updated,
"contact-type" => $contact_type,
"generation" => $generation);
"generation" => $generation];
try {
$gcontact = GContact::sanitize($gcontact);
@ -311,7 +311,7 @@ class PortableContact
return false;
}
$contact = array("url" => $profile);
$contact = ["url" => $profile];
if ($gcontacts[0]["created"] <= NULL_DATE) {
$contact['created'] = datetime_convert();
@ -329,7 +329,7 @@ class PortableContact
$server_url = normalise_link(self::detectServer($profile));
}
if (!in_array($gcontacts[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_FEED, NETWORK_OSTATUS, ""))) {
if (!in_array($gcontacts[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_FEED, NETWORK_OSTATUS, ""])) {
logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
return false;
}
@ -347,7 +347,7 @@ class PortableContact
$contact['server_url'] = $server_url;
}
if (in_array($gcontacts[0]["network"], array("", NETWORK_FEED))) {
if (in_array($gcontacts[0]["network"], ["", NETWORK_FEED])) {
$server = q(
"SELECT `network` FROM `gserver` WHERE `nurl` = '%s' AND `network` != ''",
dbesc(normalise_link($server_url))
@ -466,7 +466,7 @@ class PortableContact
return false;
}
if (($data["poll"] == "") || (in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
$fields = ['last_failure' => datetime_convert()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
@ -614,7 +614,7 @@ class PortableContact
foreach ($data->entry[0]->urls as $url) {
if ($url->type == 'zot') {
$server = array();
$server = [];
$server["platform"] = 'Hubzilla';
$server["network"] = NETWORK_DIASPORA;
return $server;
@ -674,7 +674,7 @@ class PortableContact
return false;
}
$server = array();
$server = [];
$server['register_policy'] = REGISTER_CLOSED;
@ -757,7 +757,7 @@ class PortableContact
$list = $xpath->query("//meta[@name]");
foreach ($list as $node) {
$attr = array();
$attr = [];
if ($node->attributes->length) {
foreach ($node->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value;
@ -766,8 +766,8 @@ class PortableContact
if ($attr['name'] == 'generator') {
$version_part = explode(" ", $attr['content']);
if (count($version_part) == 2) {
if (in_array($version_part[0], array("Friendika", "Friendica"))) {
$server = array();
if (in_array($version_part[0], ["Friendika", "Friendica"])) {
$server = [];
$server["platform"] = $version_part[0];
$server["version"] = $version_part[1];
$server["network"] = NETWORK_DFRN;
@ -780,14 +780,14 @@ class PortableContact
$list = $xpath->query("//meta[@property]");
foreach ($list as $node) {
$attr = array();
$attr = [];
if ($node->attributes->length) {
foreach ($node->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value;
}
}
if ($attr['property'] == 'generator' && in_array($attr['content'], array("hubzilla", "BlaBlaNet"))) {
$server = array();
if ($attr['property'] == 'generator' && in_array($attr['content'], ["hubzilla", "BlaBlaNet"])) {
$server = [];
$server["platform"] = $attr['content'];
$server["version"] = "";
$server["network"] = NETWORK_DIASPORA;
@ -863,7 +863,7 @@ class PortableContact
// Mastodon uses the "@" for user profiles.
// But this can be misunderstood.
if (parse_url($server_url, PHP_URL_USER) != '') {
dba::update('gserver', array('last_failure' => datetime_convert()), array('nurl' => normalise_link($server_url)));
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -872,14 +872,14 @@ class PortableContact
$server_url = str_replace("http://", "https://", $server_url);
// We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
$serverret = z_fetch_url($server_url."/.well-known/host-meta", false, $redirects, array('timeout' => 20));
$serverret = z_fetch_url($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]);
// Quit if there is a timeout.
// But we want to make sure to only quit if we are mostly sure that this server url fits.
if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
dba::update('gserver', array('last_failure' => datetime_convert()), array('nurl' => normalise_link($server_url)));
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -889,12 +889,12 @@ class PortableContact
$server_url = str_replace("https://", "http://", $server_url);
// We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
$serverret = z_fetch_url($server_url."/.well-known/host-meta", false, $redirects, array('timeout' => 20));
$serverret = z_fetch_url($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]);
// Quit if there is a timeout
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
dba::update('gserver', array('last_failure' => datetime_convert()), array('nurl' => normalise_link($server_url)));
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -903,7 +903,7 @@ class PortableContact
if (!$serverret["success"] || ($serverret["body"] == "") || (sizeof($xmlobj) == 0) || !is_object($xmlobj)) {
// Workaround for bad configured servers (known nginx problem)
if (!in_array($serverret["debug"]["http_code"], array("403", "404"))) {
if (!in_array($serverret["debug"]["http_code"], ["403", "404"])) {
$failure = true;
}
$possible_failure = true;
@ -1180,7 +1180,7 @@ class PortableContact
// Check for noscrape
// Friendica servers could be detected as OStatus servers
if (!$failure && in_array($network, array(NETWORK_DFRN, NETWORK_OSTATUS))) {
if (!$failure && in_array($network, [NETWORK_DFRN, NETWORK_OSTATUS])) {
$serverret = z_fetch_url($server_url."/friendica/json");
if (!$serverret["success"]) {
@ -1239,7 +1239,7 @@ class PortableContact
}
// Check again if the server exists
$found = dba::exists('gserver', array('nurl' => normalise_link($server_url)));
$found = dba::exists('gserver', ['nurl' => normalise_link($server_url)]);
$version = strip_tags($version);
$site_name = strip_tags($site_name);
@ -1342,7 +1342,7 @@ class PortableContact
$accesstoken = Config::get('system', 'instances_social_key');
if (!empty($accesstoken)) {
$api = 'https://instances.social/api/1.0/instances/list?count=0';
$header = array('Authorization: Bearer '.$accesstoken);
$header = ['Authorization: Bearer '.$accesstoken];
$serverdata = z_fetch_url($api, false, $redirects, ['headers' => $header]);
if ($serverdata['success']) {
$servers = json_decode($serverdata['body']);
@ -1586,7 +1586,7 @@ class PortableContact
logger("Store profile ".$profile_url, LOGGER_DEBUG);
$gcontact = array("url" => $profile_url,
$gcontact = ["url" => $profile_url,
"name" => $name,
"network" => $network,
"photo" => $profile_photo,
@ -1597,7 +1597,7 @@ class PortableContact
"connect" => $connect_url,
"updated" => $updated,
"contact-type" => $contact_type,
"generation" => $generation);
"generation" => $generation];
try {
$gcontact = GContact::sanitize($gcontact);

View file

@ -22,7 +22,7 @@ class Salmon
*/
public static function getKey($uri, $keyhash)
{
$ret = array();
$ret = [];
logger('Fetching salmon key for '.$uri);
@ -120,22 +120,22 @@ class Salmon
$signature3 = base64url_encode(Crypto::rsaSign($data, $owner['sprvkey']));
// At first try the non compliant method that works for GNU Social
$xmldata = array("me:env" => array("me:data" => $data,
"@attributes" => array("type" => $data_type),
$xmldata = ["me:env" => ["me:data" => $data,
"@attributes" => ["type" => $data_type],
"me:encoding" => $encoding,
"me:alg" => $algorithm,
"me:sig" => $signature,
"@attributes2" => array("key_id" => $keyhash)));
"@attributes2" => ["key_id" => $keyhash]]];
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
$namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
post_url($url, $salmon, [
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
));
]);
$a = get_app();
$return_code = $a->get_curl_code();
@ -146,22 +146,22 @@ class Salmon
logger('GNU Social salmon failed. Falling back to compliant mode');
// Now try the compliant mode that normally isn't used for GNU Social
$xmldata = array("me:env" => array("me:data" => $data,
"@attributes" => array("type" => $data_type),
$xmldata = ["me:env" => ["me:data" => $data,
"@attributes" => ["type" => $data_type],
"me:encoding" => $encoding,
"me:alg" => $algorithm,
"me:sig" => $signature2,
"@attributes2" => array("key_id" => $keyhash)));
"@attributes2" => ["key_id" => $keyhash]]];
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
$namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
post_url($url, $salmon, [
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
));
]);
$return_code = $a->get_curl_code();
}
@ -169,21 +169,21 @@ class Salmon
logger('compliant salmon failed. Falling back to old status.net');
// Last try. This will most likely fail as well.
$xmldata = array("me:env" => array("me:data" => $data,
"@attributes" => array("type" => $data_type),
$xmldata = ["me:env" => ["me:data" => $data,
"@attributes" => ["type" => $data_type],
"me:encoding" => $encoding,
"me:alg" => $algorithm,
"me:sig" => $signature3,
"@attributes2" => array("key_id" => $keyhash)));
"@attributes2" => ["key_id" => $keyhash]]];
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
$namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
post_url($url, $salmon, [
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon))
'Content-length: ' . strlen($salmon)]
);
$return_code = $a->get_curl_code();
}