localBlocklist = $localBlocklist; } /** * @param array $request * @return void * @throws HTTPException\ForbiddenException * @throws HTTPException\FoundException * @throws HTTPException\InternalServerErrorException * @throws HTTPException\MovedPermanentlyException * @throws HTTPException\TemporaryRedirectException */ protected function post(array $request = []) { $this->checkModerationAccess(); if (!isset($request['page_blocklist_upload']) && !isset($request['page_blocklist_import'])) { return; } self::checkFormSecurityTokenRedirectOnError('/moderation/blocklist/server/import', 'moderation_blocklist_import'); if (isset($request['page_blocklist_upload'])) { try { $this->blocklist = $this->localBlocklist::extractFromCSVFile($_FILES['listfile']['tmp_name']); } catch (\Throwable $e) { $this->systemMessages->addNotice($this->t('Error importing pattern file')); return; } } else if (isset($request['page_blocklist_import'])) { $this->blocklist = json_decode($request['blocklist'], true); if ($this->blocklist === null) { $this->systemMessages->addNotice($this->t('Error importing pattern file')); return; } } if (($request['mode'] ?? 'append') == 'replace') { $this->localBlocklist->set($this->blocklist); $this->systemMessages->addNotice($this->t('Local blocklist replaced with the provided file.')); } else { $count = $this->localBlocklist->append($this->blocklist); if ($count) { $this->systemMessages->addNotice($this->tt('%d pattern was added to the local blocklist.', '%d patterns were added to the local blocklist.', $count)); } else { $this->systemMessages->addNotice($this->t('No pattern was added to the local blocklist.')); } } Worker::add(Worker::PRIORITY_LOW, 'UpdateBlockedServers'); $this->baseUrl->redirect('/moderation/blocklist/server'); } /** * @param array $request * @return string * @throws HTTPException\ServiceUnavailableException */ protected function content(array $request = []): string { parent::content(); $t = Renderer::getMarkupTemplate('moderation/blocklist/server/import.tpl'); return Renderer::replaceMacros($t, [ '$l10n' => [ 'return_list' => $this->t('← Return to the list'), 'title' => $this->t('Moderation'), 'page' => $this->t('Import a Server Domain Pattern Blocklist'), 'download' => $this->t('
This file can be downloaded from the /friendica
path of any Friendica server.