summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--database.sql4
-rw-r--r--public/emotes/index.php1
-rw-r--r--src/emote.php26
3 files changed, 29 insertions, 2 deletions
diff --git a/database.sql b/database.sql
index a2df999..1340d36 100644
--- a/database.sql
+++ b/database.sql
@@ -23,7 +23,9 @@ CREATE TABLE IF NOT EXISTS emotes (
ext TEXT NOT NULL,
uploaded_by INTEGER REFERENCES users(id),
created_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP,
- visibility INTEGER NOT NULL
+ updated_at TIMESTAMP NOT NULL,
+ visibility INTEGER NOT NULL,
+ is_featured BOOLEAN NOT NULL DEFAULT false
);
CREATE TABLE IF NOT EXISTS emote_sets (
diff --git a/public/emotes/index.php b/public/emotes/index.php
index 93d6e8e..04dec65 100644
--- a/public/emotes/index.php
+++ b/public/emotes/index.php
@@ -168,6 +168,7 @@ if (CLIENT_REQUIRES_JSON) {
<section class="sidebar">
<?php
html_navigation_search();
+ html_featured_emote($db);
html_random_emote($db);
?>
</section>
diff --git a/src/emote.php b/src/emote.php
index 42cd2ac..769d62a 100644
--- a/src/emote.php
+++ b/src/emote.php
@@ -65,7 +65,7 @@ class Emote
function html_random_emote(PDO &$db)
{
- $stmt = $db->prepare("SELECT id, ext, code FROM emotes WHERE visibility = 1 ORDER BY RAND() LIMIT 1");
+ $stmt = $db->prepare("SELECT id, ext, code FROM emotes WHERE visibility = 1 AND is_featured = false ORDER BY RAND() LIMIT 1");
$stmt->execute();
if ($row = $stmt->fetch()) {
@@ -85,4 +85,28 @@ function html_random_emote(PDO &$db)
<?php
;
}
+}
+
+function html_featured_emote(PDO &$db)
+{
+ $stmt = $db->prepare("SELECT id, ext, code FROM emotes WHERE visibility = 1 AND is_featured = true ORDER BY updated_at DESC LIMIT 1");
+ $stmt->execute();
+
+ if ($row = $stmt->fetch()) {
+ echo ''
+ ?>
+ <section class="box" id="box-featured-emote">
+ <div class="box navtab">
+ <p>Featured emote</p>
+ </div>
+ <div class="box content center">
+ <a href="/emotes?id=<?php echo $row["id"] ?>">
+ <img src="/static/userdata/emotes/<?php echo $row["id"] . '/3x.' . $row["ext"] ?>"
+ alt="<?php echo $row["code"] ?>" width="192">
+ </a>
+ </div>
+ </section>
+ <?php
+ ;
+ }
} \ No newline at end of file