From 6a3a705d7382225d0d778ce4a985b737820eaef5 Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Wed, 17 Jul 2024 03:51:15 +0300 Subject: [PATCH] add 404 for moderated photos --- views/pages/Photo.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/views/pages/Photo.php b/views/pages/Photo.php index 9d5a8f8..5326d81 100644 --- a/views/pages/Photo.php +++ b/views/pages/Photo.php @@ -7,9 +7,19 @@ $id = explode('/', $_SERVER['REQUEST_URI'])[2]; $photo = new \App\Models\Photo($id); if ($photo->i('id') !== null) { $photouser = new \App\Models\User($photo->i('user_id')); - if (DB::query('SELECT * FROM photos_views WHERE user_id=:uid AND photo_id=:pid ORDER BY id DESC LIMIT 1', array(':uid' => Auth::userid(), ':pid' => $id))[0]['time'] <= time() - 86400) { - DB::query('INSERT INTO photos_views VALUES (\'0\', :uid, :pid, :time)', array(':uid' => Auth::userid(), ':pid' => $id, ':time' => time())); + if ($photo->i('moderated') === 0) { + if ($photo->i('user_id') === Auth::userid()) { + $moderated = true; + } else { + $moderated = false; + } + } else { + $moderated = true; + if (DB::query('SELECT * FROM photos_views WHERE user_id=:uid AND photo_id=:pid ORDER BY id DESC LIMIT 1', array(':uid' => Auth::userid(), ':pid' => $id))[0]['time'] <= time() - 86400) { + DB::query('INSERT INTO photos_views VALUES (\'0\', :uid, :pid, :time)', array(':uid' => Auth::userid(), ':pid' => $id, ':time' => time())); + } } + } ?> @@ -65,7 +75,7 @@ if ($photo->i('id') !== null) { i('moderated') === 0) { + if ($photo->i('moderated') === 0 && $moderated === true) { echo '

Это фото пока не опубликовано

Сейчас фотография рассматривается модераторами и пока не видна другим пользователям. Это может занять определённое время, иногда до нескольких дней.

@@ -75,7 +85,7 @@ if ($photo->i('id') !== null) { ?>
i('id') !== null) { + if ($photo->i('id') !== null && $moderated === true) { ?>