mirror of
https://github.com/friendica/friendica
synced 2026-04-19 18:27:21 +02:00
Merge pull request #15576 from Art4/update-codebase
Update codebase to PHP 7.4
This commit is contained in:
commit
47fa9484bd
60 changed files with 564 additions and 574 deletions
11
.rector.php
11
.rector.php
|
|
@ -18,15 +18,14 @@ return \Rector\Config\RectorConfig::configure()
|
|||
])
|
||||
->withIndent("\t", 4)
|
||||
->withPhpVersion(70400)
|
||||
->withPhpLevel(15)
|
||||
// ->withTypeCoverageLevel(0)
|
||||
// ->withDeadCodeLevel(0)
|
||||
// ->withCodeQualityLevel(0)
|
||||
->withRules([
|
||||
\Rector\Php71\Rector\List_\ListToArrayDestructRector::class,
|
||||
])
|
||||
->withSets([
|
||||
\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_55,
|
||||
\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_74,
|
||||
\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_74,
|
||||
])
|
||||
->withSkip([
|
||||
\Rector\Php56\Rector\FuncCall\PowToExpRector::class,
|
||||
\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class,
|
||||
])
|
||||
;
|
||||
|
|
|
|||
22
composer.lock
generated
22
composer.lock
generated
|
|
@ -7395,11 +7395,11 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "2.1.39",
|
||||
"version": "2.1.40",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6f73a2af4cbcd99c931d0fb8f08548cc0fa8224",
|
||||
"reference": "c6f73a2af4cbcd99c931d0fb8f08548cc0fa8224",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/9b2c7aeb83a75d8680ea5e7c9b7fca88052b766b",
|
||||
"reference": "9b2c7aeb83a75d8680ea5e7c9b7fca88052b766b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -7444,7 +7444,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-02-11T14:48:56+00:00"
|
||||
"time": "2026-02-23T15:04:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-strict-rules",
|
||||
|
|
@ -8455,21 +8455,21 @@
|
|||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
"version": "2.2.7",
|
||||
"version": "2.3.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rectorphp/rector.git",
|
||||
"reference": "022038537838bc8a4e526af86c2d6e38eaeff7ef"
|
||||
"reference": "bbd37aedd8df749916cffa2a947cfc4714d1ba2c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/022038537838bc8a4e526af86c2d6e38eaeff7ef",
|
||||
"reference": "022038537838bc8a4e526af86c2d6e38eaeff7ef",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/bbd37aedd8df749916cffa2a947cfc4714d1ba2c",
|
||||
"reference": "bbd37aedd8df749916cffa2a947cfc4714d1ba2c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4|^8.0",
|
||||
"phpstan/phpstan": "^2.1.26"
|
||||
"phpstan/phpstan": "^2.1.38"
|
||||
},
|
||||
"conflict": {
|
||||
"rector/rector-doctrine": "*",
|
||||
|
|
@ -8503,7 +8503,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rectorphp/rector/issues",
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.2.7"
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.3.8"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -8511,7 +8511,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-10-29T15:46:12+00:00"
|
||||
"time": "2026-02-22T09:45:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ function photos_init()
|
|||
'total' => $album['total'],
|
||||
'url' => 'photos/' . $owner['nickname'] . '/album/' . bin2hex($album['album']),
|
||||
'urlencode' => urlencode($album['album']),
|
||||
'bin2hex' => bin2hex($album['album'])
|
||||
'bin2hex' => bin2hex($album['album']),
|
||||
];
|
||||
$ret['albums'][] = $entry;
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ function photos_init()
|
|||
'$recent' => DI::l10n()->t('Recent Photos'),
|
||||
'$albums' => $ret['albums'],
|
||||
'$upload' => [DI::l10n()->t('Upload photo'), 'photos/' . $owner['nickname'] . '/upload'],
|
||||
'$can_post' => (DI::userSession()->getLocalUserId() && $owner['uid'] === DI::userSession()->getLocalUserId())
|
||||
'$can_post' => (DI::userSession()->getLocalUserId() && $owner['uid'] === DI::userSession()->getLocalUserId()),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ function photos_init()
|
|||
$tpl = Renderer::getMarkupTemplate("photos_head.tpl");
|
||||
|
||||
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
||||
'$ispublic' => DI::l10n()->t('everybody')
|
||||
'$ispublic' => DI::l10n()->t('everybody'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -183,13 +183,13 @@ function photos_post()
|
|||
"SELECT distinct(`resource-id`) AS `rid` FROM `photo` WHERE `contact-id` = ? AND `uid` = ? AND `album` = ?",
|
||||
$visitor,
|
||||
$page_owner_uid,
|
||||
$album
|
||||
$album,
|
||||
));
|
||||
} else {
|
||||
$r = DBA::toArray(DBA::p(
|
||||
"SELECT distinct(`resource-id`) AS `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?",
|
||||
DI::userSession()->getLocalUserId(),
|
||||
$album
|
||||
$album,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ function photos_post()
|
|||
$photo = $photos[0];
|
||||
Photo::update(
|
||||
['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_circle_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_circle_deny],
|
||||
['resource-id' => $resource_id, 'uid' => $page_owner_uid]
|
||||
['resource-id' => $resource_id, 'uid' => $page_owner_uid],
|
||||
);
|
||||
|
||||
// Update the photo albums cache if album name was changed
|
||||
|
|
@ -439,13 +439,13 @@ function photos_content()
|
|||
$ret = [
|
||||
'post_url' => 'profile/' . $user['nickname'] . '/photos',
|
||||
'addon_text' => $uploader,
|
||||
'default_upload' => true
|
||||
'default_upload' => true,
|
||||
];
|
||||
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
||||
$eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::PHOTO_UPLOAD_FORM, $ret)
|
||||
new ArrayFilterEvent(ArrayFilterEvent::PHOTO_UPLOAD_FORM, $ret),
|
||||
);
|
||||
|
||||
// Determine if we're in album context (uploading to a specific album)
|
||||
|
|
@ -518,7 +518,7 @@ function photos_content()
|
|||
"SELECT `resource-id`, MAX(`scale`) AS `scale` FROM `photo` WHERE `uid` = ? AND `album` = ?
|
||||
AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
|
||||
$owner_uid,
|
||||
$album
|
||||
$album,
|
||||
));
|
||||
if (DBA::isResult($r)) {
|
||||
$total = count($r);
|
||||
|
|
@ -543,7 +543,7 @@ function photos_content()
|
|||
intval($owner_uid),
|
||||
DBA::escape($album),
|
||||
$pager->getStart(),
|
||||
$pager->getItemsPerPage()
|
||||
$pager->getItemsPerPage(),
|
||||
));
|
||||
|
||||
if ($cmd === 'drop') {
|
||||
|
|
@ -603,7 +603,7 @@ function photos_content()
|
|||
|
||||
$photos[] = [
|
||||
'id' => $rr['id'],
|
||||
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2, 4),
|
||||
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . random_int(2, 4),
|
||||
'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id']
|
||||
. ($order_field === 'created' ? '?order=created' : ''),
|
||||
'title' => DI::l10n()->t('View Photo'),
|
||||
|
|
@ -715,7 +715,7 @@ function photos_content()
|
|||
$tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
|
||||
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
||||
'$prevlink' => $prevlink,
|
||||
'$nextlink' => $nextlink
|
||||
'$nextlink' => $nextlink,
|
||||
]);
|
||||
|
||||
if ($prevlink) {
|
||||
|
|
|
|||
|
|
@ -616,8 +616,8 @@ class App
|
|||
/** @var Router $router */
|
||||
$router = $this->container->create(Router::class);
|
||||
|
||||
$moduleClass = $moduleClass ?? $router->getModuleClass();
|
||||
$parameters = $router->getParameters();
|
||||
$moduleClass ??= $router->getModuleClass();
|
||||
$parameters = $router->getParameters();
|
||||
|
||||
$dice_profiler_threshold = $this->config->get('system', 'dice_profiler_threshold', 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ HELP;
|
|||
private function startsWith($haystack, $needle)
|
||||
{
|
||||
// search backwards starting from haystack length characters from the end
|
||||
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
|
||||
return $needle === "" || strrpos($haystack, (string) $needle, -strlen($haystack)) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use Friendica\Util\Proxy;
|
|||
*/
|
||||
class Avatar
|
||||
{
|
||||
const BASE_PATH = '/avatar/';
|
||||
public const BASE_PATH = '/avatar/';
|
||||
|
||||
/**
|
||||
* Returns a field array with locally cached avatar pictures
|
||||
|
|
@ -215,7 +215,7 @@ class Avatar
|
|||
}
|
||||
|
||||
$avatarpath = parse_url(self::baseUrl(), PHP_URL_PATH);
|
||||
$pos = strpos($parts['path'], $avatarpath);
|
||||
$pos = strpos($parts['path'], (string) $avatarpath);
|
||||
if ($pos !== 0) {
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,15 +315,15 @@ class Conversation
|
|||
$this->profiler->startRecording('rendering');
|
||||
$o = '';
|
||||
|
||||
$x['allow_location'] = $x['allow_location'] ?? $user['allow_location'];
|
||||
$x['default_location'] = $x['default_location'] ?? $user['default-location'];
|
||||
$x['nickname'] = $x['nickname'] ?? $user['nickname'];
|
||||
$x['lockstate'] = $x['lockstate'] ?? ACL::getLockstateForUserId($user['uid']) ? 'lock' : 'unlock';
|
||||
$x['acl'] = $x['acl'] ?? ACL::getFullSelectorHTML($this->page, $user['uid'], true);
|
||||
$x['bang'] = $x['bang'] ?? '';
|
||||
$x['visitor'] = $x['visitor'] ?? 'block';
|
||||
$x['is_owner'] = $x['is_owner'] ?? true;
|
||||
$x['profile_uid'] = $x['profile_uid'] ?? $this->session->getLocalUserId();
|
||||
$x['allow_location'] ??= $user['allow_location'];
|
||||
$x['default_location'] ??= $user['default-location'];
|
||||
$x['nickname'] ??= $user['nickname'];
|
||||
$x['lockstate'] = $x['lockstate'] ?? ACL::getLockstateForUserId($user['uid']) ? 'lock' : 'unlock';
|
||||
$x['acl'] ??= ACL::getFullSelectorHTML($this->page, $user['uid'], true);
|
||||
$x['bang'] ??= '';
|
||||
$x['visitor'] ??= 'block';
|
||||
$x['is_owner'] ??= true;
|
||||
$x['profile_uid'] ??= $this->session->getLocalUserId();
|
||||
|
||||
|
||||
$geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ class Item
|
|||
'url' => $url,
|
||||
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
'last' => false,
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ class Item
|
|||
'url' => "#",
|
||||
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
'last' => false,
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
|
|
@ -303,7 +303,7 @@ class Item
|
|||
if ($this->activity->match($item['verb'], Activity::TAG)) {
|
||||
$fields = [
|
||||
'author-id', 'author-link', 'author-name', 'author-network', 'author-link', 'author-alias',
|
||||
'verb', 'object-type', 'resource-id', 'body', 'plink'
|
||||
'verb', 'object-type', 'resource-id', 'body', 'plink',
|
||||
];
|
||||
$obj = Post::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
||||
if (!DBA::isResult($obj)) {
|
||||
|
|
@ -452,8 +452,8 @@ class Item
|
|||
|
||||
$menu[$this->l10n->t('Raw content')] = 'javascript:displaySearchText(' . $item['uri-id'] . ');';
|
||||
|
||||
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
|
||||
in_array($item['network'], Protocol::FEDERATED)
|
||||
if ((($cid == 0) || ($rel == Contact::FOLLOWER))
|
||||
&& in_array($item['network'], Protocol::FEDERATED)
|
||||
) {
|
||||
$menu[$this->l10n->t('Connect/Follow')] = 'contact/follow?url=' . urlencode($item['author-link']) . '&auto=1';
|
||||
}
|
||||
|
|
@ -496,10 +496,10 @@ class Item
|
|||
}
|
||||
|
||||
// Check conditions
|
||||
return (!($this->activity->match($item['verb'], Activity::FOLLOW) &&
|
||||
$item['object-type'] === Activity\ObjectType::NOTE &&
|
||||
empty($item['self']) &&
|
||||
$item['uid'] == $this->userSession->getLocalUserId())
|
||||
return (!($this->activity->match($item['verb'], Activity::FOLLOW)
|
||||
&& $item['object-type'] === Activity\ObjectType::NOTE
|
||||
&& empty($item['self'])
|
||||
&& $item['uid'] == $this->userSession->getLocalUserId())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -741,7 +741,7 @@ class Item
|
|||
if (is_array($shared)) {
|
||||
return [
|
||||
'comment' => BBCode::removeSharedData($item['body'] ?? ''),
|
||||
'post' => $shared
|
||||
'post' => $shared,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -752,7 +752,7 @@ class Item
|
|||
if (is_array($shared)) {
|
||||
return [
|
||||
'comment' => $attributes['comment'],
|
||||
'post' => $shared
|
||||
'post' => $shared,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -845,8 +845,8 @@ class Item
|
|||
0 => [
|
||||
'src' => $attachment_img_src,
|
||||
'width' => $attachment_img_width,
|
||||
'height' => $attachment_img_height
|
||||
]
|
||||
'height' => $attachment_img_height,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
unset($attachment['images']);
|
||||
|
|
@ -940,16 +940,16 @@ class Item
|
|||
|
||||
public function initializePost(array $post): array
|
||||
{
|
||||
$post['network'] = Protocol::DFRN;
|
||||
$post['protocol'] = Conversation::PARCEL_DIRECT;
|
||||
$post['direction'] = Conversation::PUSH;
|
||||
$post['received'] = DateTimeFormat::utcNow();
|
||||
$post['origin'] = true;
|
||||
$post['wall'] = $post['wall'] ?? true;
|
||||
$post['guid'] = $post['guid'] ?? System::createUUID();
|
||||
$post['verb'] = $post['verb'] ?? Activity::POST;
|
||||
$post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']);
|
||||
$post['thr-parent'] = $post['thr-parent'] ?? $post['uri'];
|
||||
$post['network'] = Protocol::DFRN;
|
||||
$post['protocol'] = Conversation::PARCEL_DIRECT;
|
||||
$post['direction'] = Conversation::PUSH;
|
||||
$post['received'] = DateTimeFormat::utcNow();
|
||||
$post['origin'] = true;
|
||||
$post['wall'] ??= true;
|
||||
$post['guid'] ??= System::createUUID();
|
||||
$post['verb'] ??= Activity::POST;
|
||||
$post['uri'] ??= ItemModel::newURI($post['guid']);
|
||||
$post['thr-parent'] ??= $post['uri'];
|
||||
|
||||
if (empty($post['gravity'])) {
|
||||
$post['gravity'] = ($post['uri'] == $post['thr-parent']) ? ItemModel::GRAVITY_PARENT : ItemModel::GRAVITY_COMMENT;
|
||||
|
|
@ -1031,7 +1031,7 @@ class Item
|
|||
];
|
||||
|
||||
$hook_data = $this->eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::INSERT_POST_LOCAL_END, $hook_data)
|
||||
new ArrayFilterEvent(ArrayFilterEvent::INSERT_POST_LOCAL_END, $hook_data),
|
||||
)->getArray();
|
||||
|
||||
$post = $hook_data['item'] ?? $post;
|
||||
|
|
@ -1050,7 +1050,7 @@ class Item
|
|||
$this->baseURL,
|
||||
$post,
|
||||
$address,
|
||||
$author['thumb'] ?? ''
|
||||
$author['thumb'] ?? '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -1335,7 +1335,7 @@ class Item
|
|||
\IntlChar::BLOCK_CODE_BASIC_LATIN, \IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT,
|
||||
\IntlChar::BLOCK_CODE_LATIN_EXTENDED_A, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_B,
|
||||
\IntlChar::BLOCK_CODE_LATIN_EXTENDED_C, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_D,
|
||||
\IntlChar::BLOCK_CODE_LATIN_EXTENDED_E, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL
|
||||
\IntlChar::BLOCK_CODE_LATIN_EXTENDED_E, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,12 +103,12 @@ class PageInfo
|
|||
|
||||
// It maybe is a rich content, but if it does have everything that a link has,
|
||||
// then treat it that way
|
||||
if (($data['type'] == 'rich') && is_string($data['title']) &&
|
||||
is_string($data['text']) && !empty($data['images'])) {
|
||||
if (($data['type'] == 'rich') && is_string($data['title'])
|
||||
&& is_string($data['text']) && !empty($data['images'])) {
|
||||
$data['type'] = 'link';
|
||||
}
|
||||
|
||||
$data['title'] = $data['title'] ?? '';
|
||||
$data['title'] ??= '';
|
||||
|
||||
if ((($data['type'] != 'link') && ($data['type'] != 'video') && ($data['type'] != 'photo')) || ($data['title'] == $data['url'])) {
|
||||
return '';
|
||||
|
|
@ -223,7 +223,7 @@ class PageInfo
|
|||
$hashtag = str_replace(
|
||||
[' ', '+', '/', '.', '#', "'"],
|
||||
['', '', '', '', '', ''],
|
||||
$keyword
|
||||
$keyword,
|
||||
);
|
||||
|
||||
$taglist[] = $hashtag;
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ class BBCode
|
|||
$attach_data = self::getAttachmentData($match[0]);
|
||||
if (empty($attach_data['url'])) {
|
||||
return $match[0];
|
||||
} elseif (strpos(str_replace($match[0], '', $body), $attach_data['url']) !== false) {
|
||||
} elseif (strpos(str_replace($match[0], '', $body), (string) $attach_data['url']) !== false) {
|
||||
return '';
|
||||
} elseif (empty($attach_data['title']) || $no_link_desc) {
|
||||
return " \n[url]" . $attach_data['url'] . "[/url]\n";
|
||||
|
|
@ -245,12 +245,12 @@ class BBCode
|
|||
// Add text from attached media
|
||||
if (!empty($uri_id)) {
|
||||
foreach (Post\Media::getByURIId($uri_id) as $media) {
|
||||
if (!empty($media['description']) && (stripos($text, $media['description']) === false)) {
|
||||
if (!empty($media['description']) && (stripos($text, (string) $media['description']) === false)) {
|
||||
$text .= ' ' . $media['description'];
|
||||
}
|
||||
if (in_array($media['type'], [Post\Media::HTML, Post\Media::ACTIVITY])) {
|
||||
foreach (['name', 'author-name', 'publisher-name'] as $key) {
|
||||
if (!empty($media[$key] && stripos($text, $media[$key]) === false)) {
|
||||
if (!empty($media[$key] && stripos($text, (string) $media[$key]) === false)) {
|
||||
$text .= ' ' . $media[$key];
|
||||
}
|
||||
}
|
||||
|
|
@ -535,7 +535,7 @@ class BBCode
|
|||
}
|
||||
|
||||
// If the link already is included in the post, don't add it again
|
||||
if (!empty($data['url']) && strpos($data['text'], $data['url'])) {
|
||||
if (!empty($data['url']) && strpos($data['text'], (string) $data['url'])) {
|
||||
DI::profiler()->stopRecording();
|
||||
return $data['text'] . $data['after'];
|
||||
}
|
||||
|
|
@ -811,9 +811,9 @@ class BBCode
|
|||
function ($match) use ($callback, $uriid) {
|
||||
$attributes = self::extractShareAttributes($match[2]);
|
||||
|
||||
$author_contact = Contact::getByURL($attributes['profile'], false, ['id', 'url', 'addr', 'name', 'micro']);
|
||||
$author_contact['url'] = ($author_contact['url'] ?? $attributes['profile']);
|
||||
$author_contact['addr'] = ($author_contact['addr'] ?? '');
|
||||
$author_contact = Contact::getByURL($attributes['profile'], false, ['id', 'url', 'addr', 'name', 'micro']);
|
||||
$author_contact['url'] ??= $attributes['profile'];
|
||||
$author_contact['addr'] ??= '';
|
||||
|
||||
$attributes['author'] = ($author_contact['name'] ?? '') ?: $attributes['author'];
|
||||
$attributes['avatar'] = ($author_contact['micro'] ?? '') ?: $attributes['avatar'];
|
||||
|
|
@ -1027,7 +1027,7 @@ class BBCode
|
|||
*/
|
||||
private static function expandLinksCallback(array $match): string
|
||||
{
|
||||
if (($match[3] == '') || ($match[2] == $match[3]) || stristr($match[2], $match[3])) {
|
||||
if (($match[3] == '') || ($match[2] == $match[3]) || stristr($match[2], (string) $match[3])) {
|
||||
return ($match[1] . '[url]' . $match[2] . '[/url]');
|
||||
} else {
|
||||
return ($match[1] . $match[3] . ' [url]' . $match[2] . '[/url]');
|
||||
|
|
|
|||
|
|
@ -660,7 +660,7 @@ class HTML
|
|||
|
||||
if (!$compact && ($message != '')) {
|
||||
foreach ($urls as $id => $url) {
|
||||
if ($url != '' && strpos($message, $url) === false) {
|
||||
if ($url != '' && strpos($message, (string) $url) === false) {
|
||||
$message .= "\n" . $url . ' ';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use IntlChar;
|
|||
class Plaintext
|
||||
{
|
||||
// Assumed length of an URL when shortened via the network's own url shortener (e.g. Twitter)
|
||||
const URL_LENGTH = 23;
|
||||
public const URL_LENGTH = 23;
|
||||
|
||||
/**
|
||||
* Shortens message
|
||||
|
|
@ -37,8 +37,8 @@ class Plaintext
|
|||
return mb_substr(mb_substr(trim($msg), 0, $limit), 0, -3) . $ellipsis;
|
||||
}
|
||||
|
||||
$lines = explode("\n", $msg);
|
||||
$msg = "";
|
||||
$lines = explode("\n", $msg);
|
||||
$msg = "";
|
||||
$recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
|
||||
foreach ($lines as $row => $line) {
|
||||
if (mb_strlen(trim($msg . "\n" . $line)) <= $limit) {
|
||||
|
|
@ -138,13 +138,13 @@ class Plaintext
|
|||
|
||||
if ($post['type'] == 'text') {
|
||||
$post['type'] = 'link';
|
||||
$post['url'] = $item['plink'];
|
||||
$post['url'] = $item['plink'];
|
||||
}
|
||||
}
|
||||
|
||||
$html = BBCode::convertForUriId($item['uri-id'], $post['text'] . ($post['after'] ?? ''), $htmlmode);
|
||||
$msg = HTML::toPlaintext($html, 0, true);
|
||||
$msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
|
||||
$msg = HTML::toPlaintext($html, 0, true);
|
||||
$msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
|
||||
|
||||
$complete_msg = $msg;
|
||||
|
||||
|
|
@ -170,8 +170,8 @@ class Plaintext
|
|||
|
||||
// If the link is already contained in the post, then it needn't to be added again
|
||||
// But: if the link is beyond the limit, then it has to be added.
|
||||
if (($link != '') && strstr($msg, $link)) {
|
||||
$pos = strpos($msg, $link);
|
||||
if (($link != '') && strstr($msg, (string) $link)) {
|
||||
$pos = strpos($msg, (string) $link);
|
||||
|
||||
// Will the text be shortened in the link?
|
||||
// Or is the link the last item in the post?
|
||||
|
|
@ -200,7 +200,7 @@ class Plaintext
|
|||
$msg = str_replace(' ', ' ', $msg);
|
||||
}
|
||||
|
||||
if (!in_array($link, ['', $item['plink']]) && ($post['type'] != 'photo') && (strpos($complete_msg, $link) === false)) {
|
||||
if (!in_array($link, ['', $item['plink']]) && ($post['type'] != 'photo') && (strpos($complete_msg, (string) $link) === false)) {
|
||||
$complete_msg .= "\n" . $link;
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ class Plaintext
|
|||
if (($post['type'] == 'text') && isset($post['url'])) {
|
||||
$post['url'] = $item['plink'];
|
||||
} elseif (!isset($post['url'])) {
|
||||
$limit = $limit - self::URL_LENGTH;
|
||||
$limit = $limit - self::URL_LENGTH;
|
||||
$post['url'] = $item['plink'];
|
||||
} elseif (strpos($item['body'], '[share') !== false) {
|
||||
$post['url'] = $item['plink'];
|
||||
|
|
@ -250,7 +250,7 @@ class Plaintext
|
|||
$limit = $baselimit;
|
||||
|
||||
while ($message) {
|
||||
$pos_word = mb_strpos($message, ' ');
|
||||
$pos_word = mb_strpos($message, ' ');
|
||||
$pos_paragraph = mb_strpos($message, "\n");
|
||||
|
||||
if (($pos_word !== false) && ($pos_paragraph !== false)) {
|
||||
|
|
@ -260,8 +260,8 @@ class Plaintext
|
|||
} elseif ($pos_paragraph !== false) {
|
||||
$pos = $pos_paragraph + 1;
|
||||
} else {
|
||||
$word = $message;
|
||||
$message = '';
|
||||
$word = $message;
|
||||
$message = '';
|
||||
}
|
||||
|
||||
if (trim($message)) {
|
||||
|
|
@ -324,7 +324,7 @@ class Plaintext
|
|||
|
||||
// Remove mentions and hashtag links
|
||||
$URLSearchString = '^\[\]';
|
||||
$post['text'] = preg_replace("/([#!@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $item['body']);
|
||||
$post['text'] = preg_replace("/([#!@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $item['body']);
|
||||
|
||||
// Remove abstract
|
||||
$post['text'] = BBCode::stripAbstract($post['text']);
|
||||
|
|
@ -382,10 +382,10 @@ class Plaintext
|
|||
$page = Post\Media::getByURIId($item['quote-uri-id'], [Post\Media::HTML]);
|
||||
}
|
||||
if (!empty($page)) {
|
||||
$post['type'] = 'link';
|
||||
$post['url'] = $page[0]['url'];
|
||||
$post['description'] = $page[0]['description'];
|
||||
$post['title'] = $page[0]['name'];
|
||||
$post['type'] = 'link';
|
||||
$post['url'] = $page[0]['url'];
|
||||
$post['description'] = $page[0]['description'];
|
||||
$post['title'] = $page[0]['name'];
|
||||
|
||||
if (empty($post['image']) && !empty($page[0]['preview'])) {
|
||||
$post['image'] = $page[0]['preview'];
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class TagCloud
|
|||
$r = self::tagadelic($uid, $count, $owner_id, $flags, $type);
|
||||
if (count($r)) {
|
||||
$contact = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
|
||||
$url = DI::baseUrl()->remove($contact['url']);
|
||||
$url = DI::baseUrl()->remove($contact['url']);
|
||||
|
||||
$tags = [];
|
||||
foreach ($r as $rr) {
|
||||
|
|
@ -50,9 +50,9 @@ class TagCloud
|
|||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('widget/tagcloud.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$title' => DI::l10n()->t('Tags'),
|
||||
'$tags' => $tags
|
||||
'$tags' => $tags,
|
||||
]);
|
||||
}
|
||||
return $o;
|
||||
|
|
@ -74,7 +74,7 @@ class TagCloud
|
|||
private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = Tag::HASHTAG)
|
||||
{
|
||||
$sql_options = Item::getPermissionsSQLByUserId($uid, 'post-user-view');
|
||||
$limit = $count ? sprintf('LIMIT %d', intval($count)) : '';
|
||||
$limit = $count ? sprintf('LIMIT %d', intval($count)) : '';
|
||||
|
||||
if ($flags) {
|
||||
if ($flags === 'wall') {
|
||||
|
|
@ -87,13 +87,14 @@ class TagCloud
|
|||
}
|
||||
|
||||
// Fetch tags
|
||||
$tag_stmt = DBA::p("SELECT `name`, COUNT(`name`) AS `total` FROM `tag-search-view`
|
||||
$tag_stmt = DBA::p(
|
||||
"SELECT `name`, COUNT(`name`) AS `total` FROM `tag-search-view`
|
||||
LEFT JOIN `post-user-view` ON `tag-search-view`.`uri-id` = `post-user-view`.`uri-id` AND `tag-search-view`.`uid` = `post-user-view`.`uid`
|
||||
WHERE `tag-search-view`.`uid` = ?
|
||||
AND `post-user-view`.`visible` AND NOT `post-user-view`.`deleted`
|
||||
$sql_options
|
||||
GROUP BY `name` ORDER BY `total` DESC $limit",
|
||||
$uid
|
||||
$uid,
|
||||
);
|
||||
if (!DBA::isResult($tag_stmt)) {
|
||||
return [];
|
||||
|
|
@ -113,9 +114,9 @@ class TagCloud
|
|||
private static function tagCalc(array $arr)
|
||||
{
|
||||
$tags = [];
|
||||
$min = 1000000000.0;
|
||||
$max = -1000000000.0;
|
||||
$x = 0;
|
||||
$min = 1000000000.0;
|
||||
$max = -1000000000.0;
|
||||
$x = 0;
|
||||
|
||||
if (!$arr) {
|
||||
return [];
|
||||
|
|
@ -125,15 +126,15 @@ class TagCloud
|
|||
$tags[$x][0] = $rr['name'];
|
||||
$tags[$x][1] = log($rr['total']);
|
||||
$tags[$x][2] = 0;
|
||||
$min = min($min, $tags[$x][1]);
|
||||
$max = max($max, $tags[$x][1]);
|
||||
$x ++;
|
||||
$min = min($min, $tags[$x][1]);
|
||||
$max = max($max, $tags[$x][1]);
|
||||
$x++;
|
||||
}
|
||||
|
||||
usort($tags, [self::class, 'tagsSort']);
|
||||
$range = max(0.01, $max - $min) * 1.0001;
|
||||
|
||||
for ($x = 0; $x < count($tags); $x ++) {
|
||||
for ($x = 0; $x < count($tags); $x++) {
|
||||
$tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
|
||||
}
|
||||
|
||||
|
|
@ -150,9 +151,6 @@ class TagCloud
|
|||
*/
|
||||
private static function tagsSort($a, $b)
|
||||
{
|
||||
if (strtolower($a[0]) == strtolower($b[0])) {
|
||||
return 0;
|
||||
}
|
||||
return ((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
|
||||
return strtolower($a[0]) <=> strtolower($b[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Friendica\Core\Cache\Enum;
|
|||
class ArrayCache extends AbstractCache implements ICanCacheInMemory
|
||||
{
|
||||
use CompareDeleteTrait;
|
||||
const NAME = 'array';
|
||||
public const NAME = 'array';
|
||||
|
||||
/** @var array Array with the cached data */
|
||||
protected $cachedData = [];
|
||||
|
|
@ -34,10 +34,7 @@ class ArrayCache extends AbstractCache implements ICanCacheInMemory
|
|||
*/
|
||||
public function get(string $key)
|
||||
{
|
||||
if (isset($this->cachedData[$key])) {
|
||||
return $this->cachedData[$key];
|
||||
}
|
||||
return null;
|
||||
return $this->cachedData[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class CacheLock extends AbstractLock
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
const CACHE_PREFIX = 'lock:';
|
||||
public const CACHE_PREFIX = 'lock:';
|
||||
|
||||
/**
|
||||
* @var ICanCacheInMemory
|
||||
|
|
@ -50,7 +50,7 @@ class CacheLock extends AbstractLock
|
|||
do {
|
||||
$lock = $this->cache->get($lockKey);
|
||||
// When we do want to lock something that was already locked by us.
|
||||
if ((int)$lock == getmypid()) {
|
||||
if ((int) $lock == getmypid()) {
|
||||
$got_lock = true;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ class CacheLock extends AbstractLock
|
|||
}
|
||||
|
||||
if (!$got_lock && ($timeout > 0)) {
|
||||
usleep(rand(10000, 200000));
|
||||
usleep(random_int(10000, 200000));
|
||||
}
|
||||
} while (!$got_lock && ((time() - $start) < $timeout));
|
||||
} catch (CachePersistenceException $exception) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class DatabaseLock extends AbstractLock
|
|||
do {
|
||||
$this->dba->lock('locks');
|
||||
$lock = $this->dba->selectFirst('locks', ['locked', 'pid'], [
|
||||
'`name` = ? AND `expires` >= ?', $key,DateTimeFormat::utcNow()
|
||||
'`name` = ? AND `expires` >= ?', $key,DateTimeFormat::utcNow(),
|
||||
]);
|
||||
|
||||
if ($this->dba->isResult($lock)) {
|
||||
|
|
@ -65,7 +65,7 @@ class DatabaseLock extends AbstractLock
|
|||
$this->dba->update('locks', [
|
||||
'locked' => true,
|
||||
'pid' => $this->pid,
|
||||
'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds')
|
||||
'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds'),
|
||||
], ['name' => $key]);
|
||||
$got_lock = true;
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ class DatabaseLock extends AbstractLock
|
|||
$this->dba->unlock();
|
||||
|
||||
if (!$got_lock && ($timeout > 0)) {
|
||||
usleep(rand(100000, 2000000));
|
||||
usleep(random_int(100000, 2000000));
|
||||
}
|
||||
} while (!$got_lock && ((time() - $start) < $timeout));
|
||||
} catch (\Exception $exception) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class StreamLogger extends AbstractLoggerTypeFactory
|
|||
|
||||
$fileSystem = new FileSystem();
|
||||
|
||||
$logfile = $logfile ?? $config->get('system', 'logfile');
|
||||
$logfile ??= $config->get('system', 'logfile');
|
||||
if (!@file_exists($logfile) || !@is_writable($logfile)) {
|
||||
throw new LoggerArgumentException(sprintf('%s is not a valid logfile', $logfile));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class ErrorHandler
|
|||
register_shutdown_function([$this, 'handleFatalError']);
|
||||
|
||||
$this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize);
|
||||
$this->fatalLevel = null === $level ? LogLevel::ALERT : $level;
|
||||
$this->fatalLevel = $level ?? LogLevel::ALERT;
|
||||
$this->hasFatalErrorHandler = true;
|
||||
|
||||
return $this;
|
||||
|
|
@ -219,7 +219,7 @@ class ErrorHandler
|
|||
$this->logger->log(
|
||||
$level,
|
||||
sprintf('Uncaught Exception %s: "%s" at %s line %s', self::getClass($e), $e->getMessage(), $e->getFile(), $e->getLine()),
|
||||
['exception' => $e]
|
||||
['exception' => $e],
|
||||
);
|
||||
|
||||
if ($this->previousExceptionHandler) {
|
||||
|
|
@ -262,14 +262,14 @@ class ErrorHandler
|
|||
$message .= sprintf(
|
||||
' It was called in `%s`%s.',
|
||||
$calledPlace['file'],
|
||||
isset($calledPlace['line']) ? ' in line ' . $calledPlace['line'] : ''
|
||||
isset($calledPlace['line']) ? ' in line ' . $calledPlace['line'] : '',
|
||||
);
|
||||
}
|
||||
|
||||
// fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries
|
||||
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) {
|
||||
$level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL;
|
||||
$this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]);
|
||||
$this->logger->log($level, self::codeToString($code) . ': ' . $message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]);
|
||||
} else {
|
||||
$this->lastFatalTrace = $trace;
|
||||
}
|
||||
|
|
@ -294,8 +294,8 @@ class ErrorHandler
|
|||
if ($lastError && in_array($lastError['type'], self::$fatalErrors, true)) {
|
||||
$this->logger->log(
|
||||
$this->fatalLevel,
|
||||
'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'],
|
||||
['code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line'], 'trace' => $this->lastFatalTrace]
|
||||
'Fatal Error (' . self::codeToString($lastError['type']) . '): ' . $lastError['message'],
|
||||
['code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line'], 'trace' => $this->lastFatalTrace],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Friendica\Core\PConfig\ValueObject;
|
|||
*/
|
||||
class JitPConfig extends AbstractPConfigValues
|
||||
{
|
||||
const NAME = 'jit';
|
||||
public const NAME = 'jit';
|
||||
|
||||
/**
|
||||
* @var array Array of already loaded db values (even if there was no value)
|
||||
|
|
@ -71,8 +71,8 @@ class JitPConfig extends AbstractPConfigValues
|
|||
}
|
||||
|
||||
// if the value isn't loaded or refresh is needed, load it to the cache
|
||||
if ($this->configModel->isConnected() &&
|
||||
(empty($this->db_loaded[$uid][$cat][$key]) || $refresh)) {
|
||||
if ($this->configModel->isConnected()
|
||||
&& (empty($this->db_loaded[$uid][$cat][$key]) || $refresh)) {
|
||||
$dbValue = $this->configModel->get($uid, $cat, $key);
|
||||
|
||||
if (isset($dbValue)) {
|
||||
|
|
@ -86,7 +86,7 @@ class JitPConfig extends AbstractPConfigValues
|
|||
// use the config cache for return
|
||||
$result = $this->configCache->get($uid, $cat, $key);
|
||||
|
||||
return (isset($result)) ? $result : $default_value;
|
||||
return $result ?? $default_value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Friendica\Core\PConfig\ValueObject;
|
|||
*/
|
||||
class PreloadPConfig extends AbstractPConfigValues
|
||||
{
|
||||
const NAME = 'preload';
|
||||
public const NAME = 'preload';
|
||||
|
||||
/** @var array */
|
||||
private $config_loaded;
|
||||
|
|
@ -83,7 +83,7 @@ class PreloadPConfig extends AbstractPConfigValues
|
|||
// use the config cache for return
|
||||
$result = $this->configCache->get($uid, $cat, $key);
|
||||
|
||||
return (isset($result)) ? $result : $default_value;
|
||||
return $result ?? $default_value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,43 +22,43 @@ use Friendica\Protocol\Diaspora;
|
|||
class Protocol
|
||||
{
|
||||
// Native support
|
||||
const ACTIVITYPUB = 'apub'; // ActivityPub (Pleroma, Mastodon, Osada, ...)
|
||||
const DFRN = 'dfrn'; // Friendica, Mistpark, other DFRN implementations
|
||||
const DIASPORA = 'dspr'; // Diaspora, Hubzilla, Socialhome, Ganggo
|
||||
const FEED = 'feed'; // RSS/Atom feeds with no known "post/notify" protocol
|
||||
const MAIL = 'mail'; // IMAP/POP
|
||||
public const ACTIVITYPUB = 'apub'; // ActivityPub (Pleroma, Mastodon, Osada, ...)
|
||||
public const DFRN = 'dfrn'; // Friendica, Mistpark, other DFRN implementations
|
||||
public const DIASPORA = 'dspr'; // Diaspora, Hubzilla, Socialhome, Ganggo
|
||||
public const FEED = 'feed'; // RSS/Atom feeds with no known "post/notify" protocol
|
||||
public const MAIL = 'mail'; // IMAP/POP
|
||||
|
||||
const NATIVE_SUPPORT = [self::DFRN, self::DIASPORA, self::FEED, self::MAIL, self::ACTIVITYPUB];
|
||||
public const NATIVE_SUPPORT = [self::DFRN, self::DIASPORA, self::FEED, self::MAIL, self::ACTIVITYPUB];
|
||||
|
||||
const FEDERATED = [self::DFRN, self::DIASPORA, self::ACTIVITYPUB];
|
||||
public const FEDERATED = [self::DFRN, self::DIASPORA, self::ACTIVITYPUB];
|
||||
|
||||
const SUPPORT_PRIVATE = [self::DFRN, self::DIASPORA, self::MAIL, self::ACTIVITYPUB, self::PUMPIO];
|
||||
public const SUPPORT_PRIVATE = [self::DFRN, self::DIASPORA, self::MAIL, self::ACTIVITYPUB, self::PUMPIO];
|
||||
|
||||
// Supported through a connector
|
||||
const BLUESKY = 'bsky'; // Bluesky
|
||||
const DIASPORA2 = 'dspc'; // Diaspora connector
|
||||
const DISCOURSE = 'dscs'; // Discourse
|
||||
const PNUT = 'pnut'; // pnut.io
|
||||
const PUMPIO = 'pump'; // pump.io
|
||||
const TUMBLR = 'tmbl'; // Tumblr
|
||||
const TWITTER = 'twit'; // Twitter
|
||||
public const BLUESKY = 'bsky'; // Bluesky
|
||||
public const DIASPORA2 = 'dspc'; // Diaspora connector
|
||||
public const DISCOURSE = 'dscs'; // Discourse
|
||||
public const PNUT = 'pnut'; // pnut.io
|
||||
public const PUMPIO = 'pump'; // pump.io
|
||||
public const TUMBLR = 'tmbl'; // Tumblr
|
||||
public const TWITTER = 'twit'; // Twitter
|
||||
|
||||
// Dead protocols
|
||||
const APPNET = 'apdn'; // app.net - Dead protocol
|
||||
const FACEBOOK = 'face'; // Facebook API - Not working anymore, API is closed
|
||||
const GPLUS = 'goog'; // Google+ - Dead in 2019
|
||||
const OSTATUS = 'stat'; // GNU Social and other OStatus implementations
|
||||
const STATUSNET = 'stac'; // Statusnet connector
|
||||
public const APPNET = 'apdn'; // app.net - Dead protocol
|
||||
public const FACEBOOK = 'face'; // Facebook API - Not working anymore, API is closed
|
||||
public const GPLUS = 'goog'; // Google+ - Dead in 2019
|
||||
public const OSTATUS = 'stat'; // GNU Social and other OStatus implementations
|
||||
public const STATUSNET = 'stac'; // Statusnet connector
|
||||
|
||||
// Currently unsupported
|
||||
const ICALENDAR = 'ical'; // iCalendar
|
||||
const LINKEDIN = 'lnkd'; // LinkedIn
|
||||
const MYSPACE = 'mysp'; // MySpace
|
||||
const NEWS = 'nntp'; // Network News Transfer Protocol
|
||||
const XMPP = 'xmpp'; // XMPP
|
||||
const ZOT = 'zot!'; // Zot!
|
||||
public const ICALENDAR = 'ical'; // iCalendar
|
||||
public const LINKEDIN = 'lnkd'; // LinkedIn
|
||||
public const MYSPACE = 'mysp'; // MySpace
|
||||
public const NEWS = 'nntp'; // Network News Transfer Protocol
|
||||
public const XMPP = 'xmpp'; // XMPP
|
||||
public const ZOT = 'zot!'; // Zot!
|
||||
|
||||
const PHANTOM = 'unkn'; // Place holder
|
||||
public const PHANTOM = 'unkn'; // Place holder
|
||||
|
||||
/**
|
||||
* Returns whether the provided protocol supports following
|
||||
|
|
@ -75,7 +75,7 @@ class Protocol
|
|||
|
||||
$hook_data = [
|
||||
'protocol' => $protocol,
|
||||
'result' => null
|
||||
'result' => null,
|
||||
];
|
||||
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
|
@ -102,7 +102,7 @@ class Protocol
|
|||
|
||||
$hook_data = [
|
||||
'protocol' => $protocol,
|
||||
'result' => null
|
||||
'result' => null,
|
||||
];
|
||||
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
|
@ -131,7 +131,7 @@ class Protocol
|
|||
return true;
|
||||
}
|
||||
|
||||
$protocol = $protocol ?? $contact['protocol'];
|
||||
$protocol ??= $contact['protocol'];
|
||||
|
||||
if ($protocol == self::DIASPORA) {
|
||||
$contact = Diaspora::sendShare($owner, $contact);
|
||||
|
|
@ -340,7 +340,7 @@ class Protocol
|
|||
|
||||
$hook_data = [
|
||||
'protocol' => $protocol,
|
||||
'result' => null
|
||||
'result' => null,
|
||||
];
|
||||
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ use Psr\Log\LoggerInterface;
|
|||
class StorageManager
|
||||
{
|
||||
// Default tables to look for data
|
||||
const TABLES = ['photo', 'attach'];
|
||||
public const TABLES = ['photo', 'attach'];
|
||||
|
||||
// Default storage backends
|
||||
/** @var string[] */
|
||||
const DEFAULT_BACKENDS = [
|
||||
public const DEFAULT_BACKENDS = [
|
||||
Type\Filesystem::NAME,
|
||||
Type\Database::NAME,
|
||||
];
|
||||
|
|
@ -240,12 +240,12 @@ class StorageManager
|
|||
*/
|
||||
public function isValidBackend(string $name = null, array $validBackends = null): bool
|
||||
{
|
||||
$validBackends = $validBackends ?? array_merge(
|
||||
$validBackends ??= array_merge(
|
||||
$this->validBackends,
|
||||
[
|
||||
Type\SystemResource::getName(),
|
||||
Type\ExternalResource::getName(),
|
||||
]
|
||||
],
|
||||
);
|
||||
return in_array($name, $validBackends);
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ class StorageManager
|
|||
$table,
|
||||
['id', 'data', 'backend-class', 'backend-ref'],
|
||||
['`backend-class` IS NULL or `backend-class` != ?', $destination::getName()],
|
||||
['limit' => $limit]
|
||||
['limit' => $limit],
|
||||
);
|
||||
|
||||
while ($resource = $this->dba->fetch($resources)) {
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ class Worker
|
|||
|
||||
$file = realpath($file);
|
||||
|
||||
if (strpos($file, getcwd()) !== 0) {
|
||||
if (strpos($file, (string) getcwd()) !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1374,7 +1374,7 @@ class Worker
|
|||
$new_retrial = $queue['retrial'] + 1;
|
||||
$total = 0;
|
||||
for ($retrial = 0; $retrial <= $max_level + 1; ++$retrial) {
|
||||
$delay = (($retrial + 3) ** 4) + (rand(1, 30) * ($retrial + 1));
|
||||
$delay = (($retrial + 3) ** 4) + (random_int(1, 30) * ($retrial + 1));
|
||||
$total += $delay;
|
||||
if (($total < $retrial_time) && ($retrial > $queue['retrial'])) {
|
||||
$new_retrial = $retrial;
|
||||
|
|
@ -1427,7 +1427,7 @@ class Worker
|
|||
}
|
||||
|
||||
// Calculate the delay until the next trial
|
||||
$delay = (($new_retrial + 2) ** 4) + (rand(1, 30) * ($new_retrial));
|
||||
$delay = (($new_retrial + 2) ** 4) + (random_int(1, 30) * ($new_retrial));
|
||||
$next = DateTimeFormat::utc('now + ' . $delay . ' seconds');
|
||||
|
||||
if (($priority < self::PRIORITY_MEDIUM) && ($new_retrial > 3)) {
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@ class DBA
|
|||
/**
|
||||
* Lowest possible date value
|
||||
*/
|
||||
const NULL_DATE = '0001-01-01';
|
||||
public const NULL_DATE = '0001-01-01';
|
||||
/**
|
||||
* Lowest possible datetime value
|
||||
*/
|
||||
const NULL_DATETIME = '0001-01-01 00:00:00';
|
||||
public const NULL_DATETIME = '0001-01-01 00:00:00';
|
||||
|
||||
/**
|
||||
* Lowest possible datetime(6) value
|
||||
*/
|
||||
const NULL_DATETIME6 = '0001-01-01 00:00:00.000000';
|
||||
public const NULL_DATETIME6 = '0001-01-01 00:00:00.000000';
|
||||
|
||||
public static function connect(): bool
|
||||
{
|
||||
|
|
@ -130,11 +130,11 @@ class DBA
|
|||
*/
|
||||
public static function cleanQuery(string $sql): string
|
||||
{
|
||||
$search = ["\t", "\n", "\r", " "];
|
||||
$search = ["\t", "\n", "\r", " "];
|
||||
$replace = [' ', ' ', ' ', ' '];
|
||||
do {
|
||||
$oldsql = $sql;
|
||||
$sql = str_replace($search, $replace, $sql);
|
||||
$sql = str_replace($search, $replace, $sql);
|
||||
} while ($oldsql != $sql);
|
||||
|
||||
return $sql;
|
||||
|
|
@ -518,8 +518,8 @@ class DBA
|
|||
'.',
|
||||
array_map(
|
||||
function (string $identifier) { return '`' . str_replace('`', '``', $identifier) . '`'; },
|
||||
explode('.', $identifier)
|
||||
)
|
||||
explode('.', $identifier),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -571,16 +571,14 @@ class DBA
|
|||
if (count($condition) < 1) {
|
||||
return ['1'];
|
||||
}
|
||||
|
||||
reset($condition);
|
||||
$first_key = key($condition);
|
||||
$first_key = array_key_first($condition);
|
||||
|
||||
if (is_int($first_key)) {
|
||||
// Already collapsed
|
||||
return $condition;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
$values = [];
|
||||
$condition_string = "";
|
||||
foreach ($condition as $field => $value) {
|
||||
if ($condition_string != "") {
|
||||
|
|
@ -594,7 +592,7 @@ class DBA
|
|||
* In case of mixed types, cast all as string.
|
||||
* Logic needs to be consistent with DBA::p() data types.
|
||||
*/
|
||||
$is_int = false;
|
||||
$is_int = false;
|
||||
$is_alpha = false;
|
||||
foreach ($value as $single_value) {
|
||||
if (is_int($single_value)) {
|
||||
|
|
@ -607,13 +605,13 @@ class DBA
|
|||
if ($is_int && $is_alpha) {
|
||||
foreach ($value as &$ref) {
|
||||
if (is_int($ref)) {
|
||||
$ref = (string)$ref;
|
||||
$ref = (string) $ref;
|
||||
}
|
||||
}
|
||||
unset($ref); //Prevent accidental re-use.
|
||||
}
|
||||
|
||||
$values = array_merge($values, array_values($value));
|
||||
$values = array_merge($values, array_values($value));
|
||||
$placeholders = substr(str_repeat("?, ", count($value)), 0, -2);
|
||||
$condition_string .= self::quoteIdentifier($field) . " IN (" . $placeholders . ")";
|
||||
} else {
|
||||
|
|
@ -647,7 +645,7 @@ class DBA
|
|||
}
|
||||
|
||||
$conditionStrings = [];
|
||||
$result = [];
|
||||
$result = [];
|
||||
|
||||
foreach ($conditions as $key => $condition) {
|
||||
if (!$condition) {
|
||||
|
|
|
|||
|
|
@ -831,9 +831,7 @@ class Database
|
|||
if (empty($condition)) {
|
||||
return DBStructure::existsTable($table);
|
||||
}
|
||||
|
||||
reset($condition);
|
||||
$first_key = key($condition);
|
||||
$first_key = array_key_first($condition);
|
||||
if (!is_int($first_key)) {
|
||||
$fields = [$first_key];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ use GuzzleHttp\Psr7\Uri;
|
|||
class PostUpdate
|
||||
{
|
||||
// Needed for the helper function to read from the legacy term table
|
||||
const OBJECT_TYPE_POST = 1;
|
||||
public const OBJECT_TYPE_POST = 1;
|
||||
|
||||
const VERSION = 1550;
|
||||
public const VERSION = 1550;
|
||||
|
||||
/**
|
||||
* Calls the post update functions
|
||||
|
|
@ -185,7 +185,7 @@ class PostUpdate
|
|||
Protocol::DIASPORA,
|
||||
Protocol::OSTATUS,
|
||||
Protocol::ACTIVITYPUB,
|
||||
0
|
||||
0,
|
||||
);
|
||||
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
|
|
@ -348,7 +348,7 @@ class PostUpdate
|
|||
Tag::MENTION,
|
||||
Tag::EXCLUSIVE_MENTION,
|
||||
Tag::IMPLICIT_MENTION,
|
||||
$id
|
||||
$id,
|
||||
);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
|
|
@ -357,7 +357,7 @@ class PostUpdate
|
|||
}
|
||||
|
||||
while ($term = DBA::fetch($terms)) {
|
||||
if (($term['type'] == Tag::MENTION) && !empty($term['url']) && !strstr($term['body'], $term['url'])) {
|
||||
if (($term['type'] == Tag::MENTION) && !empty($term['url']) && !strstr($term['body'], (string) $term['url'])) {
|
||||
$condition = ['nurl' => Strings::normaliseLink($term['url']), 'uid' => 0, 'deleted' => false];
|
||||
$contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
|
|
@ -366,7 +366,7 @@ class PostUpdate
|
|||
$contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
|
||||
}
|
||||
|
||||
if (DBA::isResult($contact) && (!strstr($term['body'], $contact['url']) && (empty($contact['alias']) || !strstr($term['body'], $contact['alias'])))) {
|
||||
if (DBA::isResult($contact) && (!strstr($term['body'], (string) $contact['url']) && (empty($contact['alias']) || !strstr($term['body'], (string) $contact['alias'])))) {
|
||||
$term['type'] = Tag::IMPLICIT_MENTION;
|
||||
}
|
||||
}
|
||||
|
|
@ -507,7 +507,7 @@ class PostUpdate
|
|||
'term',
|
||||
['oid'],
|
||||
["`type` IN (?, ?) AND `oid` >= ?", Category::CATEGORY, Category::FILE, $id],
|
||||
['order' => ['oid'], 'limit' => 1000, 'group_by' => ['oid']]
|
||||
['order' => ['oid'], 'limit' => 1000, 'group_by' => ['oid']],
|
||||
);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
|
|
@ -651,7 +651,7 @@ class PostUpdate
|
|||
DBA::update(
|
||||
'contact',
|
||||
['gsid' => GServer::getRealID($contact['baseurl'], true), 'baseurl' => GServer::cleanURL($contact['baseurl'])],
|
||||
['id' => $contact['id']]
|
||||
['id' => $contact['id']],
|
||||
);
|
||||
|
||||
++$rows;
|
||||
|
|
@ -706,7 +706,7 @@ class PostUpdate
|
|||
DBA::update(
|
||||
'apcontact',
|
||||
['gsid' => GServer::getRealID($apcontact['baseurl'], true), 'baseurl' => GServer::cleanURL($apcontact['baseurl'])],
|
||||
['url' => $apcontact['url']]
|
||||
['url' => $apcontact['url']],
|
||||
);
|
||||
|
||||
++$rows;
|
||||
|
|
@ -1079,7 +1079,7 @@ class PostUpdate
|
|||
WHERE NOT `source` IS NULL AND `conversation`.`protocol` = ? AND `uri-id` > ? LIMIT ?",
|
||||
Conversation::PARCEL_ACTIVITYPUB,
|
||||
$id,
|
||||
1000
|
||||
1000,
|
||||
);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
|
|
@ -1239,12 +1239,12 @@ class PostUpdate
|
|||
|
||||
$parts = parse_url($contact['url']);
|
||||
unset($parts['path']);
|
||||
$server = (string)Uri::fromParts($parts);
|
||||
$server = (string) Uri::fromParts($parts);
|
||||
|
||||
DBA::update(
|
||||
'contact',
|
||||
['gsid' => GServer::getRealID($server, true), 'baseurl' => GServer::cleanURL($server)],
|
||||
['id' => $contact['id']]
|
||||
['id' => $contact['id']],
|
||||
);
|
||||
|
||||
++$rows;
|
||||
|
|
@ -1333,10 +1333,10 @@ class PostUpdate
|
|||
return true;
|
||||
}
|
||||
|
||||
$id = (int)(DI::keyValue()->get('post_update_version_1544_id') ?? 0);
|
||||
$id = (int) (DI::keyValue()->get('post_update_version_1544_id') ?? 0);
|
||||
if ($id == 0) {
|
||||
$post = Post::selectFirstPost(['uri-id'], [], ['order' => ['uri-id' => true]]);
|
||||
$id = (int)($post['uri-id'] ?? 0);
|
||||
$id = (int) ($post['uri-id'] ?? 0);
|
||||
}
|
||||
|
||||
DI::logger()->info('Start', ['uri-id' => $id]);
|
||||
|
|
@ -1398,10 +1398,10 @@ class PostUpdate
|
|||
}
|
||||
DBA::close($engagements);
|
||||
|
||||
$id = (int)(DI::keyValue()->get('post_update_version_1550_id') ?? 0);
|
||||
$id = (int) (DI::keyValue()->get('post_update_version_1550_id') ?? 0);
|
||||
if ($id == 0) {
|
||||
$post = Post::selectFirstPost(['uri-id'], [], ['order' => ['uri-id' => true]]);
|
||||
$id = (int)($post['uri-id'] ?? 0);
|
||||
$id = (int) ($post['uri-id'] ?? 0);
|
||||
}
|
||||
|
||||
DI::logger()->info('Start', ['uri-id' => $id]);
|
||||
|
|
|
|||
|
|
@ -1505,17 +1505,13 @@ class Contact
|
|||
if ($data['network'] == Protocol::DIASPORA) {
|
||||
try {
|
||||
DI::dsprContact()->updateFromProbeArray($data);
|
||||
} catch (NotFoundException $e) {
|
||||
DI::logger()->notice($e->getMessage(), ['url' => $url, 'data' => $data]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
} catch (NotFoundException|\InvalidArgumentException $e) {
|
||||
DI::logger()->notice($e->getMessage(), ['url' => $url, 'data' => $data]);
|
||||
}
|
||||
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
|
||||
try {
|
||||
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
|
||||
} catch (NotFoundException $e) {
|
||||
DI::logger()->notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
} catch (NotFoundException|\InvalidArgumentException $e) {
|
||||
DI::logger()->notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
|
||||
}
|
||||
}
|
||||
|
|
@ -2751,17 +2747,13 @@ class Contact
|
|||
if ($data['network'] == Protocol::DIASPORA) {
|
||||
try {
|
||||
DI::dsprContact()->updateFromProbeArray($data);
|
||||
} catch (NotFoundException $e) {
|
||||
DI::logger()->notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
} catch (NotFoundException|\InvalidArgumentException $e) {
|
||||
DI::logger()->notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
|
||||
}
|
||||
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
|
||||
try {
|
||||
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
|
||||
} catch (NotFoundException $e) {
|
||||
DI::logger()->notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
} catch (NotFoundException|\InvalidArgumentException $e) {
|
||||
DI::logger()->notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -822,7 +822,7 @@ class GServer
|
|||
$serverdata = self::fetchWeeklyUsage($url, $serverdata);
|
||||
}
|
||||
|
||||
$serverdata['registered-users'] = $serverdata['registered-users'] ?? 0;
|
||||
$serverdata['registered-users'] ??= 0;
|
||||
|
||||
// On an active server there has to be at least a single user
|
||||
if (!in_array($serverdata['network'], [Protocol::PHANTOM, Protocol::FEED]) && ($serverdata['registered-users'] <= 0)) {
|
||||
|
|
|
|||
|
|
@ -44,22 +44,22 @@ use GuzzleHttp\Psr7\Uri;
|
|||
*/
|
||||
class Media
|
||||
{
|
||||
const UNKNOWN = 0;
|
||||
const IMAGE = 1;
|
||||
const VIDEO = 2;
|
||||
const AUDIO = 3;
|
||||
const TEXT = 4;
|
||||
const APPLICATION = 5;
|
||||
const TORRENT = 16;
|
||||
const HTML = 17;
|
||||
const XML = 18;
|
||||
const PLAIN = 19;
|
||||
const ACTIVITY = 20;
|
||||
const ACCOUNT = 21;
|
||||
const HLS = 22;
|
||||
const JSON = 23;
|
||||
const LD = 24;
|
||||
const DOCUMENT = 128;
|
||||
public const UNKNOWN = 0;
|
||||
public const IMAGE = 1;
|
||||
public const VIDEO = 2;
|
||||
public const AUDIO = 3;
|
||||
public const TEXT = 4;
|
||||
public const APPLICATION = 5;
|
||||
public const TORRENT = 16;
|
||||
public const HTML = 17;
|
||||
public const XML = 18;
|
||||
public const PLAIN = 19;
|
||||
public const ACTIVITY = 20;
|
||||
public const ACCOUNT = 21;
|
||||
public const HLS = 22;
|
||||
public const JSON = 23;
|
||||
public const LD = 24;
|
||||
public const DOCUMENT = 128;
|
||||
|
||||
/**
|
||||
* Insert a post-media record
|
||||
|
|
@ -166,11 +166,11 @@ class Media
|
|||
'url' => $href,
|
||||
'size' => $length,
|
||||
'mimetype' => $type,
|
||||
'description' => $title
|
||||
'description' => $title,
|
||||
]);
|
||||
|
||||
return '[attach]href="' . $media['url'] . '" length="' . $media['size'] .
|
||||
'" type="' . $media['mimetype'] . '" title="' . $media['description'] . '"[/attach]';
|
||||
return '[attach]href="' . $media['url'] . '" length="' . $media['size']
|
||||
. '" type="' . $media['mimetype'] . '" title="' . $media['description'] . '"[/attach]';
|
||||
}
|
||||
|
||||
private static function setModified(array $media, string $lastModified): array
|
||||
|
|
@ -183,8 +183,8 @@ class Media
|
|||
return $media;
|
||||
}
|
||||
|
||||
$media['modified'] = DateTimeFormat::utc($lastModified);
|
||||
$media['published'] = $media['published'] ?? $media['modified'];
|
||||
$media['modified'] = DateTimeFormat::utc($lastModified);
|
||||
$media['published'] ??= $media['modified'];
|
||||
|
||||
return $media;
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ class Media
|
|||
$media['mimetype'] = $curlResult->getContentType();
|
||||
}
|
||||
if (empty($media['size']) && $is_head) {
|
||||
$media['size'] = (int)($curlResult->getHeader('Content-Length')[0] ?? strlen($curlResult->getBodyString() ?? ''));
|
||||
$media['size'] = (int) ($curlResult->getHeader('Content-Length')[0] ?? strlen($curlResult->getBodyString() ?? ''));
|
||||
}
|
||||
$media = self::setModified($media, $curlResult->getHeader('Last-Modified')[0] ?? '');
|
||||
} else {
|
||||
|
|
@ -365,8 +365,8 @@ class Media
|
|||
}
|
||||
|
||||
if (
|
||||
!empty($item['plink']) && Strings::compareLink($item['plink'], $media['url']) &&
|
||||
parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST)
|
||||
!empty($item['plink']) && Strings::compareLink($item['plink'], $media['url'])
|
||||
&& parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST)
|
||||
) {
|
||||
DI::logger()->debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
|
||||
$media['type'] = $media['type'] == self::ACTIVITY ? self::JSON : $media['type'];
|
||||
|
|
@ -786,7 +786,7 @@ class Media
|
|||
foreach (explode("\n", $curlResult->getBodyString() ?? '') as $line) {
|
||||
if (strpos(trim($line), '#EXT-X-STREAM-INF') === 0) {
|
||||
if (preg_match('/RESOLUTION=([\d]+)x([\d]+)/', $line, $matches)) {
|
||||
$resolutions[$matches[1]] = [(int)$matches[1], (int)$matches[2]];
|
||||
$resolutions[$matches[1]] = [(int) $matches[1], (int) $matches[2]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -885,7 +885,7 @@ class Media
|
|||
'type' => self::IMAGE,
|
||||
'url' => $image,
|
||||
'preview' => $picture[2],
|
||||
'description' => $picture[3]
|
||||
'description' => $picture[3],
|
||||
];
|
||||
} elseif (self::isLinkToPhoto($picture[1], $picture[2])) {
|
||||
$body = str_replace($picture[0], '', $body);
|
||||
|
|
@ -895,7 +895,7 @@ class Media
|
|||
'type' => self::IMAGE,
|
||||
'url' => $picture[1],
|
||||
'preview' => $picture[2],
|
||||
'description' => $picture[3]
|
||||
'description' => $picture[3],
|
||||
];
|
||||
} elseif ($removepicturelinks) {
|
||||
$body = str_replace($picture[0], '', $body);
|
||||
|
|
@ -905,7 +905,7 @@ class Media
|
|||
'type' => self::UNKNOWN,
|
||||
'url' => $picture[1],
|
||||
'preview' => $picture[2],
|
||||
'description' => $picture[3]
|
||||
'description' => $picture[3],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -930,7 +930,7 @@ class Media
|
|||
'type' => self::IMAGE,
|
||||
'url' => $image,
|
||||
'preview' => $picture[2],
|
||||
'description' => null
|
||||
'description' => null,
|
||||
];
|
||||
} elseif (self::isLinkToPhoto($picture[1], $picture[2])) {
|
||||
$body = str_replace($picture[0], '', $body);
|
||||
|
|
@ -940,7 +940,7 @@ class Media
|
|||
'type' => self::IMAGE,
|
||||
'url' => $picture[1],
|
||||
'preview' => $picture[2],
|
||||
'description' => null
|
||||
'description' => null,
|
||||
];
|
||||
} elseif ($removepicturelinks) {
|
||||
$body = str_replace($picture[0], '', $body);
|
||||
|
|
@ -950,7 +950,7 @@ class Media
|
|||
'type' => self::UNKNOWN,
|
||||
'url' => $picture[1],
|
||||
'preview' => $picture[2],
|
||||
'description' => null
|
||||
'description' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1354,7 +1354,7 @@ class Media
|
|||
'src' => $links[0]['preview'],
|
||||
'height' => $links[0]['preview-height'],
|
||||
'width' => $links[0]['preview-width'],
|
||||
]]
|
||||
]],
|
||||
];
|
||||
$body .= "\n" . PageInfo::getFooterFromData($data);
|
||||
|
||||
|
|
@ -1375,7 +1375,7 @@ class Media
|
|||
return $body;
|
||||
}
|
||||
|
||||
if (strpos($body, $links[0]['url'])) {
|
||||
if (strpos($body, (string) $links[0]['url'])) {
|
||||
return $body;
|
||||
}
|
||||
|
||||
|
|
@ -1416,9 +1416,9 @@ class Media
|
|||
*/
|
||||
public static function getPreviewUrlForId(int $id, string $size = ''): string
|
||||
{
|
||||
return DI::baseUrl() . '/photo/preview/' .
|
||||
(Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '') .
|
||||
$id;
|
||||
return DI::baseUrl() . '/photo/preview/'
|
||||
. (Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '')
|
||||
. $id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1430,9 +1430,9 @@ class Media
|
|||
*/
|
||||
public static function getUrlForId(int $id, string $size = ''): string
|
||||
{
|
||||
return DI::baseUrl() . '/photo/media/' .
|
||||
(Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '') .
|
||||
$id;
|
||||
return DI::baseUrl() . '/photo/media/'
|
||||
. (Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '')
|
||||
. $id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -860,7 +860,7 @@ class Profile
|
|||
}
|
||||
|
||||
$parent = User::getOwnerDataById($parent_uid);
|
||||
if (strpos($about, $parent['addr']) || strpos($about, $parent['url'])) {
|
||||
if (strpos($about, (string) $parent['addr']) || strpos($about, (string) $parent['url'])) {
|
||||
return $about;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,13 +54,13 @@ class User
|
|||
*
|
||||
* @{
|
||||
*/
|
||||
const PAGE_FLAGS_NORMAL = 0;
|
||||
const PAGE_FLAGS_SOAPBOX = 1;
|
||||
const PAGE_FLAGS_COMMUNITY = 2;
|
||||
const PAGE_FLAGS_FREELOVE = 3;
|
||||
const PAGE_FLAGS_BLOG = 4;
|
||||
const PAGE_FLAGS_PRVGROUP = 5;
|
||||
const PAGE_FLAGS_COMM_MAN = 6;
|
||||
public const PAGE_FLAGS_NORMAL = 0;
|
||||
public const PAGE_FLAGS_SOAPBOX = 1;
|
||||
public const PAGE_FLAGS_COMMUNITY = 2;
|
||||
public const PAGE_FLAGS_FREELOVE = 3;
|
||||
public const PAGE_FLAGS_BLOG = 4;
|
||||
public const PAGE_FLAGS_PRVGROUP = 5;
|
||||
public const PAGE_FLAGS_COMM_MAN = 6;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
@ -84,12 +84,12 @@ class User
|
|||
* This will only be assigned to contacts, not to user accounts
|
||||
* @{
|
||||
*/
|
||||
const ACCOUNT_TYPE_PERSON = 0;
|
||||
const ACCOUNT_TYPE_ORGANISATION = 1;
|
||||
const ACCOUNT_TYPE_NEWS = 2;
|
||||
const ACCOUNT_TYPE_COMMUNITY = 3;
|
||||
const ACCOUNT_TYPE_RELAY = 4;
|
||||
const ACCOUNT_TYPE_DELETED = 127;
|
||||
public const ACCOUNT_TYPE_PERSON = 0;
|
||||
public const ACCOUNT_TYPE_ORGANISATION = 1;
|
||||
public const ACCOUNT_TYPE_NEWS = 2;
|
||||
public const ACCOUNT_TYPE_COMMUNITY = 3;
|
||||
public const ACCOUNT_TYPE_RELAY = 4;
|
||||
public const ACCOUNT_TYPE_DELETED = 127;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
@ -170,7 +170,7 @@ class User
|
|||
$system['region'] = '';
|
||||
$system['postal-code'] = '';
|
||||
$system['country-name'] = '';
|
||||
$system['homepage'] = (string)DI::baseUrl();
|
||||
$system['homepage'] = (string) DI::baseUrl();
|
||||
$system['dob'] = '0000-00-00';
|
||||
|
||||
// Ensure that the user contains data
|
||||
|
|
@ -503,7 +503,7 @@ class User
|
|||
// Check if the avatar field is filled and the photo directs to the correct path
|
||||
$avatar = Photo::selectFirst(['resource-id'], ['uid' => $uid, 'profile' => true]);
|
||||
if (DBA::isResult($avatar)) {
|
||||
$repair = empty($owner['avatar']) || !strpos($owner['photo'], $avatar['resource-id']);
|
||||
$repair = empty($owner['avatar']) || !strpos($owner['photo'], (string) $avatar['resource-id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -755,7 +755,7 @@ class User
|
|||
'username' => $username,
|
||||
'password' => $password,
|
||||
'authenticated' => 0,
|
||||
'user_record' => null
|
||||
'user_record' => null,
|
||||
];
|
||||
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
|
@ -815,7 +815,7 @@ class User
|
|||
'uid' => $user_info,
|
||||
'account_expired' => false,
|
||||
'account_removed' => false,
|
||||
'verified' => true
|
||||
'verified' => true,
|
||||
];
|
||||
if (!$with_blocked) {
|
||||
$condition = DBA::mergeConditions($condition, ['blocked' => false]);
|
||||
|
|
@ -825,7 +825,7 @@ class User
|
|||
$condition = [
|
||||
"(`email` = ? OR `username` = ? OR `nickname` = ?)
|
||||
AND `verified` AND NOT `account_removed` AND NOT `account_expired`",
|
||||
$user_info, $user_info, $user_info
|
||||
$user_info, $user_info, $user_info,
|
||||
];
|
||||
if (!$with_blocked) {
|
||||
$condition = DBA::mergeConditions($condition, ['blocked' => false]);
|
||||
|
|
@ -905,7 +905,7 @@ class User
|
|||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
|
||||
return false;
|
||||
|
|
@ -1008,7 +1008,7 @@ class User
|
|||
'password' => $password_hashed,
|
||||
'pwdreset' => null,
|
||||
'pwdreset_time' => null,
|
||||
'legacy_password' => false
|
||||
'legacy_password' => false,
|
||||
];
|
||||
return DBA::update('user', $fields, ['uid' => $uid]);
|
||||
}
|
||||
|
|
@ -1025,7 +1025,7 @@ class User
|
|||
{
|
||||
return DBA::exists('user', [
|
||||
'uid' => $uid,
|
||||
'email' => self::getAdminEmailList()
|
||||
'email' => self::getAdminEmailList(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -1337,7 +1337,7 @@ class User
|
|||
'language' => $language,
|
||||
'timezone' => 'UTC',
|
||||
'register_date' => DateTimeFormat::utcNow(),
|
||||
'default-location' => ''
|
||||
'default-location' => '',
|
||||
]);
|
||||
|
||||
if ($insert_result) {
|
||||
|
|
@ -1566,7 +1566,7 @@ class User
|
|||
$user,
|
||||
DI::config()->get('config', 'sitename'),
|
||||
DI::baseUrl(),
|
||||
($register['password'] ?? '') ?: 'Sent in a previous email'
|
||||
($register['password'] ?? '') ?: 'Sent in a previous email',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1597,8 +1597,8 @@ class User
|
|||
// Delete the avatar
|
||||
Photo::delete(['uid' => $register['uid']]);
|
||||
|
||||
return DBA::delete('user', ['uid' => $register['uid']]) &&
|
||||
Register::deleteByHash($register['hash']);
|
||||
return DBA::delete('user', ['uid' => $register['uid']])
|
||||
&& Register::deleteByHash($register['hash']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1616,9 +1616,9 @@ class User
|
|||
*/
|
||||
public static function createMinimal(string $name, string $email, string $nick, string $lang = L10n::DEFAULT, string $avatar = ''): bool
|
||||
{
|
||||
if (empty($name) ||
|
||||
empty($email) ||
|
||||
empty($nick)) {
|
||||
if (empty($name)
|
||||
|| empty($email)
|
||||
|| empty($nick)) {
|
||||
throw new HTTPException\InternalServerErrorException('Invalid arguments.');
|
||||
}
|
||||
|
||||
|
|
@ -1629,7 +1629,7 @@ class User
|
|||
'nickname' => $nick,
|
||||
'verified' => 1,
|
||||
'language' => $lang,
|
||||
'photo' => $avatar
|
||||
'photo' => $avatar,
|
||||
]);
|
||||
|
||||
$user = $result['user'];
|
||||
|
|
@ -1702,7 +1702,7 @@ class User
|
|||
$sitename,
|
||||
$siteurl,
|
||||
$user['nickname'],
|
||||
$password
|
||||
$password,
|
||||
));
|
||||
|
||||
$email = DI::emailer()
|
||||
|
|
@ -1736,7 +1736,7 @@ class User
|
|||
Thank you for registering at %2$s. Your account has been created.
|
||||
',
|
||||
$user['username'],
|
||||
$sitename
|
||||
$sitename,
|
||||
));
|
||||
$body = Strings::deindent($l10n->t(
|
||||
'
|
||||
|
|
@ -1769,7 +1769,7 @@ class User
|
|||
$sitename,
|
||||
$siteurl,
|
||||
$user['username'],
|
||||
$password
|
||||
$password,
|
||||
));
|
||||
|
||||
$email = DI::emailer()
|
||||
|
|
@ -1877,14 +1877,14 @@ class User
|
|||
$identities = [[
|
||||
'uid' => $user['uid'],
|
||||
'username' => $user['username'],
|
||||
'nickname' => $user['nickname']
|
||||
'nickname' => $user['nickname'],
|
||||
]];
|
||||
|
||||
// Then add all the children
|
||||
$r = DBA::select(
|
||||
'user',
|
||||
['uid', 'username', 'nickname'],
|
||||
['parent-uid' => $user['uid'], 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]
|
||||
['parent-uid' => $user['uid'], 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false],
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$identities = array_merge($identities, DBA::toArray($r));
|
||||
|
|
@ -1894,7 +1894,7 @@ class User
|
|||
$r = DBA::select(
|
||||
'user',
|
||||
['uid', 'username', 'nickname'],
|
||||
['uid' => $user['parent-uid'], 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]
|
||||
['uid' => $user['parent-uid'], 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false],
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$identities = DBA::toArray($r);
|
||||
|
|
@ -1904,7 +1904,7 @@ class User
|
|||
$r = DBA::select(
|
||||
'user',
|
||||
['uid', 'username', 'nickname'],
|
||||
['parent-uid' => $user['parent-uid'], 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]
|
||||
['parent-uid' => $user['parent-uid'], 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false],
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$identities = array_merge($identities, DBA::toArray($r));
|
||||
|
|
@ -1916,7 +1916,7 @@ class User
|
|||
FROM `manage`
|
||||
INNER JOIN `user` ON `manage`.`mid` = `user`.`uid`
|
||||
WHERE NOT `user`.`account_removed` AND `manage`.`uid` = ?",
|
||||
$user['uid']
|
||||
$user['uid'],
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$identities = array_merge($identities, DBA::toArray($r));
|
||||
|
|
@ -1978,7 +1978,7 @@ class User
|
|||
['uid', 'last-activity', 'last-item'],
|
||||
["`verified` AND `last-activity` > ? AND NOT `blocked`
|
||||
AND NOT `account_removed` AND NOT `account_expired`",
|
||||
DBA::NULL_DATETIME]
|
||||
DBA::NULL_DATETIME],
|
||||
);
|
||||
if (!DBA::isResult($userStmt)) {
|
||||
return $statistics;
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
|
|||
class Cookie
|
||||
{
|
||||
/** @var int Default expire duration in days */
|
||||
const DEFAULT_EXPIRE = 7;
|
||||
public const DEFAULT_EXPIRE = 7;
|
||||
/** @var string The name of the Friendica cookie */
|
||||
const NAME = 'Friendica';
|
||||
public const NAME = 'Friendica';
|
||||
/** @var string The path of the Friendica cookie */
|
||||
const PATH = '/';
|
||||
public const PATH = '/';
|
||||
/** @var string The domain name of the Friendica cookie */
|
||||
const DOMAIN = '';
|
||||
public const DOMAIN = '';
|
||||
/** @var bool True, if the cookie should only be accessible through HTTP */
|
||||
const HTTPONLY = true;
|
||||
public const HTTPONLY = true;
|
||||
|
||||
/** @var string The remote address of this node */
|
||||
private $remoteAddr;
|
||||
|
|
@ -49,8 +49,11 @@ class Cookie
|
|||
$this->sslEnabled = $baseURL->getScheme() === 'https';
|
||||
$this->sitePrivateKey = $config->get('system', 'site_prvkey');
|
||||
|
||||
$authCookieDays = $config->get('system', 'auth_cookie_lifetime',
|
||||
self::DEFAULT_EXPIRE);
|
||||
$authCookieDays = $config->get(
|
||||
'system',
|
||||
'auth_cookie_lifetime',
|
||||
self::DEFAULT_EXPIRE,
|
||||
);
|
||||
$this->lifetime = $authCookieDays * 24 * 60 * 60;
|
||||
|
||||
$this->remoteAddr = $request->getRemoteAddress();
|
||||
|
|
@ -120,8 +123,8 @@ class Cookie
|
|||
*/
|
||||
public function reset(array $data): bool
|
||||
{
|
||||
return $this->clear() &&
|
||||
$this->setMultiple($data);
|
||||
return $this->clear()
|
||||
&& $this->setMultiple($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -144,7 +147,7 @@ class Cookie
|
|||
return $this->setCookie(
|
||||
json_encode(['ip' => $this->remoteAddr] + $this->data),
|
||||
$this->lifetime + time(),
|
||||
$this->sslEnabled
|
||||
$this->sslEnabled,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -160,10 +163,12 @@ class Cookie
|
|||
* @return bool If output exists prior to calling this function,
|
||||
*
|
||||
*/
|
||||
protected function setCookie(string $value = null, int $expire = null,
|
||||
bool $secure = null): bool
|
||||
{
|
||||
return setcookie(self::NAME, $value, $expire, self::PATH, self::DOMAIN, $secure, self::HTTPONLY);
|
||||
protected function setCookie(
|
||||
string $value = null,
|
||||
int $expire = null,
|
||||
bool $secure = null
|
||||
): bool {
|
||||
return setcookie(self::NAME, $value, ['expires' => $expire, 'path' => self::PATH, 'domain' => self::DOMAIN, 'secure' => $secure, 'httponly' => self::HTTPONLY]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -180,7 +185,7 @@ class Cookie
|
|||
return hash_hmac(
|
||||
'sha256',
|
||||
hash_hmac('sha256', $privateData, $privateKey),
|
||||
$this->sitePrivateKey
|
||||
$this->sitePrivateKey,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +201,7 @@ class Cookie
|
|||
{
|
||||
return hash_equals(
|
||||
$this->hashPrivateData($privateData, $privateKey),
|
||||
$hash
|
||||
$hash,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ class ApiResponse extends Response
|
|||
*/
|
||||
public function addFormattedContent(string $root_element, array $data, string $format = null, int $cid = 0)
|
||||
{
|
||||
$format = $format ?? 'json';
|
||||
$format ??= 'json';
|
||||
|
||||
$return = $this->formatData($root_element, $format, $data, $cid);
|
||||
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ class Network extends Timeline
|
|||
$this->order = 'commented';
|
||||
}
|
||||
|
||||
$this->selectedTab = $this->selectedTab ?? $this->order;
|
||||
$this->selectedTab ??= $this->order;
|
||||
|
||||
// Upon updates in the background and order by last comment we order by received date,
|
||||
// since otherwise the feed will optically jump, when some already visible thread has been updated.
|
||||
|
|
|
|||
|
|
@ -42,19 +42,19 @@ class Babel extends BaseModule
|
|||
$bbcode = $request['text'];
|
||||
$results[] = [
|
||||
'title' => 'Source input',
|
||||
'content' => $visible_whitespace($bbcode)
|
||||
'content' => $visible_whitespace($bbcode),
|
||||
];
|
||||
|
||||
$plain = Text\BBCode::toPlaintext($bbcode, false);
|
||||
$results[] = [
|
||||
'title' => 'BBCode::toPlaintext',
|
||||
'content' => $visible_whitespace($plain)
|
||||
'content' => $visible_whitespace($plain),
|
||||
];
|
||||
|
||||
$html = Text\BBCode::convertForUriId(0, $bbcode);
|
||||
$results[] = [
|
||||
'title' => 'BBCode::convert (raw HTML)',
|
||||
'content' => $visible_whitespace($html)
|
||||
'content' => $visible_whitespace($html),
|
||||
];
|
||||
|
||||
$results[] = [
|
||||
|
|
@ -64,41 +64,41 @@ class Babel extends BaseModule
|
|||
|
||||
$results[] = [
|
||||
'title' => 'BBCode::convert',
|
||||
'content' => $html
|
||||
'content' => $html,
|
||||
];
|
||||
|
||||
$bbcode2 = Text\HTML::toBBCode($html);
|
||||
$results[] = [
|
||||
'title' => 'BBCode::convert => HTML::toBBCode',
|
||||
'content' => $visible_whitespace($bbcode2)
|
||||
'content' => $visible_whitespace($bbcode2),
|
||||
];
|
||||
|
||||
$markdown = Text\BBCode::toMarkdown($bbcode);
|
||||
$results[] = [
|
||||
'title' => 'BBCode::toMarkdown',
|
||||
'content' => $visible_whitespace($markdown)
|
||||
'content' => $visible_whitespace($markdown),
|
||||
];
|
||||
|
||||
$html2 = Text\Markdown::convert($markdown);
|
||||
$results[] = [
|
||||
'title' => 'BBCode::toMarkdown => Markdown::convert (raw HTML)',
|
||||
'content' => $visible_whitespace($html2)
|
||||
'content' => $visible_whitespace($html2),
|
||||
];
|
||||
$results[] = [
|
||||
'title' => 'BBCode::toMarkdown => Markdown::convert',
|
||||
'content' => $html2
|
||||
'content' => $html2,
|
||||
];
|
||||
|
||||
$bbcode3 = Text\Markdown::toBBCode($markdown);
|
||||
$results[] = [
|
||||
'title' => 'BBCode::toMarkdown => Markdown::toBBCode',
|
||||
'content' => $visible_whitespace($bbcode3)
|
||||
'content' => $visible_whitespace($bbcode3),
|
||||
];
|
||||
|
||||
$bbcode4 = Text\HTML::toBBCode($html2);
|
||||
$results[] = [
|
||||
'title' => 'BBCode::toMarkdown => Markdown::convert => HTML::toBBCode',
|
||||
'content' => $visible_whitespace($bbcode4)
|
||||
'content' => $visible_whitespace($bbcode4),
|
||||
];
|
||||
|
||||
$tags = Text\BBCode::getTags($bbcode);
|
||||
|
|
@ -106,7 +106,7 @@ class Babel extends BaseModule
|
|||
$body = Item::setHashtags($bbcode);
|
||||
$results[] = [
|
||||
'title' => 'Item Body',
|
||||
'content' => $visible_whitespace($body)
|
||||
'content' => $visible_whitespace($body),
|
||||
];
|
||||
$results[] = [
|
||||
'title' => 'Item Tags',
|
||||
|
|
@ -116,16 +116,16 @@ class Babel extends BaseModule
|
|||
$body2 = PageInfo::searchAndAppendToBody($bbcode, true);
|
||||
$results[] = [
|
||||
'title' => 'PageInfo::appendToBody',
|
||||
'content' => $visible_whitespace($body2)
|
||||
'content' => $visible_whitespace($body2),
|
||||
];
|
||||
$html3 = Text\BBCode::convertForUriId(0, $body2);
|
||||
$results[] = [
|
||||
'title' => 'PageInfo::appendToBody => BBCode::convert (raw HTML)',
|
||||
'content' => $visible_whitespace($html3)
|
||||
'content' => $visible_whitespace($html3),
|
||||
];
|
||||
$results[] = [
|
||||
'title' => 'PageInfo::appendToBody => BBCode::convert',
|
||||
'content' => $html3
|
||||
'content' => $html3,
|
||||
];
|
||||
break;
|
||||
case 'diaspora':
|
||||
|
|
@ -138,7 +138,7 @@ class Babel extends BaseModule
|
|||
$markdown = XML::unescape($diaspora);
|
||||
// no break
|
||||
case 'markdown':
|
||||
$markdown = $markdown ?? trim($request['text']);
|
||||
$markdown ??= trim($request['text']);
|
||||
|
||||
$results[] = [
|
||||
'title' => 'Source input (Markdown)',
|
||||
|
|
@ -153,7 +153,7 @@ class Babel extends BaseModule
|
|||
|
||||
$results[] = [
|
||||
'title' => 'Markdown::convert',
|
||||
'content' => $html
|
||||
'content' => $html,
|
||||
];
|
||||
|
||||
$bbcode = Text\Markdown::toBBCode($markdown);
|
||||
|
|
@ -171,7 +171,7 @@ class Babel extends BaseModule
|
|||
|
||||
$results[] = [
|
||||
'title' => 'HTML Input',
|
||||
'content' => $html
|
||||
'content' => $html,
|
||||
];
|
||||
|
||||
$purified = Text\HTML::purify($html);
|
||||
|
|
@ -194,18 +194,18 @@ class Babel extends BaseModule
|
|||
$bbcode = Text\HTML::toBBCode($html);
|
||||
$results[] = [
|
||||
'title' => 'HTML::toBBCode',
|
||||
'content' => $visible_whitespace($bbcode)
|
||||
'content' => $visible_whitespace($bbcode),
|
||||
];
|
||||
|
||||
$html2 = Text\BBCode::convertForUriId(0, $bbcode);
|
||||
$results[] = [
|
||||
'title' => 'HTML::toBBCode => BBCode::convert',
|
||||
'content' => $html2
|
||||
'content' => $html2,
|
||||
];
|
||||
|
||||
$results[] = [
|
||||
'title' => 'HTML::toBBCode => BBCode::convert (raw HTML)',
|
||||
'content' => htmlspecialchars($html2)
|
||||
'content' => htmlspecialchars($html2),
|
||||
];
|
||||
|
||||
$bbcode2plain = Text\BBCode::toPlaintext($bbcode);
|
||||
|
|
@ -217,7 +217,7 @@ class Babel extends BaseModule
|
|||
$markdown = Text\HTML::toMarkdown($html);
|
||||
$results[] = [
|
||||
'title' => 'HTML::toMarkdown',
|
||||
'content' => $visible_whitespace($markdown)
|
||||
'content' => $visible_whitespace($markdown),
|
||||
];
|
||||
|
||||
$text = Text\HTML::toPlaintext($html, 0);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Ping extends BaseModule
|
|||
$home_count = 0;
|
||||
$register_count = 0;
|
||||
$sysnotify_count = 0;
|
||||
$circles_unseen = [];
|
||||
$circles_unseen = [];
|
||||
$groups_unseen = [];
|
||||
|
||||
$event_count = 0;
|
||||
|
|
@ -110,12 +110,12 @@ class Ping extends BaseModule
|
|||
|
||||
$condition = [
|
||||
"`unseen` AND `uid` = ? AND NOT `origin` AND `wall` AND (`vid` != ? OR `vid` IS NULL)",
|
||||
$this->session->getLocalUserId(), Verb::getID(Activity::FOLLOW)
|
||||
$this->session->getLocalUserId(), Verb::getID(Activity::FOLLOW),
|
||||
];
|
||||
|
||||
$home_count = Post::count($condition);
|
||||
|
||||
if ($this->config->get('system','compute_circle_counts')) {
|
||||
if ($this->config->get('system', 'compute_circle_counts')) {
|
||||
// Find out how unseen network posts are spread across circles
|
||||
foreach (Circle::countUnseen($this->session->getLocalUserId()) as $circle_count) {
|
||||
if ($circle_count['count'] > 0) {
|
||||
|
|
@ -138,16 +138,19 @@ class Ping extends BaseModule
|
|||
$mail_count = $this->database->count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", $this->session->getLocalUserId(), $myurl]);
|
||||
|
||||
if (Register::getPolicy() === Register::APPROVE && $this->session->isSiteAdmin()) {
|
||||
$registrations = \Friendica\Model\Register::getPending();
|
||||
$registrations = \Friendica\Model\Register::getPending();
|
||||
$register_count = count($registrations);
|
||||
}
|
||||
|
||||
$cachekey = 'ping:events:' . $this->session->getLocalUserId();
|
||||
$events = $this->cache->get($cachekey);
|
||||
if (is_null($events)) {
|
||||
$events = $this->database->selectToArray('event', ['type', 'start'],
|
||||
$events = $this->database->selectToArray(
|
||||
'event',
|
||||
['type', 'start'],
|
||||
["`uid` = ? AND `start` < ? AND `finish` > ? AND NOT `ignore`",
|
||||
$this->session->getLocalUserId(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]);
|
||||
$this->session->getLocalUserId(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()],
|
||||
);
|
||||
$this->cache->set($cachekey, $events, Duration::HOUR);
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +210,7 @@ class Ping extends BaseModule
|
|||
$registration['url'],
|
||||
$this->l10n->t('{0} requested registration'),
|
||||
new \DateTime($registration['created'], new \DateTimeZone('UTC')),
|
||||
new Uri($this->baseUrl . '/moderation/users/pending')
|
||||
new Uri($this->baseUrl . '/moderation/users/pending'),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -216,7 +219,7 @@ class Ping extends BaseModule
|
|||
$registrations[0]['url'],
|
||||
$this->l10n->t('{0} and %d others requested registration', count($registrations) - 1),
|
||||
new \DateTime($registrations[0]['created'], new \DateTimeZone('UTC')),
|
||||
new Uri($this->baseUrl . '/moderation/users/pending')
|
||||
new Uri($this->baseUrl . '/moderation/users/pending'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -227,11 +230,7 @@ class Ping extends BaseModule
|
|||
|
||||
// Unseen messages are kept at the top
|
||||
if ($a['seen'] == $b['seen']) {
|
||||
if ($a['timestamp'] == $b['timestamp']) {
|
||||
return 0;
|
||||
} else {
|
||||
return $a['timestamp'] < $b['timestamp'] ? 1 : -1;
|
||||
}
|
||||
return $b['timestamp'] <=> $a['timestamp'];
|
||||
} else {
|
||||
return $a['seen'] ? 1 : -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class Photo extends BaseApi
|
|||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
$cacheable = ($photo['allow_cid'] . $photo['allow_gid'] . $photo['deny_cid'] . $photo['deny_gid'] === '') && (isset($photo['cacheable']) ? $photo['cacheable'] : true);
|
||||
$cacheable = ($photo['allow_cid'] . $photo['allow_gid'] . $photo['deny_cid'] . $photo['deny_gid'] === '') && ($photo['cacheable'] ?? true);
|
||||
|
||||
$stamp = microtime(true);
|
||||
$imgdata = '';
|
||||
|
|
@ -239,7 +239,7 @@ class Photo extends BaseApi
|
|||
'scale' => $scale, 'resource' => $photo['resource-id'],
|
||||
'total' => number_format($total, 3), 'fetch' => number_format($fetch, 3),
|
||||
'data' => number_format($data, 3), 'checksum' => number_format($checksum, 3),
|
||||
'output' => number_format($output, 3), 'rest' => number_format($rest, 3)
|
||||
'output' => number_format($output, 3), 'rest' => number_format($rest, 3),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ class Photo extends BaseApi
|
|||
return MPhoto::getPhoto($matches[1], $matches[2], self::getCurrentUserID());
|
||||
}
|
||||
|
||||
return MPhoto::createPhotoForExternalResource($url, (int)DI::userSession()->getLocalUserId(), $media['mimetype'] ?? '', $media['blurhash'], $width, $height);
|
||||
return MPhoto::createPhotoForExternalResource($url, (int) DI::userSession()->getLocalUserId(), $media['mimetype'] ?? '', $media['blurhash'], $width, $height);
|
||||
case 'media':
|
||||
$media = DBA::selectFirst('post-media', ['url', 'height', 'width', 'mimetype', 'uri-id', 'blurhash'], ['id' => $id, 'type' => Post\Media::IMAGE]);
|
||||
if (empty($media)) {
|
||||
|
|
@ -305,14 +305,14 @@ class Photo extends BaseApi
|
|||
return MPhoto::getPhoto($matches[1], $matches[2], self::getCurrentUserID());
|
||||
}
|
||||
|
||||
return MPhoto::createPhotoForExternalResource($media['url'], (int)DI::userSession()->getLocalUserId(), $media['mimetype'], $media['blurhash'], $media['width'], $media['height']);
|
||||
return MPhoto::createPhotoForExternalResource($media['url'], (int) DI::userSession()->getLocalUserId(), $media['mimetype'], $media['blurhash'], $media['width'], $media['height']);
|
||||
case 'link':
|
||||
$link = DBA::selectFirst('post-link', ['url', 'mimetype', 'blurhash', 'width', 'height'], ['id' => $id]);
|
||||
if (empty($link)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return MPhoto::createPhotoForExternalResource($link['url'], (int)DI::userSession()->getLocalUserId(), $link['mimetype'] ?? '', $link['blurhash'] ?? '', $link['width'] ?? 0, $link['height'] ?? 0);
|
||||
return MPhoto::createPhotoForExternalResource($link['url'], (int) DI::userSession()->getLocalUserId(), $link['mimetype'] ?? '', $link['blurhash'] ?? '', $link['width'] ?? 0, $link['height'] ?? 0);
|
||||
case 'contact':
|
||||
$fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'blurhash', 'xmpp', 'addr', 'network', 'failed', 'updated', 'next-update'];
|
||||
$contact = Contact::getById($id, $fields);
|
||||
|
|
|
|||
|
|
@ -83,19 +83,19 @@ class Response implements ICanCreateResponses
|
|||
|
||||
switch ($type) {
|
||||
case static::TYPE_HTML:
|
||||
$content_type = $content_type ?? 'text/html; charset=utf-8';
|
||||
$content_type ??= 'text/html; charset=utf-8';
|
||||
break;
|
||||
case static::TYPE_JSON:
|
||||
$content_type = $content_type ?? 'application/json';
|
||||
$content_type ??= 'application/json';
|
||||
break;
|
||||
case static::TYPE_XML:
|
||||
$content_type = $content_type ?? 'text/xml';
|
||||
$content_type ??= 'text/xml';
|
||||
break;
|
||||
case static::TYPE_RSS:
|
||||
$content_type = $content_type ?? 'application/rss+xml';
|
||||
$content_type ??= 'application/rss+xml';
|
||||
break;
|
||||
case static::TYPE_ATOM:
|
||||
$content_type = $content_type ?? 'application/atom+xml';
|
||||
$content_type ??= 'application/atom+xml';
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ use Psr\Log\LoggerInterface;
|
|||
|
||||
class Import extends \Friendica\BaseModule
|
||||
{
|
||||
const IMPORT_DEBUG = false;
|
||||
const MEMORY_LIMIT = 67108864; // 64MB
|
||||
public const IMPORT_DEBUG = false;
|
||||
public const MEMORY_LIMIT = 67108864; // 64MB
|
||||
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
|
|
@ -233,11 +233,11 @@ class Import extends \Friendica\BaseModule
|
|||
}
|
||||
|
||||
// Backward compatibility
|
||||
$account['circle'] = $account['circle'] ?? $account['group'];
|
||||
$account['circle_member'] = $account['circle_member'] ?? $account['group_member'];
|
||||
$account['circle'] ??= $account['group'];
|
||||
$account['circle_member'] ??= $account['group_member'];
|
||||
|
||||
$oldBaseUrl = $account['baseurl'];
|
||||
$newBaseUrl = (string)$this->baseUrl;
|
||||
$newBaseUrl = (string) $this->baseUrl;
|
||||
|
||||
$oldAddr = str_replace('http://', '@', Strings::normaliseLink($oldBaseUrl));
|
||||
$newAddr = str_replace('http://', '@', Strings::normaliseLink($newBaseUrl));
|
||||
|
|
@ -404,7 +404,7 @@ class Import extends \Friendica\BaseModule
|
|||
$photo['allow_cid'],
|
||||
$photo['allow_gid'],
|
||||
$photo['deny_cid'],
|
||||
$photo['deny_gid']
|
||||
$photo['deny_gid'],
|
||||
);
|
||||
|
||||
if ($r === false) {
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class Notify extends BaseRepository
|
|||
$Notify->link,
|
||||
$Notify->parent,
|
||||
$Notify->otype,
|
||||
$Notify->uid
|
||||
$Notify->uid,
|
||||
];
|
||||
return $this->db->update(self::$table_name, ['seen' => true], $condition);
|
||||
}
|
||||
|
|
@ -261,13 +261,13 @@ class Notify extends BaseRepository
|
|||
}
|
||||
}
|
||||
|
||||
$siteurl = (string)$this->baseUrl;
|
||||
$siteurl = (string) $this->baseUrl;
|
||||
$sitename = $this->config->get('config', 'sitename');
|
||||
|
||||
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
|
||||
// the database, and an email is sent if applicable.
|
||||
// default, if not specified: true
|
||||
$show_in_notification_page = isset($params['show_in_notification_page']) ? $params['show_in_notification_page'] : true;
|
||||
$show_in_notification_page = $params['show_in_notification_page'] ?? true;
|
||||
|
||||
$title = $params['item']['title'] ?? '';
|
||||
$body = $params['item']['body'] ?? '';
|
||||
|
|
@ -354,7 +354,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $l10n->t(
|
||||
'%1$s posted to [url=%2$s]your wall[/url]',
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
$params['link']
|
||||
$params['link'],
|
||||
);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to the conversation.');
|
||||
|
|
@ -371,7 +371,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $l10n->t(
|
||||
'You\'ve received [url=%1$s]an introduction[/url] from %2$s.',
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
);
|
||||
|
||||
$body = $l10n->t('You may visit their profile at %s', $params['source_link']);
|
||||
|
|
@ -389,7 +389,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $l10n->t(
|
||||
'%1$s is your friend at %2$s',
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
$sitename
|
||||
$sitename,
|
||||
);
|
||||
break;
|
||||
case Activity::FOLLOW:
|
||||
|
|
@ -400,7 +400,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $l10n->t(
|
||||
'You have a new follower at %2$s : %1$s',
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
$sitename
|
||||
$sitename,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -418,7 +418,7 @@ class Notify extends BaseRepository
|
|||
'You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.',
|
||||
$itemlink,
|
||||
'[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
);
|
||||
|
||||
$body = $l10n->t('Name:') . ' ' . $params['item']['name'] . "\n";
|
||||
|
|
@ -439,7 +439,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $l10n->t(
|
||||
'%2$s has accepted your [url=%1$s]connection request[/url].',
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
);
|
||||
|
||||
$body = $l10n->t('You are now friends and may exchange status updates, photos, and messages without restriction.');
|
||||
|
|
@ -455,7 +455,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $l10n->t(
|
||||
'%2$s has accepted your [url=%1$s]connection request[/url].',
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
);
|
||||
|
||||
$body = $l10n->t('\'%1$s\' has chosen to accept you a fan, which restricts some forms of communication - such as private messaging and some profile interactions. If this is a celebrity or community page, these settings were applied automatically.', $params['source_name']);
|
||||
|
|
@ -478,7 +478,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $l10n->t(
|
||||
'You\'ve received a [url=%1$s]registration request[/url] from %2$s.',
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
);
|
||||
|
||||
$body = $l10n->t(
|
||||
|
|
@ -486,7 +486,7 @@ class Notify extends BaseRepository
|
|||
$params['source_name'],
|
||||
$siteurl,
|
||||
$params['source_mail'],
|
||||
$params['source_nick']
|
||||
$params['source_nick'],
|
||||
);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to approve or reject the request.');
|
||||
|
|
@ -502,7 +502,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $l10n->t(
|
||||
'You\'ve received a [url=%1$s]new registration[/url] from %2$s.',
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
);
|
||||
|
||||
$body = $l10n->t(
|
||||
|
|
@ -510,7 +510,7 @@ class Notify extends BaseRepository
|
|||
$params['source_name'],
|
||||
$siteurl,
|
||||
$params['source_mail'],
|
||||
$params['source_nick']
|
||||
$params['source_nick'],
|
||||
);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to have a look at the new registration.');
|
||||
|
|
@ -570,7 +570,7 @@ class Notify extends BaseRepository
|
|||
'sitelink' => $sitelink,
|
||||
'tsitelink' => $tsitelink,
|
||||
'hsitelink' => $hsitelink,
|
||||
'itemlink' => $itemlink
|
||||
'itemlink' => $itemlink,
|
||||
];
|
||||
|
||||
$hook_data = $this->eventDispatcher->dispatch(
|
||||
|
|
@ -625,7 +625,7 @@ class Notify extends BaseRepository
|
|||
'notify-id' => $notify_id,
|
||||
'master-parent-uri-id' => $parent_uri_id,
|
||||
'receiver-uid' => $params['uid'],
|
||||
'parent-item' => 0
|
||||
'parent-item' => 0,
|
||||
];
|
||||
DBA::insert('notify-threads', $fields);
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ class Notify extends BaseRepository
|
|||
$emailBuilder->withPhoto(
|
||||
$hook_data['source_photo'],
|
||||
$hook_data['source_link'] ?? $sitelink,
|
||||
$hook_data['source_name'] ?? $sitename
|
||||
$hook_data['source_name'] ?? $sitename,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -766,7 +766,7 @@ class Notify extends BaseRepository
|
|||
$Notification->uid,
|
||||
Model\Item::ITEM_FIELDLIST,
|
||||
['uid' => [0, $Notification->uid], 'uri-id' => $Notification->targetUriId, 'deleted' => false],
|
||||
['order' => ['uid' => true]]
|
||||
['order' => ['uid' => true]],
|
||||
);
|
||||
if (empty($item)) {
|
||||
$this->logger->info('Item not found', ['uri-id' => $Notification->targetUriId, 'type' => $Notification->type]);
|
||||
|
|
@ -789,7 +789,7 @@ class Notify extends BaseRepository
|
|||
$condition = [
|
||||
'type' => [Model\Notification\Type::TAG_SELF, Model\Notification\Type::COMMENT, Model\Notification\Type::SHARE],
|
||||
'link' => $params['link'],
|
||||
'verb' => Activity::POST
|
||||
'verb' => Activity::POST,
|
||||
];
|
||||
if ($this->existsForUser($Notification->uid, $condition)) {
|
||||
$this->logger->info('Duplicate found, quitting', $condition + ['uid' => $Notification->uid]);
|
||||
|
|
@ -838,7 +838,7 @@ class Notify extends BaseRepository
|
|||
$epreamble = $msg['rich'];
|
||||
|
||||
$sitename = $this->config->get('config', 'sitename');
|
||||
$siteurl = (string)$this->baseUrl;
|
||||
$siteurl = (string) $this->baseUrl;
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to the conversation.');
|
||||
$tsitelink = sprintf($sitelink, $siteurl);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class HttpClient implements ICanSendHttpRequests
|
|||
}
|
||||
}
|
||||
$parts['path'] = implode('/', $parts2);
|
||||
$url = (string)Uri::fromParts((array)$parts);
|
||||
$url = (string) Uri::fromParts((array) $parts);
|
||||
|
||||
if (Network::isUrlBlocked($url)) {
|
||||
$this->logger->info('Domain is blocked.', ['url' => $url]);
|
||||
|
|
@ -147,8 +147,8 @@ class HttpClient implements ICanSendHttpRequests
|
|||
|
||||
$conf[RequestOptions::ON_HEADERS] = function (ResponseInterface $response) use ($opts) {
|
||||
if (
|
||||
!empty($opts[HttpClientOptions::CONTENT_LENGTH]) &&
|
||||
(int)$response->getHeaderLine('Content-Length') > $opts[HttpClientOptions::CONTENT_LENGTH]
|
||||
!empty($opts[HttpClientOptions::CONTENT_LENGTH])
|
||||
&& (int) $response->getHeaderLine('Content-Length') > $opts[HttpClientOptions::CONTENT_LENGTH]
|
||||
) {
|
||||
throw new TransferException('The file is too big!');
|
||||
}
|
||||
|
|
@ -168,14 +168,14 @@ class HttpClient implements ICanSendHttpRequests
|
|||
return new GuzzleResponse($response, $url);
|
||||
} catch (TransferException $exception) {
|
||||
if (
|
||||
$exception instanceof RequestException &&
|
||||
$exception->hasResponse()
|
||||
$exception instanceof RequestException
|
||||
&& $exception->hasResponse()
|
||||
) {
|
||||
return new GuzzleResponse($exception->getResponse(), $url, $exception->getCode(), '');
|
||||
} else {
|
||||
return new CurlResult($this->logger, $url, '', ['http_code' => 500], $exception->getCode(), '');
|
||||
}
|
||||
} catch (InvalidArgumentException | \InvalidArgumentException $argumentException) {
|
||||
} catch (InvalidArgumentException|\InvalidArgumentException $argumentException) {
|
||||
$this->logger->info('Invalid Argument for HTTP call.', ['url' => $url, 'method' => $method, 'exception' => $argumentException]);
|
||||
return new CurlResult($this->logger, $url, '', ['http_code' => 500], $argumentException->getCode(), $argumentException->getMessage());
|
||||
} finally {
|
||||
|
|
@ -198,7 +198,7 @@ class HttpClient implements ICanSendHttpRequests
|
|||
public function get(string $url, string $accept_content = HttpClientAccept::DEFAULT, array $opts = []): ICanHandleHttpResponses
|
||||
{
|
||||
// In case there is no
|
||||
$opts[HttpClientOptions::ACCEPT_CONTENT] = $opts[HttpClientOptions::ACCEPT_CONTENT] ?? $accept_content;
|
||||
$opts[HttpClientOptions::ACCEPT_CONTENT] ??= $accept_content;
|
||||
|
||||
return $this->request('get', $url, $opts);
|
||||
}
|
||||
|
|
@ -279,7 +279,7 @@ class HttpClient implements ICanSendHttpRequests
|
|||
HttpClientOptions::TIMEOUT => $timeout,
|
||||
HttpClientOptions::COOKIEJAR => $cookiejar,
|
||||
HttpClientOptions::REQUEST => $request,
|
||||
]
|
||||
],
|
||||
);
|
||||
return $ret->getBodyString();
|
||||
} catch (\Throwable $th) {
|
||||
|
|
@ -291,7 +291,7 @@ class HttpClient implements ICanSendHttpRequests
|
|||
private function getUserAgent(string $type = ''): string
|
||||
{
|
||||
// @see https://developers.whatismybrowser.com/learn/browser-detection/user-agents/user-agent-best-practices
|
||||
$userAgent = App::PLATFORM . '/' . App::VERSION . ' DatabaseVersion/' . DB_UPDATE_VERSION;
|
||||
$userAgent = App::PLATFORM . '/' . App::VERSION . ' DatabaseVersion/' . DB_UPDATE_VERSION;
|
||||
if ($type != '') {
|
||||
$userAgent .= ' Request/' . $type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ class CurlResult implements ICanHandleHttpResponses
|
|||
}
|
||||
}
|
||||
|
||||
$this->redirectUrl = (string)Uri::fromParts((array)$redirect_parts);
|
||||
$this->redirectUrl = (string) Uri::fromParts((array) $redirect_parts);
|
||||
$this->isRedirectUrl = true;
|
||||
$this->redirectIsPermanent = $this->returnCode == 301 || $this->returnCode == 308;
|
||||
} else {
|
||||
|
|
@ -266,11 +266,7 @@ class CurlResult implements ICanHandleHttpResponses
|
|||
|
||||
$headers = $this->getHeaderArray();
|
||||
|
||||
if (isset($headers[$header])) {
|
||||
return $headers[$header];
|
||||
}
|
||||
|
||||
return [];
|
||||
return $headers[$header] ?? [];
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
|||
|
|
@ -227,12 +227,12 @@ class Probe
|
|||
unset($data['networks']);
|
||||
if (!empty($data['network'])) {
|
||||
$networks[$data['network']] = $data;
|
||||
$ap_profile['guid'] = $ap_profile['guid'] ?? $data['guid'] ?? null;
|
||||
$ap_profile['about'] = $ap_profile['about'] ?? $data['about'] ?? null;
|
||||
$ap_profile['keywords'] = $data['keywords'] ?? null;
|
||||
$ap_profile['location'] = $data['location'] ?? null;
|
||||
$ap_profile['poco'] = $data['poco'] ?? null;
|
||||
$ap_profile['openwebauth'] = $data['openwebauth'] ?? null;
|
||||
$ap_profile['guid'] ??= $data['guid'] ?? null;
|
||||
$ap_profile['about'] ??= $data['about'] ?? null;
|
||||
$ap_profile['keywords'] = $data['keywords'] ?? null;
|
||||
$ap_profile['location'] = $data['location'] ?? null;
|
||||
$ap_profile['poco'] = $data['poco'] ?? null;
|
||||
$ap_profile['openwebauth'] = $data['openwebauth'] ?? null;
|
||||
}
|
||||
$data = $ap_profile;
|
||||
$data['networks'] = $networks;
|
||||
|
|
@ -1440,9 +1440,9 @@ class Probe
|
|||
|
||||
// And put them together again
|
||||
$scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '';
|
||||
$host = isset($parts['host']) ? $parts['host'] : '';
|
||||
$host = $parts['host'] ?? '';
|
||||
$port = isset($parts['port']) ? ':' . $parts['port'] : '';
|
||||
$path = isset($parts['path']) ? $parts['path'] : '';
|
||||
$path = $parts['path'] ?? '';
|
||||
$query = isset($parts['query']) ? '?' . $parts['query'] : '';
|
||||
$fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
|
||||
|
||||
|
|
|
|||
|
|
@ -98,14 +98,14 @@ class Status extends BaseDataTransferObject
|
|||
public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null, array $emojis = null)
|
||||
{
|
||||
$reblogged = !empty($reblog);
|
||||
$this->id = (string)$item['uri-id'];
|
||||
$this->id = (string) $item['uri-id'];
|
||||
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
|
||||
$this->edited_at = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON);
|
||||
|
||||
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
|
||||
$this->in_reply_to_id = (string)$item['thr-parent-id'];
|
||||
$this->in_reply_to_id = (string) $item['thr-parent-id'];
|
||||
$this->in_reply_to_status = $in_reply;
|
||||
$this->in_reply_to_account_id = (string)$item['parent-author-id'];
|
||||
$this->in_reply_to_account_id = (string) $item['parent-author-id'];
|
||||
}
|
||||
|
||||
$this->sensitive = $sensitive;
|
||||
|
|
@ -116,8 +116,7 @@ class Status extends BaseDataTransferObject
|
|||
|
||||
$languages = json_decode($item['language'] ?? '', true);
|
||||
if (is_array($languages)) {
|
||||
reset($languages);
|
||||
$this->language = key($languages);
|
||||
$this->language = array_key_first($languages);
|
||||
} else {
|
||||
$this->language = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ class Image
|
|||
return;
|
||||
}
|
||||
|
||||
$ort = isset($exif['IFD0']['Orientation']) ? $exif['IFD0']['Orientation'] : 1;
|
||||
$ort = $exif['IFD0']['Orientation'] ?? 1;
|
||||
|
||||
switch ($ort) {
|
||||
case 1: // nothing
|
||||
|
|
|
|||
|
|
@ -1100,7 +1100,7 @@ class Post
|
|||
$profile = Contact::getByURL($term['url'], false, ['addr', 'contact-type']);
|
||||
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, (string) $profile['addr'])
|
||||
) {
|
||||
$text .= '@' . $profile['addr'] . ' ';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ use Friendica\Util\XML;
|
|||
*/
|
||||
class Transmitter
|
||||
{
|
||||
const CACHEKEY_FEATURED = 'transmitter:getFeatured:';
|
||||
const CACHEKEY_CONTACTS = 'transmitter:getContacts:';
|
||||
public const CACHEKEY_FEATURED = 'transmitter:getFeatured:';
|
||||
public const CACHEKEY_CONTACTS = 'transmitter:getContacts:';
|
||||
|
||||
/**
|
||||
* Add relay servers to the list of inboxes
|
||||
|
|
@ -248,7 +248,7 @@ class Transmitter
|
|||
|
||||
$condition = [
|
||||
"`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
||||
$owner_cid, Post\Collection::FEATURED
|
||||
$owner_cid, Post\Collection::FEATURED,
|
||||
];
|
||||
|
||||
$condition = DBA::mergeConditions($condition, [
|
||||
|
|
@ -260,7 +260,7 @@ class Transmitter
|
|||
'parent-network' => Protocol::FEDERATED,
|
||||
'origin' => true,
|
||||
'deleted' => false,
|
||||
'visible' => true
|
||||
'visible' => true,
|
||||
]);
|
||||
|
||||
$count = Post::count($condition);
|
||||
|
|
@ -315,10 +315,10 @@ class Transmitter
|
|||
public static function getService(): array
|
||||
{
|
||||
return [
|
||||
'id' => (string)DI::baseUrl() . '/friendica',
|
||||
'id' => (string) DI::baseUrl() . '/friendica',
|
||||
'type' => 'Application',
|
||||
'name' => App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION,
|
||||
'url' => (string)DI::baseUrl(),
|
||||
'url' => (string) DI::baseUrl(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ class Transmitter
|
|||
if ($full && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) {
|
||||
$data['vcard:hasAddress'] = [
|
||||
'@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'],
|
||||
'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality']
|
||||
'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -386,11 +386,11 @@ class Transmitter
|
|||
|
||||
$data['url'] = $owner['url'];
|
||||
$data['manuallyApprovesFollowers'] = in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
|
||||
$data['discoverable'] = (bool)$owner['net-publish'] && $full;
|
||||
$data['discoverable'] = (bool) $owner['net-publish'] && $full;
|
||||
$data['publicKey'] = [
|
||||
'id' => $owner['url'] . '#main-key',
|
||||
'owner' => $owner['url'],
|
||||
'publicKeyPem' => $owner['pubkey']
|
||||
'publicKeyPem' => $owner['pubkey'],
|
||||
];
|
||||
$data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
|
||||
if ($full && $uid != 0) {
|
||||
|
|
@ -422,7 +422,7 @@ class Transmitter
|
|||
$custom_fields[] = [
|
||||
'type' => 'PropertyValue',
|
||||
'name' => $profile_field->label,
|
||||
'value' => BBCode::convertForUriId($owner['uri-id'], $profile_field->value)
|
||||
'value' => BBCode::convertForUriId($owner['uri-id'], $profile_field->value),
|
||||
];
|
||||
};
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ class Transmitter
|
|||
'name' => $contact['name'],
|
||||
'icon' => ['type' => 'Image', 'url' => Contact::getAvatarUrlForId($cid, '', $contact['updated'])],
|
||||
'image' => ['type' => 'Image', 'url' => Contact::getHeaderUrlForId($cid, '', $contact['updated'])],
|
||||
'manuallyApprovesFollowers' => (bool)$contact['manually-approve'],
|
||||
'manuallyApprovesFollowers' => (bool) $contact['manually-approve'],
|
||||
'discoverable' => !$contact['unsearchable'],
|
||||
];
|
||||
|
||||
|
|
@ -1311,7 +1311,7 @@ class Transmitter
|
|||
*/
|
||||
public static function createCachedActivityFromItem(int $item_id, bool $force = false, bool $object_mode = false, $announce_activity = false)
|
||||
{
|
||||
$cachekey = 'APDelivery:createActivity:' . $item_id . ':' . (int)$object_mode . ':' . (int)$announce_activity;
|
||||
$cachekey = 'APDelivery:createActivity:' . $item_id . ':' . (int) $object_mode . ':' . (int) $announce_activity;
|
||||
|
||||
if (!$force) {
|
||||
$data = DI::cache()->get($cachekey);
|
||||
|
|
@ -1701,7 +1701,7 @@ class Transmitter
|
|||
// otherwise we just return the link
|
||||
return '[url]' . $match[1] . '[/url]';
|
||||
},
|
||||
$text
|
||||
$text,
|
||||
);
|
||||
|
||||
// Remove all pictures
|
||||
|
|
@ -1834,7 +1834,7 @@ class Transmitter
|
|||
} else {
|
||||
$data['attributedTo'] = $item['author-link'];
|
||||
}
|
||||
$data['sensitive'] = (bool)$item['sensitive'];
|
||||
$data['sensitive'] = (bool) $item['sensitive'];
|
||||
|
||||
if (!empty($item['context']) && ($item['context'] != './')) {
|
||||
$data['context'] = $item['context'];
|
||||
|
|
@ -1955,8 +1955,8 @@ class Transmitter
|
|||
if ($item['private'] != Item::PRIVATE) {
|
||||
$data['interactionPolicy'] = [
|
||||
'canQuote' => [
|
||||
'automaticApproval' => [ActivityPub::PUBLIC_COLLECTION]
|
||||
]
|
||||
'automaticApproval' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -1966,7 +1966,7 @@ class Transmitter
|
|||
$data['replies'] = [
|
||||
'id' => $item['uri'] . '/replies',
|
||||
'type' => 'Collection',
|
||||
'totalItems' => Post::countPosts(['thr-parent-id' => $item['uri-id'], 'gravity' => Item::GRAVITY_COMMENT, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]])
|
||||
'totalItems' => Post::countPosts(['thr-parent-id' => $item['uri-id'], 'gravity' => Item::GRAVITY_COMMENT, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]]),
|
||||
];
|
||||
|
||||
if (empty($data['location']) && (!empty($item['coord']) || !empty($item['location']))) {
|
||||
|
|
@ -2026,9 +2026,9 @@ class Transmitter
|
|||
|
||||
$activity['diaspora:guid'] = $item['guid'];
|
||||
$activity['actor'] = $item['author-link'];
|
||||
$activity['target'] = (string)$target->id;
|
||||
$activity['target'] = (string) $target->id;
|
||||
$activity['summary'] = BBCode::toPlaintext($item['body']);
|
||||
$activity['object'] = ['id' => (string)$object->id, 'type' => 'tag', 'name' => (string)$object->title, 'content' => (string)$object->content];
|
||||
$activity['object'] = ['id' => (string) $object->id, 'type' => 'tag', 'name' => (string) $object->title, 'content' => (string) $object->content];
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
|
@ -2159,7 +2159,7 @@ class Transmitter
|
|||
'content' => $suggestion->note,
|
||||
'instrument' => self::getService(),
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
'cc' => [],
|
||||
];
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
|
|
@ -2187,7 +2187,7 @@ class Transmitter
|
|||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'instrument' => self::getService(),
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
'cc' => [],
|
||||
];
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
|
|
@ -2220,7 +2220,7 @@ class Transmitter
|
|||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'instrument' => self::getService(),
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
'cc' => [],
|
||||
];
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
|
|
@ -2252,7 +2252,7 @@ class Transmitter
|
|||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['followers']],
|
||||
'cc' => []
|
||||
'cc' => [],
|
||||
];
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
|
|
@ -2340,7 +2340,7 @@ class Transmitter
|
|||
|
||||
$condition = [
|
||||
'verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
|
||||
'author-id' => Contact::getPublicIdByUserId($uid)
|
||||
'author-id' => Contact::getPublicIdByUserId($uid),
|
||||
];
|
||||
if (Post::exists($condition)) {
|
||||
DI::logger()->info('Follow for ' . $object . ' for user ' . $uid . ' does already exist.');
|
||||
|
|
@ -2398,7 +2398,7 @@ class Transmitter
|
|||
'id' => $id,
|
||||
'type' => 'Follow',
|
||||
'actor' => $profile['url'],
|
||||
'object' => $owner['url']
|
||||
'object' => $owner['url'],
|
||||
],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
|
|
@ -2437,7 +2437,7 @@ class Transmitter
|
|||
'id' => $objectId,
|
||||
'type' => 'Follow',
|
||||
'actor' => $profile['url'],
|
||||
'object' => $owner['url']
|
||||
'object' => $owner['url'],
|
||||
],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
|
|
@ -2484,7 +2484,7 @@ class Transmitter
|
|||
'id' => $object_id,
|
||||
'type' => 'Follow',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $profile['url']
|
||||
'object' => $profile['url'],
|
||||
],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
|
|
@ -2531,7 +2531,7 @@ class Transmitter
|
|||
'id' => $object_id,
|
||||
'type' => 'Block',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $profile['url']
|
||||
'object' => $profile['url'],
|
||||
],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
|
|
@ -2607,8 +2607,8 @@ class Transmitter
|
|||
if (
|
||||
!empty($profile['addr'])
|
||||
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY
|
||||
&& !strstr($body, $profile['addr'])
|
||||
&& !strstr($body, $tag['url'])
|
||||
&& !strstr($body, (string) $profile['addr'])
|
||||
&& !strstr($body, (string) $tag['url'])
|
||||
&& $tag['url'] !== $authorLink
|
||||
) {
|
||||
$mentions[] = '@[url=' . $tag['url'] . ']' . $profile['nick'] . '[/url]';
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class DFRN
|
|||
// These values aren't sent when sending from the queue.
|
||||
/// @todo Check if we can set these values from the queue or if they are needed at all.
|
||||
$item['entry:comment-allow'] = ($item['entry:comment-allow'] ?? '') ?: true;
|
||||
$item['entry:cid'] = $item['entry:cid'] ?? 0;
|
||||
$item['entry:cid'] ??= 0;
|
||||
|
||||
$entry = self::entry($doc, 'text', $item, $owner, $item['entry:comment-allow'], $item['entry:cid']);
|
||||
if (isset($entry)) {
|
||||
|
|
|
|||
|
|
@ -3472,7 +3472,7 @@ class Diaspora
|
|||
$profile = Contact::getByURL($profile_url, false, ['addr', 'name']);
|
||||
if (
|
||||
!empty($profile['addr'])
|
||||
&& !strstr($body, $profile['addr'])
|
||||
&& !strstr($body, (string) $profile['addr'])
|
||||
&& !strstr($body, $profile_url)
|
||||
) {
|
||||
$body = '@[url=' . $profile_url . ']' . $profile['name'] . '[/url] ' . $body;
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ class Feed
|
|||
if (!$dryRun) {
|
||||
$condition = [
|
||||
"`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
||||
$importer['uid'], $item['uri'], Protocol::FEED, Protocol::DFRN
|
||||
$importer['uid'], $item['uri'], Protocol::FEED, Protocol::DFRN,
|
||||
];
|
||||
$previous = Post::selectFirst(['id', 'created'], $condition);
|
||||
if (DBA::isResult($previous)) {
|
||||
|
|
@ -544,7 +544,7 @@ class Feed
|
|||
if (in_array($attribute->name, ['url', 'href'])) {
|
||||
$href = $attribute->textContent;
|
||||
} elseif ($attribute->name == 'length') {
|
||||
$length = (int)$attribute->textContent;
|
||||
$length = (int) $attribute->textContent;
|
||||
} elseif ($attribute->name == 'type') {
|
||||
$type = $attribute->textContent;
|
||||
}
|
||||
|
|
@ -665,7 +665,7 @@ class Feed
|
|||
$item['plink'],
|
||||
false,
|
||||
$fetch_further_information == LocalRelationship::FFI_BOTH,
|
||||
$contact['ffi_keyword_denylist'] ?? ''
|
||||
$contact['ffi_keyword_denylist'] ?? '',
|
||||
);
|
||||
|
||||
if (!empty($data)) {
|
||||
|
|
@ -712,7 +712,7 @@ class Feed
|
|||
DI::logger()->info('Stored feed', ['item' => $item]);
|
||||
|
||||
$notify = Item::isRemoteSelf($contact, $item);
|
||||
$item['wall'] = (bool)$notify;
|
||||
$item['wall'] = (bool) $notify;
|
||||
|
||||
// Distributed items should have a well-formatted URI.
|
||||
// Additionally, we have to avoid conflicts with identical URI between imported feeds and these items.
|
||||
|
|
@ -734,7 +734,7 @@ class Feed
|
|||
} else {
|
||||
$postings[] = [
|
||||
'item' => $item, 'notify' => $notify,
|
||||
'taglist' => $taglist, 'attachments' => $attachments
|
||||
'taglist' => $taglist, 'attachments' => $attachments,
|
||||
];
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1027,7 +1027,7 @@ class Feed
|
|||
$owner['uid'], $check_date, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
|
||||
Item::GRAVITY_ACTIVITY, Activity::ANNOUNCE,
|
||||
Item::PRIVATE, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA,
|
||||
$authorid
|
||||
$authorid,
|
||||
];
|
||||
|
||||
if ($filter === 'comments') {
|
||||
|
|
@ -1208,8 +1208,8 @@ class Feed
|
|||
'',
|
||||
[
|
||||
'rel' => 'alternate', 'type' => 'text/html',
|
||||
'href' => DI::baseUrl() . '/display/' . $item['guid']
|
||||
]
|
||||
'href' => DI::baseUrl() . '/display/' . $item['guid'],
|
||||
],
|
||||
);
|
||||
|
||||
XML::addElement($doc, $entry, 'published', DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
|
||||
|
|
@ -1250,13 +1250,13 @@ class Feed
|
|||
if (isset($parent_plink)) {
|
||||
$attributes = [
|
||||
'ref' => $item['thr-parent'],
|
||||
'href' => $parent_plink
|
||||
'href' => $parent_plink,
|
||||
];
|
||||
XML::addElement($doc, $entry, 'thr:in-reply-to', '', $attributes);
|
||||
|
||||
$attributes = [
|
||||
'rel' => 'related',
|
||||
'href' => $parent_plink
|
||||
'href' => $parent_plink,
|
||||
];
|
||||
XML::addElement($doc, $entry, 'link', '', $attributes);
|
||||
}
|
||||
|
|
@ -1410,9 +1410,9 @@ class Feed
|
|||
if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) {
|
||||
$entry->setAttribute('xmlns:activity', ActivityNamespace::ACTIVITY);
|
||||
|
||||
$contact = Contact::getByURL($item['author-link']) ?: $owner;
|
||||
$contact['nickname'] = $contact['nickname'] ?? $contact['nick'];
|
||||
$author = self::addAuthor($doc, $contact);
|
||||
$contact = Contact::getByURL($item['author-link']) ?: $owner;
|
||||
$contact['nickname'] ??= $contact['nick'];
|
||||
$author = self::addAuthor($doc, $contact);
|
||||
$entry->appendChild($author);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@ class OAuthRequest
|
|||
private $http_url;
|
||||
// for debug purposes
|
||||
public $base_string;
|
||||
public static $version = '1.0';
|
||||
public static $version = '1.0';
|
||||
public static $POST_INPUT = 'php://input';
|
||||
|
||||
function __construct($http_method, $http_url, $parameters = null)
|
||||
public function __construct($http_method, $http_url, $parameters = null)
|
||||
{
|
||||
@$parameters or $parameters = [];
|
||||
$parameters = array_merge(OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
|
||||
$this->parameters = $parameters;
|
||||
$this->http_method = $http_method;
|
||||
$this->http_url = $http_url;
|
||||
$parameters = array_merge(OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
|
||||
$this->parameters = $parameters;
|
||||
$this->http_method = $http_method;
|
||||
$this->http_url = $http_url;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -43,11 +43,11 @@ class OAuthRequest
|
|||
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
|
||||
? 'http'
|
||||
: 'https';
|
||||
@$http_url or $http_url = $scheme .
|
||||
'://' . $_SERVER['HTTP_HOST'] .
|
||||
':' .
|
||||
$_SERVER['SERVER_PORT'] .
|
||||
$_SERVER['REQUEST_URI'];
|
||||
@$http_url or $http_url = $scheme
|
||||
. '://' . $_SERVER['HTTP_HOST']
|
||||
. ':'
|
||||
. $_SERVER['SERVER_PORT']
|
||||
. $_SERVER['REQUEST_URI'];
|
||||
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
// We weren't handed any parameters, so let's find the ones relevant to
|
||||
|
|
@ -67,11 +67,11 @@ class OAuthRequest
|
|||
$http_method == "POST"
|
||||
&& @strstr(
|
||||
$request_headers["Content-Type"],
|
||||
"application/x-www-form-urlencoded"
|
||||
"application/x-www-form-urlencoded",
|
||||
)
|
||||
) {
|
||||
$post_data = OAuthUtil::parse_parameters(
|
||||
file_get_contents(self::$POST_INPUT)
|
||||
$post_data = OAuthUtil::parse_parameters(
|
||||
file_get_contents(self::$POST_INPUT),
|
||||
);
|
||||
$parameters = array_merge($parameters, $post_data);
|
||||
}
|
||||
|
|
@ -80,14 +80,14 @@ class OAuthRequest
|
|||
// and add those overriding any duplicates from GET or POST
|
||||
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
|
||||
$header_parameters = OAuthUtil::split_header(
|
||||
$request_headers['Authorization']
|
||||
$request_headers['Authorization'],
|
||||
);
|
||||
$parameters = array_merge($parameters, $header_parameters);
|
||||
$parameters = array_merge($parameters, $header_parameters);
|
||||
}
|
||||
}
|
||||
// fix for friendica redirect system
|
||||
|
||||
$http_url = substr($http_url, 0, strpos($http_url, $parameters['pagename']) + strlen($parameters['pagename']));
|
||||
$http_url = substr($http_url, 0, strpos($http_url, (string) $parameters['pagename']) + strlen($parameters['pagename']));
|
||||
unset($parameters['pagename']);
|
||||
|
||||
return new OAuthRequest($http_method, $http_url, $parameters);
|
||||
|
|
@ -107,14 +107,15 @@ class OAuthRequest
|
|||
public static function from_consumer_and_token(OAuthConsumer $consumer, $http_method, $http_url, array $parameters = null, OAuthToken $token = null)
|
||||
{
|
||||
@$parameters or $parameters = [];
|
||||
$defaults = [
|
||||
$defaults = [
|
||||
"oauth_version" => OAuthRequest::$version,
|
||||
"oauth_nonce" => OAuthRequest::generate_nonce(),
|
||||
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
|
||||
"oauth_consumer_key" => $consumer->key,
|
||||
];
|
||||
if ($token)
|
||||
if ($token) {
|
||||
$defaults['oauth_token'] = $token->key;
|
||||
}
|
||||
|
||||
$parameters = array_merge($defaults, $parameters);
|
||||
|
||||
|
|
@ -139,7 +140,7 @@ class OAuthRequest
|
|||
|
||||
public function get_parameter($name)
|
||||
{
|
||||
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
|
||||
return $this->parameters[$name] ?? null;
|
||||
}
|
||||
|
||||
public function get_parameters()
|
||||
|
|
@ -244,10 +245,11 @@ class OAuthRequest
|
|||
*/
|
||||
public function to_postdata(bool $raw = false)
|
||||
{
|
||||
if ($raw)
|
||||
if ($raw) {
|
||||
return $this->parameters;
|
||||
else
|
||||
} else {
|
||||
return OAuthUtil::build_http_query($this->parameters);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -264,19 +266,22 @@ class OAuthRequest
|
|||
if ($realm) {
|
||||
$out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
|
||||
$first = false;
|
||||
} else
|
||||
} else {
|
||||
$out = 'Authorization: OAuth';
|
||||
}
|
||||
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
if (substr($k, 0, 5) != "oauth") continue;
|
||||
if (substr($k, 0, 5) != "oauth") {
|
||||
continue;
|
||||
}
|
||||
if (is_array($v)) {
|
||||
throw new OAuthException('Arrays not supported in headers');
|
||||
}
|
||||
$out .= ($first) ? ' ' : ',';
|
||||
$out .= OAuthUtil::urlencode_rfc3986($k) .
|
||||
'="' .
|
||||
OAuthUtil::urlencode_rfc3986($v) .
|
||||
'"';
|
||||
$out .= ($first) ? ' ' : ',';
|
||||
$out .= OAuthUtil::urlencode_rfc3986($k)
|
||||
. '="'
|
||||
. OAuthUtil::urlencode_rfc3986($v)
|
||||
. '"';
|
||||
$first = false;
|
||||
}
|
||||
return $out;
|
||||
|
|
@ -293,7 +298,7 @@ class OAuthRequest
|
|||
$this->set_parameter(
|
||||
"oauth_signature_method",
|
||||
$signature_method->get_name(),
|
||||
false
|
||||
false,
|
||||
);
|
||||
$signature = $this->build_signature($signature_method, $consumer, $token);
|
||||
$this->set_parameter("oauth_signature", $signature, false);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use Psr\Log\LoggerInterface;
|
|||
abstract class MailBuilder
|
||||
{
|
||||
/** @var string The default email banner in case nothing else is defined */
|
||||
const DEFAULT_EMAIL_BANNER = 'images/friendica-32.png';
|
||||
public const DEFAULT_EMAIL_BANNER = 'images/friendica-32.png';
|
||||
|
||||
/** @var L10n */
|
||||
protected $l10n;
|
||||
|
|
@ -199,7 +199,7 @@ abstract class MailBuilder
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setHeader(string $name, string $value)
|
||||
public function setHeader(string $name, string $value)
|
||||
{
|
||||
$this->headers[$name] = [$value];
|
||||
|
||||
|
|
@ -218,8 +218,8 @@ abstract class MailBuilder
|
|||
*/
|
||||
public function build(bool $raw = false)
|
||||
{
|
||||
if ((empty($this->recipientAddress)) &&
|
||||
!empty($this->recipientUid)) {
|
||||
if ((empty($this->recipientAddress))
|
||||
&& !empty($this->recipientUid)) {
|
||||
$user = User::getById($this->recipientUid, ['email']);
|
||||
|
||||
if (!empty($user['email'])) {
|
||||
|
|
@ -235,7 +235,7 @@ abstract class MailBuilder
|
|||
throw new UnprocessableEntityException('Sender address or name is missing.');
|
||||
}
|
||||
|
||||
$this->senderNoReply = $this->senderNoReply ?? $this->senderAddress;
|
||||
$this->senderNoReply ??= $this->senderAddress;
|
||||
|
||||
$msgHtml = $this->getHtmlMessage() ?? '';
|
||||
|
||||
|
|
@ -247,8 +247,11 @@ abstract class MailBuilder
|
|||
'$product' => App::PLATFORM,
|
||||
'$htmlversion' => $msgHtml,
|
||||
'$sitename' => $this->config->get('config', 'sitename'),
|
||||
'$banner' => $this->config->get('system', 'email_banner',
|
||||
$this->baseUrl . DIRECTORY_SEPARATOR . self::DEFAULT_EMAIL_BANNER),
|
||||
'$banner' => $this->config->get(
|
||||
'system',
|
||||
'email_banner',
|
||||
$this->baseUrl . DIRECTORY_SEPARATOR . self::DEFAULT_EMAIL_BANNER,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -261,6 +264,7 @@ abstract class MailBuilder
|
|||
$msgHtml,
|
||||
$this->getPlaintextMessage() ?? '',
|
||||
$this->headers,
|
||||
$this->recipientUid ?? null);
|
||||
$this->recipientUid ?? null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class Emailer
|
|||
$this->config,
|
||||
$this->logger,
|
||||
$this->getSiteEmailAddress(),
|
||||
$this->getSiteEmailName()
|
||||
$this->getSiteEmailName(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ class Emailer
|
|||
$this->config,
|
||||
$this->logger,
|
||||
$this->getSiteEmailAddress(),
|
||||
$this->getSiteEmailName()
|
||||
$this->getSiteEmailName(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -158,10 +158,10 @@ class Emailer
|
|||
$messageSubject = Email::encodeHeader(html_entity_decode($email->getSubject(), ENT_QUOTES, 'UTF-8'), 'UTF-8');
|
||||
|
||||
// generate a mime boundary
|
||||
$mimeBoundary = rand(0, 9) . '-'
|
||||
. rand(100000000, 999999999) . '-'
|
||||
. rand(100000000, 999999999) . '=:'
|
||||
. rand(10000, 99999);
|
||||
$mimeBoundary = random_int(0, 9) . '-'
|
||||
. random_int(100000000, 999999999) . '-'
|
||||
. random_int(100000000, 999999999) . '=:'
|
||||
. random_int(10000, 99999);
|
||||
|
||||
$messageHeader = $email->getAdditionalMailHeaderString();
|
||||
if ($countMessageId === 0) {
|
||||
|
|
@ -169,29 +169,29 @@ class Emailer
|
|||
}
|
||||
|
||||
// generate a multipart/alternative message header
|
||||
$messageHeader .=
|
||||
"From: $fromName <{$fromAddress}>\r\n" .
|
||||
"Reply-To: $fromName <{$replyTo}>\r\n" .
|
||||
"MIME-Version: 1.0\r\n" .
|
||||
"Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
|
||||
$messageHeader
|
||||
.= "From: $fromName <{$fromAddress}>\r\n"
|
||||
. "Reply-To: $fromName <{$replyTo}>\r\n"
|
||||
. "MIME-Version: 1.0\r\n"
|
||||
. "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
|
||||
|
||||
// assemble the final multipart message body with the text and html types included
|
||||
$textBody = chunk_split(base64_encode($email->getMessage(true)));
|
||||
$htmlBody = chunk_split(base64_encode($email->getMessage()));
|
||||
$multipartMessageBody = "--" . $mimeBoundary . "\n" . // plain text section
|
||||
"Content-Type: text/plain; charset=UTF-8\n" .
|
||||
"Content-Transfer-Encoding: base64\n\n" .
|
||||
$textBody . "\n";
|
||||
$multipartMessageBody = "--" . $mimeBoundary . "\n" // plain text section
|
||||
. "Content-Type: text/plain; charset=UTF-8\n"
|
||||
. "Content-Transfer-Encoding: base64\n\n"
|
||||
. $textBody . "\n";
|
||||
|
||||
if (!$email_textonly && !is_null($email->getMessage())) {
|
||||
$multipartMessageBody .=
|
||||
"--" . $mimeBoundary . "\n" . // text/html section
|
||||
"Content-Type: text/html; charset=UTF-8\n" .
|
||||
"Content-Transfer-Encoding: base64\n\n" .
|
||||
$htmlBody . "\n";
|
||||
$multipartMessageBody
|
||||
.= "--" . $mimeBoundary . "\n" // text/html section
|
||||
. "Content-Type: text/html; charset=UTF-8\n"
|
||||
. "Content-Transfer-Encoding: base64\n\n"
|
||||
. $htmlBody . "\n";
|
||||
}
|
||||
$multipartMessageBody .=
|
||||
"--" . $mimeBoundary . "--\n"; // message ending
|
||||
$multipartMessageBody
|
||||
.= "--" . $mimeBoundary . "--\n"; // message ending
|
||||
|
||||
if ($this->config->get('system', 'sendmail_params', true)) {
|
||||
$sendmail_params = '-f ' . $fromAddress;
|
||||
|
|
@ -220,7 +220,7 @@ class Emailer
|
|||
$hookdata['subject'],
|
||||
$hookdata['body'],
|
||||
$hookdata['headers'],
|
||||
$hookdata['parameters']
|
||||
$hookdata['parameters'],
|
||||
);
|
||||
|
||||
$this->logger->debug('Email message header', ['To' => $email->getToAddress(), 'messageHeader' => $messageHeader, 'return' => ($res) ? 'true' : 'false']);
|
||||
|
|
|
|||
|
|
@ -32,18 +32,18 @@ use Friendica\Model\Post;
|
|||
*/
|
||||
class ParseUrl
|
||||
{
|
||||
const DEFAULT_EXPIRATION_FAILURE = 'now + 1 day';
|
||||
const DEFAULT_EXPIRATION_SUCCESS = 'now + 3 months';
|
||||
public const DEFAULT_EXPIRATION_FAILURE = 'now + 1 day';
|
||||
public const DEFAULT_EXPIRATION_SUCCESS = 'now + 3 months';
|
||||
|
||||
/**
|
||||
* Maximum number of characters for the description
|
||||
*/
|
||||
const MAX_DESC_COUNT = 250;
|
||||
public const MAX_DESC_COUNT = 250;
|
||||
|
||||
/**
|
||||
* Minimum number of characters for the description
|
||||
*/
|
||||
const MIN_DESC_COUNT = 100;
|
||||
public const MIN_DESC_COUNT = 100;
|
||||
|
||||
/**
|
||||
* Fetch the content type of the given url
|
||||
|
|
@ -147,7 +147,7 @@ class ParseUrl
|
|||
'created' => DateTimeFormat::utcNow(),
|
||||
'expires' => $expires,
|
||||
],
|
||||
Database::INSERT_UPDATE
|
||||
Database::INSERT_UPDATE,
|
||||
);
|
||||
|
||||
return $data;
|
||||
|
|
@ -268,7 +268,7 @@ class ParseUrl
|
|||
|
||||
if ($cacheControlHeader = $curlResult->getHeader('Cache-Control')[0] ?? '') {
|
||||
if (preg_match('/max-age=([0-9]+)/i', $cacheControlHeader, $matches)) {
|
||||
$maxAge = max(86400, (int)array_pop($matches));
|
||||
$maxAge = max(86400, (int) array_pop($matches));
|
||||
|
||||
$siteinfo['expires'] = DateTimeFormat::utc("now + $maxAge seconds");
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ class ParseUrl
|
|||
if (isset($mediaType->parameters['charset'])) {
|
||||
$charset = $mediaType->parameters['charset'];
|
||||
}
|
||||
} catch(\InvalidArgumentException $e) {
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
}
|
||||
|
||||
$siteinfo['charset'] = $charset;
|
||||
|
|
@ -546,7 +546,7 @@ class ParseUrl
|
|||
}
|
||||
|
||||
if (!empty($siteinfo['image'])) {
|
||||
$siteinfo['images'] = $siteinfo['images'] ?? [];
|
||||
$siteinfo['images'] ??= [];
|
||||
array_unshift($siteinfo['images'], ['url' => $siteinfo['image']]);
|
||||
unset($siteinfo['image']);
|
||||
}
|
||||
|
|
@ -1394,7 +1394,7 @@ class ParseUrl
|
|||
DI::logger()->debug('Found oEmbed JSON from Embera', ['url' => $url]);
|
||||
}
|
||||
|
||||
if (!isset($data['type']) || !isset($data['provider_url'])) {
|
||||
if (!isset($data['type']) || !isset($data['provider_url'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,17 +96,17 @@ class Strings
|
|||
'v',
|
||||
'w', 'wh',
|
||||
'x',
|
||||
'z', 'zh'
|
||||
'z', 'zh',
|
||||
];
|
||||
|
||||
$midcons = [
|
||||
'ck', 'ct', 'gn', 'ld', 'lf', 'lm', 'lt', 'mb', 'mm', 'mn', 'mp',
|
||||
'nd', 'ng', 'nk', 'nt', 'rn', 'rp', 'rt'
|
||||
'nd', 'ng', 'nk', 'nt', 'rn', 'rp', 'rt',
|
||||
];
|
||||
|
||||
$noend = [
|
||||
'bl', 'br', 'cl', 'cr', 'dr', 'fl', 'fr', 'gl', 'gr',
|
||||
'kh', 'kl', 'kr', 'mn', 'pl', 'pr', 'rh', 'tr', 'qu', 'wh', 'q'
|
||||
'kh', 'kl', 'kr', 'mn', 'pl', 'pr', 'rh', 'tr', 'qu', 'wh', 'q',
|
||||
];
|
||||
|
||||
$start = mt_rand(0, 2);
|
||||
|
|
@ -444,7 +444,7 @@ class Strings
|
|||
{
|
||||
$string_length = mb_strlen($string);
|
||||
|
||||
$length = $length ?? $string_length;
|
||||
$length ??= $string_length;
|
||||
|
||||
if ($start < 0) {
|
||||
$start = max(0, $string_length + $start);
|
||||
|
|
@ -494,7 +494,7 @@ class Strings
|
|||
|
||||
return $return;
|
||||
},
|
||||
$text
|
||||
$text,
|
||||
);
|
||||
|
||||
if (is_null($return)) {
|
||||
|
|
@ -513,7 +513,7 @@ class Strings
|
|||
}
|
||||
return $return;
|
||||
},
|
||||
$text
|
||||
$text,
|
||||
);
|
||||
|
||||
return $text;
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ class Temporal
|
|||
return DI::l10n()->t('never');
|
||||
}
|
||||
|
||||
$clock = $clock ?? new SystemClock();
|
||||
$clock ??= new SystemClock();
|
||||
|
||||
$localtime = $posted_date . ' UTC';
|
||||
$abs = strtotime($localtime);
|
||||
|
|
|
|||
|
|
@ -303,8 +303,8 @@ class XML
|
|||
$tag = $data['tag'];
|
||||
$type = $data['type'];
|
||||
$level = $data['level'];
|
||||
$attributes = isset($data['attributes']) ? $data['attributes'] : null;
|
||||
$value = isset($data['value']) ? $data['value'] : null;
|
||||
$attributes = $data['attributes'] ?? null;
|
||||
$value = $data['value'] ?? null;
|
||||
|
||||
$result = [];
|
||||
$attributes_data = [];
|
||||
|
|
@ -341,7 +341,7 @@ class XML
|
|||
if (!is_array($current) || (!in_array($tag, array_keys($current)))) { // Insert New tag
|
||||
$current[$tag] = $result;
|
||||
if ($attributes_data) {
|
||||
$current[$tag. '_attr'] = $attributes_data;
|
||||
$current[$tag . '_attr'] = $attributes_data;
|
||||
}
|
||||
$repeated_tag_index[$tag . '_' . $level] = 1;
|
||||
|
||||
|
|
@ -355,9 +355,9 @@ class XML
|
|||
$current[$tag] = [$current[$tag], $result]; // This will combine the existing item and the new item together to make an array
|
||||
$repeated_tag_index[$tag . '_' . $level] = 2;
|
||||
|
||||
if (isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
|
||||
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
|
||||
unset($current[$tag.'_attr']);
|
||||
if (isset($current[$tag . '_attr'])) { // The attribute of the last(0th) tag must be moved as well
|
||||
$current[$tag]['0_attr'] = $current[$tag . '_attr'];
|
||||
unset($current[$tag . '_attr']);
|
||||
}
|
||||
}
|
||||
$last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
|
||||
|
|
@ -369,7 +369,7 @@ class XML
|
|||
$current[$tag] = $result;
|
||||
$repeated_tag_index[$tag . '_' . $level] = 1;
|
||||
if ($priority == 'tag' and $attributes_data) {
|
||||
$current[$tag. '_attr'] = $attributes_data;
|
||||
$current[$tag . '_attr'] = $attributes_data;
|
||||
}
|
||||
} else { // If taken, put all things inside a list(array)
|
||||
if (isset($current[$tag][0]) and is_array($current[$tag])) { // If it is already an array...
|
||||
|
|
@ -385,10 +385,10 @@ class XML
|
|||
$current[$tag] = [$current[$tag], $result]; //...Make it an array using the existing value and the new value
|
||||
$repeated_tag_index[$tag . '_' . $level] = 1;
|
||||
if ($priority == 'tag' and $get_attributes) {
|
||||
if (isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
|
||||
if (isset($current[$tag . '_attr'])) { // The attribute of the last(0th) tag must be moved as well
|
||||
|
||||
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
|
||||
unset($current[$tag.'_attr']);
|
||||
$current[$tag]['0_attr'] = $current[$tag . '_attr'];
|
||||
unset($current[$tag . '_attr']);
|
||||
}
|
||||
|
||||
if ($attributes_data) {
|
||||
|
|
|
|||
|
|
@ -657,9 +657,9 @@ return [
|
|||
'/stats/caching' => [Module\StatsCaching::class, [R::GET]],
|
||||
|
||||
'/network' => [
|
||||
'[/{content}]' => [Module\Conversation\Network::class, [R::GET]],
|
||||
'/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d-\d\d-\d\d}]' => [Module\Conversation\Network::class, [R::GET]],
|
||||
'/circle/{circle_id:\d+}' => [Module\Conversation\Network::class, [R::GET]],
|
||||
'[/{content}]' => [Module\Conversation\Network::class, [R::GET]],
|
||||
'/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d\-\d\d-\d\d}]' => [Module\Conversation\Network::class, [R::GET]],
|
||||
'/circle/{circle_id:\d+}' => [Module\Conversation\Network::class, [R::GET]],
|
||||
],
|
||||
|
||||
'/randprof' => [Module\RandomProfile::class, [R::GET]],
|
||||
|
|
@ -672,10 +672,10 @@ return [
|
|||
'/tos' => [Module\Tos::class, [R::GET]],
|
||||
|
||||
'/ping_network' => [
|
||||
'[/]' => [Module\Ping\Network::class, [R::GET]],
|
||||
'/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d-\d\d-\d\d}]' => [Module\Ping\Network::class, [R::GET]],
|
||||
'/group/{contact_id:\d+}' => [Module\Ping\Network::class, [R::GET]],
|
||||
'/circle/{circle_id:\d+}' => [Module\Ping\Network::class, [R::GET]],
|
||||
'[/]' => [Module\Ping\Network::class, [R::GET]],
|
||||
'/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d\-\d\d-\d\d}]' => [Module\Ping\Network::class, [R::GET]],
|
||||
'/group/{contact_id:\d+}' => [Module\Ping\Network::class, [R::GET]],
|
||||
'/circle/{circle_id:\d+}' => [Module\Ping\Network::class, [R::GET]],
|
||||
],
|
||||
|
||||
'/update_channel[/{content}]' => [Module\Update\Channel::class, [R::GET]],
|
||||
|
|
@ -686,10 +686,10 @@ return [
|
|||
'/update_display' => [Module\Update\Display::class, [R::GET]],
|
||||
|
||||
'/update_network' => [
|
||||
'[/]' => [Module\Update\Network::class, [R::GET]],
|
||||
'/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d-\d\d-\d\d}]' => [Module\Update\Network::class, [R::GET]],
|
||||
'/group/{contact_id:\d+}' => [Module\Update\Network::class, [R::GET]],
|
||||
'/circle/{circle_id:\d+}' => [Module\Update\Network::class, [R::GET]],
|
||||
'[/]' => [Module\Update\Network::class, [R::GET]],
|
||||
'/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d\-\d\d-\d\d}]' => [Module\Update\Network::class, [R::GET]],
|
||||
'/group/{contact_id:\d+}' => [Module\Update\Network::class, [R::GET]],
|
||||
'/circle/{circle_id:\d+}' => [Module\Update\Network::class, [R::GET]],
|
||||
],
|
||||
|
||||
'/update_notes' => [Module\Update\Notes::class, [R::GET]],
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
|
|||
echo $page['title'];
|
||||
} ?></title>
|
||||
<meta request="<?php echo htmlspecialchars($_REQUEST['pagename'] ?? '') ?>">
|
||||
<script type="text/javascript">var baseurl = "<?php echo (string)DI::baseUrl(); ?>";</script>
|
||||
<script type="text/javascript">var baseurl = "<?php echo (string) DI::baseUrl(); ?>";</script>
|
||||
<script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script>
|
||||
<?php
|
||||
// Because we use minimal for modals the header and the included js stuff should be only loaded
|
||||
|
|
@ -54,14 +54,14 @@ $scheme = frio_scheme_get_current_for_user($uid);
|
|||
if ($scheme != FRIO_CUSTOM_SCHEME) {
|
||||
if (file_exists('view/theme/frio/scheme/' . $scheme . '.php')) {
|
||||
$schemefile = 'view/theme/frio/scheme/' . $scheme . '.php';
|
||||
$scheme_accent = DI::pConfig()->get($uid, 'frio', 'scheme_accent') ?:
|
||||
DI::config()->get('frio', 'scheme_accent') ?: FRIO_SCHEME_ACCENT_BLUE;
|
||||
$scheme_accent = DI::pConfig()->get($uid, 'frio', 'scheme_accent')
|
||||
?: DI::config()->get('frio', 'scheme_accent') ?: FRIO_SCHEME_ACCENT_BLUE;
|
||||
|
||||
require_once $schemefile;
|
||||
}
|
||||
}
|
||||
|
||||
$nav_bg = $nav_bg ?? DI::pConfig()->get($uid, 'frio', 'nav_bg', DI::config()->get('frio', 'nav_bg', '#708fa0'));
|
||||
$nav_bg ??= DI::pConfig()->get($uid, 'frio', 'nav_bg', DI::config()->get('frio', 'nav_bg', '#708fa0'));
|
||||
|
||||
echo '<meta name="theme-color" content="' . $nav_bg . '" />';
|
||||
?>
|
||||
|
|
@ -76,8 +76,8 @@ echo '<meta name="theme-color" content="' . $nav_bg . '" />';
|
|||
str_replace(
|
||||
"~system.banner~",
|
||||
DI::config()->get('system', 'banner'),
|
||||
$page['nav']
|
||||
)
|
||||
$page['nav'],
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ function is_modal()
|
|||
$modalpages = get_modalpage_list();
|
||||
|
||||
foreach ($modalpages as $r => $value) {
|
||||
if (strpos($_REQUEST['pagename'], $value) !== false) {
|
||||
if (strpos($_REQUEST['pagename'], (string) $value) !== false) {
|
||||
$is_modal = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ function is_standard_page($pagetitle)
|
|||
$standardpages = get_standard_page_list();
|
||||
|
||||
foreach ($standardpages as $r => $value) {
|
||||
if (strpos($pagetitle, $value) !== false) {
|
||||
if (strpos($pagetitle, (string) $value) !== false) {
|
||||
$is_standard_page = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue