diff options
| -rw-r--r-- | public/emotes/index.php | 5 | ||||
| -rw-r--r-- | src/emote.php | 24 |
2 files changed, 28 insertions, 1 deletions
diff --git a/public/emotes/index.php b/public/emotes/index.php index dc406f5..93d6e8e 100644 --- a/public/emotes/index.php +++ b/public/emotes/index.php @@ -166,7 +166,10 @@ if (CLIENT_REQUIRES_JSON) { <section class="content row"> <section class="sidebar"> - <?php html_navigation_search() ?> + <?php + html_navigation_search(); + html_random_emote($db); + ?> </section> <section class="content"> <?php display_alert() ?> diff --git a/src/emote.php b/src/emote.php index 63d5746..42cd2ac 100644 --- a/src/emote.php +++ b/src/emote.php @@ -62,3 +62,27 @@ class Emote return $this->visibility; } } + +function html_random_emote(PDO &$db) +{ + $stmt = $db->prepare("SELECT id, ext, code FROM emotes WHERE visibility = 1 ORDER BY RAND() LIMIT 1"); + $stmt->execute(); + + if ($row = $stmt->fetch()) { + echo '' + ?> + <section class="box" id="box-random-emote"> + <div class="box navtab"> + <p>Random 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 |
