misuzu/public/manage/general/emoticon.php

40 lines
1.3 KiB
PHP
Raw Normal View History

2019-07-05 00:14:05 +00:00
<?php
namespace Misuzu;
2019-07-05 00:14:05 +00:00
require_once '../../../misuzu.php';
if(!perms_check_user(MSZ_PERMS_GENERAL, user_session_current('user_id'), General::PERM_MANAGE_EMOTES)) {
2019-07-05 00:14:05 +00:00
echo render_error(403);
return;
}
$emoteId = !empty($_GET['e']) && is_string($_GET['e']) ? (int)$_GET['e'] : 0;
if($emoteId > 0) {
$emoteInfo = emotes_get_by_id($emoteId);
}
if(csrf_verify_request()
&& isset($_POST['emote_order']) && isset($_POST['emote_hierarchy'])
&& !empty($_POST['emote_string']) && !empty($_POST['emote_url'])) {
if(empty($emoteInfo)) {
$emoteId = emotes_add($_POST['emote_string'], $_POST['emote_url'], $_POST['emote_hierarchy'], $_POST['emote_order']);
if($emoteId > 0) {
// seems like an odd decision to redirect back to the emoticons index, but it'll probably be nicer in the long run
url_redirect('manage-general-emoticons');
return;
} else {
echo "SOMETHING HAPPENED {$emoteId}";
}
} else {
emotes_update_url($emoteInfo['emote_url'], $_POST['emote_url'], $_POST['emote_hierarchy'], $_POST['emote_order']);
emotes_update_string($emoteId, $_POST['emote_string']);
$emoteInfo = emotes_get_by_id($emoteId);
}
}
Template::render('manage.general.emoticon', [
2019-07-05 00:14:05 +00:00
'emote_info' => $emoteInfo ?? null,
]);