From 44334d654977ed4ecd601c7a47127f91dea1517d Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 14 May 2025 23:18:20 +0500 Subject: feat: emote source --- database.sql | 6 ++++++ public/emotes/index.php | 15 +++++++++++++-- public/emotes/upload.php | 16 +++++++++++++--- public/system/emotes/index.php | 9 +++++++++ src/emote.php | 10 +++++++++- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/database.sql b/database.sql index a92ad46..6ce0c96 100644 --- a/database.sql +++ b/database.sql @@ -137,6 +137,12 @@ CREATE TABLE IF NOT EXISTS actions ( created_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP ); +-- ------------------------- +-- ALTERS +-- ------------------------- + +ALTER TABLE emotes ADD COLUMN IF NOT EXISTS source TEXT; + -- ------------------------- -- INSERTIONS -- ------------------------- diff --git a/public/emotes/index.php b/public/emotes/index.php index 978515f..68ae983 100644 --- a/public/emotes/index.php +++ b/public/emotes/index.php @@ -77,7 +77,8 @@ function display_list_emotes(PDO &$db, string $search, string $sort_by, int $pag $uploader, $row["is_in_user_set"], $row["rating"], - $row["visibility"] + $row["visibility"], + $row["source"] )); } @@ -107,7 +108,8 @@ function display_emote(PDO &$db, string $id) $row["uploaded_by"], false, ["total" => $row["total_rating"], "average" => $row["average_rating"]], - $row["visibility"] + $row["visibility"], + $row["source"] ); } } @@ -476,6 +478,15 @@ if (CLIENT_REQUIRES_JSON) { } ?> + get_source()): ?> + + Source + + get_source() ?> + + + diff --git a/public/emotes/upload.php b/public/emotes/upload.php index 2c37c26..a9d416c 100644 --- a/public/emotes/upload.php +++ b/public/emotes/upload.php @@ -100,9 +100,14 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") {

test

- + +
+ + +
+
@@ -323,6 +328,11 @@ if (empty($notes)) { $notes = null; } +$source = str_safe($_POST["source"] ?? "", null); +if (empty($source)) { + $source = null; +} + $visibility = clamp(intval($_POST["visibility"], EMOTE_VISIBILITY_DEFAULT), 0, 2); if (MOD_EMOTES_APPROVE && $visibility == 1 && EMOTE_VISIBILITY_DEFAULT != 1) { @@ -333,8 +343,8 @@ if (MOD_EMOTES_APPROVE && $visibility == 1 && EMOTE_VISIBILITY_DEFAULT != 1) { $db = new PDO(DB_URL, DB_USER, DB_PASS); $id = bin2hex(random_bytes(16)); -$stmt = $db->prepare("INSERT INTO emotes(id, code, notes, uploaded_by, visibility) VALUES (?, ?, ?, ?, ?)"); -$stmt->execute([$id, $code, $notes, $uploaded_by, $visibility]); +$stmt = $db->prepare("INSERT INTO emotes(id, code, notes, source, uploaded_by, visibility) VALUES (?, ?, ?, ?, ?, ?)"); +$stmt->execute([$id, $code, $notes, $source, $uploaded_by, $visibility]); $path = "../static/userdata/emotes/$id"; diff --git a/public/system/emotes/index.php b/public/system/emotes/index.php index 9732bdb..9e88d83 100644 --- a/public/system/emotes/index.php +++ b/public/system/emotes/index.php @@ -179,6 +179,15 @@ if (isset($_GET["id"])) { Notes Empty' ?> + + + Source + + " + target="_blank"> + + + diff --git a/src/emote.php b/src/emote.php index ea9e52c..8e7da38 100644 --- a/src/emote.php +++ b/src/emote.php @@ -10,7 +10,9 @@ class Emote public bool $is_in_user_set; public int $visibility; - function __construct($id, $code, $ext, $created_at, $uploaded_by, $is_in_user_set, $rating, $visibility) + public string|null $source; + + function __construct($id, $code, $ext, $created_at, $uploaded_by, $is_in_user_set, $rating, $visibility, $source) { $this->id = $id; $this->code = $code; @@ -20,6 +22,7 @@ class Emote $this->is_in_user_set = $is_in_user_set; $this->rating = $rating; $this->visibility = $visibility; + $this->source = $source; } function get_id() @@ -61,6 +64,11 @@ class Emote { return $this->visibility; } + + function get_source() + { + return $this->source; + } } function html_random_emote(PDO &$db) -- cgit v1.2.3