summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-10-26 16:08:03 +0500
committerilotterytea <iltsu@alright.party>2025-10-26 16:08:03 +0500
commitd3baca2f2df52d78566024c26f694d1f26693b25 (patch)
tree8747f843aecb225adbc187e472d4d35f865d684f
parent70da8f231232dbc3bccdb4976d65ba49050a8634 (diff)
feat: sound page
-rw-r--r--sounds/index.php77
-rw-r--r--static/style.css23
2 files changed, 85 insertions, 15 deletions
diff --git a/sounds/index.php b/sounds/index.php
index c2a50b8..8b72940 100644
--- a/sounds/index.php
+++ b/sounds/index.php
@@ -4,10 +4,20 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/partials.php';
$db = new PDO(DB_URL, DB_USER, DB_PASS);
-$stmt = $db->prepare('SELECT * FROM sounds ORDER BY uploaded_at DESC');
-$stmt->execute();
-$sounds = $stmt->fetchAll(PDO::FETCH_ASSOC);
+if (isset($_GET['id']) && !empty(trim($_GET['id']))) {
+ $stmt = $db->prepare('SELECT s.*, u.username AS uploader_name
+ FROM sounds s
+ LEFT JOIN users u ON u.id = s.uploaded_by
+ WHERE s.id = ?
+ ');
+ $stmt->execute([$_GET['id']]);
+ $sound = $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
+} else {
+ $stmt = $db->prepare('SELECT * FROM sounds ORDER BY uploaded_at DESC');
+ $stmt->execute();
+ $sounds = $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
?>
<!DOCTYPE html>
<html>
@@ -21,19 +31,56 @@ $sounds = $stmt->fetchAll(PDO::FETCH_ASSOC);
<body>
<?php html_header() ?>
<main>
- <section class="sound-list">
- <?php foreach ($sounds as $s): ?>
- <div class="box sound-item">
- <audio controls>
- <source src="<?= SOUND_DIRECTORY_PREFIX ?>/<?= $s['id'] ?>.ogg" type="audio/ogg">
- </audio>
- <a href="/sounds/?id=<?= $s['id'] ?>"><?= $s['code'] ?></a>
+ <?php if (isset($sound)): ?>
+ <section class="column gap-8">
+ <div class="box">
+ <div class="tab">
+ <p>Sound - <?= $sound['code'] ?></p>
+ </div>
+ <div class="content column justify-center align-center gap-16">
+ <audio controls>
+ <source src="<?= sprintf("%s/%d.ogg", SOUND_DIRECTORY_PREFIX, $sound['id']) ?>"
+ type="audio/ogg">
+ </audio>
+ </div>
</div>
- <?php endforeach; ?>
- <?php if (empty($sounds)): ?>
- <p>No sounds</p>
- <?php endif; ?>
- </section>
+ <div class="box">
+ <a href="/sounds/add.php?id=<?= $sound['id'] ?>">
+ <button>Add</button>
+ </a>
+ </div>
+ <div class="box">
+ <table>
+ <tr>
+ <th>Uploader</th>
+ <td>
+ <p>
+ <?php if (isset($sound['uploaded_by'])): ?>
+ <a href="/users/?id=<?= $sound['uploaded_by'] ?>"><?= $sound['uploader_name'] ?></a>
+ <?php else: ?>
+ <i>Anonymous</i>
+ <?php endif; ?>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </section>
+ <?php else: ?>
+ <section class="sound-list">
+ <?php foreach ($sounds as $s): ?>
+ <div class="box sound-item">
+ <audio controls>
+ <source src="<?= SOUND_DIRECTORY_PREFIX ?>/<?= $s['id'] ?>.ogg" type="audio/ogg">
+ </audio>
+ <a href="/sounds/?id=<?= $s['id'] ?>"><?= $s['code'] ?></a>
+ </div>
+ <?php endforeach; ?>
+ <?php if (empty($sounds)): ?>
+ <p>No sounds</p>
+ <?php endif; ?>
+ </section>
+ <?php endif; ?>
</main>
</body>
diff --git a/static/style.css b/static/style.css
index 05a2676..6a62cb5 100644
--- a/static/style.css
+++ b/static/style.css
@@ -8,6 +8,8 @@
* {
padding: 0;
margin: 0;
+
+ font-family: Arial, Helvetica, sans-serif;
}
body {
@@ -96,4 +98,25 @@ header .brand>a {
.row {
display: flex;
flex-direction: row;
+}
+
+.column {
+ display: flex;
+ flex-direction: column;
+}
+
+.justify-center {
+ justify-content: center;
+}
+
+.align-center {
+ align-items: center;
+}
+
+.gap-8 {
+ gap: 8px;
+}
+
+.gap-16 {
+ gap: 16px;
} \ No newline at end of file