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 +++++++++++++++++++++++++++++++++++++++++++++++ public/mod.php | 86 +++---------------------------------------------- public/static/style.css | 21 ++++++++++++ 3 files changed, 108 insertions(+), 82 deletions(-) create mode 100644 public/catalogue.php (limited to 'public') 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 diff --git a/public/mod.php b/public/mod.php index 2d45e76..de789ce 100644 --- a/public/mod.php +++ b/public/mod.php @@ -6,6 +6,8 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/../lib/alert.php'; session_start(); +$db = new PDO(DB_URL, DB_USER, DB_PASS); + if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!isset($_POST['password'])) { generate_alert('/mod.php', 'No password set!', 400, null); @@ -38,34 +40,6 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { generate_alert('/mod.php', 'Authorized!', 200, null); exit(); } - -$files = []; - -$page = intval($_GET['fp'] ?? '1'); -$max_pages = 0; - -if (isset($_SESSION['is_moderator'])) { - $quantity = 10; - - $filelist = glob(FILE_UPLOAD_DIRECTORY . '/*.*'); - usort($filelist, function ($a, $b) { - return filemtime($b) - filemtime($a); - }); - - $selected_files = array_slice($filelist, ($page - 1) * $quantity, $quantity); - - $max_pages = ceil(count($filelist) / $quantity); - - foreach ($selected_files as $f) { - $name = basename($f); - $id = explode('.', $name); - array_push($files, [ - 'name' => $name, - 'id' => $id[0], - 'extension' => $id[1] - ]); - } -} ?> @@ -80,60 +54,8 @@ if (isset($_SESSION['is_moderator'])) { - -
-

Files (Page / )

-
- - - - - - - - - - - - - - - - - -
FileAgeActions
- - - - - - - - - - - -
- -
- = 1): ?> - - - - - - - - - -
-
- -

No files to moderate...

- +

Now you can access moderator related panels!

+

TODO: add more mod features here

Log in to the moderation system


diff --git a/public/static/style.css b/public/static/style.css index 53c246e..7298fcb 100644 --- a/public/static/style.css +++ b/public/static/style.css @@ -271,6 +271,27 @@ button[type=submit]:hover { align-self: flex-end; } +/** FILE CATALOG (WALL) */ +.wall { + display: flex; + flex-wrap: wrap; + gap: 16px; +} + +.wall .brick { + display: flex; + align-items: center; + justify-content: center; + + width: 128px; + height: 128px; +} + +.brick img { + min-width: 100%; + height: auto; +} + /** SHORTCUTS */ .column { display: flex; -- cgit v1.2.3