Merge branch '2024.03-rc' of https://github.com/friendica/friendica into 2024.03-rc

This commit is contained in:
Michael 2024-02-24 11:01:44 +00:00
commit 00bb538fd0
12 changed files with 40 additions and 59 deletions

View file

@ -95,12 +95,12 @@ class Attachment extends BaseFactory
$remote = $attachment['url']; $remote = $attachment['url'];
if ($type == 'image') { if ($type == 'image') {
$url = Post\Media::getPreviewUrlForId($attachment['id']); $url = Post\Media::getPreviewUrlForId($attachment['id']);
$preview = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_SMALL); $preview = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_MEDIUM);
} else { } else {
$url = $attachment['url']; $url = $attachment['url'];
if (!empty($attachment['preview'])) { if (!empty($attachment['preview'])) {
$preview = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_SMALL); $preview = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_MEDIUM);
} else { } else {
$preview = ''; $preview = '';
} }

View file

@ -925,9 +925,6 @@ class Event
$end_short = ''; $end_short = '';
} }
// Format the event location.
$location = self::locationToArray($item['event-location']);
// Construct the profile link (magic-auth). // Construct the profile link (magic-auth).
$author = [ $author = [
'uid' => 0, 'uid' => 0,
@ -964,7 +961,7 @@ class Event
'$show_map_label' => DI::l10n()->t('Show map'), '$show_map_label' => DI::l10n()->t('Show map'),
'$hide_map_label' => DI::l10n()->t('Hide map'), '$hide_map_label' => DI::l10n()->t('Hide map'),
'$map_btn_label' => DI::l10n()->t('Show map'), '$map_btn_label' => DI::l10n()->t('Show map'),
'$location' => $location '$location' => self::locationToTemplateVars($item['event-location']),
]); ]);
return $return; return $return;
@ -984,7 +981,7 @@ class Event
* 'coordinates' => Latitude and longitude (e.g. '48.864716,2.349014').<br> * 'coordinates' => Latitude and longitude (e.g. '48.864716,2.349014').<br>
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function locationToArray(string $s = ''): array private static function locationToTemplateVars(string $s = ''): array
{ {
if ($s == '') { if ($s == '') {
return []; return [];

View file

@ -30,6 +30,8 @@ class PhpInfo extends BaseAdmin
{ {
self::checkAdminAccess(); self::checkAdminAccess();
self::checkFormSecurityTokenForbiddenOnError('phpinfo', 't');
phpinfo(); phpinfo();
System::exit(); System::exit();
} }

View file

@ -65,11 +65,7 @@ class Attach extends BaseModule
// error in Chrome for filenames with commas in them // error in Chrome for filenames with commas in them
header('Content-type: ' . $item['filetype']); header('Content-type: ' . $item['filetype']);
header('Content-length: ' . $item['filesize']); header('Content-length: ' . $item['filesize']);
if (isset($_GET['attachment']) && $_GET['attachment'] === '0') {
header('Content-disposition: filename="' . $item['filename'] . '"');
} else {
header('Content-disposition: attachment; filename="' . $item['filename'] . '"'); header('Content-disposition: attachment; filename="' . $item['filename'] . '"');
}
echo $data; echo $data;
System::exit(); System::exit();

View file

@ -104,7 +104,7 @@ abstract class BaseAdmin extends BaseModule
'logsview' => ['admin/logs/view' , DI::l10n()->t('View Logs') , 'viewlogs'], 'logsview' => ['admin/logs/view' , DI::l10n()->t('View Logs') , 'viewlogs'],
]], ]],
'diagnostics' => [DI::l10n()->t('Diagnostics'), [ 'diagnostics' => [DI::l10n()->t('Diagnostics'), [
'phpinfo' => ['admin/phpinfo' , DI::l10n()->t('PHP Info') , 'phpinfo'], 'phpinfo' => ['admin/phpinfo?t=' . self::getFormSecurityToken('phpinfo'), DI::l10n()->t('PHP Info') , 'phpinfo'],
'probe' => ['probe' , DI::l10n()->t('probe address') , 'probe'], 'probe' => ['probe' , DI::l10n()->t('probe address') , 'probe'],
'webfinger' => ['webfinger' , DI::l10n()->t('check webfinger') , 'webfinger'], 'webfinger' => ['webfinger' , DI::l10n()->t('check webfinger') , 'webfinger'],
'babel' => ['babel' , DI::l10n()->t('Babel') , 'babel'], 'babel' => ['babel' , DI::l10n()->t('Babel') , 'babel'],

View file

@ -142,7 +142,8 @@ class API extends BaseModule
{ {
$eventId = !empty($request['event_id']) ? intval($request['event_id']) : 0; $eventId = !empty($request['event_id']) ? intval($request['event_id']) : 0;
$uid = (int)$this->session->getLocalUserId(); $uid = (int)$this->session->getLocalUserId();
$cid = !empty($request['cid']) ? intval($request['cid']) : 0; // No overwriting event.cid on edit
$cid = !empty($request['cid']) && !$eventId ? intval($request['cid']) : 0;
$strStartDateTime = Strings::escapeHtml($request['start_text'] ?? ''); $strStartDateTime = Strings::escapeHtml($request['start_text'] ?? '');
$strFinishDateTime = Strings::escapeHtml($request['finish_text'] ?? ''); $strFinishDateTime = Strings::escapeHtml($request['finish_text'] ?? '');

View file

@ -43,10 +43,11 @@ class Babel extends BaseModule
} }
$results = []; $results = [];
if (!empty($_REQUEST['text'])) { if (!empty($request['text'])) {
switch (($_REQUEST['type'] ?? '') ?: 'bbcode') { self::checkFormSecurityTokenForbiddenOnError('babel');
switch (($request['type'] ?? '') ?: 'bbcode') {
case 'bbcode': case 'bbcode':
$bbcode = $_REQUEST['text']; $bbcode = $request['text'];
$results[] = [ $results[] = [
'title' => DI::l10n()->t('Source input'), 'title' => DI::l10n()->t('Source input'),
'content' => visible_whitespace($bbcode) 'content' => visible_whitespace($bbcode)
@ -136,7 +137,7 @@ class Babel extends BaseModule
]; ];
break; break;
case 'diaspora': case 'diaspora':
$diaspora = trim($_REQUEST['text']); $diaspora = trim($request['text']);
$results[] = [ $results[] = [
'title' => DI::l10n()->t('Source input (Diaspora format)'), 'title' => DI::l10n()->t('Source input (Diaspora format)'),
'content' => visible_whitespace($diaspora), 'content' => visible_whitespace($diaspora),
@ -144,7 +145,7 @@ class Babel extends BaseModule
$markdown = XML::unescape($diaspora); $markdown = XML::unescape($diaspora);
case 'markdown': case 'markdown':
$markdown = $markdown ?? trim($_REQUEST['text']); $markdown = $markdown ?? trim($request['text']);
$results[] = [ $results[] = [
'title' => DI::l10n()->t('Source input (Markdown)'), 'title' => DI::l10n()->t('Source input (Markdown)'),
@ -169,7 +170,7 @@ class Babel extends BaseModule
]; ];
break; break;
case 'html' : case 'html' :
$html = trim($_REQUEST['text']); $html = trim($request['text']);
$results[] = [ $results[] = [
'title' => DI::l10n()->t('Raw HTML input'), 'title' => DI::l10n()->t('Raw HTML input'),
'content' => visible_whitespace($html), 'content' => visible_whitespace($html),
@ -239,7 +240,7 @@ class Babel extends BaseModule
]; ];
break; break;
case 'twitter': case 'twitter':
$json = trim($_REQUEST['text']); $json = trim($request['text']);
if (file_exists('addon/twitter/twitter.php')) { if (file_exists('addon/twitter/twitter.php')) {
require_once 'addon/twitter/twitter.php'; require_once 'addon/twitter/twitter.php';
@ -302,13 +303,14 @@ class Babel extends BaseModule
$tpl = Renderer::getMarkupTemplate('babel.tpl'); $tpl = Renderer::getMarkupTemplate('babel.tpl');
$o = Renderer::replaceMacros($tpl, [ $o = Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->t('Babel Diagnostic'), '$title' => DI::l10n()->t('Babel Diagnostic'),
'$text' => ['text', DI::l10n()->t('Source text'), $_REQUEST['text'] ?? '', ''], '$form_security_token' => self::getFormSecurityToken('babel'),
'$type_bbcode' => ['type', DI::l10n()->t('BBCode'), 'bbcode', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'bbcode'], '$text' => ['text', DI::l10n()->t('Source text'), $request['text'] ?? '', ''],
'$type_diaspora' => ['type', DI::l10n()->t('Diaspora'), 'diaspora', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'diaspora'], '$type_bbcode' => ['type', DI::l10n()->t('BBCode'), 'bbcode', '', (($request['type'] ?? '') ?: 'bbcode') == 'bbcode'],
'$type_markdown' => ['type', DI::l10n()->t('Markdown'), 'markdown', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'markdown'], '$type_diaspora' => ['type', DI::l10n()->t('Diaspora'), 'diaspora', '', (($request['type'] ?? '') ?: 'bbcode') == 'diaspora'],
'$type_html' => ['type', DI::l10n()->t('HTML'), 'html', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'html'], '$type_markdown' => ['type', DI::l10n()->t('Markdown'), 'markdown', '', (($request['type'] ?? '') ?: 'bbcode') == 'markdown'],
'$type_html' => ['type', DI::l10n()->t('HTML'), 'html', '', (($request['type'] ?? '') ?: 'bbcode') == 'html'],
'$flag_twitter' => file_exists('addon/twitter/twitter.php'), '$flag_twitter' => file_exists('addon/twitter/twitter.php'),
'$type_twitter' => ['type', DI::l10n()->t('Twitter Source / Tweet URL (requires API key)'), 'twitter', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'twitter'], '$type_twitter' => ['type', DI::l10n()->t('Twitter Source / Tweet URL (requires API key)'), 'twitter', '', (($request['type'] ?? '') ?: 'bbcode') == 'twitter'],
'$results' => $results, '$results' => $results,
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
]); ]);

View file

@ -100,7 +100,6 @@ class Photo extends BaseApi
$id = $account['id']; $id = $account['id'];
} }
// Contact Id Fallback, to remove after version 2021.12
if (isset($this->parameters['contact_id'])) { if (isset($this->parameters['contact_id'])) {
$id = intval($this->parameters['contact_id']); $id = intval($this->parameters['contact_id']);
} }
@ -115,12 +114,6 @@ class Photo extends BaseApi
$id = $user['uid']; $id = $user['uid'];
} }
// User Id Fallback, to remove after version 2021.12
if (!empty($this->parameters['uid_ext'])) {
$id = intval(pathinfo($this->parameters['uid_ext'], PATHINFO_FILENAME));
}
// Please refactor this for the love of everything that's good
if (isset($this->parameters['id'])) { if (isset($this->parameters['id'])) {
$id = $this->parameters['id']; $id = $this->parameters['id'];
} }

View file

@ -29,7 +29,6 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Database\Definition\DbaDefinition; use Friendica\Database\Definition\DbaDefinition;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
@ -47,8 +46,7 @@ use Psr\Log\LoggerInterface;
**/ **/
class UserExport extends BaseSettings class UserExport extends BaseSettings
{ {
/** @var DbaDefinition */ private DbaDefinition $dbaDefinition;
private $dbaDefinition;
public function __construct(DbaDefinition $dbaDefinition, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) public function __construct(DbaDefinition $dbaDefinition, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{ {
@ -86,10 +84,12 @@ class UserExport extends BaseSettings
* options shown on "Export personal data" page * options shown on "Export personal data" page
* list of array( 'link url', 'link text', 'help text' ) * list of array( 'link url', 'link text', 'help text' )
*/ */
$t = self::getFormSecurityToken('userexport');
$options = [ $options = [
['settings/userexport/account', $this->l10n->t('Export account'), $this->l10n->t('Export your account info and contacts. Use this to make a backup of your account and/or to move it to another server.')], ['settings/userexport/account?t=' . $t, $this->l10n->t('Export account'), $this->l10n->t('Export your account info and contacts. Use this to make a backup of your account and/or to move it to another server.')],
['settings/userexport/backup', $this->l10n->t('Export all'), $this->l10n->t('Export your account info, contacts and all your items as json. Could be a very big file, and could take a lot of time. Use this to make a full backup of your account (photos are not exported)')], ['settings/userexport/backup?t=' . $t, $this->l10n->t('Export all'), $this->l10n->t('Export your account info, contacts and all your items as json. Could be a very big file, and could take a lot of time. Use this to make a full backup of your account (photos are not exported)')],
['settings/userexport/contact', $this->l10n->t('Export Contacts to CSV'), $this->l10n->t('Export the list of the accounts you are following as CSV file. Compatible to e.g. Mastodon.')], ['settings/userexport/contact?t=' . $t, $this->l10n->t('Export Contacts to CSV'), $this->l10n->t('Export the list of the accounts you are following as CSV file. Compatible to e.g. Mastodon.')],
]; ];
Hook::callAll('uexport_options', $options); Hook::callAll('uexport_options', $options);
@ -115,20 +115,21 @@ class UserExport extends BaseSettings
} }
if (isset($this->parameters['action'])) { if (isset($this->parameters['action'])) {
self::checkFormSecurityTokenForbiddenOnError('userexport', 't');
switch ($this->parameters['action']) { switch ($this->parameters['action']) {
case 'backup': case 'backup':
header('Content-type: application/json'); header('Content-type: application/json');
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $this->parameters['action'] . '"'); header('Content-Disposition: attachment; filename="' . $this->session->getLocalUserNickname() . '.' . $this->parameters['action'] . '"');
$this->echoAll($this->session->getLocalUserId()); $this->echoAll($this->session->getLocalUserId());
break; break;
case 'account': case 'account':
header('Content-type: application/json'); header('Content-type: application/json');
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $this->parameters['action'] . '"'); header('Content-Disposition: attachment; filename="' . $this->session->getLocalUserNickname() . '.' . $this->parameters['action'] . '"');
$this->echoAccount($this->session->getLocalUserId()); $this->echoAccount($this->session->getLocalUserId());
break; break;
case 'contact': case 'contact':
header('Content-type: application/csv'); header('Content-type: application/csv');
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '-contacts.csv' . '"'); header('Content-Disposition: attachment; filename="' . $this->session->getLocalUserNickname() . '-contacts.csv' . '"');
$this->echoContactsAsCSV($this->session->getLocalUserId()); $this->echoContactsAsCSV($this->session->getLocalUserId());
break; break;
} }
@ -156,12 +157,9 @@ class UserExport extends BaseSettings
if (!isset($row[$column])) { if (!isset($row[$column])) {
continue; continue;
} }
if ($field['type'] == 'datetime') {
$p[$column] = $row[$column] ?? DBA::NULL_DATETIME;
} else {
$p[$column] = $row[$column]; $p[$column] = $row[$column];
} }
}
$result[] = $p; $result[] = $p;
} }
DBA::close($rows); DBA::close($rows);

View file

@ -570,22 +570,13 @@ return [
'/{name}' => [Module\Photo::class, [R::GET]], '/{name}' => [Module\Photo::class, [R::GET]],
'/{type}/{id:\d+}' => [Module\Photo::class, [R::GET]], '/{type}/{id:\d+}' => [Module\Photo::class, [R::GET]],
'/{type:contact|header}/{guid}' => [Module\Photo::class, [R::GET]], '/{type:contact|header}/{guid}' => [Module\Photo::class, [R::GET]],
// User Id Fallback, to remove after version 2021.12
'/{type}/{uid_ext:\d+\..*}' => [Module\Photo::class, [R::GET]],
'/{type}/{nickname_ext}' => [Module\Photo::class, [R::GET]], '/{type}/{nickname_ext}' => [Module\Photo::class, [R::GET]],
// Contact Id Fallback, to remove after version 2021.12
'/{type:contact|header}/{customsize:\d+}/{contact_id:\d+}' => [Module\Photo::class, [R::GET]], '/{type:contact|header}/{customsize:\d+}/{contact_id:\d+}' => [Module\Photo::class, [R::GET]],
'/{type:contact|header}/{customsize:\d+}/{guid}' => [Module\Photo::class, [R::GET]], '/{type:contact|header}/{customsize:\d+}/{guid}' => [Module\Photo::class, [R::GET]],
'/{type}/{customsize:\d+}/{id:\d+}' => [Module\Photo::class, [R::GET]], '/{type}/{customsize:\d+}/{id:\d+}' => [Module\Photo::class, [R::GET]],
// User Id Fallback, to remove after version 2021.12
'/{type}/{customsize:\d+}/{uid_ext:\d+\..*}' => [Module\Photo::class, [R::GET]],
'/{type}/{customsize:\d+}/{nickname_ext}' => [Module\Photo::class, [R::GET]], '/{type}/{customsize:\d+}/{nickname_ext}' => [Module\Photo::class, [R::GET]],
], ],
// Kept for backwards-compatibility
// @TODO remove by version 2023.12
'/photos/{nickname}' => [Module\Profile\Photos::class, [R::GET]],
'/ping' => [Module\Notifications\Ping::class, [R::GET]], '/ping' => [Module\Notifications\Ping::class, [R::GET]],
'/post' => [ '/post' => [

View file

@ -1,6 +1,7 @@
<div id="babel" class="generic-page-wrapper"> <div id="babel" class="generic-page-wrapper">
<h2>{{$title}}</h2> <h2>{{$title}}</h2>
<form action="babel" method="post" class="panel panel-default"> <form action="babel" method="post" class="panel panel-default">
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
<div class="panel-body"> <div class="panel-body">
<div class="form-group"> <div class="form-group">
{{include file="field_textarea.tpl" field=$text}} {{include file="field_textarea.tpl" field=$text}}

View file

@ -23,7 +23,7 @@
</span> </span>
{{if $location.name}} {{if $location.name}}
<span role="presentation" aria-hidden="true"> · </span> <span role="presentation" aria-hidden="true"> · </span>
<span class="event-location event-card-location">{{$location.name nofilter}}</span> <span class="event-location event-card-location">{{$location.name}}</span>
{{/if}} {{/if}}
</div> </div>
<div class="event-card-profile-name profile-entry-name"> <div class="event-card-profile-name profile-entry-name">