From 999bfa6cad76900d4550e00e8e29f0252fb006b5 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 22 Apr 2025 22:39:58 +0500 Subject: feat: inbox system --- database.sql | 10 +++++ public/inbox.php | 76 ++++++++++++++++++++++++++++++++++++ public/static/img/icons/inbox/0.png | Bin 0 -> 587 bytes public/static/img/icons/inbox/1.png | Bin 0 -> 781 bytes public/static/img/icons/inbox/2.png | Bin 0 -> 641 bytes src/partials.php | 15 +++++++ 6 files changed, 101 insertions(+) create mode 100644 public/inbox.php create mode 100644 public/static/img/icons/inbox/0.png create mode 100644 public/static/img/icons/inbox/1.png create mode 100644 public/static/img/icons/inbox/2.png diff --git a/database.sql b/database.sql index ec59cf8..15c73e8 100644 --- a/database.sql +++ b/database.sql @@ -55,4 +55,14 @@ CREATE TABLE IF NOT EXISTS ratings ( emote_id INTEGER NOT NULL REFERENCES emotes(id), rate INTEGER NOT NULL, rated_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS inbox_messages ( + id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, + recipient_id INTEGER NOT NULL REFERENCES users(id), + message_type INTEGER NOT NULL, + contents TEXT NOT NULL, + link TEXT, + sent_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP, + has_read BOOLEAN NOT NULL DEFAULT false ); \ No newline at end of file diff --git a/public/inbox.php b/public/inbox.php new file mode 100644 index 0000000..878bfe4 --- /dev/null +++ b/public/inbox.php @@ -0,0 +1,76 @@ +prepare("SELECT * FROM inbox_messages WHERE recipient_id = ? ORDER BY sent_at DESC"); +$stmt->execute([$_SESSION["user_id"]]); + +$messages = $stmt->fetchAll(PDO::FETCH_ASSOC); + +$stmt = $db->prepare("UPDATE inbox_messages SET has_read = true WHERE recipient_id = ?"); +$stmt->execute([$_SESSION["user_id"]]); + +?> + + + + + Inbox - alright.party + + + + +
+
+ +
+
+ +
+ + + + + + + '; + + echo ''; + echo ''; + + echo ''; + + echo ''; + } + ?> +
Contents
' . $message["contents"]; + echo ' (' . format_timestamp(time() - strtotime($message["sent_at"])) . ' ago)'; + echo ''; + if ($message["link"]) { + echo '[ View ]'; + } + echo '
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/public/static/img/icons/inbox/0.png b/public/static/img/icons/inbox/0.png new file mode 100644 index 0000000..c149c2b Binary files /dev/null and b/public/static/img/icons/inbox/0.png differ diff --git a/public/static/img/icons/inbox/1.png b/public/static/img/icons/inbox/1.png new file mode 100644 index 0000000..89c8129 Binary files /dev/null and b/public/static/img/icons/inbox/1.png differ diff --git a/public/static/img/icons/inbox/2.png b/public/static/img/icons/inbox/2.png new file mode 100644 index 0000000..7348aed Binary files /dev/null and b/public/static/img/icons/inbox/2.png differ diff --git a/src/partials.php b/src/partials.php index 71f4f63..174b1d3 100644 --- a/src/partials.php +++ b/src/partials.php @@ -12,6 +12,21 @@ function html_navigation_bar() Users Upload Account + prepare("SELECT COUNT(*) FROM inbox_messages WHERE recipient_id = ? AND has_read = false"); + $stmt->execute([$_SESSION["user_id"]]); + $unread_count = intval($stmt->fetch()[0]); + echo '' ?> + + Inbox 0 ? "($unread_count)" : "" ?> + +