From 312b5d6e873d53b78db4bef628fe01391a30cdb0 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 18 Jun 2025 15:00:49 +0500 Subject: feat: file bans --- public/index.php | 124 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 52 deletions(-) (limited to 'public/index.php') diff --git a/public/index.php b/public/index.php index 7788bbe..b03b063 100644 --- a/public/index.php +++ b/public/index.php @@ -40,16 +40,13 @@ if (FILE_CATALOG_FANCY_VIEW && $file_id) { exit(); } - $file_path = FILE_UPLOAD_DIRECTORY . "/{$file_id}.{$file_ext}"; - - if (!file_exists($file_path)) { - http_response_code(404); - exit(); - } - - $stmt = $db->prepare('SELECT fm.*, f.* + $stmt = $db->prepare('SELECT fm.*, f.*, + hb.reason AS ban_reason, + CASE WHEN fb.hash_ban IS NOT NULL THEN 1 ELSE 0 END AS is_banned FROM files f LEFT JOIN file_metadata fm ON fm.id = f.id + LEFT JOIN file_bans fb ON fb.id = f.id + LEFT JOIN hash_bans hb ON hb.sha256 = fb.hash_ban WHERE f.id = ? AND f.extension = ? '); $stmt->execute([$file_id, $file_ext]); @@ -60,6 +57,8 @@ if (FILE_CATALOG_FANCY_VIEW && $file_id) { exit(); } + $file_exists = is_file(FILE_UPLOAD_DIRECTORY . "/$file_id.$file_ext"); + // counting views $viewed_file_ids = $_SESSION['viewed_file_ids'] ?? []; if (!in_array($file['id'], $viewed_file_ids)) { @@ -153,54 +152,75 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); -
-
-
-
- -

- -

File

- -
- -
- - Image file. - - - - - -
- -

This file cannot be displayed.

- -
+
- + @@ -324,7 +344,7 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); - + -- cgit v1.2.3