From 2e84e2a301fe270f6911f597149cd88d9dc85abe Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 15 May 2025 02:13:55 +0500 Subject: feat: mod comments --- public/account/login/index.php | 3 +- public/static/style.css | 6 +++ public/system/emotes/index.php | 46 ++++++++++++----------- public/system/emotes/manip.php | 76 -------------------------------------- public/system/emotes/verdict.php | 80 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 99 deletions(-) delete mode 100644 public/system/emotes/manip.php create mode 100644 public/system/emotes/verdict.php (limited to 'public') diff --git a/public/account/login/index.php b/public/account/login/index.php index f9e7125..ace116d 100644 --- a/public/account/login/index.php +++ b/public/account/login/index.php @@ -85,8 +85,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
- Login with Twitch + Login with Twitch

Logging in via Twitch gives you the ability to use emotes in your Twitch chat.

diff --git a/public/static/style.css b/public/static/style.css index 218df1a..0abe8d0 100644 --- a/public/static/style.css +++ b/public/static/style.css @@ -262,6 +262,12 @@ button.purple:hover, background: #ac88ea; } +button.big, +.button.big { + padding: 8px 24px; + font-size: 18px; +} + /** ---------- LIST diff --git a/public/system/emotes/index.php b/public/system/emotes/index.php index eaabf4d..bcc1441 100644 --- a/public/system/emotes/index.php +++ b/public/system/emotes/index.php @@ -131,19 +131,6 @@ if (isset($_GET["id"])) {
- -
-
- " style="display: none;"> - - -
-
- " style="display: none;"> - - -
-
@@ -208,15 +195,26 @@ if (isset($_GET["id"])) {
- -
- -
-

No one has done anything on this emote...

+ +
+ " style="display: none;"> + +
+ +
+ + +
+
+ +
+ +
+
-
+ @@ -224,4 +222,10 @@ if (isset($_GET["id"])) { + + \ No newline at end of file diff --git a/public/system/emotes/manip.php b/public/system/emotes/manip.php deleted file mode 100644 index 2e8c391..0000000 --- a/public/system/emotes/manip.php +++ /dev/null @@ -1,76 +0,0 @@ -prepare("SELECT id, code, uploaded_by FROM emotes WHERE id = ? AND visibility = 2 LIMIT 1"); -$stmt->execute([$id]); - -if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $verdict = 2; - - switch ($action) { - case "approve": { - $db->prepare("UPDATE emotes SET visibility = 1 WHERE id = ?") - ->execute([$row["id"]]); - $verdict = 1; - break; - } - case "reject": { - $db->prepare("UPDATE emotes SET visibility = 0 WHERE id = ?") - ->execute([$row["id"]]); - $verdict = 0; - break; - } - default: { - generate_alert("/system/emotes", "Unknown action"); - exit; - } - } - - $comment = str_safe($_POST["comment"] ?? "", EMOTE_COMMENT_MAX_LENGTH, false); - - if ($comment == "") { - $comment = null; - } - - $db->prepare("INSERT INTO mod_actions(user_id, emote_id, verdict, comment) VALUES (?, ?, ?, ?)") - ->execute([$_SESSION["user_id"], $row["id"], $verdict, $comment]); - - if ($row["uploaded_by"] != null) { - $contents = match ($verdict) { - 0 => 'Your emote "' . $row["code"] . '" has been unlisted! Anyone can add it via a direct link.', - 1 => 'Your emote "' . $row["code"] . '" has been approved! Enjoy!', - default => 'We did something with your emote "' . $row["code"] . '"' - }; - - $db->prepare("INSERT INTO inbox_messages(recipient_id, message_type, contents, link) VALUES (?, ?, ?, ?)") - ->execute([$row["uploaded_by"], "1", $contents, "/emotes?id=" . $row["id"]]); - } - - generate_alert("/system/emotes", 'Emote "' . $row["code"] . '" has been ' . ($verdict == 0 ? 'rejected (unlisted)' : 'approved (public)') . '!', 200); - exit; -} - -generate_alert("system/emotes", "Emote ID $id not found", 404); \ No newline at end of file diff --git a/public/system/emotes/verdict.php b/public/system/emotes/verdict.php new file mode 100644 index 0000000..df2f5ba --- /dev/null +++ b/public/system/emotes/verdict.php @@ -0,0 +1,80 @@ +prepare("SELECT id, code, uploaded_by FROM emotes WHERE id = ? AND visibility = 2 LIMIT 1"); +$stmt->execute([$id]); + +if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $verdict = 2; + + switch ($action) { + case "approve": { + $db->prepare("UPDATE emotes SET visibility = 1 WHERE id = ?") + ->execute([$row["id"]]); + $verdict = 1; + break; + } + case "reject": { + $db->prepare("UPDATE emotes SET visibility = 0 WHERE id = ?") + ->execute([$row["id"]]); + $verdict = 0; + break; + } + default: { + generate_alert("/system/emotes", "Unknown action"); + exit; + } + } + + $comment = str_safe($_POST["comment"] ?? "", null, false); + + if ($comment == "") { + $comment = null; + } + + $db->prepare("INSERT INTO mod_actions(user_id, emote_id, verdict, comment) VALUES (?, ?, ?, ?)") + ->execute([$_SESSION["user_id"], $row["id"], $verdict, $comment]); + + if ($row["uploaded_by"] != null) { + $contents = match ($verdict) { + 0 => 'Your emote "' . $row["code"] . '" has been unlisted! Anyone can add it via a direct link.', + 1 => 'Your emote "' . $row["code"] . '" has been approved! Enjoy!', + default => 'We did something with your emote "' . $row["code"] . '"' + }; + + if ($comment != null) { + $contents .= " Mod's comment: $comment"; + } + + $db->prepare("INSERT INTO inbox_messages(recipient_id, message_type, contents, link) VALUES (?, ?, ?, ?)") + ->execute([$row["uploaded_by"], "1", $contents, "/emotes?id=" . $row["id"]]); + } + + generate_alert("/system/emotes", 'Emote "' . $row["code"] . '" has been ' . ($verdict == 0 ? 'unlisted' : 'set to public') . '!', 200); + exit; +} + +generate_alert("system/emotes", "Emote ID $id not found", 404); \ No newline at end of file -- cgit v1.2.3