false, 'error' => $message], JSON_UNESCAPED_UNICODE); exit; } set_flash('error', $message); redirect('/members.php'); }; if (!isset(REACTION_TYPES[$type]) || $id <= 0 || !in_array($emoji, REACTION_EMOJIS, true)) { $fail('Diese Reaktion gibt es nicht.'); } // Inhalt, Bild und Besitzer laden - reagieren darf nur, wer den Inhalt auch sehen kann. $me = current_user(); if ($type === 'picture') { $stmt = db()->prepare( 'SELECT g.id AS picture_id, g.user_id AS owner_id, g.status, g.user_id AS author_id, u.gallery_comments_enabled, u.status AS owner_status FROM member_gallery g JOIN users u ON u.id = g.user_id WHERE g.id = ? AND g.is_background = 0' ); } else { $stmt = db()->prepare( 'SELECT g.id AS picture_id, g.user_id AS owner_id, c.status, c.author_id, u.gallery_comments_enabled, u.status AS owner_status FROM gallery_comments c JOIN member_gallery g ON g.id = c.gallery_id JOIN users u ON u.id = g.user_id WHERE c.id = ?' ); } $stmt->execute([$id]); $content = $stmt->fetch(); $canSee = $content && $content['owner_status'] === 'active' && ($content['status'] === 'visible' || (int) $content['author_id'] === (int) $me['id'] || moderation_can()); if (!$canSee) { $fail('Diesen Inhalt gibt es nicht (mehr).'); } if (empty($content['gallery_comments_enabled'])) { $fail('Unter diesen Bildern sind Kommentare und Reaktionen abgeschaltet.'); } if (!security_throttle('reaction')) { $fail('Du reagierst gerade sehr schnell - bitte kurz warten.'); } reaction_toggle($type, $id, $emoji); if ($isAjax) { header('Content-Type: application/json; charset=UTF-8'); $reactions = reactions_for($type, [$id])[$id] ?? []; echo json_encode(['ok' => true, 'html' => reactions_bar_html($type, $id, $reactions, true, $type === 'comment')], JSON_UNESCAPED_UNICODE); exit; } redirect('/member_picture.php?id=' . (int) $content['picture_id'] . ($type === 'comment' ? '#kommentar-' . $id : ''));