Merge pull request #7744 from MrPetovan/task/7190-remove-defaults-src
Replace deprecated calls to defaults() by ?? and ?: in src/
This commit is contained in:
commit
70023dccbd
45 changed files with 259 additions and 253 deletions
|
@ -70,7 +70,7 @@ class Arguments
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of a argv key
|
* Returns the value of a argv key
|
||||||
* @todo there are a lot of $a->argv usages in combination with defaults() which can be replaced with this method
|
* @todo there are a lot of $a->argv usages in combination with ?? which can be replaced with this method
|
||||||
*
|
*
|
||||||
* @param int $position the position of the argument
|
* @param int $position the position of the argument
|
||||||
* @param mixed $default the default value if not found
|
* @param mixed $default the default value if not found
|
||||||
|
|
|
@ -338,12 +338,12 @@ class BaseURL
|
||||||
/* Relative script path to the web server root
|
/* Relative script path to the web server root
|
||||||
* Not all of those $_SERVER properties can be present, so we do by inverse priority order
|
* Not all of those $_SERVER properties can be present, so we do by inverse priority order
|
||||||
*/
|
*/
|
||||||
$relative_script_path = '';
|
$relative_script_path =
|
||||||
$relative_script_path = defaults($this->server, 'REDIRECT_URL', $relative_script_path);
|
($this->server['REDIRECT_URL'] ?? '') ?:
|
||||||
$relative_script_path = defaults($this->server, 'REDIRECT_URI', $relative_script_path);
|
($this->server['REDIRECT_URI'] ?? '') ?:
|
||||||
$relative_script_path = defaults($this->server, 'REDIRECT_SCRIPT_URL', $relative_script_path);
|
($this->server['REDIRECT_SCRIPT_URL'] ?? '') ?:
|
||||||
$relative_script_path = defaults($this->server, 'SCRIPT_URL', $relative_script_path);
|
($this->server['SCRIPT_URL'] ?? '') ?:
|
||||||
$relative_script_path = defaults($this->server, 'REQUEST_URI', $relative_script_path);
|
$this->server['REQUEST_URI'] ?? '';
|
||||||
|
|
||||||
/* $relative_script_path gives /relative/path/to/friendica/module/parameter
|
/* $relative_script_path gives /relative/path/to/friendica/module/parameter
|
||||||
* QUERY_STRING gives pagename=module/parameter
|
* QUERY_STRING gives pagename=module/parameter
|
||||||
|
|
|
@ -60,7 +60,7 @@ class BaseObject
|
||||||
throw new InternalServerErrorException('DICE isn\'t initialized.');
|
throw new InternalServerErrorException('DICE isn\'t initialized.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists($name) || interface_exists($name )) {
|
if (class_exists($name) || interface_exists($name)) {
|
||||||
return self::$dice->create($name);
|
return self::$dice->create($name);
|
||||||
} else {
|
} else {
|
||||||
throw new InternalServerErrorException('Class \'' . $name . '\' isn\'t valid.');
|
throw new InternalServerErrorException('Class \'' . $name . '\' isn\'t valid.');
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Pager
|
||||||
{
|
{
|
||||||
$this->setQueryString($queryString);
|
$this->setQueryString($queryString);
|
||||||
$this->setItemsPerPage($itemsPerPage);
|
$this->setItemsPerPage($itemsPerPage);
|
||||||
$this->setPage(defaults($_GET, 'page', 1));
|
$this->setPage(($_GET['page'] ?? 0) ?: 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -244,7 +244,7 @@ class BBCode extends BaseObject
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$has_title = !empty($item['title']);
|
$has_title = !empty($item['title']);
|
||||||
$plink = defaults($item, 'plink', '');
|
$plink = $item['plink'] ?? '';
|
||||||
$post = self::getAttachmentData($body);
|
$post = self::getAttachmentData($body);
|
||||||
|
|
||||||
// Get all linked images with alternative image description
|
// Get all linked images with alternative image description
|
||||||
|
@ -610,7 +610,7 @@ class BBCode extends BaseObject
|
||||||
throw new Exception('OEmbed is disabled for this attachment.');
|
throw new Exception('OEmbed is disabled for this attachment.');
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$data['title'] = defaults($data, 'title', $data['url']);
|
$data['title'] = ($data['title'] ?? '') ?: $data['url'];
|
||||||
|
|
||||||
if ($simplehtml != 4) {
|
if ($simplehtml != 4) {
|
||||||
$return = sprintf('<div class="type-%s">', $data['type']);
|
$return = sprintf('<div class="type-%s">', $data['type']);
|
||||||
|
@ -645,7 +645,7 @@ class BBCode extends BaseObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim(defaults($data, 'text', '') . ' ' . $return . ' ' . defaults($data, 'after', ''));
|
return trim(($data['text'] ?? '') . ' ' . $return . ' ' . ($data['after'] ?? ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function removeShareInformation($Text, $plaintext = false, $nolink = false)
|
public static function removeShareInformation($Text, $plaintext = false, $nolink = false)
|
||||||
|
@ -655,10 +655,10 @@ class BBCode extends BaseObject
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
return $Text;
|
return $Text;
|
||||||
} elseif ($nolink) {
|
} elseif ($nolink) {
|
||||||
return $data['text'] . defaults($data, 'after', '');
|
return $data['text'] . ($data['after'] ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = htmlentities(defaults($data, 'title', ''), ENT_QUOTES, 'UTF-8', false);
|
$title = htmlentities($data['title'] ?? '', ENT_QUOTES, 'UTF-8', false);
|
||||||
$text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
|
$text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
|
||||||
if ($plaintext || (($title != '') && strstr($text, $title))) {
|
if ($plaintext || (($title != '') && strstr($text, $title))) {
|
||||||
$data['title'] = $data['url'];
|
$data['title'] = $data['url'];
|
||||||
|
@ -941,7 +941,7 @@ class BBCode extends BaseObject
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach(['author', 'profile', 'avatar', 'link', 'posted'] as $field) {
|
foreach(['author', 'profile', 'avatar', 'link', 'posted'] as $field) {
|
||||||
preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
|
preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
|
||||||
$attributes[$field] = html_entity_decode(defaults($matches, 2, ''), ENT_QUOTES, 'UTF-8');
|
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
// We only call this so that a previously unknown contact can be added.
|
// We only call this so that a previously unknown contact can be added.
|
||||||
|
@ -960,11 +960,11 @@ class BBCode extends BaseObject
|
||||||
Contact::getIdForURL($attributes['profile'], 0, true, $default);
|
Contact::getIdForURL($attributes['profile'], 0, true, $default);
|
||||||
|
|
||||||
$author_contact = Contact::getDetailsByURL($attributes['profile']);
|
$author_contact = Contact::getDetailsByURL($attributes['profile']);
|
||||||
$author_contact['addr'] = defaults($author_contact, 'addr' , Protocol::getAddrFromProfileUrl($attributes['profile']));
|
$author_contact['addr'] = ($author_contact['addr'] ?? '') ?: Protocol::getAddrFromProfileUrl($attributes['profile']);
|
||||||
|
|
||||||
$attributes['author'] = defaults($author_contact, 'name' , $attributes['author']);
|
$attributes['author'] = ($author_contact['name'] ?? '') ?: $attributes['author'];
|
||||||
$attributes['avatar'] = defaults($author_contact, 'micro', $attributes['avatar']);
|
$attributes['avatar'] = ($author_contact['micro'] ?? '') ?: $attributes['avatar'];
|
||||||
$attributes['profile'] = defaults($author_contact, 'url' , $attributes['profile']);
|
$attributes['profile'] = ($author_contact['url'] ?? '') ?: $attributes['profile'];
|
||||||
|
|
||||||
if ($attributes['avatar']) {
|
if ($attributes['avatar']) {
|
||||||
$attributes['avatar'] = ProxyUtils::proxifyUrl($attributes['avatar'], false, ProxyUtils::SIZE_THUMB);
|
$attributes['avatar'] = ProxyUtils::proxifyUrl($attributes['avatar'], false, ProxyUtils::SIZE_THUMB);
|
||||||
|
@ -1241,7 +1241,7 @@ class BBCode extends BaseObject
|
||||||
$try_oembed_callback = function ($match)
|
$try_oembed_callback = function ($match)
|
||||||
{
|
{
|
||||||
$url = $match[1];
|
$url = $match[1];
|
||||||
$title = defaults($match, 2, null);
|
$title = $match[2] ?? null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$return = OEmbed::getHTML($url, $title);
|
$return = OEmbed::getHTML($url, $title);
|
||||||
|
|
|
@ -872,8 +872,8 @@ class HTML
|
||||||
$url = '';
|
$url = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'), [
|
return Renderer::replaceMacros(Renderer::getMarkupTemplate($textmode ? 'micropro_txt.tpl' : 'micropro_img.tpl'), [
|
||||||
'$click' => defaults($contact, 'click', ''),
|
'$click' => $contact['click'] ?? '',
|
||||||
'$class' => $class,
|
'$class' => $class,
|
||||||
'$url' => $url,
|
'$url' => $url,
|
||||||
'$photo' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
|
'$photo' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
|
||||||
|
|
|
@ -57,7 +57,7 @@ class CalendarExport
|
||||||
|
|
||||||
// $a->data is only available if the profile page is visited. If the visited page is not part
|
// $a->data is only available if the profile page is visited. If the visited page is not part
|
||||||
// of the profile page it should be the personal /events page. So we can use $a->user.
|
// of the profile page it should be the personal /events page. So we can use $a->user.
|
||||||
$user = defaults($a->data['user'], 'nickname', $a->user['nickname']);
|
$user = ($a->data['user']['nickname'] ?? '') ?: $a->user['nickname'];
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate("widget/events.tpl");
|
$tpl = Renderer::getMarkupTemplate("widget/events.tpl");
|
||||||
$return = Renderer::replaceMacros($tpl, [
|
$return = Renderer::replaceMacros($tpl, [
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ContactBlock
|
||||||
|
|
||||||
if ($total) {
|
if ($total) {
|
||||||
// Only show followed for personal accounts, followers for pages
|
// Only show followed for personal accounts, followers for pages
|
||||||
if (defaults($profile, 'account-type', User::ACCOUNT_TYPE_PERSON) == User::ACCOUNT_TYPE_PERSON) {
|
if ((($profile['account-type'] ?? '') ?: User::ACCOUNT_TYPE_PERSON) == User::ACCOUNT_TYPE_PERSON) {
|
||||||
$rel = [Contact::SHARING, Contact::FRIEND];
|
$rel = [Contact::SHARING, Contact::FRIEND];
|
||||||
} else {
|
} else {
|
||||||
$rel = [Contact::FOLLOWER, Contact::FRIEND];
|
$rel = [Contact::FOLLOWER, Contact::FRIEND];
|
||||||
|
|
|
@ -41,12 +41,12 @@ class ACL extends BaseObject
|
||||||
|
|
||||||
$networks = null;
|
$networks = null;
|
||||||
|
|
||||||
$size = defaults($options, 'size', 4);
|
$size = ($options['size'] ?? 0) ?: 4;
|
||||||
$mutual = !empty($options['mutual_friends']);
|
$mutual = !empty($options['mutual_friends']);
|
||||||
$single = !empty($options['single']) && empty($options['multiple']);
|
$single = !empty($options['single']) && empty($options['multiple']);
|
||||||
$exclude = defaults($options, 'exclude', false);
|
$exclude = $options['exclude'] ?? false;
|
||||||
|
|
||||||
switch (defaults($options, 'networks', Protocol::PHANTOM)) {
|
switch (($options['networks'] ?? '') ?: Protocol::PHANTOM) {
|
||||||
case 'DFRN_ONLY':
|
case 'DFRN_ONLY':
|
||||||
$networks = [Protocol::DFRN];
|
$networks = [Protocol::DFRN];
|
||||||
break;
|
break;
|
||||||
|
@ -226,13 +226,13 @@ class ACL extends BaseObject
|
||||||
|
|
||||||
$acl_regex = '/<([0-9]+)>/i';
|
$acl_regex = '/<([0-9]+)>/i';
|
||||||
|
|
||||||
preg_match_all($acl_regex, defaults($user, 'allow_cid', ''), $matches);
|
preg_match_all($acl_regex, $user['allow_cid'] ?? '', $matches);
|
||||||
$allow_cid = $matches[1];
|
$allow_cid = $matches[1];
|
||||||
preg_match_all($acl_regex, defaults($user, 'allow_gid', ''), $matches);
|
preg_match_all($acl_regex, $user['allow_gid'] ?? '', $matches);
|
||||||
$allow_gid = $matches[1];
|
$allow_gid = $matches[1];
|
||||||
preg_match_all($acl_regex, defaults($user, 'deny_cid', ''), $matches);
|
preg_match_all($acl_regex, $user['deny_cid'] ?? '', $matches);
|
||||||
$deny_cid = $matches[1];
|
$deny_cid = $matches[1];
|
||||||
preg_match_all($acl_regex, defaults($user, 'deny_gid', ''), $matches);
|
preg_match_all($acl_regex, $user['deny_gid'] ?? '', $matches);
|
||||||
$deny_gid = $matches[1];
|
$deny_gid = $matches[1];
|
||||||
|
|
||||||
// Reformats the ACL data so that it is accepted by the JS frontend
|
// Reformats the ACL data so that it is accepted by the JS frontend
|
||||||
|
@ -301,10 +301,10 @@ class ACL extends BaseObject
|
||||||
'$showall' => L10n::t('Visible to everybody'),
|
'$showall' => L10n::t('Visible to everybody'),
|
||||||
'$show' => L10n::t('show'),
|
'$show' => L10n::t('show'),
|
||||||
'$hide' => L10n::t('don\'t show'),
|
'$hide' => L10n::t('don\'t show'),
|
||||||
'$allowcid' => json_encode(defaults($default_permissions, 'allow_cid', [])), // we need arrays for Javascript since we call .remove() and .push() on this values
|
'$allowcid' => json_encode(($default_permissions['allow_cid'] ?? '') ?: []), // We need arrays for
|
||||||
'$allowgid' => json_encode(defaults($default_permissions, 'allow_gid', [])),
|
'$allowgid' => json_encode(($default_permissions['allow_gid'] ?? '') ?: []), // Javascript since we
|
||||||
'$denycid' => json_encode(defaults($default_permissions, 'deny_cid', [])),
|
'$denycid' => json_encode(($default_permissions['deny_cid'] ?? '') ?: []), // call .remove() and
|
||||||
'$denygid' => json_encode(defaults($default_permissions, 'deny_gid', [])),
|
'$denygid' => json_encode(($default_permissions['deny_gid'] ?? '') ?: []), // .push() on these values
|
||||||
'$networks' => $show_jotnets,
|
'$networks' => $show_jotnets,
|
||||||
'$emailcc' => L10n::t('CC: email addresses'),
|
'$emailcc' => L10n::t('CC: email addresses'),
|
||||||
'$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
|
'$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Authentication extends BaseObject
|
||||||
$value = json_encode([
|
$value = json_encode([
|
||||||
"uid" => $user["uid"],
|
"uid" => $user["uid"],
|
||||||
"hash" => self::getCookieHashForUser($user),
|
"hash" => self::getCookieHashForUser($user),
|
||||||
"ip" => defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0')
|
"ip" => ($_SERVER['REMOTE_ADDR'] ?? '') ?: '0.0.0.0'
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$value = "";
|
$value = "";
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Friendica\Model;
|
||||||
/**
|
/**
|
||||||
* This class is responsible for all system-wide configuration values in Friendica
|
* This class is responsible for all system-wide configuration values in Friendica
|
||||||
* There are two types of storage
|
* There are two types of storage
|
||||||
* - The Config-Files (loaded into the FileCache @see Cache\ConfigCache )
|
* - The Config-Files (loaded into the FileCache @see Cache\ConfigCache)
|
||||||
* - The Config-DB-Table (per Config-DB-model @see Model\Config\Config )
|
* - The Config-DB-Table (per Config-DB-model @see Model\Config\Config)
|
||||||
*/
|
*/
|
||||||
abstract class Configuration
|
abstract class Configuration
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ abstract class Configuration
|
||||||
*
|
*
|
||||||
* Get a particular config value from the given category ($cat)
|
* Get a particular config value from the given category ($cat)
|
||||||
* and the $key from a cached storage either from the $this->configAdapter
|
* and the $key from a cached storage either from the $this->configAdapter
|
||||||
* (@see IConfigAdapter ) or from the $this->configCache (@see ConfigCache ).
|
* (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
|
||||||
*
|
*
|
||||||
* @param string $cat The category of the configuration value
|
* @param string $cat The category of the configuration value
|
||||||
* @param string $key The configuration key to query
|
* @param string $key The configuration key to query
|
||||||
|
@ -89,7 +89,7 @@ abstract class Configuration
|
||||||
* @brief Deletes the given key from the system configuration.
|
* @brief Deletes the given key from the system configuration.
|
||||||
*
|
*
|
||||||
* Removes the configured value from the stored cache in $this->configCache
|
* Removes the configured value from the stored cache in $this->configCache
|
||||||
* (@see ConfigCache ) and removes it from the database (@see IConfigAdapter ).
|
* (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
|
||||||
*
|
*
|
||||||
* @param string $cat The category of the configuration value
|
* @param string $cat The category of the configuration value
|
||||||
* @param string $key The configuration key to delete
|
* @param string $key The configuration key to delete
|
||||||
|
|
|
@ -8,7 +8,7 @@ use Friendica\Model;
|
||||||
* This class is responsible for the user-specific configuration values in Friendica
|
* This class is responsible for the user-specific configuration values in Friendica
|
||||||
* The values are set through the Config-DB-Table (per Config-DB-model @see Model\Config\PConfig)
|
* The values are set through the Config-DB-Table (per Config-DB-model @see Model\Config\PConfig)
|
||||||
*
|
*
|
||||||
* The configuration cache (@see Cache\PConfigCache ) is used for temporary caching of database calls. This will
|
* The configuration cache (@see Cache\PConfigCache) is used for temporary caching of database calls. This will
|
||||||
* increase the performance.
|
* increase the performance.
|
||||||
*/
|
*/
|
||||||
abstract class PConfiguration
|
abstract class PConfiguration
|
||||||
|
@ -52,7 +52,7 @@ abstract class PConfiguration
|
||||||
* @param string $cat The category of the configuration value
|
* @param string $cat The category of the configuration value
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @see PConfigCache )
|
* @see PConfigCache
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract public function load(int $uid, string $cat = 'config');
|
abstract public function load(int $uid, string $cat = 'config');
|
||||||
|
@ -63,7 +63,7 @@ abstract class PConfiguration
|
||||||
*
|
*
|
||||||
* Get a particular user's config value from the given category ($cat)
|
* Get a particular user's config value from the given category ($cat)
|
||||||
* and the $key with the $uid from a cached storage either from the $this->configAdapter
|
* and the $key with the $uid from a cached storage either from the $this->configAdapter
|
||||||
* (@see IConfigAdapter ) or from the $this->configCache (@see PConfigCache ).
|
* (@see IConfigAdapter) or from the $this->configCache (@see PConfigCache).
|
||||||
*
|
*
|
||||||
* @param int $uid The user_id
|
* @param int $uid The user_id
|
||||||
* @param string $cat The category of the configuration value
|
* @param string $cat The category of the configuration value
|
||||||
|
@ -96,7 +96,7 @@ abstract class PConfiguration
|
||||||
* Deletes the given key from the users's configuration.
|
* Deletes the given key from the users's configuration.
|
||||||
*
|
*
|
||||||
* Removes the configured value from the stored cache in $this->configCache
|
* Removes the configured value from the stored cache in $this->configCache
|
||||||
* (@see ConfigCache ) and removes it from the database (@see IConfigAdapter )
|
* (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
|
||||||
* with the given $uid.
|
* with the given $uid.
|
||||||
*
|
*
|
||||||
* @param int $uid The user_id
|
* @param int $uid The user_id
|
||||||
|
|
|
@ -137,7 +137,7 @@ class NotificationsManager extends BaseObject
|
||||||
*/
|
*/
|
||||||
public function getTabs()
|
public function getTabs()
|
||||||
{
|
{
|
||||||
$selected = defaults(self::getApp()->argv, 1, '');
|
$selected = self::getApp()->argv[1] ?? '';
|
||||||
|
|
||||||
$tabs = [
|
$tabs = [
|
||||||
[
|
[
|
||||||
|
|
|
@ -136,7 +136,7 @@ class Renderer extends BaseObject
|
||||||
*/
|
*/
|
||||||
public static function getTemplateEngine()
|
public static function getTemplateEngine()
|
||||||
{
|
{
|
||||||
$template_engine = defaults(self::$theme, 'template_engine', 'smarty3');
|
$template_engine = (self::$theme['template_engine'] ?? '') ?: 'smarty3';
|
||||||
|
|
||||||
if (isset(self::$template_engines[$template_engine])) {
|
if (isset(self::$template_engines[$template_engine])) {
|
||||||
if (isset(self::$template_engine_instance[$template_engine])) {
|
if (isset(self::$template_engine_instance[$template_engine])) {
|
||||||
|
|
|
@ -56,21 +56,20 @@ class Search extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that we do have a contact entry
|
// Ensure that we do have a contact entry
|
||||||
Contact::getIdForURL(defaults($user_data, 'url', ''));
|
Contact::getIdForURL($user_data['url'] ?? '');
|
||||||
|
|
||||||
$contactDetails = Contact::getDetailsByURL(defaults($user_data, 'url', ''), local_user());
|
$contactDetails = Contact::getDetailsByURL($user_data['url'] ?? '', local_user());
|
||||||
$itemUrl = defaults($contactDetails, 'addr', defaults($user_data, 'url', ''));
|
|
||||||
|
|
||||||
$result = new ContactResult(
|
$result = new ContactResult(
|
||||||
defaults($user_data, 'name', ''),
|
$user_data['name'] ?? '',
|
||||||
defaults($user_data, 'addr', ''),
|
$user_data['addr'] ?? '',
|
||||||
$itemUrl,
|
($contactDetails['addr'] ?? '') ?: ($user_data['url'] ?? ''),
|
||||||
defaults($user_data, 'url', ''),
|
$user_data['url'] ?? '',
|
||||||
defaults($user_data, 'photo', ''),
|
$user_data['photo'] ?? '',
|
||||||
defaults($user_data, 'network', ''),
|
$user_data['network'] ?? '',
|
||||||
defaults($contactDetails, 'id', 0),
|
$contactDetails['id'] ?? 0,
|
||||||
0,
|
0,
|
||||||
defaults($user_data, 'tags', '')
|
$user_data['tags'] ?? ''
|
||||||
);
|
);
|
||||||
|
|
||||||
return new ResultList(1, 1, 1, [$result]);
|
return new ResultList(1, 1, 1, [$result]);
|
||||||
|
@ -117,27 +116,28 @@ class Search extends BaseObject
|
||||||
$results = json_decode($resultJson, true);
|
$results = json_decode($resultJson, true);
|
||||||
|
|
||||||
$resultList = new ResultList(
|
$resultList = new ResultList(
|
||||||
defaults($results, 'page', 1),
|
($results['page'] ?? 0) ?: 1,
|
||||||
defaults($results, 'count', 0),
|
$results['count'] ?? 0,
|
||||||
defaults($results, 'itemsperpage', 30)
|
($results['itemsperpage'] ?? 0) ?: 30
|
||||||
);
|
);
|
||||||
|
|
||||||
$profiles = defaults($results, 'profiles', []);
|
$profiles = $results['profiles'] ?? [];
|
||||||
|
|
||||||
foreach ($profiles as $profile) {
|
foreach ($profiles as $profile) {
|
||||||
$contactDetails = Contact::getDetailsByURL(defaults($profile, 'profile_url', ''), local_user());
|
$profile_url = $profile['profile_url'] ?? '';
|
||||||
$itemUrl = defaults($contactDetails, 'addr', defaults($profile, 'profile_url', ''));
|
$contactDetails = Contact::getDetailsByURL($profile_url, local_user());
|
||||||
|
|
||||||
$result = new ContactResult(
|
$result = new ContactResult(
|
||||||
defaults($profile, 'name', ''),
|
$profile['name'] ?? '',
|
||||||
defaults($profile, 'addr', ''),
|
$profile['addr'] ?? '',
|
||||||
$itemUrl,
|
($contactDetails['addr'] ?? '') ?: $profile_url,
|
||||||
defaults($profile, 'profile_url', ''),
|
$profile_url,
|
||||||
defaults($profile, 'photo', ''),
|
$profile['photo'] ?? '',
|
||||||
Protocol::DFRN,
|
Protocol::DFRN,
|
||||||
defaults($contactDetails, 'cid', 0),
|
$contactDetails['cid'] ?? 0,
|
||||||
0,
|
0,
|
||||||
defaults($profile, 'tags', ''));
|
$profile['tags'] ?? ''
|
||||||
|
);
|
||||||
|
|
||||||
$resultList->addResult($result);
|
$resultList->addResult($result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class Session
|
||||||
'page_flags' => $user_record['page-flags'],
|
'page_flags' => $user_record['page-flags'],
|
||||||
'my_url' => $a->getBaseURL() . '/profile/' . $user_record['nickname'],
|
'my_url' => $a->getBaseURL() . '/profile/' . $user_record['nickname'],
|
||||||
'my_address' => $user_record['nickname'] . '@' . substr($a->getBaseURL(), strpos($a->getBaseURL(), '://') + 3),
|
'my_address' => $user_record['nickname'] . '@' . substr($a->getBaseURL(), strpos($a->getBaseURL(), '://') + 3),
|
||||||
'addr' => defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0')
|
'addr' => ($_SERVER['REMOTE_ADDR'] ?? '') ?: '0.0.0.0'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self::setVisitorsContacts();
|
self::setVisitorsContacts();
|
||||||
|
|
|
@ -48,7 +48,7 @@ class StorageManager
|
||||||
public static function getByName($name)
|
public static function getByName($name)
|
||||||
{
|
{
|
||||||
self::setup();
|
self::setup();
|
||||||
return defaults(self::$backends, $name, '');
|
return self::$backends[$name] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -421,7 +421,7 @@ class DBStructure
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($database[$name]["table_status"]["Comment"])) {
|
if (isset($database[$name]["table_status"]["Comment"])) {
|
||||||
$structurecomment = defaults($structure, "comment", "");
|
$structurecomment = $structure["comment"] ?? '';
|
||||||
if ($database[$name]["table_status"]["Comment"] != $structurecomment) {
|
if ($database[$name]["table_status"]["Comment"] != $structurecomment) {
|
||||||
$sql2 = "COMMENT = '" . DBA::escape($structurecomment) . "'";
|
$sql2 = "COMMENT = '" . DBA::escape($structurecomment) . "'";
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ class DBStructure
|
||||||
// Compare the field structure field by field
|
// Compare the field structure field by field
|
||||||
foreach ($structure["fields"] AS $fieldname => $parameters) {
|
foreach ($structure["fields"] AS $fieldname => $parameters) {
|
||||||
// Compare the field definition
|
// Compare the field definition
|
||||||
$field_definition = defaults($database[$name]["fields"], $fieldname, ['Collation' => '']);
|
$field_definition = ($database[$name]["fields"][$fieldname] ?? '') ?: ['Collation' => ''];
|
||||||
|
|
||||||
// Define the default collation if not given
|
// Define the default collation if not given
|
||||||
if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) {
|
if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) {
|
||||||
|
@ -717,8 +717,8 @@ class DBStructure
|
||||||
* @todo You cannot rename a primary key if "auto increment" is set
|
* @todo You cannot rename a primary key if "auto increment" is set
|
||||||
*
|
*
|
||||||
* @param string $table Table name
|
* @param string $table Table name
|
||||||
* @param array $columns Columns Syntax for Rename: [ $old1 => [ $new1, $type1 ], $old2 => [ $new2, $type2 ], ... ] )
|
* @param array $columns Columns Syntax for Rename: [ $old1 => [ $new1, $type1 ], $old2 => [ $new2, $type2 ], ... ]
|
||||||
* Syntax for Primary Key: [ $col1, $col2, ...] )
|
* Syntax for Primary Key: [ $col1, $col2, ...]
|
||||||
* @param int $type The type of renaming (Default is Column)
|
* @param int $type The type of renaming (Default is Column)
|
||||||
*
|
*
|
||||||
* @return boolean Was the renaming successful?
|
* @return boolean Was the renaming successful?
|
||||||
|
|
|
@ -1078,14 +1078,14 @@ class Contact extends BaseObject
|
||||||
$profile["micro"] = $profile["thumb"];
|
$profile["micro"] = $profile["thumb"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((empty($profile["addr"]) || empty($profile["name"])) && (defaults($profile, "gid", 0) != 0)
|
if ((empty($profile["addr"]) || empty($profile["name"])) && !empty($profile["gid"])
|
||||||
&& in_array($profile["network"], Protocol::FEDERATED)
|
&& in_array($profile["network"], Protocol::FEDERATED)
|
||||||
) {
|
) {
|
||||||
Worker::add(PRIORITY_LOW, "UpdateGContact", $url);
|
Worker::add(PRIORITY_LOW, "UpdateGContact", $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show contact details of Diaspora contacts only if connected
|
// Show contact details of Diaspora contacts only if connected
|
||||||
if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == Protocol::DIASPORA)) {
|
if (empty($profile["cid"]) && ($profile["network"] ?? "") == Protocol::DIASPORA) {
|
||||||
$profile["location"] = "";
|
$profile["location"] = "";
|
||||||
$profile["about"] = "";
|
$profile["about"] = "";
|
||||||
$profile["gender"] = "";
|
$profile["gender"] = "";
|
||||||
|
@ -1504,25 +1504,25 @@ class Contact extends BaseObject
|
||||||
'created' => DateTimeFormat::utcNow(),
|
'created' => DateTimeFormat::utcNow(),
|
||||||
'url' => $data['url'],
|
'url' => $data['url'],
|
||||||
'nurl' => Strings::normaliseLink($data['url']),
|
'nurl' => Strings::normaliseLink($data['url']),
|
||||||
'addr' => defaults($data, 'addr', ''),
|
'addr' => $data['addr'] ?? '',
|
||||||
'alias' => defaults($data, 'alias', ''),
|
'alias' => $data['alias'] ?? '',
|
||||||
'notify' => defaults($data, 'notify', ''),
|
'notify' => $data['notify'] ?? '',
|
||||||
'poll' => defaults($data, 'poll', ''),
|
'poll' => $data['poll'] ?? '',
|
||||||
'name' => defaults($data, 'name', ''),
|
'name' => $data['name'] ?? '',
|
||||||
'nick' => defaults($data, 'nick', ''),
|
'nick' => $data['nick'] ?? '',
|
||||||
'photo' => defaults($data, 'photo', ''),
|
'photo' => $data['photo'] ?? '',
|
||||||
'keywords' => defaults($data, 'keywords', ''),
|
'keywords' => $data['keywords'] ?? '',
|
||||||
'location' => defaults($data, 'location', ''),
|
'location' => $data['location'] ?? '',
|
||||||
'about' => defaults($data, 'about', ''),
|
'about' => $data['about'] ?? '',
|
||||||
'network' => $data['network'],
|
'network' => $data['network'],
|
||||||
'pubkey' => defaults($data, 'pubkey', ''),
|
'pubkey' => $data['pubkey'] ?? '',
|
||||||
'rel' => self::SHARING,
|
'rel' => self::SHARING,
|
||||||
'priority' => defaults($data, 'priority', 0),
|
'priority' => $data['priority'] ?? 0,
|
||||||
'batch' => defaults($data, 'batch', ''),
|
'batch' => $data['batch'] ?? '',
|
||||||
'request' => defaults($data, 'request', ''),
|
'request' => $data['request'] ?? '',
|
||||||
'confirm' => defaults($data, 'confirm', ''),
|
'confirm' => $data['confirm'] ?? '',
|
||||||
'poco' => defaults($data, 'poco', ''),
|
'poco' => $data['poco'] ?? '',
|
||||||
'baseurl' => defaults($data, 'baseurl', ''),
|
'baseurl' => $data['baseurl'] ?? '',
|
||||||
'name-date' => DateTimeFormat::utcNow(),
|
'name-date' => DateTimeFormat::utcNow(),
|
||||||
'uri-date' => DateTimeFormat::utcNow(),
|
'uri-date' => DateTimeFormat::utcNow(),
|
||||||
'avatar-date' => DateTimeFormat::utcNow(),
|
'avatar-date' => DateTimeFormat::utcNow(),
|
||||||
|
@ -1589,7 +1589,7 @@ class Contact extends BaseObject
|
||||||
$fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl'];
|
$fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl'];
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$updated[$field] = defaults($data, $field, $contact[$field]);
|
$updated[$field] = ($data[$field] ?? '') ?: $contact[$field];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($updated['addr'] != $contact['addr']) || (!empty($data['alias']) && ($data['alias'] != $contact['alias']))) {
|
if (($updated['addr'] != $contact['addr']) || (!empty($data['alias']) && ($data['alias'] != $contact['alias']))) {
|
||||||
|
@ -2469,9 +2469,9 @@ class Contact extends BaseObject
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = defaults($datarray, 'author-link', $pub_contact['url']);
|
$url = ($datarray['author-link'] ?? '') ?: $pub_contact['url'];
|
||||||
$name = $pub_contact['name'];
|
$name = $pub_contact['name'];
|
||||||
$photo = defaults($pub_contact, 'avatar', $pub_contact["photo"]);
|
$photo = ($pub_contact['avatar'] ?? '') ?: $pub_contact["photo"];
|
||||||
$nick = $pub_contact['nick'];
|
$nick = $pub_contact['nick'];
|
||||||
$network = $pub_contact['network'];
|
$network = $pub_contact['network'];
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Conversation
|
||||||
*/
|
*/
|
||||||
public static function insert(array $arr)
|
public static function insert(array $arr)
|
||||||
{
|
{
|
||||||
if (in_array(defaults($arr, 'network', Protocol::PHANTOM),
|
if (in_array(($arr['network'] ?? '') ?: Protocol::PHANTOM,
|
||||||
[Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
|
[Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
|
||||||
$conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
|
$conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
|
||||||
|
|
||||||
|
@ -76,8 +76,13 @@ class Conversation
|
||||||
unset($old_conv['source']);
|
unset($old_conv['source']);
|
||||||
}
|
}
|
||||||
// Update structure data all the time but the source only when its from a better protocol.
|
// Update structure data all the time but the source only when its from a better protocol.
|
||||||
if (empty($conversation['source']) || (!empty($old_conv['source']) &&
|
if (
|
||||||
($old_conv['protocol'] < defaults($conversation, 'protocol', self::PARCEL_UNKNOWN)))) {
|
empty($conversation['source'])
|
||||||
|
|| (
|
||||||
|
!empty($old_conv['source'])
|
||||||
|
&& ($old_conv['protocol'] < (($conversation['protocol'] ?? '') ?: self::PARCEL_UNKNOWN))
|
||||||
|
)
|
||||||
|
) {
|
||||||
unset($conversation['protocol']);
|
unset($conversation['protocol']);
|
||||||
unset($conversation['source']);
|
unset($conversation['source']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,30 +242,30 @@ class Event extends BaseObject
|
||||||
public static function store($arr)
|
public static function store($arr)
|
||||||
{
|
{
|
||||||
$event = [];
|
$event = [];
|
||||||
$event['id'] = intval(defaults($arr, 'id' , 0));
|
$event['id'] = intval($arr['id'] ?? 0);
|
||||||
$event['uid'] = intval(defaults($arr, 'uid' , 0));
|
$event['uid'] = intval($arr['uid'] ?? 0);
|
||||||
$event['cid'] = intval(defaults($arr, 'cid' , 0));
|
$event['cid'] = intval($arr['cid'] ?? 0);
|
||||||
$event['guid'] = defaults($arr, 'guid' , System::createUUID());
|
$event['guid'] = ($arr['guid'] ?? '') ?: System::createUUID();
|
||||||
$event['uri'] = defaults($arr, 'uri' , Item::newURI($event['uid'], $event['guid']));
|
$event['uri'] = ($arr['uri'] ?? '') ?: Item::newURI($event['uid'], $event['guid']);
|
||||||
$event['type'] = defaults($arr, 'type' , 'event');
|
$event['type'] = ($arr['type'] ?? '') ?: 'event';
|
||||||
$event['summary'] = defaults($arr, 'summary' , '');
|
$event['summary'] = $arr['summary'] ?? '';
|
||||||
$event['desc'] = defaults($arr, 'desc' , '');
|
$event['desc'] = $arr['desc'] ?? '';
|
||||||
$event['location'] = defaults($arr, 'location' , '');
|
$event['location'] = $arr['location'] ?? '';
|
||||||
$event['allow_cid'] = defaults($arr, 'allow_cid', '');
|
$event['allow_cid'] = $arr['allow_cid'] ?? '';
|
||||||
$event['allow_gid'] = defaults($arr, 'allow_gid', '');
|
$event['allow_gid'] = $arr['allow_gid'] ?? '';
|
||||||
$event['deny_cid'] = defaults($arr, 'deny_cid' , '');
|
$event['deny_cid'] = $arr['deny_cid'] ?? '';
|
||||||
$event['deny_gid'] = defaults($arr, 'deny_gid' , '');
|
$event['deny_gid'] = $arr['deny_gid'] ?? '';
|
||||||
$event['adjust'] = intval(defaults($arr, 'adjust' , 0));
|
$event['adjust'] = intval($arr['adjust'] ?? 0);
|
||||||
$event['nofinish'] = intval(defaults($arr, 'nofinish' , !empty($event['start']) && empty($event['finish'])));
|
$event['nofinish'] = intval(!empty($arr['nofinish'] || !empty($event['start']) && empty($event['finish'])));
|
||||||
|
|
||||||
$event['created'] = DateTimeFormat::utc(defaults($arr, 'created' , 'now'));
|
$event['created'] = DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now');
|
||||||
$event['edited'] = DateTimeFormat::utc(defaults($arr, 'edited' , 'now'));
|
$event['edited'] = DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now');
|
||||||
$event['start'] = DateTimeFormat::utc(defaults($arr, 'start' , DBA::NULL_DATETIME));
|
$event['start'] = DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME);
|
||||||
$event['finish'] = DateTimeFormat::utc(defaults($arr, 'finish' , DBA::NULL_DATETIME));
|
$event['finish'] = DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME);
|
||||||
if ($event['finish'] < DBA::NULL_DATETIME) {
|
if ($event['finish'] < DBA::NULL_DATETIME) {
|
||||||
$event['finish'] = DBA::NULL_DATETIME;
|
$event['finish'] = DBA::NULL_DATETIME;
|
||||||
}
|
}
|
||||||
$private = intval(defaults($arr, 'private', 0));
|
$private = intval($arr['private'] ?? 0);
|
||||||
|
|
||||||
$conditions = ['uid' => $event['uid']];
|
$conditions = ['uid' => $event['uid']];
|
||||||
if ($event['cid']) {
|
if ($event['cid']) {
|
||||||
|
@ -333,7 +333,7 @@ class Event extends BaseObject
|
||||||
$item_arr['uri'] = $event['uri'];
|
$item_arr['uri'] = $event['uri'];
|
||||||
$item_arr['parent-uri'] = $event['uri'];
|
$item_arr['parent-uri'] = $event['uri'];
|
||||||
$item_arr['guid'] = $event['guid'];
|
$item_arr['guid'] = $event['guid'];
|
||||||
$item_arr['plink'] = defaults($arr, 'plink', '');
|
$item_arr['plink'] = $arr['plink'] ?? '';
|
||||||
$item_arr['post-type'] = Item::PT_EVENT;
|
$item_arr['post-type'] = Item::PT_EVENT;
|
||||||
$item_arr['wall'] = $event['cid'] ? 0 : 1;
|
$item_arr['wall'] = $event['cid'] ? 0 : 1;
|
||||||
$item_arr['contact-id'] = $contact['id'];
|
$item_arr['contact-id'] = $contact['id'];
|
||||||
|
|
|
@ -255,7 +255,7 @@ class GContact
|
||||||
WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND
|
WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND
|
||||||
((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR
|
((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR
|
||||||
(`gcontact`.`updated` >= `gcontact`.`last_failure`))
|
(`gcontact`.`updated` >= `gcontact`.`last_failure`))
|
||||||
AND `gcontact`.`nurl` IN (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ",
|
AND `gcontact`.`nurl` IN (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d) ",
|
||||||
intval($cid),
|
intval($cid),
|
||||||
intval($uid),
|
intval($uid),
|
||||||
intval($uid),
|
intval($uid),
|
||||||
|
@ -281,7 +281,7 @@ class GContact
|
||||||
"SELECT count(*) as `total`
|
"SELECT count(*) as `total`
|
||||||
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||||
where `glink`.`zcid` = %d
|
where `glink`.`zcid` = %d
|
||||||
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) ",
|
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0) ",
|
||||||
intval($zcid),
|
intval($zcid),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
@ -353,7 +353,7 @@ class GContact
|
||||||
"SELECT `gcontact`.*
|
"SELECT `gcontact`.*
|
||||||
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||||
where `glink`.`zcid` = %d
|
where `glink`.`zcid` = %d
|
||||||
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
|
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0)
|
||||||
$sql_extra limit %d, %d",
|
$sql_extra limit %d, %d",
|
||||||
intval($zcid),
|
intval($zcid),
|
||||||
intval($uid),
|
intval($uid),
|
||||||
|
@ -686,9 +686,9 @@ class GContact
|
||||||
$doprobing = (((time() - $last_contact) > (90 * 86400)) && ((time() - $last_failure) > (90 * 86400)));
|
$doprobing = (((time() - $last_contact) > (90 * 86400)) && ((time() - $last_failure) > (90 * 86400)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$contact['location'] = defaults($contact, 'location', '');
|
$contact['location'] = $contact['location'] ?? '';
|
||||||
$contact['about'] = defaults($contact, 'about', '');
|
$contact['about'] = $contact['about'] ?? '';
|
||||||
$contact['generation'] = defaults($contact, 'generation', 0);
|
$contact['generation'] = $contact['generation'] ?? 0;
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"INSERT INTO `gcontact` (`name`, `nick`, `addr` , `network`, `url`, `nurl`, `photo`, `created`, `updated`, `location`, `about`, `hide`, `generation`)
|
"INSERT INTO `gcontact` (`name`, `nick`, `addr` , `network`, `url`, `nurl`, `photo`, `created`, `updated`, `location`, `about`, `hide`, `generation`)
|
||||||
|
|
|
@ -814,7 +814,7 @@ class GServer
|
||||||
|
|
||||||
if (!empty($data['version'])) {
|
if (!empty($data['version'])) {
|
||||||
$serverdata['platform'] = 'mastodon';
|
$serverdata['platform'] = 'mastodon';
|
||||||
$serverdata['version'] = defaults($data, 'version', '');
|
$serverdata['version'] = $data['version'] ?? '';
|
||||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ class GServer
|
||||||
$serverdata['info'] = trim($data['info']);
|
$serverdata['info'] = trim($data['info']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$register_policy = defaults($data, 'register_policy', 'REGISTER_CLOSED');
|
$register_policy = ($data['register_policy'] ?? '') ?: 'REGISTER_CLOSED';
|
||||||
switch ($register_policy) {
|
switch ($register_policy) {
|
||||||
case 'REGISTER_OPEN':
|
case 'REGISTER_OPEN':
|
||||||
$serverdata['register_policy'] = Register::OPEN;
|
$serverdata['register_policy'] = Register::OPEN;
|
||||||
|
@ -1030,7 +1030,7 @@ class GServer
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$serverdata['platform'] = defaults($data, 'platform', '');
|
$serverdata['platform'] = $data['platform'] ?? '';
|
||||||
|
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1313,11 +1313,11 @@ class Item extends BaseObject
|
||||||
$priority = $notify;
|
$priority = $notify;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$item['network'] = trim(defaults($item, 'network', Protocol::PHANTOM));
|
$item['network'] = trim(($item['network'] ?? '') ?: Protocol::PHANTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['guid'] = self::guid($item, $notify);
|
$item['guid'] = self::guid($item, $notify);
|
||||||
$item['uri'] = Strings::escapeTags(trim(defaults($item, 'uri', self::newURI($item['uid'], $item['guid']))));
|
$item['uri'] = Strings::escapeTags(trim(($item['uri'] ?? '') ?: self::newURI($item['uid'], $item['guid'])));
|
||||||
|
|
||||||
// Store URI data
|
// Store URI data
|
||||||
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
||||||
|
@ -1419,47 +1419,47 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['wall'] = intval(defaults($item, 'wall', 0));
|
$item['wall'] = intval($item['wall'] ?? 0);
|
||||||
$item['extid'] = trim(defaults($item, 'extid', ''));
|
$item['extid'] = trim($item['extid'] ?? '');
|
||||||
$item['author-name'] = trim(defaults($item, 'author-name', ''));
|
$item['author-name'] = trim($item['author-name'] ?? '');
|
||||||
$item['author-link'] = trim(defaults($item, 'author-link', ''));
|
$item['author-link'] = trim($item['author-link'] ?? '');
|
||||||
$item['author-avatar'] = trim(defaults($item, 'author-avatar', ''));
|
$item['author-avatar'] = trim($item['author-avatar'] ?? '');
|
||||||
$item['owner-name'] = trim(defaults($item, 'owner-name', ''));
|
$item['owner-name'] = trim($item['owner-name'] ?? '');
|
||||||
$item['owner-link'] = trim(defaults($item, 'owner-link', ''));
|
$item['owner-link'] = trim($item['owner-link'] ?? '');
|
||||||
$item['owner-avatar'] = trim(defaults($item, 'owner-avatar', ''));
|
$item['owner-avatar'] = trim($item['owner-avatar'] ?? '');
|
||||||
$item['received'] = (isset($item['received']) ? DateTimeFormat::utc($item['received']) : DateTimeFormat::utcNow());
|
$item['received'] = (isset($item['received']) ? DateTimeFormat::utc($item['received']) : DateTimeFormat::utcNow());
|
||||||
$item['created'] = (isset($item['created']) ? DateTimeFormat::utc($item['created']) : $item['received']);
|
$item['created'] = (isset($item['created']) ? DateTimeFormat::utc($item['created']) : $item['received']);
|
||||||
$item['edited'] = (isset($item['edited']) ? DateTimeFormat::utc($item['edited']) : $item['created']);
|
$item['edited'] = (isset($item['edited']) ? DateTimeFormat::utc($item['edited']) : $item['created']);
|
||||||
$item['changed'] = (isset($item['changed']) ? DateTimeFormat::utc($item['changed']) : $item['created']);
|
$item['changed'] = (isset($item['changed']) ? DateTimeFormat::utc($item['changed']) : $item['created']);
|
||||||
$item['commented'] = (isset($item['commented']) ? DateTimeFormat::utc($item['commented']) : $item['created']);
|
$item['commented'] = (isset($item['commented']) ? DateTimeFormat::utc($item['commented']) : $item['created']);
|
||||||
$item['title'] = trim(defaults($item, 'title', ''));
|
$item['title'] = trim($item['title'] ?? '');
|
||||||
$item['location'] = trim(defaults($item, 'location', ''));
|
$item['location'] = trim($item['location'] ?? '');
|
||||||
$item['coord'] = trim(defaults($item, 'coord', ''));
|
$item['coord'] = trim($item['coord'] ?? '');
|
||||||
$item['visible'] = (isset($item['visible']) ? intval($item['visible']) : 1);
|
$item['visible'] = (isset($item['visible']) ? intval($item['visible']) : 1);
|
||||||
$item['deleted'] = 0;
|
$item['deleted'] = 0;
|
||||||
$item['parent-uri'] = trim(defaults($item, 'parent-uri', $item['uri']));
|
$item['parent-uri'] = trim(($item['parent-uri'] ?? '') ?: $item['uri']);
|
||||||
$item['post-type'] = defaults($item, 'post-type', self::PT_ARTICLE);
|
$item['post-type'] = ($item['post-type'] ?? '') ?: self::PT_ARTICLE;
|
||||||
$item['verb'] = trim(defaults($item, 'verb', ''));
|
$item['verb'] = trim($item['verb'] ?? '');
|
||||||
$item['object-type'] = trim(defaults($item, 'object-type', ''));
|
$item['object-type'] = trim($item['object-type'] ?? '');
|
||||||
$item['object'] = trim(defaults($item, 'object', ''));
|
$item['object'] = trim($item['object'] ?? '');
|
||||||
$item['target-type'] = trim(defaults($item, 'target-type', ''));
|
$item['target-type'] = trim($item['target-type'] ?? '');
|
||||||
$item['target'] = trim(defaults($item, 'target', ''));
|
$item['target'] = trim($item['target'] ?? '');
|
||||||
$item['plink'] = trim(defaults($item, 'plink', ''));
|
$item['plink'] = trim($item['plink'] ?? '');
|
||||||
$item['allow_cid'] = trim(defaults($item, 'allow_cid', ''));
|
$item['allow_cid'] = trim($item['allow_cid'] ?? '');
|
||||||
$item['allow_gid'] = trim(defaults($item, 'allow_gid', ''));
|
$item['allow_gid'] = trim($item['allow_gid'] ?? '');
|
||||||
$item['deny_cid'] = trim(defaults($item, 'deny_cid', ''));
|
$item['deny_cid'] = trim($item['deny_cid'] ?? '');
|
||||||
$item['deny_gid'] = trim(defaults($item, 'deny_gid', ''));
|
$item['deny_gid'] = trim($item['deny_gid'] ?? '');
|
||||||
$item['private'] = intval(defaults($item, 'private', 0));
|
$item['private'] = intval($item['private'] ?? 0);
|
||||||
$item['body'] = trim(defaults($item, 'body', ''));
|
$item['body'] = trim($item['body'] ?? '');
|
||||||
$item['tag'] = trim(defaults($item, 'tag', ''));
|
$item['tag'] = trim($item['tag'] ?? '');
|
||||||
$item['attach'] = trim(defaults($item, 'attach', ''));
|
$item['attach'] = trim($item['attach'] ?? '');
|
||||||
$item['app'] = trim(defaults($item, 'app', ''));
|
$item['app'] = trim($item['app'] ?? '');
|
||||||
$item['origin'] = intval(defaults($item, 'origin', 0));
|
$item['origin'] = intval($item['origin'] ?? 0);
|
||||||
$item['postopts'] = trim(defaults($item, 'postopts', ''));
|
$item['postopts'] = trim($item['postopts'] ?? '');
|
||||||
$item['resource-id'] = trim(defaults($item, 'resource-id', ''));
|
$item['resource-id'] = trim($item['resource-id'] ?? '');
|
||||||
$item['event-id'] = intval(defaults($item, 'event-id', 0));
|
$item['event-id'] = intval($item['event-id'] ?? 0);
|
||||||
$item['inform'] = trim(defaults($item, 'inform', ''));
|
$item['inform'] = trim($item['inform'] ?? '');
|
||||||
$item['file'] = trim(defaults($item, 'file', ''));
|
$item['file'] = trim($item['file'] ?? '');
|
||||||
|
|
||||||
// When there is no content then we don't post it
|
// When there is no content then we don't post it
|
||||||
if ($item['body'].$item['title'] == '') {
|
if ($item['body'].$item['title'] == '') {
|
||||||
|
@ -1479,12 +1479,12 @@ class Item extends BaseObject
|
||||||
$item['edited'] = DateTimeFormat::utcNow();
|
$item['edited'] = DateTimeFormat::utcNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['plink'] = defaults($item, 'plink', System::baseUrl() . '/display/' . urlencode($item['guid']));
|
$item['plink'] = ($item['plink'] ?? '') ?: System::baseUrl() . '/display/' . urlencode($item['guid']);
|
||||||
|
|
||||||
$default = ['url' => $item['author-link'], 'name' => $item['author-name'],
|
$default = ['url' => $item['author-link'], 'name' => $item['author-name'],
|
||||||
'photo' => $item['author-avatar'], 'network' => $item['network']];
|
'photo' => $item['author-avatar'], 'network' => $item['network']];
|
||||||
|
|
||||||
$item['author-id'] = defaults($item, 'author-id', Contact::getIdForURL($item['author-link'], 0, false, $default));
|
$item['author-id'] = ($item['author-id'] ?? 0) ?: Contact::getIdForURL($item['author-link'], 0, false, $default);
|
||||||
|
|
||||||
if (Contact::isBlocked($item['author-id'])) {
|
if (Contact::isBlocked($item['author-id'])) {
|
||||||
Logger::notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
Logger::notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
||||||
|
@ -1504,7 +1504,7 @@ class Item extends BaseObject
|
||||||
$default = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
|
$default = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
|
||||||
'photo' => $item['owner-avatar'], 'network' => $item['network']];
|
'photo' => $item['owner-avatar'], 'network' => $item['network']];
|
||||||
|
|
||||||
$item['owner-id'] = defaults($item, 'owner-id', Contact::getIdForURL($item['owner-link'], 0, false, $default));
|
$item['owner-id'] = ($item['owner-id'] ?? 0) ?: Contact::getIdForURL($item['owner-link'], 0, false, $default);
|
||||||
|
|
||||||
if (Contact::isBlocked($item['owner-id'])) {
|
if (Contact::isBlocked($item['owner-id'])) {
|
||||||
Logger::notice('Owner is blocked node-wide', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]);
|
Logger::notice('Owner is blocked node-wide', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]);
|
||||||
|
@ -2453,7 +2453,7 @@ class Item extends BaseObject
|
||||||
Contact::unmarkForArchival($contact);
|
Contact::unmarkForArchival($contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
$update = (!$arr['private'] && ((defaults($arr, 'author-link', '') === defaults($arr, 'owner-link', '')) || ($arr["parent-uri"] === $arr["uri"])));
|
$update = (!$arr['private'] && ((($arr['author-link'] ?? '') === ($arr['owner-link'] ?? '')) || ($arr["parent-uri"] === $arr["uri"])));
|
||||||
|
|
||||||
// Is it a forum? Then we don't care about the rules from above
|
// Is it a forum? Then we don't care about the rules from above
|
||||||
if (!$update && in_array($arr["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN]) && ($arr["parent-uri"] === $arr["uri"])) {
|
if (!$update && in_array($arr["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN]) && ($arr["parent-uri"] === $arr["uri"])) {
|
||||||
|
@ -3334,8 +3334,8 @@ class Item extends BaseObject
|
||||||
{
|
{
|
||||||
$body = $item["body"];
|
$body = $item["body"];
|
||||||
|
|
||||||
$rendered_hash = defaults($item, 'rendered-hash', '');
|
$rendered_hash = $item['rendered-hash'] ?? '';
|
||||||
$rendered_html = defaults($item, 'rendered-html', '');
|
$rendered_html = $item['rendered-html'] ?? '';
|
||||||
|
|
||||||
if ($rendered_hash == ''
|
if ($rendered_hash == ''
|
||||||
|| $rendered_html == ""
|
|| $rendered_html == ""
|
||||||
|
@ -3491,7 +3491,7 @@ class Item extends BaseObject
|
||||||
$filesubtype = 'unkn';
|
$filesubtype = 'unkn';
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = Strings::escapeHtml(trim(defaults($mtch, 4, $mtch[1])));
|
$title = Strings::escapeHtml(trim(($mtch[4] ?? '') ?: $mtch[1]));
|
||||||
$title .= ' ' . $mtch[2] . ' ' . L10n::t('bytes');
|
$title .= ' ' . $mtch[2] . ' ' . L10n::t('bytes');
|
||||||
|
|
||||||
$icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>';
|
$icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>';
|
||||||
|
|
|
@ -90,7 +90,7 @@ class ItemContent extends BaseObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = Text\BBCode::convert($post['text'] . defaults($post, 'after', ''), false, $htmlmode);
|
$html = Text\BBCode::convert($post['text'] . ($post['after'] ?? ''), false, $htmlmode);
|
||||||
$msg = Text\HTML::toPlaintext($html, 0, true);
|
$msg = Text\HTML::toPlaintext($html, 0, true);
|
||||||
$msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
|
$msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class ItemContent extends BaseObject
|
||||||
if ($post['type'] == 'link') {
|
if ($post['type'] == 'link') {
|
||||||
$link = $post['url'];
|
$link = $post['url'];
|
||||||
} elseif ($post['type'] == 'text') {
|
} elseif ($post['type'] == 'text') {
|
||||||
$link = defaults($post, 'url', '');
|
$link = $post['url'] ?? '';
|
||||||
} elseif ($post['type'] == 'video') {
|
} elseif ($post['type'] == 'video') {
|
||||||
$link = $post['url'];
|
$link = $post['url'];
|
||||||
} elseif ($post['type'] == 'photo') {
|
} elseif ($post['type'] == 'photo') {
|
||||||
|
|
|
@ -22,10 +22,10 @@ class PermissionSet extends BaseObject
|
||||||
public static function fetchIDForPost(&$postarray)
|
public static function fetchIDForPost(&$postarray)
|
||||||
{
|
{
|
||||||
$condition = ['uid' => $postarray['uid'],
|
$condition = ['uid' => $postarray['uid'],
|
||||||
'allow_cid' => self::sortPermissions(defaults($postarray, 'allow_cid', '')),
|
'allow_cid' => self::sortPermissions($postarray['allow_cid'] ?? ''),
|
||||||
'allow_gid' => self::sortPermissions(defaults($postarray, 'allow_gid', '')),
|
'allow_gid' => self::sortPermissions($postarray['allow_gid'] ?? ''),
|
||||||
'deny_cid' => self::sortPermissions(defaults($postarray, 'deny_cid', '')),
|
'deny_cid' => self::sortPermissions($postarray['deny_cid'] ?? ''),
|
||||||
'deny_gid' => self::sortPermissions(defaults($postarray, 'deny_gid', ''))];
|
'deny_gid' => self::sortPermissions($postarray['deny_gid'] ?? '')];
|
||||||
|
|
||||||
$set = DBA::selectFirst('permissionset', ['id'], $condition);
|
$set = DBA::selectFirst('permissionset', ['id'], $condition);
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ class Profile
|
||||||
$location .= $profile['locality'];
|
$location .= $profile['locality'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($profile['region']) && (defaults($profile, 'locality', '') != $profile['region'])) {
|
if (!empty($profile['region']) && (($profile['locality'] ?? '') != $profile['region'])) {
|
||||||
if ($location) {
|
if ($location) {
|
||||||
$location .= ', ';
|
$location .= ', ';
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ class Profile
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
|
$profile['picdate'] = urlencode($profile['picdate'] ?? '');
|
||||||
|
|
||||||
if (($profile['network'] != '') && ($profile['network'] != Protocol::DFRN)) {
|
if (($profile['network'] != '') && ($profile['network'] != Protocol::DFRN)) {
|
||||||
$profile['network_link'] = Strings::formatNetworkName($profile['network'], $profile['url']);
|
$profile['network_link'] = Strings::formatNetworkName($profile['network'], $profile['url']);
|
||||||
|
@ -384,7 +384,7 @@ class Profile
|
||||||
|
|
||||||
if (Contact::canReceivePrivateMessages($profile)) {
|
if (Contact::canReceivePrivateMessages($profile)) {
|
||||||
if ($visitor_is_followed || $visitor_is_following) {
|
if ($visitor_is_followed || $visitor_is_following) {
|
||||||
$wallmessage_link = $visitor_base_path . '/message/new/' . base64_encode(defaults($profile, 'addr', ''));
|
$wallmessage_link = $visitor_base_path . '/message/new/' . base64_encode($profile['addr'] ?? '');
|
||||||
} elseif ($visitor_is_authenticated && !empty($profile['unkmail'])) {
|
} elseif ($visitor_is_authenticated && !empty($profile['unkmail'])) {
|
||||||
$wallmessage_link = 'wallmessage/' . $profile['nickname'];
|
$wallmessage_link = 'wallmessage/' . $profile['nickname'];
|
||||||
}
|
}
|
||||||
|
@ -460,14 +460,14 @@ class Profile
|
||||||
$diaspora = [
|
$diaspora = [
|
||||||
'guid' => $profile['guid'],
|
'guid' => $profile['guid'],
|
||||||
'podloc' => System::baseUrl(),
|
'podloc' => System::baseUrl(),
|
||||||
'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
|
'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false'),
|
||||||
'nickname' => $profile['nickname'],
|
'nickname' => $profile['nickname'],
|
||||||
'fullname' => $profile['name'],
|
'fullname' => $profile['name'],
|
||||||
'firstname' => $firstname,
|
'firstname' => $firstname,
|
||||||
'lastname' => $lastname,
|
'lastname' => $lastname,
|
||||||
'photo300' => defaults($profile, 'contact_photo', ''),
|
'photo300' => $profile['contact_photo'] ?? '',
|
||||||
'photo100' => defaults($profile, 'contact_thumb', ''),
|
'photo100' => $profile['contact_thumb'] ?? '',
|
||||||
'photo50' => defaults($profile, 'contact_micro', ''),
|
'photo50' => $profile['contact_micro'] ?? '',
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$diaspora = false;
|
$diaspora = false;
|
||||||
|
@ -530,7 +530,7 @@ class Profile
|
||||||
$p['photo'] = ProxyUtils::proxifyUrl($p['photo'], false, ProxyUtils::SIZE_SMALL);
|
$p['photo'] = ProxyUtils::proxifyUrl($p['photo'], false, ProxyUtils::SIZE_SMALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$p['url'] = Contact::magicLink(defaults($p, 'url', $profile_url));
|
$p['url'] = Contact::magicLink(($p['url'] ?? '') ?: $profile_url);
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('profile_vcard.tpl');
|
$tpl = Renderer::getMarkupTemplate('profile_vcard.tpl');
|
||||||
$o .= Renderer::replaceMacros($tpl, [
|
$o .= Renderer::replaceMacros($tpl, [
|
||||||
|
|
|
@ -132,7 +132,7 @@ class Filesystem implements IStorage
|
||||||
|
|
||||||
public static function saveOptions($data)
|
public static function saveOptions($data)
|
||||||
{
|
{
|
||||||
$storagepath = defaults($data, 'storagepath', '');
|
$storagepath = $data['storagepath'] ?? '';
|
||||||
if ($storagepath === '' || !is_dir($storagepath)) {
|
if ($storagepath === '' || !is_dir($storagepath)) {
|
||||||
return [
|
return [
|
||||||
'storagepath' => L10n::t('Enter a valid existing folder')
|
'storagepath' => L10n::t('Enter a valid existing folder')
|
||||||
|
|
|
@ -210,7 +210,7 @@ class Term
|
||||||
{
|
{
|
||||||
$profile_base = System::baseUrl();
|
$profile_base = System::baseUrl();
|
||||||
$profile_data = parse_url($profile_base);
|
$profile_data = parse_url($profile_base);
|
||||||
$profile_path = defaults($profile_data, 'path', '');
|
$profile_path = $profile_data['path'] ?? '';
|
||||||
$profile_base_friendica = $profile_data['host'] . $profile_path . '/profile/';
|
$profile_base_friendica = $profile_data['host'] . $profile_path . '/profile/';
|
||||||
$profile_base_diaspora = $profile_data['host'] . $profile_path . '/u/';
|
$profile_base_diaspora = $profile_data['host'] . $profile_path . '/u/';
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ class CurlResult
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->returnCode == 301 || $this->returnCode == 302 || $this->returnCode == 303 || $this->returnCode== 307) {
|
if ($this->returnCode == 301 || $this->returnCode == 302 || $this->returnCode == 303 || $this->returnCode== 307) {
|
||||||
$redirect_parts = parse_url(defaults($this->info, 'redirect_url', ''));
|
$redirect_parts = parse_url($this->info['redirect_url'] ?? '');
|
||||||
if (empty($redirect_parts)) {
|
if (empty($redirect_parts)) {
|
||||||
$redirect_parts = [];
|
$redirect_parts = [];
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ class CurlResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = parse_url(defaults($this->info, 'url', ''));
|
$parts = parse_url($this->info['url'] ?? '');
|
||||||
if (empty($parts)) {
|
if (empty($parts)) {
|
||||||
$parts = [];
|
$parts = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,7 +348,7 @@ class Probe
|
||||||
if (!self::$istimeout) {
|
if (!self::$istimeout) {
|
||||||
$ap_profile = ActivityPub::probeProfile($uri);
|
$ap_profile = ActivityPub::probeProfile($uri);
|
||||||
|
|
||||||
if (empty($data) || (!empty($ap_profile) && empty($network) && (defaults($data, 'network', '') != Protocol::DFRN))) {
|
if (empty($data) || (!empty($ap_profile) && empty($network) && (($data['network'] ?? '') == Protocol::DFRN))) {
|
||||||
$data = $ap_profile;
|
$data = $ap_profile;
|
||||||
} elseif (!empty($ap_profile)) {
|
} elseif (!empty($ap_profile)) {
|
||||||
$ap_profile['batch'] = '';
|
$ap_profile['batch'] = '';
|
||||||
|
@ -363,7 +363,7 @@ class Probe
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['photo'])) {
|
if (!empty($data['photo'])) {
|
||||||
$data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink(defaults($data, 'baseurl', '')), Strings::normaliseLink($data['photo']));
|
$data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink($data['baseurl'] ?? ''), Strings::normaliseLink($data['photo']));
|
||||||
} else {
|
} else {
|
||||||
$data['photo'] = System::baseUrl() . '/images/person-300.jpg';
|
$data['photo'] = System::baseUrl() . '/images/person-300.jpg';
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ class Probe
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file is too large then exit
|
// If the file is too large then exit
|
||||||
if (defaults($curlResult->getInfo(), 'download_content_length', 0) > 1000000) {
|
if (($curlResult->getInfo()['download_content_length'] ?? 0) > 1000000) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ class Probe
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$path_parts = explode("/", trim(defaults($parts, 'path', ''), "/"));
|
$path_parts = explode("/", trim($parts['path'] ?? '', "/"));
|
||||||
|
|
||||||
while (!$lrdd && (sizeof($path_parts) > 1)) {
|
while (!$lrdd && (sizeof($path_parts) > 1)) {
|
||||||
$host .= "/".array_shift($path_parts);
|
$host .= "/".array_shift($path_parts);
|
||||||
|
@ -921,19 +921,19 @@ class Probe
|
||||||
|
|
||||||
if (empty($data["addr"]) || empty($data["nick"])) {
|
if (empty($data["addr"]) || empty($data["nick"])) {
|
||||||
$probe_data = self::uri($profile_link);
|
$probe_data = self::uri($profile_link);
|
||||||
$data["addr"] = defaults($data, "addr", $probe_data["addr"]);
|
$data["addr"] = ($data["addr"] ?? '') ?: $probe_data["addr"];
|
||||||
$data["nick"] = defaults($data, "nick", $probe_data["nick"]);
|
$data["nick"] = ($data["nick"] ?? '') ?: $probe_data["nick"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$prof_data["addr"] = $data["addr"];
|
$prof_data["addr"] = $data["addr"];
|
||||||
$prof_data["nick"] = $data["nick"];
|
$prof_data["nick"] = $data["nick"];
|
||||||
$prof_data["dfrn-request"] = defaults($data, 'request', null);
|
$prof_data["dfrn-request"] = $data['request'] ?? null;
|
||||||
$prof_data["dfrn-confirm"] = defaults($data, 'confirm', null);
|
$prof_data["dfrn-confirm"] = $data['confirm'] ?? null;
|
||||||
$prof_data["dfrn-notify"] = defaults($data, 'notify' , null);
|
$prof_data["dfrn-notify"] = $data['notify'] ?? null;
|
||||||
$prof_data["dfrn-poll"] = defaults($data, 'poll' , null);
|
$prof_data["dfrn-poll"] = $data['poll'] ?? null;
|
||||||
$prof_data["photo"] = defaults($data, 'photo' , null);
|
$prof_data["photo"] = $data['photo'] ?? null;
|
||||||
$prof_data["fn"] = defaults($data, 'name' , null);
|
$prof_data["fn"] = $data['name'] ?? null;
|
||||||
$prof_data["key"] = defaults($data, 'pubkey' , null);
|
$prof_data["key"] = $data['pubkey'] ?? null;
|
||||||
|
|
||||||
Logger::log("Result for profile ".$profile_link.": ".print_r($prof_data, true), Logger::DEBUG);
|
Logger::log("Result for profile ".$profile_link.": ".print_r($prof_data, true), Logger::DEBUG);
|
||||||
|
|
||||||
|
@ -959,7 +959,7 @@ class Probe
|
||||||
$data["network"] = Protocol::DFRN;
|
$data["network"] = Protocol::DFRN;
|
||||||
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
|
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
|
||||||
$data["poll"] = $link["href"];
|
$data["poll"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
|
||||||
$data["url"] = $link["href"];
|
$data["url"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
|
||||||
$hcard_url = $link["href"];
|
$hcard_url = $link["href"];
|
||||||
|
@ -1169,7 +1169,7 @@ class Probe
|
||||||
$data["baseurl"] = trim($link["href"], '/');
|
$data["baseurl"] = trim($link["href"], '/');
|
||||||
} elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
|
||||||
$data["guid"] = $link["href"];
|
$data["guid"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
|
||||||
$data["url"] = $link["href"];
|
$data["url"] = $link["href"];
|
||||||
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
|
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
|
||||||
$data["poll"] = $link["href"];
|
$data["poll"] = $link["href"];
|
||||||
|
@ -1267,7 +1267,7 @@ class Probe
|
||||||
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
|
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
|
||||||
foreach (array_reverse($webfinger["links"]) as $link) {
|
foreach (array_reverse($webfinger["links"]) as $link) {
|
||||||
if (($link["rel"] == "http://webfinger.net/rel/profile-page")
|
if (($link["rel"] == "http://webfinger.net/rel/profile-page")
|
||||||
&& (defaults($link, "type", "") == "text/html")
|
&& (($link["type"] ?? "") == "text/html")
|
||||||
&& ($link["href"] != "")
|
&& ($link["href"] != "")
|
||||||
) {
|
) {
|
||||||
$data["url"] = $link["href"];
|
$data["url"] = $link["href"];
|
||||||
|
@ -1436,7 +1436,7 @@ class Probe
|
||||||
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
|
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
|
||||||
foreach (array_reverse($webfinger["links"]) as $link) {
|
foreach (array_reverse($webfinger["links"]) as $link) {
|
||||||
if (($link["rel"] == "http://webfinger.net/rel/profile-page")
|
if (($link["rel"] == "http://webfinger.net/rel/profile-page")
|
||||||
&& (defaults($link, "type", "") == "text/html")
|
&& (($link["type"] ?? "") == "text/html")
|
||||||
&& ($link["href"] != "")
|
&& ($link["href"] != "")
|
||||||
) {
|
) {
|
||||||
$data["url"] = $link["href"];
|
$data["url"] = $link["href"];
|
||||||
|
|
|
@ -805,7 +805,7 @@ class Post extends BaseObject
|
||||||
$terms = Term::tagArrayFromItemId($this->getId(), [Term::MENTION, Term::IMPLICIT_MENTION]);
|
$terms = Term::tagArrayFromItemId($this->getId(), [Term::MENTION, Term::IMPLICIT_MENTION]);
|
||||||
foreach ($terms as $term) {
|
foreach ($terms as $term) {
|
||||||
$profile = Contact::getDetailsByURL($term['url']);
|
$profile = Contact::getDetailsByURL($term['url']);
|
||||||
if (!empty($profile['addr']) && (defaults($profile, 'contact-type', Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
|
if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
|
||||||
($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
|
($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
|
||||||
$text .= '@' . $profile['addr'] . ' ';
|
$text .= '@' . $profile['addr'] . ' ';
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,8 @@ class ActivityPub
|
||||||
*/
|
*/
|
||||||
public static function isRequest()
|
public static function isRequest()
|
||||||
{
|
{
|
||||||
return stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/activity+json') ||
|
return stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
|
||||||
stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/ld+json');
|
stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Processor
|
||||||
|
|
||||||
$tag_text = '';
|
$tag_text = '';
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (in_array(defaults($tag, 'type', ''), ['Mention', 'Hashtag'])) {
|
if (in_array($tag['type'] ?? '', ['Mention', 'Hashtag'])) {
|
||||||
if (!empty($tag_text)) {
|
if (!empty($tag_text)) {
|
||||||
$tag_text .= ',';
|
$tag_text .= ',';
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ class Processor
|
||||||
if (!isset($attach['length'])) {
|
if (!isset($attach['length'])) {
|
||||||
$attach['length'] = "0";
|
$attach['length'] = "0";
|
||||||
}
|
}
|
||||||
$item["attach"] .= '[attach]href="'.$attach['url'].'" length="'.$attach['length'].'" type="'.$attach['mediaType'].'" title="'.defaults($attach, 'name', '').'"[/attach]';
|
$item["attach"] .= '[attach]href="'.$attach['url'].'" length="'.$attach['length'].'" type="'.$attach['mediaType'].'" title="'.($attach['name'] ?? '') .'"[/attach]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ class Processor
|
||||||
self::fetchMissingActivity($activity['reply-to-id'], $activity);
|
self::fetchMissingActivity($activity['reply-to-id'], $activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['diaspora_signed_text'] = defaults($activity, 'diaspora:comment', '');
|
$item['diaspora_signed_text'] = $activity['diaspora:comment'] ?? '';
|
||||||
|
|
||||||
self::postItem($activity, $item);
|
self::postItem($activity, $item);
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ class Processor
|
||||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||||
$item['object-type'] = ACTIVITY_OBJ_NOTE;
|
$item['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||||
|
|
||||||
$item['diaspora_signed_text'] = defaults($activity, 'diaspora:like', '');
|
$item['diaspora_signed_text'] = $activity['diaspora:like'] ?? '';
|
||||||
|
|
||||||
self::postItem($activity, $item);
|
self::postItem($activity, $item);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ class Processor
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['plink'] = defaults($activity, 'alternate-url', $item['uri']);
|
$item['plink'] = $activity['alternate-url'] ?? $item['uri'];
|
||||||
|
|
||||||
$item = self::constructAttachList($activity['attachments'], $item, !empty($activity['source']));
|
$item = self::constructAttachList($activity['attachments'], $item, !empty($activity['source']));
|
||||||
|
|
||||||
|
@ -583,8 +583,8 @@ class Processor
|
||||||
$activity['@context'] = $object['@context'];
|
$activity['@context'] = $object['@context'];
|
||||||
unset($object['@context']);
|
unset($object['@context']);
|
||||||
$activity['id'] = $object['id'];
|
$activity['id'] = $object['id'];
|
||||||
$activity['to'] = defaults($object, 'to', []);
|
$activity['to'] = $object['to'] ?? [];
|
||||||
$activity['cc'] = defaults($object, 'cc', []);
|
$activity['cc'] = $object['cc'] ?? [];
|
||||||
$activity['actor'] = $actor;
|
$activity['actor'] = $actor;
|
||||||
$activity['object'] = $object;
|
$activity['object'] = $object;
|
||||||
$activity['published'] = $published;
|
$activity['published'] = $published;
|
||||||
|
@ -628,7 +628,7 @@ class Processor
|
||||||
$item = ['author-id' => Contact::getIdForURL($activity['actor']),
|
$item = ['author-id' => Contact::getIdForURL($activity['actor']),
|
||||||
'author-link' => $activity['actor']];
|
'author-link' => $activity['actor']];
|
||||||
|
|
||||||
$note = Strings::escapeTags(trim(defaults($activity, 'content', '')));
|
$note = Strings::escapeTags(trim($activity['content'] ?? ''));
|
||||||
|
|
||||||
// Ensure that the contact has got the right network type
|
// Ensure that the contact has got the right network type
|
||||||
self::switchContact($item['author-id']);
|
self::switchContact($item['author-id']);
|
||||||
|
@ -893,7 +893,7 @@ class Processor
|
||||||
|
|
||||||
// Extract one prepended mention at a time from the body
|
// Extract one prepended mention at a time from the body
|
||||||
while(preg_match('#^(@\[url=([^\]]+)].*?\[\/url]\s)(.*)#is', $body, $matches)) {
|
while(preg_match('#^(@\[url=([^\]]+)].*?\[\/url]\s)(.*)#is', $body, $matches)) {
|
||||||
if (!in_array($matches[2], $potential_mentions) ) {
|
if (!in_array($matches[2], $potential_mentions)) {
|
||||||
$kept_mentions[] = $matches[1];
|
$kept_mentions[] = $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ class Receiver
|
||||||
*/
|
*/
|
||||||
public static function isRequest()
|
public static function isRequest()
|
||||||
{
|
{
|
||||||
return stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/activity+json') ||
|
return stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
|
||||||
stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/ld+json');
|
stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,7 +260,7 @@ class Receiver
|
||||||
$object_data['type'] = $type;
|
$object_data['type'] = $type;
|
||||||
$object_data['actor'] = $actor;
|
$object_data['actor'] = $actor;
|
||||||
$object_data['item_receiver'] = $receivers;
|
$object_data['item_receiver'] = $receivers;
|
||||||
$object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers);
|
$object_data['receiver'] = array_merge($object_data['receiver'] ?? [], $receivers);
|
||||||
|
|
||||||
Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG);
|
Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG);
|
||||||
|
|
||||||
|
@ -301,9 +301,9 @@ class Receiver
|
||||||
$conversation = [
|
$conversation = [
|
||||||
'protocol' => Conversation::PARCEL_ACTIVITYPUB,
|
'protocol' => Conversation::PARCEL_ACTIVITYPUB,
|
||||||
'item-uri' => $activity['id'],
|
'item-uri' => $activity['id'],
|
||||||
'reply-to-uri' => defaults($activity, 'reply-to-id', ''),
|
'reply-to-uri' => $activity['reply-to-id'] ?? '',
|
||||||
'conversation-href' => defaults($activity, 'context', ''),
|
'conversation-href' => $activity['context'] ?? '',
|
||||||
'conversation-uri' => defaults($activity, 'conversation', ''),
|
'conversation-uri' => $activity['conversation'] ?? '',
|
||||||
'source' => $body,
|
'source' => $body,
|
||||||
'received' => DateTimeFormat::utcNow()];
|
'received' => DateTimeFormat::utcNow()];
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ class Receiver
|
||||||
|
|
||||||
if (!empty($actor)) {
|
if (!empty($actor)) {
|
||||||
$profile = APContact::getByURL($actor);
|
$profile = APContact::getByURL($actor);
|
||||||
$followers = defaults($profile, 'followers', '');
|
$followers = $profile['followers'] ?? '';
|
||||||
|
|
||||||
Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, Logger::DEBUG);
|
Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, Logger::DEBUG);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -119,8 +119,8 @@ class DFRN
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
// These values aren't sent when sending from the queue.
|
// These values aren't sent when sending from the queue.
|
||||||
/// @todo Check if we can set these values from the queue or if they are needed at all.
|
/// @todo Check if we can set these values from the queue or if they are needed at all.
|
||||||
$item["entry:comment-allow"] = defaults($item, "entry:comment-allow", true);
|
$item["entry:comment-allow"] = ($item["entry:comment-allow"] ?? '') ?: true;
|
||||||
$item["entry:cid"] = defaults($item, "entry:cid", 0);
|
$item["entry:cid"] = $item["entry:cid"] ?? 0;
|
||||||
|
|
||||||
$entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
|
$entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
|
||||||
if (isset($entry)) {
|
if (isset($entry)) {
|
||||||
|
@ -1259,7 +1259,7 @@ class DFRN
|
||||||
$sent_dfrn_id = hex2bin((string) $res->dfrn_id);
|
$sent_dfrn_id = hex2bin((string) $res->dfrn_id);
|
||||||
$challenge = hex2bin((string) $res->challenge);
|
$challenge = hex2bin((string) $res->challenge);
|
||||||
$perm = (($res->perm) ? $res->perm : null);
|
$perm = (($res->perm) ? $res->perm : null);
|
||||||
$dfrn_version = (float) (($res->dfrn_version) ? $res->dfrn_version : 2.0);
|
$dfrn_version = floatval($res->dfrn_version ?: 2.0);
|
||||||
$rino_remote_version = intval($res->rino);
|
$rino_remote_version = intval($res->rino);
|
||||||
$page = (($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? 1 : 0);
|
$page = (($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? 1 : 0);
|
||||||
|
|
||||||
|
@ -2019,8 +2019,8 @@ class DFRN
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['title' => defaults($item, 'title', ''), 'body' => defaults($item, 'body', ''),
|
$fields = ['title' => $item['title'] ?? '', 'body' => $item['body'] ?? '',
|
||||||
'tag' => defaults($item, 'tag', ''), 'changed' => DateTimeFormat::utcNow(),
|
'tag' => $item['tag'] ?? '', 'changed' => DateTimeFormat::utcNow(),
|
||||||
'edited' => DateTimeFormat::utc($item["edited"])];
|
'edited' => DateTimeFormat::utc($item["edited"])];
|
||||||
|
|
||||||
$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
|
$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
|
||||||
|
|
|
@ -544,7 +544,7 @@ class Email
|
||||||
}
|
}
|
||||||
|
|
||||||
$quotelevel = 0;
|
$quotelevel = 0;
|
||||||
$nextline = trim(defaults($arrbody, $i + 1, ''));
|
$nextline = trim($arrbody[$i + 1] ?? '');
|
||||||
while ((strlen($nextline)>0) && ((substr($nextline, 0, 1) == '>')
|
while ((strlen($nextline)>0) && ((substr($nextline, 0, 1) == '>')
|
||||||
|| (substr($nextline, 0, 1) == ' '))) {
|
|| (substr($nextline, 0, 1) == ' '))) {
|
||||||
if (substr($nextline, 0, 1) == '>') {
|
if (substr($nextline, 0, 1) == '>') {
|
||||||
|
|
|
@ -74,7 +74,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
$author["author-id"] = Contact::getIdForURL($author["author-link"]);
|
$author["author-id"] = Contact::getIdForURL($author["author-link"]);
|
||||||
|
|
||||||
$author['contact-id'] = defaults($contact, 'id', $author['author-id']);
|
$author['contact-id'] = ($contact['id'] ?? 0) ?: $author['author-id'];
|
||||||
|
|
||||||
$contact = [];
|
$contact = [];
|
||||||
|
|
||||||
|
@ -1131,7 +1131,7 @@ class OStatus
|
||||||
if (!isset($attribute['length'])) {
|
if (!isset($attribute['length'])) {
|
||||||
$attribute['length'] = "0";
|
$attribute['length'] = "0";
|
||||||
}
|
}
|
||||||
$item["attach"] .= '[attach]href="'.$attribute['href'].'" length="'.$attribute['length'].'" type="'.$attribute['type'].'" title="'.defaults($attribute, 'title', '').'"[/attach]';
|
$item["attach"] .= '[attach]href="'.$attribute['href'].'" length="'.$attribute['length'].'" type="'.$attribute['type'].'" title="'.($attribute['title'] ?? '') .'"[/attach]';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "related":
|
case "related":
|
||||||
|
@ -1403,7 +1403,8 @@ class OStatus
|
||||||
"href" => $siteinfo["url"],
|
"href" => $siteinfo["url"],
|
||||||
"type" => "text/html; charset=UTF-8",
|
"type" => "text/html; charset=UTF-8",
|
||||||
"length" => "",
|
"length" => "",
|
||||||
"title" => defaults($siteinfo, "title", $siteinfo["url"])];
|
"title" => ($siteinfo["title"] ?? '') ?: $siteinfo["url"],
|
||||||
|
];
|
||||||
XML::addElement($doc, $root, "link", "", $attributes);
|
XML::addElement($doc, $root, "link", "", $attributes);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Emailer
|
||||||
.rand(10000, 99999);
|
.rand(10000, 99999);
|
||||||
|
|
||||||
// generate a multipart/alternative message header
|
// generate a multipart/alternative message header
|
||||||
$messageHeader = defaults($params, 'additionalMailHeader', '') .
|
$messageHeader = ($params['additionalMailHeader'] ?? '') .
|
||||||
"From: $fromName <{$params['fromEmail']}>\n" .
|
"From: $fromName <{$params['fromEmail']}>\n" .
|
||||||
"Reply-To: $fromName <{$params['replyTo']}>\n" .
|
"Reply-To: $fromName <{$params['replyTo']}>\n" .
|
||||||
"MIME-Version: 1.0\n" .
|
"MIME-Version: 1.0\n" .
|
||||||
|
|
|
@ -111,7 +111,7 @@ class SyslogLogger extends AbstractLogger
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps the LogLevel (@see LogLevel ) to a SysLog priority (@see http://php.net/manual/en/function.syslog.php#refsect1-function.syslog-parameters )
|
* Maps the LogLevel (@see LogLevel) to a SysLog priority (@see http://php.net/manual/en/function.syslog.php#refsect1-function.syslog-parameters)
|
||||||
*
|
*
|
||||||
* @param string $level A LogLevel
|
* @param string $level A LogLevel
|
||||||
*
|
*
|
||||||
|
|
|
@ -104,7 +104,7 @@ class Network
|
||||||
|
|
||||||
$parts2 = [];
|
$parts2 = [];
|
||||||
$parts = parse_url($url);
|
$parts = parse_url($url);
|
||||||
$path_parts = explode('/', defaults($parts, 'path', ''));
|
$path_parts = explode('/', $parts['path'] ?? '');
|
||||||
foreach ($path_parts as $part) {
|
foreach ($path_parts as $part) {
|
||||||
if (strlen($part) <> mb_strlen($part)) {
|
if (strlen($part) <> mb_strlen($part)) {
|
||||||
$parts2[] = rawurlencode($part);
|
$parts2[] = rawurlencode($part);
|
||||||
|
@ -380,7 +380,7 @@ class Network
|
||||||
/// @TODO Really suppress function outcomes? Why not find them + debug them?
|
/// @TODO Really suppress function outcomes? Why not find them + debug them?
|
||||||
$h = @parse_url($url);
|
$h = @parse_url($url);
|
||||||
|
|
||||||
if (!empty($h['host']) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
|
if (!empty($h['host']) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP))) {
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ class Network
|
||||||
$h = substr($addr, strpos($addr, '@') + 1);
|
$h = substr($addr, strpos($addr, '@') + 1);
|
||||||
|
|
||||||
// Concerning the @ see here: https://stackoverflow.com/questions/36280957/dns-get-record-a-temporary-server-error-occurred
|
// Concerning the @ see here: https://stackoverflow.com/questions/36280957/dns-get-record-a-temporary-server-error-occurred
|
||||||
if ($h && (@dns_get_record($h, DNS_A + DNS_MX) || filter_var($h, FILTER_VALIDATE_IP) )) {
|
if ($h && (@dns_get_record($h, DNS_A + DNS_MX) || filter_var($h, FILTER_VALIDATE_IP))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ($h && @dns_get_record($h, DNS_CNAME + DNS_MX)) {
|
if ($h && @dns_get_record($h, DNS_CNAME + DNS_MX)) {
|
||||||
|
@ -801,8 +801,8 @@ class Network
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$path = "";
|
$path = "";
|
||||||
do {
|
do {
|
||||||
$path1 = defaults($pathparts1, $i, '');
|
$path1 = $pathparts1[$i] ?? '';
|
||||||
$path2 = defaults($pathparts2, $i, '');
|
$path2 = $pathparts2[$i] ?? '';
|
||||||
|
|
||||||
if ($path1 == $path2) {
|
if ($path1 == $path2) {
|
||||||
$path .= $path1."/";
|
$path .= $path1."/";
|
||||||
|
|
|
@ -141,7 +141,7 @@ class ParseUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file is too large then exit
|
// If the file is too large then exit
|
||||||
if (defaults($curlResult->getInfo(), 'download_content_length', 0) > 1000000) {
|
if (($curlResult->getInfo()['download_content_length'] ?? 0) > 1000000) {
|
||||||
return $siteinfo;
|
return $siteinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ use Psr\Log\LoggerInterface;
|
||||||
* A class to store profiling data
|
* A class to store profiling data
|
||||||
* It can handle different logging data for specific functions or global performance measures
|
* It can handle different logging data for specific functions or global performance measures
|
||||||
*
|
*
|
||||||
* It stores the data as log entries (@see LoggerInterface )
|
* It stores the data as log entries (@see LoggerInterface)
|
||||||
*/
|
*/
|
||||||
class Profiler implements ContainerInterface
|
class Profiler implements ContainerInterface
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ class Profiler implements ContainerInterface
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$duration = (float) (microtime(true) - $timestamp);
|
$duration = floatval(microtime(true) - $timestamp);
|
||||||
|
|
||||||
if (!isset($this->performance[$value])) {
|
if (!isset($this->performance[$value])) {
|
||||||
// Prevent ugly E_NOTICE
|
// Prevent ugly E_NOTICE
|
||||||
|
|
|
@ -250,7 +250,7 @@ class Delivery extends BaseObject
|
||||||
*/
|
*/
|
||||||
private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
|
private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
|
||||||
{
|
{
|
||||||
Logger::log('Deliver ' . defaults($target_item, 'guid', $target_item['id']) . ' via DFRN to ' . (empty($contact['addr']) ? $contact['url'] : $contact['addr']));
|
Logger::info('Deliver ' . (($target_item['guid'] ?? '') ?: $target_item['id']) . ' via DFRN to ' . (($contact['addr'] ?? '') ?: $contact['url']));
|
||||||
|
|
||||||
if ($cmd == self::MAIL) {
|
if ($cmd == self::MAIL) {
|
||||||
$item = $target_item;
|
$item = $target_item;
|
||||||
|
@ -278,7 +278,7 @@ class Delivery extends BaseObject
|
||||||
$atom = DFRN::entries($msgitems, $owner);
|
$atom = DFRN::entries($msgitems, $owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::log('Notifier entry: ' . $contact["url"] . ' ' . defaults($target_item, 'guid', $target_item['id']) . ' entry: ' . $atom, Logger::DATA);
|
Logger::debug('Notifier entry: ' . $contact["url"] . ' ' . (($target_item['guid'] ?? '') ?: $target_item['id']) . ' entry: ' . $atom, Logger::DATA);
|
||||||
|
|
||||||
$basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3));
|
$basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3));
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ class Delivery extends BaseObject
|
||||||
$protocol = Model\ItemDeliveryData::LEGACY_DFRN;
|
$protocol = Model\ItemDeliveryData::LEGACY_DFRN;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::info('DFRN Delivery', ['cmd' => $cmd, 'url' => $contact['url'], 'guid' => defaults($target_item, 'guid', $target_item['id']), 'return' => $deliver_status]);
|
Logger::info('DFRN Delivery', ['cmd' => $cmd, 'url' => $contact['url'], 'guid' => ($target_item['guid'] ?? '') ?: $target_item['id'], 'return' => $deliver_status]);
|
||||||
|
|
||||||
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
|
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
|
||||||
// We successfully delivered a message, the contact is alive
|
// We successfully delivered a message, the contact is alive
|
||||||
|
@ -372,7 +372,7 @@ class Delivery extends BaseObject
|
||||||
// The message could not be delivered. We mark the contact as "dead"
|
// The message could not be delivered. We mark the contact as "dead"
|
||||||
Model\Contact::markForArchival($contact);
|
Model\Contact::markForArchival($contact);
|
||||||
|
|
||||||
Logger::info('Delivery failed: defer message', ['id' => defaults($target_item, 'guid', $target_item['id'])]);
|
Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
|
||||||
if (!Worker::defer() && in_array($cmd, [Delivery::POST, Delivery::POKE])) {
|
if (!Worker::defer() && in_array($cmd, [Delivery::POST, Delivery::POKE])) {
|
||||||
Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
|
Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ class Delivery extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($contact['contact-type']) || ($contact['contact-type'] != Model\Contact::TYPE_RELAY)) {
|
if (empty($contact['contact-type']) || ($contact['contact-type'] != Model\Contact::TYPE_RELAY)) {
|
||||||
Logger::info('Delivery failed: defer message', ['id' => defaults($target_item, 'guid', $target_item['id'])]);
|
Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
|
||||||
// defer message for redelivery
|
// defer message for redelivery
|
||||||
if (!Worker::defer() && in_array($cmd, [Delivery::POST, Delivery::POKE])) {
|
if (!Worker::defer() && in_array($cmd, [Delivery::POST, Delivery::POKE])) {
|
||||||
Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
|
Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class GProbe {
|
||||||
$result = Cache::get("gprobe:".$urlparts["host"]);
|
$result = Cache::get("gprobe:".$urlparts["host"]);
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) {
|
if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) {
|
||||||
Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".defaults($_SERVER, "REMOTE_ADDR", '').". server data: ".print_r($_SERVER, true), Logger::DEBUG);
|
Logger::debug("DDoS attempt detected for " . $urlparts["host"] . " by " . ($_SERVER["REMOTE_ADDR"] ?? ''), ['$_SERVER' => $_SERVER]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue