{$kb}KB
"; } if ($image_size = getimagesize($path)) { echo "$image_size[0]x$image_size[1]
"; } echo '"rating ASC", "recent" => "e.created_at DESC", "oldest" => "e.created_at ASC", default => "rating DESC" }; $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%"; $current_emote_set_id = $_SESSION["user_active_emote_set_id"] ?? ""; $stmt->bindParam(1, $current_user_id, PDO::PARAM_STR); $stmt->bindParam(2, $current_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(); $emotes = []; $rows = $stmt->fetchAll(); foreach ($rows as $row) { $uploader = null; if ($row["uploaded_by"]) { $private_profile = $row["uploaded_by"] == ($_SESSION["user_id"] ?? "") ? "" : "AND up.private_profile = FALSE"; $stmt = $db->prepare("SELECT u.id, u.username FROM users u INNER JOIN user_preferences up ON up.id = u.id WHERE u.id = ? $private_profile "); $stmt->execute([$row["uploaded_by"]]); $uploader = $stmt->fetch(PDO::FETCH_ASSOC) ?? null; } array_push($emotes, new Emote( $row["id"], $row["code"], "webp", intval(strtotime($row["created_at"])), $uploader, $row["is_in_user_set"], $row["rating"], $row["visibility"], $row["source"], [] )); } return $emotes; } 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, 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 = ?"); $stmt->execute([$_SESSION["user_id"] ?? "", $id]); $emote = null; if ($row = $stmt->fetch()) { if ($row["id"] != null) { $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"); $emote = new Emote( $row["id"], $row["code"], "webp", intval(strtotime($row["created_at"])), $row["uploaded_by"], false, ["total" => $row["total_rating"], "average" => $row["average_rating"]], $row["visibility"], $row["source"], $tags ); } } if ($emote == null) { if (CLIENT_REQUIRES_JSON) { json_response([ "status_code" => 404, "message" => "Emote ID $id does not exist", "data" => null ], 404); exit; } header("Location: /404.php"); exit; } return $emote; } $emotes = null; $emote = null; $id = $_GET["id"] ?? ""; $db = new PDO(DB_URL, DB_USER, DB_PASS); $page = max(1, intval($_GET["p"] ?? "1")); $limit = 50; $total_emotes = 0; $total_pages = 0; $search = $_GET["q"] ?? ""; $sort_by = $_GET["sort_by"] ?? ""; if (empty($id)) { $emotes = display_list_emotes($db, $search, $sort_by, $page, $limit); $total_emotes = count($emotes); $total_pages = ceil($total_emotes / $limit); } else { $emote = display_emote($db, $id); } if (CLIENT_REQUIRES_JSON) { json_response([ "status_code" => 200, "message" => null, "data" => $emotes ?? $emote ]); exit; } ?>
{$kb}KB
"; } if ($image_size = getimagesize($path)) { echo "$image_size[0]x$image_size[1]
"; } echo 'Log in to get additional features...
| Tags | get_tags() as $tag) { echo "$tag "; } ?> | |
|---|---|---|
| Uploader | get_uploaded_by()) {
$stmt = $db->prepare("SELECT u.username, up.private_profile, r.name AS role_name, r.badge_id AS role_badge_id, ub.badge_id AS custom_badge_id
FROM users u
INNER JOIN user_preferences up ON up.id = u.id
LEFT JOIN role_assigns ra ON ra.user_id = u.id
LEFT JOIN roles r ON r.id = ra.role_id
LEFT JOIN user_badges ub ON ub.user_id = u.id
WHERE u.id = ?
");
$stmt->execute([$emote->get_uploaded_by()]);
if ($row = $stmt->fetch()) {
$show_private_badge = $row["private_profile"];
$username = $row["username"];
$link = "/users.php?id=" . $emote->get_uploaded_by();
$badge = ["role_name" => $row["role_name"], "role_badge_id" => $row["role_badge_id"]];
$custom_badge = $row["custom_badge_id"];
}
}
echo "";
echo $username;
echo "";
if ($show_private_badge) {
echo " ";
}
echo ', get_created_at());
echo ' UTC">about ' . format_timestamp(time() - $emote->get_created_at()) . " ago";
?> |
|
| Approver | ';
echo '' . $row["username"] . '';
if ($row["role_badge_id"]) {
echo ' ";
}
echo ', ';
echo format_timestamp(strtotime($row["created_at"]) - $emote->get_created_at()) . ' after upload';
echo ' | |
| Rating | get_rating()["total"] < RATING_EMOTE_MIN_VOTES) { echo 'Not rated (' . $emote->get_rating()["total"] . ') | '; } 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", "'; echo ""; 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() ?> |
Added in $count channels
"; } else { echo "No one has added this emote yet... :'("; } ?>
';
echo '' . ($e->get_uploaded_by() == null ? (ANONYMOUS_DEFAULT_NAME . "*") : $e->get_uploaded_by()["username"]) . '
'; echo ''; } ?>