. * */ namespace Friendica\Module\Admin\Blocklist; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Module\BaseAdmin; use Friendica\Util\Strings; class Server extends BaseAdmin { public static function post(array $parameters = []) { parent::post($parameters); if (empty($_POST['page_blocklist_save']) && empty($_POST['page_blocklist_edit'])) { return; } parent::checkFormSecurityTokenRedirectOnError('/admin/blocklist/server', 'admin_blocklist'); if (!empty($_POST['page_blocklist_save'])) { // Add new item to blocklist $blocklist = DI::config()->get('system', 'blocklist'); $blocklist[] = [ 'domain' => Strings::escapeTags(trim($_POST['newentry_domain'])), 'reason' => Strings::escapeTags(trim($_POST['newentry_reason'])) ]; DI::config()->set('system', 'blocklist', $blocklist); info(DI::l10n()->t('Server domain pattern added to blocklist.') . EOL); } else { // Edit the entries from blocklist $blocklist = []; foreach ($_POST['domain'] as $id => $domain) { // Trimming whitespaces as well as any lingering slashes $domain = Strings::escapeTags(trim($domain, "\x00..\x1F/")); $reason = Strings::escapeTags(trim($_POST['reason'][$id])); if (empty($_POST['delete'][$id])) { $blocklist[] = [ 'domain' => $domain, 'reason' => $reason ]; } } DI::config()->set('system', 'blocklist', $blocklist); } DI::baseUrl()->redirect('admin/blocklist/server'); } public static function content(array $parameters = []) { parent::content($parameters); $blocklist = DI::config()->get('system', 'blocklist'); $blocklistform = []; if (is_array($blocklist)) { foreach ($blocklist as $id => $b) { $blocklistform[] = [ 'domain' => ["domain[$id]", DI::l10n()->t('Blocked server domain pattern'), $b['domain'], '', 'required', '', ''], 'reason' => ["reason[$id]", DI::l10n()->t("Reason for the block"), $b['reason'], '', 'required', '', ''], 'delete' => ["delete[$id]", DI::l10n()->t("Delete server domain pattern") . ' (' . $b['domain'] . ')', false, DI::l10n()->t("Check to delete this entry from the blocklist")] ]; } } $t = Renderer::getMarkupTemplate('admin/blocklist/server.tpl'); return Renderer::replaceMacros($t, [ '$title' => DI::l10n()->t('Administration'), '$page' => DI::l10n()->t('Server Domain Pattern Blocklist'), '$intro' => DI::l10n()->t('This page can be used to define a blocklist of server domain patterns from the federated network that are not allowed to interact with your node. For each domain pattern you should also provide the reason why you block it.'), '$public' => DI::l10n()->t('The list of blocked server domain patterns will be made publically available on the /friendica page so that your users and people investigating communication problems can find the reason easily.'), '$syntax' => DI::l10n()->t('
The server domain pattern syntax is case-insensitive shell wildcard, comprising the following special characters:
*
: Any number of characters?
: Any single character[<char1><char2>...]
: char1 or char2