43 lines
1.8 KiB
PHP
43 lines
1.8 KiB
PHP
<?php
|
|
namespace Misuzu;
|
|
|
|
if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|
die('Script must be called through the Misuzu route dispatcher.');
|
|
|
|
if(!$msz->authInfo->getPerms('global')->check(Perm::G_FORUM_TOPIC_REDIRS_MANAGE))
|
|
Template::throwError(403);
|
|
|
|
if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
if(!$msz->csrfCtx->verifyLegacy())
|
|
throw new \Exception("Request verification failed.");
|
|
|
|
$rTopicId = !empty($_POST['topic_redir_id']) && is_scalar($_POST['topic_redir_id']) ? trim((string)$_POST['topic_redir_id']) : '';
|
|
$rTopicURL = !empty($_POST['topic_redir_url']) && is_scalar($_POST['topic_redir_url']) ? trim((string)$_POST['topic_redir_url']) : '';
|
|
|
|
$msz->logsCtx->createAuthedLog('FORUM_TOPIC_REDIR_CREATE', [$rTopicId]);
|
|
$msz->forumCtx->topicRedirects->createTopicRedirect($rTopicId, $msz->authInfo->userInfo, $rTopicURL);
|
|
Tools::redirect($msz->routingCtx->urls->format('manage-forum-topic-redirs'));
|
|
return;
|
|
}
|
|
|
|
if(!empty($_GET['m']) && $_GET['m'] === 'explode') {
|
|
if(!$msz->csrfCtx->verifyLegacy())
|
|
throw new \Exception("Request verification failed.");
|
|
|
|
$rTopicId = !empty($_GET['t']) && is_scalar($_GET['t']) ? (string)$_GET['t'] : '';
|
|
$msz->logsCtx->createAuthedLog('FORUM_TOPIC_REDIR_REMOVE', [$rTopicId]);
|
|
$msz->forumCtx->topicRedirects->deleteTopicRedirect($rTopicId);
|
|
Tools::redirect($msz->routingCtx->urls->format('manage-forum-topic-redirs'));
|
|
return;
|
|
}
|
|
|
|
$pagination = Pagination::fromInput($msz->forumCtx->topicRedirects->countTopicRedirects(), 20);
|
|
if(!$pagination->validOffset)
|
|
Template::throwError(404);
|
|
|
|
$redirs = $msz->forumCtx->topicRedirects->getTopicRedirects(pagination: $pagination);
|
|
|
|
Template::render('manage.forum.redirs', [
|
|
'manage_redirs' => $redirs,
|
|
'manage_redirs_pagination' => $pagination,
|
|
]);
|