From 2c51a000a9f2f51f54b761e4975086f9db3780a4 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 3 May 2025 16:50:50 +0500 Subject: upd: big changes in database.sql + .webp is now default image format --- public/emotes/index.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'public/emotes/index.php') diff --git a/public/emotes/index.php b/public/emotes/index.php index 3491ab8..2c2cff7 100644 --- a/public/emotes/index.php +++ b/public/emotes/index.php @@ -61,7 +61,7 @@ function display_list_emotes(PDO &$db, string $search, string $sort_by, int $pag array_push($emotes, new Emote( $row["id"], $row["code"], - $row["ext"], + "webp", intval(strtotime($row["created_at"])), $uploader, $row["is_in_user_set"], @@ -73,7 +73,7 @@ function display_list_emotes(PDO &$db, string $search, string $sort_by, int $pag return $emotes; } -function display_emote(PDO &$db, int $id) +function display_emote(PDO &$db, string $id) { $stmt = $db->prepare("SELECT e.*, COALESCE(COUNT(r.rate), 0) as total_rating, COALESCE(ROUND(AVG(r.rate), 2), 0) AS average_rating @@ -89,7 +89,7 @@ function display_emote(PDO &$db, int $id) $emote = new Emote( $row["id"], $row["code"], - $row["ext"], + "webp", intval(strtotime($row["created_at"])), $row["uploaded_by"], false, @@ -130,14 +130,14 @@ $total_pages = 0; $search = "%" . ($_GET["q"] ?? "") . "%"; $sort_by = $_GET["sort_by"] ?? ""; -if ($id == "" || !is_numeric($id)) { +if (empty($id)) { $emotes = display_list_emotes($db, $search, $sort_by, $page, $limit); $stmt = $db->prepare("SELECT COUNT(*) FROM emotes WHERE code LIKE ? AND visibility = 1"); $stmt->execute([$search]); $total_emotes = $stmt->fetch()[0]; $total_pages = ceil($total_emotes / $limit); } else { - $emote = display_emote($db, intval($id)); + $emote = display_emote($db, $id); } if (CLIENT_REQUIRES_JSON) { @@ -180,14 +180,14 @@ if (CLIENT_REQUIRES_JSON) { get_code() : "$total_emotes Emotes - Page $page/$total_pages" ?> + if ($emote != null) { ?>
- <?php echo $emote->get_code() ?> - <?php echo $emote->get_code() ?> - <?php echo $emote->get_code() ?>
@@ -200,14 +200,14 @@ if (CLIENT_REQUIRES_JSON) { $added = false; if (isset($_SESSION["user_emote_set_id"])) { - $stmt = $db->prepare("SELECT id, name FROM emote_set_contents WHERE emote_set_id = ? AND emote_id = ?"); + $stmt = $db->prepare("SELECT id, code FROM emote_set_contents WHERE emote_set_id = ? AND emote_id = ?"); $stmt->execute([$_SESSION["user_emote_set_id"], $emote->get_id()]); $added = false; if ($row = $stmt->fetch()) { $added = true; - $emote_current_name = $row["name"] ?? $emote->get_code(); + $emote_current_name = $row["code"] ?? $emote->get_code(); } } @@ -419,7 +419,7 @@ if (CLIENT_REQUIRES_JSON) { echo ''; } - 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