2022-09-13 13:14:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
2023-07-12 21:52:55 +00:00
|
|
|
use RuntimeException;
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
if(!$msz->authInfo->getPerms('global')->check(Perm::G_EMOTES_MANAGE))
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(403);
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2023-07-12 21:52:55 +00:00
|
|
|
if(CSRF::validateRequest() && !empty($_GET['emote'])) {
|
|
|
|
$emoteId = (string)filter_input(INPUT_GET, 'emote', FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
|
|
|
|
try {
|
2024-11-30 04:09:29 +00:00
|
|
|
$emoteInfo = $msz->emotes->getEmote($emoteId);
|
2023-07-12 21:52:55 +00:00
|
|
|
} catch(RuntimeException $ex) {
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(404);
|
2022-09-13 13:14:49 +00:00
|
|
|
}
|
|
|
|
|
2023-07-12 21:52:55 +00:00
|
|
|
if(!empty($_GET['delete'])) {
|
2024-11-30 04:09:29 +00:00
|
|
|
$msz->emotes->deleteEmote($emoteInfo);
|
|
|
|
$msz->createAuditLog('EMOTICON_DELETE', [$emoteInfo->id]);
|
2023-07-12 21:52:55 +00:00
|
|
|
} else {
|
|
|
|
if(isset($_GET['order'])) {
|
|
|
|
$order = filter_input(INPUT_GET, 'order');
|
2023-09-10 20:02:11 +00:00
|
|
|
$offset = $order === 'i' ? 10 : ($order === 'd' ? -10 : 0);
|
2024-11-30 04:09:29 +00:00
|
|
|
$msz->emotes->updateEmoteOrderOffset($emoteInfo, $offset);
|
|
|
|
$msz->createAuditLog('EMOTICON_ORDER', [$emoteInfo->id]);
|
2023-07-12 21:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(isset($_GET['alias'])) {
|
|
|
|
$alias = (string)filter_input(INPUT_GET, 'alias');
|
2024-11-30 04:09:29 +00:00
|
|
|
if($msz->emotes->checkEmoteString($alias) === '') {
|
|
|
|
$msz->emotes->addEmoteString($emoteInfo, $alias);
|
|
|
|
$msz->createAuditLog('EMOTICON_ALIAS', [$emoteInfo->id, $alias]);
|
2023-07-15 02:05:49 +00:00
|
|
|
}
|
2023-07-12 21:52:55 +00:00
|
|
|
}
|
2022-09-13 13:14:49 +00:00
|
|
|
}
|
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
Tools::redirect($msz->urls->format('manage-general-emoticons'));
|
2022-09-13 13:14:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Template::render('manage.general.emoticons', [
|
2024-11-30 04:09:29 +00:00
|
|
|
'emotes' => $msz->emotes->getEmotes(),
|
2022-09-13 13:14:49 +00:00
|
|
|
]);
|