From 01b4d8ac76a2a6a7ee57dd173f3894022977d2cb Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 18 Jun 2025 13:34:08 +0500 Subject: feat: file catalogue --- public/catalogue.php | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 public/catalogue.php (limited to 'public/catalogue.php') diff --git a/public/catalogue.php b/public/catalogue.php new file mode 100644 index 0000000..756675a --- /dev/null +++ b/public/catalogue.php @@ -0,0 +1,83 @@ +query('SELECT COUNT(id) AS all_files FROM files'); +$stmt->execute(); + +$max_pages = ceil(($stmt->fetch(PDO::FETCH_ASSOC)['all_files'] ?: 0) / $limit); +$page = min($page, $max_pages - 1); + +// getting files +$offset = $page * $limit; + +$stmt = $db->query("SELECT f.id, f.mime, f.extension + FROM files f + ORDER BY f.uploaded_at DESC + LIMIT $limit OFFSET $offset +"); +$stmt->execute(); + +$files = $stmt->fetchAll(); +?> + + + + + File Catalogue (Page <?= $page + 1 ?>/<?= $max_pages ?>) - <?= INSTANCE_NAME ?> + + + + + +
+ + +
+ = 0): ?> + ← Previous page + + + → Next page + +
+ +
+ + + +
+
+ + + \ No newline at end of file -- cgit v1.2.3