From d2251781e3b175df5de96c5b07002ea50ff9561d Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sun, 24 Aug 2025 20:26:36 -0700 Subject: [PATCH] Edit chatroom messages endpoint --- database/editChatroomMessage.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 database/editChatroomMessage.php diff --git a/database/editChatroomMessage.php b/database/editChatroomMessage.php new file mode 100644 index 0000000..afc43ec --- /dev/null +++ b/database/editChatroomMessage.php @@ -0,0 +1,32 @@ +\/\?\\\\|`~]+$/', $content)) exit; + +$conn = newConnection(); + +$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); +$stmt->bind_param("ss", $token, $username); +$stmt->execute(); +$result = $stmt->get_result(); +$row = $result->fetch_assoc(); +if (!$row) exit; +$stmt->close(); + +$user_id = $row["id"]; +$content = base64_encode($content); + +$stmt = $conn->prepare("UPDATE chats SET content = ? WHERE userId = ? AND id = ?"); +$stmt->bind_param("sii", $content, $user_id, $id); +$stmt->execute(); +$stmt->close(); + +$conn->close(); \ No newline at end of file