misuzu/public-legacy/manage/forum/redirs.php

46 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Misuzu;
$authInfo = $msz->getAuthInfo();
if(!$authInfo->getPerms('global')->check(Perm::G_FORUM_TOPIC_REDIRS_MANAGE))
Template::throwError(403);
2024-10-05 02:40:29 +00:00
$urls = $msz->getUrls();
$forumCtx = $msz->getForumContext();
$forumTopicRedirects = $forumCtx->getTopicRedirects();
2023-08-28 01:17:34 +00:00
if($_SERVER['REQUEST_METHOD'] === 'POST') {
if(!CSRF::validateRequest())
throw new \Exception("Request verification failed.");
2023-08-28 01:17:34 +00:00
$rTopicId = (string)filter_input(INPUT_POST, 'topic_redir_id');
$rTopicURL = trim((string)filter_input(INPUT_POST, 'topic_redir_url'));
$msz->createAuditLog('FORUM_TOPIC_REDIR_CREATE', [$rTopicId]);
$forumTopicRedirects->createTopicRedirect($rTopicId, $authInfo->getUserInfo(), $rTopicURL);
2023-09-08 20:40:48 +00:00
Tools::redirect($urls->format('manage-forum-topic-redirs'));
return;
}
if(filter_input(INPUT_GET, 'm') === 'explode') {
if(!CSRF::validateRequest())
throw new \Exception("Request verification failed.");
2023-08-28 01:17:34 +00:00
$rTopicId = (string)filter_input(INPUT_GET, 't');
$msz->createAuditLog('FORUM_TOPIC_REDIR_REMOVE', [$rTopicId]);
$forumTopicRedirects->deleteTopicRedirect($rTopicId);
2023-09-08 20:40:48 +00:00
Tools::redirect($urls->format('manage-forum-topic-redirs'));
return;
}
$pagination = new Pagination($forumTopicRedirects->countTopicRedirects(), 20);
if(!$pagination->hasValidOffset())
Template::throwError(404);
$redirs = $forumTopicRedirects->getTopicRedirects(pagination: $pagination);
Template::render('manage.forum.redirs', [
'manage_redirs' => $redirs,
'manage_redirs_pagination' => $pagination,
]);