Merge remote-tracking branch 'upstream/develop' into untrusted

This commit is contained in:
Michael 2022-07-27 17:56:56 +00:00
commit ff9dc1e291
17 changed files with 777 additions and 304 deletions

View File

@ -171,18 +171,11 @@ function remote_user()
* @param string $s - Text of notice * @param string $s - Text of notice
* *
* @return void * @return void
* @deprecated since version 2022.09, use \Friendica\Navigation\SystemMessages instead
*/ */
function notice(string $s) function notice(string $s)
{ {
if (empty($_SESSION)) { \Friendica\DI::sysmsg()->addNotice($s);
return;
}
if (empty($_SESSION['sysmsg'])) {
$_SESSION['sysmsg'] = [];
}
$_SESSION['sysmsg'][] = $s;
} }
/** /**
@ -193,16 +186,9 @@ function notice(string $s)
* @param string $s - Text of notice * @param string $s - Text of notice
* *
* @return void * @return void
* @deprecated since version 2022.09, use \Friendica\Navigation\SystemMessages instead
*/ */
function info(string $s) function info(string $s)
{ {
if (empty($_SESSION)) { \Friendica\DI::sysmsg()->addInfo($s);
return;
}
if (empty($_SESSION['sysmsg_info'])) {
$_SESSION['sysmsg_info'] = [];
}
$_SESSION['sysmsg_info'][] = $s;
} }

View File

@ -648,10 +648,6 @@ class App
header('X-Account-Management-Status: none'); header('X-Account-Management-Status: none');
} }
$_SESSION['sysmsg'] = Core\Session::get('sysmsg', []);
$_SESSION['sysmsg_info'] = Core\Session::get('sysmsg_info', []);
$_SESSION['last_updated'] = Core\Session::get('last_updated', []);
/* /*
* check_config() is responsible for running update scripts. These automatically * check_config() is responsible for running update scripts. These automatically
* update the DB schema whenever we push a new one out. It also checks to see if * update the DB schema whenever we push a new one out. It also checks to see if

View File

@ -22,6 +22,7 @@
namespace Friendica; namespace Friendica;
use Dice\Dice; use Dice\Dice;
use Friendica\Navigation\SystemMessages;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**
@ -234,6 +235,14 @@ abstract class DI
return self::$dice->create(Core\System::class); return self::$dice->create(Core\System::class);
} }
/**
* @return \Friendica\Navigation\SystemMessages
*/
public static function sysmsg()
{
return self::$dice->create(SystemMessages::class);
}
// //
// "LoggerInterface" instances // "LoggerInterface" instances
// //

View File

@ -243,27 +243,31 @@ class Event
*/ */
public static function store(array $arr): int public static function store(array $arr): int
{ {
$event = []; $guid = $arr['guid'] ?? '' ?: System::createUUID();
$event['id'] = intval($arr['id'] ?? 0); $uri = $arr['uri'] ?? '' ?: Item::newURI($guid);
$event['uid'] = intval($arr['uid'] ?? 0); $event = [
$event['cid'] = intval($arr['cid'] ?? 0); 'id' => intval($arr['id'] ?? 0),
$event['guid'] = ($arr['guid'] ?? '') ?: System::createUUID(); 'uid' => intval($arr['uid'] ?? 0),
$event['uri'] = ($arr['uri'] ?? '') ?: Item::newURI($event['guid']); 'cid' => intval($arr['cid'] ?? 0),
$event['uri-id'] = ItemURI::insert(['uri' => $event['uri'], 'guid' => $event['guid']]); 'guid' => $guid,
$event['type'] = ($arr['type'] ?? '') ?: 'event'; 'uri' => $uri,
$event['summary'] = $arr['summary'] ?? ''; 'uri-id' => ItemURI::insert(['uri' => $uri, 'guid' => $guid]),
$event['desc'] = $arr['desc'] ?? ''; 'type' => ($arr['type'] ?? '') ?: 'event',
$event['location'] = $arr['location'] ?? ''; 'summary' => $arr['summary'] ?? '',
$event['allow_cid'] = $arr['allow_cid'] ?? ''; 'desc' => $arr['desc'] ?? '',
$event['allow_gid'] = $arr['allow_gid'] ?? ''; 'location' => $arr['location'] ?? '',
$event['deny_cid'] = $arr['deny_cid'] ?? ''; 'allow_cid' => $arr['allow_cid'] ?? '',
$event['deny_gid'] = $arr['deny_gid'] ?? ''; 'allow_gid' => $arr['allow_gid'] ?? '',
$event['nofinish'] = intval($arr['nofinish'] ?? (!empty($event['start']) && empty($event['finish']))); 'deny_cid' => $arr['deny_cid'] ?? '',
'deny_gid' => $arr['deny_gid'] ?? '',
'nofinish' => intval($arr['nofinish'] ?? (!empty($arr['start']) && empty($arr['finish']))),
'created' => DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now'),
'edited' => DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now'),
'start' => DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME),
'finish' => DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME),
];
$event['created'] = DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now');
$event['edited'] = DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now');
$event['start'] = DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME);
$event['finish'] = DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME);
if ($event['finish'] < DBA::NULL_DATETIME) { if ($event['finish'] < DBA::NULL_DATETIME) {
$event['finish'] = DBA::NULL_DATETIME; $event['finish'] = DBA::NULL_DATETIME;
} }

View File

@ -138,25 +138,29 @@ class Group
*/ */
public static function getIdsByContactId(int $cid): array public static function getIdsByContactId(int $cid): array
{ {
$return = []; $contact = Contact::getById($cid, ['rel']);
if (!$contact) {
return [];
}
$groupIds = [];
$stmt = DBA::select('group_member', ['gid'], ['contact-id' => $cid]); $stmt = DBA::select('group_member', ['gid'], ['contact-id' => $cid]);
while ($group = DBA::fetch($stmt)) { while ($group = DBA::fetch($stmt)) {
$return[] = $group['gid']; $groupIds[] = $group['gid'];
} }
DBA::close($stmt); DBA::close($stmt);
// Meta-groups // Meta-groups
$contact = Contact::getById($cid, ['rel']);
if ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND) { if ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND) {
$return[] = self::FOLLOWERS; $groupIds[] = self::FOLLOWERS;
} }
if ($contact['rel'] == Contact::FRIEND) { if ($contact['rel'] == Contact::FRIEND) {
$return[] = self::MUTUALS; $groupIds[] = self::MUTUALS;
} }
return $return; return $groupIds;
} }
/** /**

View File

@ -0,0 +1,163 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Module\Admin\Blocklist\Server;
use Friendica\App;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Module\Response;
use Friendica\Navigation\SystemMessages;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
class Import extends \Friendica\Module\BaseAdmin
{
/** @var IManageConfigValues */
private $config;
/** @var SystemMessages */
private $sysmsg;
/** @var array of blocked server domain patterns */
private $blocklist = [];
public function __construct(IManageConfigValues $config, SystemMessages $sysmsg, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->config = $config;
$this->sysmsg = $sysmsg;
}
/**
* @param array $request
* @return void
* @throws \Friendica\Network\HTTPException\ForbiddenException
* @throws \Friendica\Network\HTTPException\FoundException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \Friendica\Network\HTTPException\MovedPermanentlyException
* @throws \Friendica\Network\HTTPException\TemporaryRedirectException
*/
protected function post(array $request = [])
{
self::checkAdminAccess();
if (!isset($_POST['page_blocklist_upload']) && !isset($_POST['page_blocklist_import'])) {
return;
}
self::checkFormSecurityTokenRedirectOnError('/admin/blocklist/server/import', 'admin_blocklist_import');
if (isset($_POST['page_blocklist_upload'])) {
if (($fp = fopen($_FILES['listfile']['tmp_name'], 'r')) !== false) {
$blocklist = [];
while (($data = fgetcsv($fp, 1000, ',')) !== false) {
$domain = $data[0];
if (count($data) == 0) {
$reason = 'blocked';
} else {
$reason = $data[1];
}
$blocklist[] = [
'domain' => $domain,
'reason' => $reason
];
}
} else {
$this->sysmsg->addNotice($this->l10n->t('Error importing pattern file'));
return;
}
$this->blocklist = $blocklist;
return;
}
if (isset($_POST['page_blocklist_import'])) {
$blocklist = json_decode($_POST['blocklist'], true);
if ($blocklist === null) {
$this->sysmsg->addNotice($this->l10n->t('Error importing pattern file'));
return;
}
if (($_POST['mode'] ?? 'append') == 'replace') {
$this->config->set('system', 'blocklist', $blocklist);
$this->sysmsg->addNotice($this->l10n->t('Local blocklist replaced with the provided file.'));
} else {
$localBlocklist = $this->config->get('system', 'blocklist', []);
$localPatterns = array_column($localBlocklist, 'domain');
$importedPatterns = array_column($blocklist, 'domain');
$patternsToAppend = array_diff($importedPatterns, $localPatterns);
if (count($patternsToAppend)) {
foreach (array_keys($patternsToAppend) as $key) {
$localBlocklist[] = $blocklist[$key];
}
$this->config->set('system', 'blocklist', $localBlocklist);
$this->sysmsg->addNotice($this->l10n->tt('%d pattern was added to the local blocklist.', '%d patterns were added to the local blocklist.', count($patternsToAppend)));
} else {
$this->sysmsg->addNotice($this->l10n->t('No pattern was added to the local blocklist.'));
}
}
$this->baseUrl->redirect('/admin/blocklist/server');
}
}
/**
* @param array $request
* @return string
* @throws \Friendica\Network\HTTPException\ServiceUnavailableException
*/
protected function content(array $request = []): string
{
parent::content();
$t = Renderer::getMarkupTemplate('admin/blocklist/server/import.tpl');
return Renderer::replaceMacros($t, [
'$l10n' => [
'return_list' => $this->l10n->t('← Return to the list'),
'title' => $this->l10n->t('Administration'),
'page' => $this->l10n->t('Import a Server Domain Pattern Blocklist'),
'download' => $this->l10n->t('<p>This file can be downloaded from the <code>/friendica</code> path of any Friendica server.</p>'),
'upload' => $this->l10n->t('Upload file'),
'patterns' => $this->l10n->t('Patterns to import'),
'domain_pattern' => $this->l10n->t('Domain Pattern'),
'block_reason' => $this->l10n->t('Block Reason'),
'mode' => $this->l10n->t('Import Mode'),
'import' => $this->l10n->t('Import Patterns'),
'pattern_count' => $this->l10n->tt('%d total pattern', '%d total patterns', count($this->blocklist)),
],
'$listfile' => ['listfile', $this->l10n->t('Server domain pattern blocklist CSV file'), '', '', $this->l10n->t('Required'), '', 'file'],
'$mode_append' => ['mode', $this->l10n->t('Append'), 'append', $this->l10n->t('Imports patterns from the file that weren\'t already existing in the current blocklist.'), 'checked="checked"'],
'$mode_replace' => ['mode', $this->l10n->t('Replace'), 'replace', $this->l10n->t('Replaces the current blocklist by the imported patterns.')],
'$blocklist' => $this->blocklist,
'$baseurl' => $this->baseUrl->get(true),
'$form_security_token' => self::getFormSecurityToken('admin_blocklist_import')
]);
}
}

View File

@ -84,8 +84,10 @@ class Index extends BaseAdmin
<li><code>*</code>: Any number of characters</li> <li><code>*</code>: Any number of characters</li>
<li><code>?</code>: Any single character</li> <li><code>?</code>: Any single character</li>
</ul>'), </ul>'),
'importtitle' => DI::l10n()->t('Import server domain pattern blocklist'),
'addtitle' => DI::l10n()->t('Add new entry to the blocklist'), 'addtitle' => DI::l10n()->t('Add new entry to the blocklist'),
'submit' => DI::l10n()->t('Check pattern'), 'importsubmit' => DI::l10n()->t('Upload file'),
'addsubmit' => DI::l10n()->t('Check pattern'),
'savechanges' => DI::l10n()->t('Save changes to the blocklist'), 'savechanges' => DI::l10n()->t('Save changes to the blocklist'),
'currenttitle' => DI::l10n()->t('Current Entries in the Blocklist'), 'currenttitle' => DI::l10n()->t('Current Entries in the Blocklist'),
'thurl' => DI::l10n()->t('Blocked server domain pattern'), 'thurl' => DI::l10n()->t('Blocked server domain pattern'),
@ -93,10 +95,12 @@ class Index extends BaseAdmin
'delentry' => DI::l10n()->t('Delete entry from the blocklist'), 'delentry' => DI::l10n()->t('Delete entry from the blocklist'),
'confirm_delete' => DI::l10n()->t('Delete entry from the blocklist?'), 'confirm_delete' => DI::l10n()->t('Delete entry from the blocklist?'),
], ],
'$listfile' => ['listfile', DI::l10n()->t('Server domain pattern blocklist CSV file'), '', '', DI::l10n()->t('Required'), '', 'file'],
'$newdomain' => ['pattern', DI::l10n()->t('Server Domain Pattern'), '', DI::l10n()->t('The domain pattern of the new server to add to the blocklist. Do not include the protocol.'), DI::l10n()->t('Required'), '', ''], '$newdomain' => ['pattern', DI::l10n()->t('Server Domain Pattern'), '', DI::l10n()->t('The domain pattern of the new server to add to the blocklist. Do not include the protocol.'), DI::l10n()->t('Required'), '', ''],
'$entries' => $blocklistform, '$entries' => $blocklistform,
'$baseurl' => DI::baseUrl()->get(true), '$baseurl' => DI::baseUrl()->get(true),
'$form_security_token' => self::getFormSecurityToken('admin_blocklist') '$form_security_token' => self::getFormSecurityToken('admin_blocklist'),
'$form_security_token_import' => self::getFormSecurityToken('admin_blocklist_import'),
]); ]);
} }
} }

View File

@ -0,0 +1,71 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Module\Blocklist\Domain;
use Friendica\App;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Module\Response;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
class Download extends \Friendica\BaseModule
{
/** @var IManageConfigValues */
private $config;
public function __construct(IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->config = $config;
}
protected function rawContent(array $request = [])
{
$blocklist = $this->config->get('system', 'blocklist');
$blocklistJson = json_encode($blocklist, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$hash = md5($blocklistJson);
$etag = 'W/"' . $hash . '"';
if (trim($_SERVER['HTTP_IF_NONE_MATCH'] ?? '') == $etag) {
header("HTTP/1.1 304 Not Modified");
}
header('Content-Type: text/csv');
header('Content-Transfer-Encoding: Binary');
header('Content-disposition: attachment; filename="' . $this->baseUrl->getHostname() . '_domain_blocklist_' . substr($hash, 0, 6) . '.csv"');
header("Etag: $etag");
$fp = fopen('php://output', 'w');
foreach ($blocklist as $domain) {
fputcsv($fp, $domain);
}
fclose($fp);
System::exit();
}
}

View File

@ -59,13 +59,13 @@ class Notify extends BaseModule
} }
} }
private static function dispatchPublic(string $postdata) private static function dispatchPublic(string $postdata): bool
{ {
$msg = Diaspora::decodeRaw($postdata, '', true); $msg = Diaspora::decodeRaw($postdata, '', true);
if (!is_array($msg)) { if (!is_array($msg)) {
// We have to fail silently to be able to hand it over to the salmon parser // We have to fail silently to be able to hand it over to the salmon parser
Logger::warning('Diaspora::decodeRaw() has failed for some reason.'); Logger::warning('Diaspora::decodeRaw() has failed for some reason.');
return; return false;
} }
// Fetch the corresponding public contact // Fetch the corresponding public contact
@ -87,6 +87,8 @@ class Notify extends BaseModule
// Now we should be able to import it // Now we should be able to import it
$ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::RELAY); $ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::RELAY);
System::xmlExit($ret, 'Done'); System::xmlExit($ret, 'Done');
return true;
} }
private static function dispatchPrivate(array $user, string $postdata) private static function dispatchPrivate(array $user, string $postdata)

View File

@ -76,12 +76,13 @@ class Friendica extends BaseModule
if (!empty($blockList)) { if (!empty($blockList)) {
$blocked = [ $blocked = [
'title' => DI::l10n()->t('On this server the following remote servers are blocked.'), 'title' => DI::l10n()->t('On this server the following remote servers are blocked.'),
'header' => [ 'header' => [
DI::l10n()->t('Blocked domain'), DI::l10n()->t('Blocked domain'),
DI::l10n()->t('Reason for the block'), DI::l10n()->t('Reason for the block'),
], ],
'list' => $blockList, 'download' => DI::l10n()->t('Download this list in CSV format'),
'list' => $blockList,
]; ];
} else { } else {
$blocked = null; $blocked = null;

View File

@ -42,6 +42,7 @@ use Friendica\Navigation\Notifications\Exception\NoMessageException;
use Friendica\Navigation\Notifications\Factory; use Friendica\Navigation\Notifications\Factory;
use Friendica\Navigation\Notifications\Repository; use Friendica\Navigation\Notifications\Repository;
use Friendica\Navigation\Notifications\ValueObject; use Friendica\Navigation\Notifications\ValueObject;
use Friendica\Navigation\SystemMessages;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
@ -50,6 +51,8 @@ use Psr\Log\LoggerInterface;
class Ping extends BaseModule class Ping extends BaseModule
{ {
/** @var SystemMessages */
private $systemMessages;
/** @var Repository\Notification */ /** @var Repository\Notification */
private $notificationRepo; private $notificationRepo;
/** @var Introduction */ /** @var Introduction */
@ -57,10 +60,11 @@ class Ping extends BaseModule
/** @var Factory\FormattedNavNotification */ /** @var Factory\FormattedNavNotification */
private $formattedNavNotification; private $formattedNavNotification;
public function __construct(Repository\Notification $notificationRepo, Introduction $introductionRepo, Factory\FormattedNavNotification $formattedNavNotification, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) public function __construct(SystemMessages $systemMessages, Repository\Notification $notificationRepo, Introduction $introductionRepo, Factory\FormattedNavNotification $formattedNavNotification, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{ {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->systemMessages = $systemMessages;
$this->notificationRepo = $notificationRepo; $this->notificationRepo = $notificationRepo;
$this->introductionRepo = $introductionRepo; $this->introductionRepo = $introductionRepo;
$this->formattedNavNotification = $formattedNavNotification; $this->formattedNavNotification = $formattedNavNotification;
@ -256,19 +260,6 @@ class Ping extends BaseModule
usort($navNotifications, $sort_function); usort($navNotifications, $sort_function);
} }
$sysmsgs = [];
$sysmsgs_info = [];
if (!empty($_SESSION['sysmsg'])) {
$sysmsgs = $_SESSION['sysmsg'];
unset($_SESSION['sysmsg']);
}
if (!empty($_SESSION['sysmsg_info'])) {
$sysmsgs_info = $_SESSION['sysmsg_info'];
unset($_SESSION['sysmsg_info']);
}
$notification_count = $sysnotify_count + $intro_count + $register_count; $notification_count = $sysnotify_count + $intro_count + $register_count;
$data = []; $data = [];
@ -289,8 +280,8 @@ class Ping extends BaseModule
$data['notifications'] = $navNotifications; $data['notifications'] = $navNotifications;
$data['sysmsgs'] = [ $data['sysmsgs'] = [
'notice' => $sysmsgs, 'notice' => $this->systemMessages->flushNotices(),
'info' => $sysmsgs_info 'info' => $this->systemMessages->flushInfos(),
]; ];
if (isset($_GET['callback'])) { if (isset($_GET['callback'])) {

View File

@ -0,0 +1,87 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Friendica is a communications platform for integrated social communications
* utilising decentralised communications and linkage to several indie social
* projects - as well as popular mainstream providers.
*
* Our mission is to free our friends and families from the clutches of
* data-harvesting corporations, and pave the way to a future where social
* communications are free and open and flow between alternate providers as
* easily as email does today.
*/
namespace Friendica\Navigation;
use Friendica\Core\Session\Capability\IHandleSessions;
class SystemMessages
{
/**
* @var IHandleSessions
*/
private $session;
public function __construct(IHandleSessions $session)
{
$this->session = $session;
}
public function addNotice(string $message)
{
$sysmsg = $this->getNotices();
$sysmsg[] = $message;
$this->session->set('sysmsg', $sysmsg);
}
public function getNotices(): array
{
return $this->session->get('sysmsg', []);
}
public function flushNotices(): array
{
$notices = $this->getNotices();
$this->session->remove('sysmsg');
return $notices;
}
public function addInfo(string $message)
{
$sysmsg = $this->getNotices();
$sysmsg[] = $message;
$this->session->set('sysmsg_info', $sysmsg);
}
public function getInfos(): array
{
return $this->session->get('sysmsg_info', []);
}
public function flushInfos(): array
{
$notices = $this->getInfos();
$this->session->remove('sysmsg_info');
return $notices;
}
}

View File

@ -310,9 +310,10 @@ return [
'/addons/{addon}' => [Module\Admin\Addons\Details::class, [R::GET, R::POST]], '/addons/{addon}' => [Module\Admin\Addons\Details::class, [R::GET, R::POST]],
'/blocklist/contact' => [Module\Admin\Blocklist\Contact::class, [R::GET, R::POST]], '/blocklist/contact' => [Module\Admin\Blocklist\Contact::class, [R::GET, R::POST]],
'/blocklist/server' => [Module\Admin\Blocklist\Server\Index::class, [R::GET, R::POST]], '/blocklist/server' => [Module\Admin\Blocklist\Server\Index::class, [R::GET, R::POST]],
'/blocklist/server/add' => [Module\Admin\Blocklist\Server\Add::class, [R::GET, R::POST]], '/blocklist/server/add' => [Module\Admin\Blocklist\Server\Add::class, [R::GET, R::POST]],
'/blocklist/server/import' => [Module\Admin\Blocklist\Server\Import::class, [R::GET, R::POST]],
'/dbsync[/{action}[/{update:\d+}]]' => [Module\Admin\DBSync::class, [R::GET]], '/dbsync[/{action}[/{update:\d+}]]' => [Module\Admin\DBSync::class, [R::GET]],
@ -353,6 +354,9 @@ return [
'/attach/{item:\d+}' => [Module\Attach::class, [R::GET]], '/attach/{item:\d+}' => [Module\Attach::class, [R::GET]],
'/babel' => [Module\Debug\Babel::class, [R::GET, R::POST]], '/babel' => [Module\Debug\Babel::class, [R::GET, R::POST]],
'/debug/ap' => [Module\Debug\ActivityPubConversion::class, [R::GET, R::POST]], '/debug/ap' => [Module\Debug\ActivityPubConversion::class, [R::GET, R::POST]],
'/blocklist/domain/download' => [Module\Blocklist\Domain\Download::class, [R::GET]],
'/bookmarklet' => [Module\Bookmarklet::class, [R::GET]], '/bookmarklet' => [Module\Bookmarklet::class, [R::GET]],
'/community[/{content}]' => [Module\Conversation\Community::class, [R::GET]], '/community[/{content}]' => [Module\Conversation\Community::class, [R::GET]],

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
<div id="adminpage">
<p><a href="{{$baseurl}}/admin/blocklist/server">{{$l10n.return_list}}</a></p>
<h1>{{$l10n.title}} - {{$l10n.page}}</h1>
{{if !$blocklist}}
{{$l10n.download nofilter}}
<form action="{{$baseurl}}/admin/blocklist/server/import" method="post" enctype="multipart/form-data">
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
{{include file="field_input.tpl" field=$listfile}}
<div class="submit">
<button type="submit" class="btn btn-primary" name="page_blocklist_upload" value="{{$l10n.upload}}">{{$l10n.upload}}</button>
</div>
</form>
{{else}}
<h2>{{$l10n.patterns}}</h2>
<form action="{{$baseurl}}/admin/blocklist/server/import" method="post">
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
<input type="hidden" name="blocklist" value="{{$blocklist|json_encode}}">
<table class="table table-condensed table-striped table-bordered">
<thead>
<tr>
<th>{{$l10n.domain_pattern}}</th>
<th>{{$l10n.block_reason}}</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">{{$l10n.pattern_count}}</td>
</tr>
</tfoot>
<tbody>
{{foreach $blocklist as $block}}
<tr>
<th>{{$block.domain}}</th>
<td>{{$block.reason}}</td>
</tr>
{{/foreach}}
</tbody>
</table>
<div role="radiogroup" aria-labelledby="mode">
<label id="mode">{{$l10n.mode}}</label>
{{include file="field_radio.tpl" field=$mode_append}}
{{include file="field_radio.tpl" field=$mode_replace}}
</div>
<div class="submit">
<button type="submit" class="btn btn-primary" name="page_blocklist_import" value="{{$l10n.import}}">{{$l10n.import}}</button>
</div>
</form>
{{/if}}
</div>

View File

@ -7,13 +7,24 @@
<h1>{{$l10n.title}} - {{$l10n.page}}</h1> <h1>{{$l10n.title}} - {{$l10n.page}}</h1>
<p>{{$l10n.intro}}</p> <p>{{$l10n.intro}}</p>
<p>{{$l10n.public nofilter}}</p> <p>{{$l10n.public nofilter}}</p>
{{$l10n.syntax nofilter}}
<h2>{{$l10n.importtitle}}</h2>
{{$l10n.download nofilter}}
<form action="{{$baseurl}}/admin/blocklist/server/import" method="post" enctype="multipart/form-data">
<input type="hidden" name="form_security_token" value="{{$form_security_token_import}}">
{{include file="field_input.tpl" field=$listfile}}
<div class="submit">
<button type="submit" class="btn btn-primary" name="page_blocklist_upload">{{$l10n.importsubmit}}</button>
</div>
</form>
<h2>{{$l10n.addtitle}}</h2> <h2>{{$l10n.addtitle}}</h2>
{{$l10n.syntax nofilter}}
<form action="{{$baseurl}}/admin/blocklist/server/add" method="get"> <form action="{{$baseurl}}/admin/blocklist/server/add" method="get">
{{include file="field_input.tpl" field=$newdomain}} {{include file="field_input.tpl" field=$newdomain}}
<div class="submit"> <div class="submit">
<button type="submit" class="btn btn-primary">{{$l10n.submit}}</button> <button type="submit" class="btn btn-primary">{{$l10n.addsubmit}}</button>
</div> </div>
</form> </form>

View File

@ -1,28 +1,22 @@
<div id="friendica" class="generic-page-wrapper"> <div id="friendica">
<h1>Friendica</h1> <h1>Friendica</h1>
<br>
<p>{{$about nofilter}}</p> <p>{{$about nofilter}}</p>
<br>
<p>{{$friendica nofilter}}</p> <p>{{$friendica nofilter}}</p>
<br>
<p>{{$bugs nofilter}}</p> <p>{{$bugs nofilter}}</p>
<br>
<p>{{$info nofilter}}</p> <p>{{$info nofilter}}</p>
<br>
<p>{{$visible_addons.title nofilter}}</p> <p>{{$visible_addons.title nofilter}}</p>
{{if $visible_addons.list}} {{if $visible_addons.list}}
<div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">{{$visible_addons.list}}</div> <div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">{{$visible_addons.list}}</div>
{{/if}} {{/if}}
{{if $tos}} {{if $tos}}
<p>{{$tos nofilter}}</p> <p>{{$tos nofilter}}</p>
{{/if}} {{/if}}
{{if $block_list}} {{if $block_list}}
<div id="about_blocklist"> <div id="about_blocklist">
<p>{{$block_list.title}}</p> <p>{{$block_list.title}}</p>
<br>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
@ -39,9 +33,9 @@
{{/foreach}} {{/foreach}}
</tbody> </tbody>
</table> </table>
<p><a href="/blocklist/domain/download"><i class="fa fa-download"></i> {{$block_list.download}}</a></p>
</div> </div>
{{/if}}
{{/if}} {{$hooked nofilter}}
{{$hooked nofilter}}
</div> </div>