prepare("SELECT e.*,
CASE WHEN EXISTS (
SELECT 1
FROM emote_set_contents ec
INNER JOIN emote_sets es ON es.id = ec.emote_set_id
WHERE ec.emote_id = e.id AND es.owner_id = ?
) THEN 1 ELSE 0 END AS is_in_user_set
FROM emotes e " .
(($search != "") ? "WHERE e.code LIKE ?" : "")
.
"
ORDER BY e.created_at ASC
LIMIT ? OFFSET ?
");
if ($search == "") {
$stmt->bindParam(1, $user_id, PDO::PARAM_INT);
$stmt->bindParam(2, $limit, PDO::PARAM_INT);
$stmt->bindParam(3, $offset, PDO::PARAM_INT);
} else {
$search = "%$search%";
$stmt->bindParam(1, $user_id, PDO::PARAM_INT);
$stmt->bindParam(2, $search, PDO::PARAM_STR);
$stmt->bindParam(3, $limit, PDO::PARAM_INT);
$stmt->bindParam(4, $offset, PDO::PARAM_INT);
}
$stmt->execute();
$emotes = [];
$rows = $stmt->fetchAll();
foreach ($rows as $row) {
array_push($emotes, new Emote(
$row["id"],
$row["code"],
$row["ext"],
intval(strtotime($row["created_at"])),
$row["uploaded_by"],
$row["is_in_user_set"]
));
}
return $emotes;
}
function display_emote(int $id)
{
$db = new PDO(DB_URL, DB_USER, DB_PASS);
$stmt = $db->prepare("SELECT * FROM emotes WHERE id = ?");
$stmt->execute([$id]);
$emote = null;
if ($row = $stmt->fetch()) {
$emote = new Emote(
$row["id"],
$row["code"],
$row["ext"],
intval(strtotime($row["created_at"])),
$row["uploaded_by"],
false
);
}
if ($emote == null) {
header("Location: /404.php");
exit;
}
return $emote;
}
$emotes = null;
$emote = null;
$id = $_GET["id"] ?? "";
if ($id == "" || !is_numeric($id)) {
$page = intval($_GET["p"] ?? "0");
$limit = 50;
$emotes = display_list_emotes($page, $limit);
} else {
$emote = display_emote(intval($id));
}
?>
get_code() : "Emotes"
?> - alright.party
prepare("SELECT id FROM emote_set_contents WHERE emote_set_id = ? AND emote_id = ?");
$stmt->execute([$_SESSION["user_emote_set_id"], $emote->get_id()]);
$added = $stmt->rowCount() > 0;
}
$db = null;
?>
Log in to get additional features...
| Uploader |
get_uploaded_by()) {
$db = new PDO(DB_URL, DB_USER, DB_PASS);
$stmt = $db->prepare("SELECT username FROM users WHERE id = ?");
$stmt->execute([$emote->get_uploaded_by()]);
if ($row = $stmt->fetch()) {
$username = $row["username"];
$link = "/users.php?id=" . $emote->get_uploaded_by();
}
$db = null;
}
echo "";
echo $username;
echo "";
echo ', get_created_at());
echo ' UTC">about ' . format_timestamp(time() - $emote->get_created_at()) . " ago";
?> |
| Rating |
Not rated |
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
WHERE ec.emote_id = ?");
$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... :'(";
}
?>
get_id() . '">';
if ($e->is_added_by_user()) {
echo '

';
}
echo '
 . '/2x.' . $e->get_ext() . ')
';
echo '
' . $e->get_code() . '
';
echo '';
}
?>