prepare("SELECT e.id, e.code, e.created_at, e.source, e.visibility, COALESCE(COUNT(r.rate), 0) as total_rating, COALESCE(ROUND(AVG(r.rate), 2), 0) AS average_rating, CASE WHEN up.private_profile = FALSE OR up.id = ? THEN e.uploaded_by ELSE NULL END AS uploaded_by FROM emotes e LEFT JOIN user_preferences up ON up.id = e.uploaded_by LEFT JOIN ratings AS r ON r.emote_id = e.id WHERE e.id = ? LIMIT 1 "); $stmt->execute([$user_id, $id]); $row = $stmt->fetch(); if ($row["id"]) { // fetching emote tags $stmt = $db->prepare("SELECT t.code FROM tags t INNER JOIN tag_assigns ta ON ta.emote_id = ? WHERE t.id = ta.tag_id "); $stmt->execute([$row["id"]]); $tags = $stmt->fetchAll(PDO::FETCH_ASSOC); $tags = array_column($tags, "code"); $row["tags"] = $tags; $row["ext"] = "webp"; $emote = Emote::from_array_with_user($row, $db); } else { generate_alert("/404.php", "Emote ID $id does not exists", 404); exit; } } // fetching all emotes else { $sort_by = $_GET["s"] ?? "high_ratings"; $sort = match ($sort_by) { "low_ratings" => "rating ASC", "recent" => "e.created_at DESC", "oldest" => "e.created_at ASC", default => "rating DESC" }; $page = max(1, intval($_GET["p"] ?? "1")); $limit = 50; $offset = ($page - 1) * $limit; $search = $_GET["q"] ?? ""; // fetching emotes $stmt = $db->prepare("SELECT e.*, CASE WHEN up.private_profile = FALSE OR up.id = ? THEN e.uploaded_by ELSE NULL END AS uploaded_by, CASE WHEN EXISTS ( SELECT 1 FROM emote_set_contents ec INNER JOIN emote_sets es ON es.id = ec.emote_set_id JOIN acquired_emote_sets aes ON aes.emote_set_id = es.id WHERE ec.emote_id = e.id AND es.id = ? ) THEN 1 ELSE 0 END AS is_in_user_set, COALESCE(COUNT(r.rate), 0) AS rating FROM emotes e LEFT JOIN user_preferences up ON up.id = e.uploaded_by LEFT JOIN ratings AS r ON r.emote_id = e.id LEFT JOIN tag_assigns ta ON ta.emote_id = e.id LEFT JOIN tags t ON t.id = ta.tag_id WHERE (t.code = ? OR e.code LIKE ?) AND e.visibility = 1 GROUP BY e.id, e.code, e.created_at ORDER BY $sort LIMIT ? OFFSET ? "); $sql_search = "%$search%"; $user_emote_set_id = $_SESSION["user_active_emote_set_id"] ?? ""; $stmt->bindParam(1, $user_id, PDO::PARAM_STR); $stmt->bindParam(2, $user_emote_set_id, PDO::PARAM_STR); $stmt->bindParam(3, $search, PDO::PARAM_STR); $stmt->bindParam(4, $sql_search, PDO::PARAM_STR); $stmt->bindParam(5, $limit, PDO::PARAM_INT); $stmt->bindParam(6, $offset, PDO::PARAM_INT); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $emotes = []; foreach ($rows as $row) { array_push($emotes, Emote::from_array_with_user($row, $db)); } $stmt = $db->prepare("SELECT COUNT(*) FROM emotes WHERE code LIKE ? AND visibility = 1"); $stmt->execute([$sql_search]); $total_emotes = $stmt->fetch()[0]; $total_pages = ceil($total_emotes / $limit); } if (CLIENT_REQUIRES_JSON) { json_response([ "status_code" => 200, "message" => null, "data" => $emotes ?? $emote ]); exit; } ?> <?php echo ($emote != null ? "Emote " . $emote->get_code() : "Emotes") . ' - ' . CONFIG['instance']['name'] ?>
'; echo ''; $path = $_SERVER["DOCUMENT_ROOT"] . '/static/userdata/emotes/' . $emote->get_id() . "/{$size}x.webp"; echo '
'; if ($file_size = filesize($path)) { $kb = sprintf("%.2f", $file_size / 1024); echo "

{$kb}KB

"; } if ($image_size = getimagesize($path)) { echo "

$image_size[0]x$image_size[1]

"; } echo '
'; } ?>
prepare("SELECT id, code FROM emote_set_contents WHERE emote_set_id = ? AND emote_id = ?"); $stmt->execute([$_SESSION["user_active_emote_set_id"], $emote->get_id()]); $added = false; if ($row = $stmt->fetch()) { $added = true; $emote_current_name = $row["code"] ?? $emote->get_code(); } } if (isset($_SESSION["user_role"]) && $_SESSION["user_role"]["permission_emoteset_own"]) { echo '' ?>
" style="display: none;">
" style="display: none;">
get_uploaded_by() === $_SESSION["user_id"]): ?>
prepare("SELECT rate FROM ratings WHERE user_id = ? AND emote_id = ?"); $stmt->execute([$_SESSION["user_id"], $id]); if ($row = $stmt->fetch()) { echo 'You gave '; } else { foreach (CONFIG['rating']['names'] as $key => $value) { echo '
'; echo ''; echo ""; echo '
'; } } } if (CONFIG['reports']['enable'] && $_SESSION["user_role"]["permission_report"]) { echo "Report emote"; } } ?>

Log in to get additional features...

get_tags())): ?> prepare("SELECT u.id, a.created_at FROM users u INNER JOIN mod_actions a ON a.emote_id = ? WHERE u.id = a.user_id"); $stmt->execute([$emote->get_id()]); if ($row = $stmt->fetch()) { $approver = User::get_user_by_id($db, $row["id"]); echo ''; } if (CONFIG['rating']['enable']): ?> get_rating()["total"] < CONFIG['rating']['minvotes']) { echo ''; } else { $rating = $emote->get_rating()["average"]; // TODO: make it customizable list($rating_classname, $rating_name) = match (true) { in_range($rating, 0.75, 1.0) => [ "gemerald", " Shiny Gemerald! " ], in_range($rating, 0.25, 0.75) => ["gem", " Gem "], in_range($rating, -0.25, 0.25) => ["iron", "Iron"], in_range($rating, -0.75, -0.25) => ["coal", " Coal "], in_range($rating, -1.0, -0.75) => [ "brimstone", " !!!AVOID THIS CANCER-GIVING BRIMSTONE!!! " ] }; echo ''; } ?> get_source()): ?>
Tags get_tags() as $tag) { echo "$tag "; } ?>
Uploader get_uploaded_by()) { $u = $emote->get_uploaded_by(); $show_private_badge = $u->private_profile; $username = $u->username; $link = "/users.php?id={$u->id}"; $badge = $u->role; $custom_badge = $u->custom_badge; } echo ""; echo $username; echo ""; if ($show_private_badge) { echo " (Private)"; } if ($badge && $badge->badge) { echo " ## {$badge->name}"; } if ($custom_badge) { echo " "; } echo ', get_created_at()); echo ' UTC">about ' . format_timestamp(time() - $emote->get_created_at()) . " ago"; ?>
Approver'; echo "{$approver->username}"; if ($approver->role && $approver->role->badge) { echo " ## {$approver->role->name}"; } if ($approver->custom_badge) { echo " "; } echo ', '; echo format_timestamp(strtotime($row["created_at"]) - $emote->get_created_at()) . ' after upload'; echo '
Rating Not rated (' . $emote->get_rating()["total"] . ') '; echo "$rating_name"; echo ' (' . $emote->get_rating()["total"] . ')'; echo '
Visibility get_visibility()) { case 0: echo 'Unlisted'; break; case 1: echo 'Public'; break; case 2: echo 'Pending approval (unlisted for a moment)'; break; default: echo 'N/A'; break; } ?>
Source get_source() ?>
prepare("SELECT users.id, users.username FROM users INNER JOIN emote_sets AS es ON es.owner_id = users.id INNER JOIN emote_set_contents AS ec ON ec.emote_set_id = es.id INNER JOIN acquired_emote_sets AS aes ON aes.emote_set_id = es.id WHERE ec.emote_id = ? AND aes.is_default = TRUE"); $stmt->execute([$emote->get_id()]); $count = $stmt->rowCount(); $db = null; if ($count > 0) { echo "

Added in $count channels

"; } else { echo "No one has added this emote yet... :'("; } ?>
fetch()) { echo '' . $row["username"] . ''; } ?>
1) { echo '' ?>