Check if a comment is deleted before voting.
This commit is contained in:
parent
744fa99230
commit
ee2d608dc3
1 changed files with 8 additions and 7 deletions
|
@ -28,13 +28,6 @@ $commentPerms = comments_get_perms(user_session_current('user_id', 0));
|
|||
|
||||
switch ($_GET['m'] ?? null) {
|
||||
case 'vote':
|
||||
$comment = (int)($_GET['c'] ?? 0);
|
||||
|
||||
if ($comment < 1) {
|
||||
echo render_info_or_json($isXHR, 'Missing data.', 400);
|
||||
break;
|
||||
}
|
||||
|
||||
$vote = (int)($_GET['v'] ?? 0);
|
||||
|
||||
if (!array_key_exists($vote, MSZ_COMMENTS_VOTE_TYPES)) {
|
||||
|
@ -42,6 +35,14 @@ switch ($_GET['m'] ?? null) {
|
|||
break;
|
||||
}
|
||||
|
||||
$comment = (int)($_GET['c'] ?? 0);
|
||||
$commentInfo = comments_post_get($comment, false);
|
||||
|
||||
if (!$commentInfo || $commentInfo['comment_deleted'] !== null) {
|
||||
echo render_info_or_json($isXHR, "This comment doesn't exist!", 400);
|
||||
break;
|
||||
}
|
||||
|
||||
$vote = MSZ_COMMENTS_VOTE_TYPES[(int)($_GET['v'] ?? 0)];
|
||||
$voteResult = comments_vote_add(
|
||||
$comment,
|
||||
|
|
Loading…
Add table
Reference in a new issue