From 5ab2480c609b3f2540f5eb840e9cf3eb0589317d Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Mon, 28 Apr 2025 00:58:53 +0500 Subject: feat: display emote's author name --- public/emotes/index.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'public/emotes/index.php') diff --git a/public/emotes/index.php b/public/emotes/index.php index c278e93..d37b3f5 100644 --- a/public/emotes/index.php +++ b/public/emotes/index.php @@ -51,12 +51,20 @@ function display_list_emotes(PDO &$db, int $page, int $limit): array $rows = $stmt->fetchAll(); foreach ($rows as $row) { + $uploader = null; + + if ($row["uploaded_by"]) { + $stmt = $db->prepare("SELECT id, username FROM users WHERE id = ?"); + $stmt->execute([$row["uploaded_by"]]); + $uploader = $stmt->fetch(PDO::FETCH_ASSOC); + } + array_push($emotes, new Emote( $row["id"], $row["code"], $row["ext"], intval(strtotime($row["created_at"])), - $row["uploaded_by"], + $uploader, $row["is_in_user_set"], $row["rating"] )); @@ -357,7 +365,8 @@ if (CLIENT_REQUIRES_JSON) { } echo '' . $e->get_code() . ''; - echo '

' . $e->get_code() . '

'; + echo '

' . $e->get_code() . '

'; + echo '

' . ($e->get_uploaded_by() == null ? (ANONYMOUS_DEFAULT_NAME . "*") : $e->get_uploaded_by()["username"]) . '

'; echo ''; } ?> -- cgit v1.2.3