46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
namespace Misuzu;
|
|
|
|
if(!$msz->isLoggedIn() || !perms_check_user(MSZ_PERMS_GENERAL, $msz->getActiveUser()->getId(), MSZ_PERM_FORUM_TOPIC_REDIRS)) {
|
|
echo render_error(403);
|
|
return;
|
|
}
|
|
|
|
$forum = $msz->getForum();
|
|
|
|
if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
if(!CSRF::validateRequest())
|
|
throw new \Exception("Request verification failed.");
|
|
|
|
$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]);
|
|
$forum->createTopicRedirect($rTopicId, $msz->getActiveUser(), $rTopicURL);
|
|
url_redirect('manage-forum-topic-redirs');
|
|
return;
|
|
}
|
|
|
|
if(filter_input(INPUT_GET, 'm') === 'explode') {
|
|
if(!CSRF::validateRequest())
|
|
throw new \Exception("Request verification failed.");
|
|
|
|
$rTopicId = (string)filter_input(INPUT_GET, 't');
|
|
$msz->createAuditLog('FORUM_TOPIC_REDIR_REMOVE', [$rTopicId]);
|
|
$forum->deleteTopicRedirect($rTopicId);
|
|
url_redirect('manage-forum-topic-redirs');
|
|
return;
|
|
}
|
|
|
|
$pagination = new Pagination($forum->countTopicRedirects(), 20);
|
|
if(!$pagination->hasValidOffset()) {
|
|
echo render_error(404);
|
|
return;
|
|
}
|
|
|
|
$redirs = $forum->getTopicRedirects(pagination: $pagination);
|
|
|
|
Template::render('manage.forum.redirs', [
|
|
'manage_redirs' => $redirs,
|
|
'manage_redirs_pagination' => $pagination,
|
|
]);
|