misuzu/public-legacy/manage/general/emoticons.php

47 lines
1.4 KiB
PHP
Raw Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu;
use RuntimeException;
2022-09-13 13:14:49 +00:00
if(!$msz->getAuthInfo()->getPerms('global')->check(Perm::G_EMOTES_MANAGE))
Template::throwError(403);
2022-09-13 13:14:49 +00:00
$emotes = $msz->getEmotes();
2022-09-13 13:14:49 +00:00
if(CSRF::validateRequest() && !empty($_GET['emote'])) {
$emoteId = (string)filter_input(INPUT_GET, 'emote', FILTER_SANITIZE_NUMBER_INT);
try {
$emoteInfo = $emotes->getEmote($emoteId);
} catch(RuntimeException $ex) {
Template::throwError(404);
2022-09-13 13:14:49 +00:00
}
if(!empty($_GET['delete'])) {
$emotes->deleteEmote($emoteInfo);
$msz->createAuditLog('EMOTICON_DELETE', [$emoteInfo->getId()]);
} else {
if(isset($_GET['order'])) {
$order = filter_input(INPUT_GET, 'order');
$offset = $order === 'i' ? 1 : ($order === 'd' ? -1 : 0);
$emotes->updateEmoteOrderOffset($emoteInfo, $offset);
$msz->createAuditLog('EMOTICON_ORDER', [$emoteInfo->getId()]);
}
if(isset($_GET['alias'])) {
$alias = (string)filter_input(INPUT_GET, 'alias');
2023-07-15 02:05:49 +00:00
if($emotes->checkEmoteString($alias) === '') {
$emotes->addEmoteString($emoteInfo, $alias);
$msz->createAuditLog('EMOTICON_ALIAS', [$emoteInfo->getId(), $alias]);
2023-07-15 02:05:49 +00:00
}
}
2022-09-13 13:14:49 +00:00
}
2023-09-08 20:40:48 +00:00
Tools::redirect($msz->getURLs()->format('manage-general-emoticons'));
2022-09-13 13:14:49 +00:00
return;
}
Template::render('manage.general.emoticons', [
'emotes' => $emotes->getEmotes(),
2022-09-13 13:14:49 +00:00
]);