From 0e357c0e42808ee41b3959d3ac01285016adca72 Mon Sep 17 00:00:00 2001 From: Alex Assistant Date: Fri, 20 Feb 2026 15:08:13 +0300 Subject: [PATCH] Public: stacked before/after and editable welcome text; admin media/comments mode polish --- admin.php | 16 ++++++++++++++++ index.php | 7 ++++--- lib/db_gallery.php | 18 ++++++++++++++++++ migrations/002_site_settings.sql | 5 +++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 migrations/002_site_settings.sql diff --git a/admin.php b/admin.php index 0c37aa0..94ad555 100644 --- a/admin.php +++ b/admin.php @@ -36,6 +36,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $message = 'Раздел создан'; } + if ($action === 'update_welcome') { + $text = trim((string)($_POST['welcome_text'] ?? '')); + settingSet('welcome_text', $text); + $message = 'Приветственное сообщение сохранено'; + } + if ($action === 'upload_before_bulk') { $sectionId = (int)($_POST['section_id'] ?? 0); if ($sectionId < 1 || !sectionById($sectionId)) throw new RuntimeException('Выбери раздел'); @@ -131,6 +137,7 @@ $activeSectionId = (int)($_GET['section_id'] ?? ($_POST['section_id'] ?? ($secti $photos = $activeSectionId > 0 ? photosBySection($activeSectionId) : []; $commenters = commentersAll(); $latestComments = commentsLatest(80); +$welcomeText = settingGet('welcome_text', 'Добро пожаловать в галерею. Выберите раздел слева, чтобы посмотреть фотографии.'); $adminMode = (string)($_GET['mode'] ?? 'media'); if (!in_array($adminMode, ['media', 'comments'], true)) { $adminMode = 'media'; @@ -304,6 +311,15 @@ function nextUniqueCodeName(string $base): string
+
+

Приветственное сообщение (публичная часть)

+
+ +

+ +
+
+

Загрузка фото “до” в выбранный раздел

0): ?> diff --git a/index.php b/index.php index ccb80a2..23c9683 100644 --- a/index.php +++ b/index.php @@ -35,6 +35,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && (string)($_POST['action'] ?? '') == $sections = sectionsAll(); $activeSectionId = (int)($_GET['section_id'] ?? 0); $activePhotoId = (int)($_GET['photo_id'] ?? 0); +$welcomeText = settingGet('welcome_text', 'Добро пожаловать в галерею. Выберите раздел слева, чтобы посмотреть фотографии.'); $photo = $activePhotoId > 0 ? photoById($activePhotoId) : null; $comments = $photo ? commentsByPhoto($activePhotoId) : []; @@ -126,7 +127,7 @@ function outputWatermarked(string $path, string $mime): never Фотогалерея - +
@@ -145,7 +146,7 @@ function outputWatermarked(string $path, string $mime): never

← к разделу

-
+
До обработки
После обработки (watermark)
@@ -171,7 +172,7 @@ function outputWatermarked(string $path, string $mime): never

Фотографии

-

Выберите раздел слева.

+

В разделе пока нет фотографий.

diff --git a/lib/db_gallery.php b/lib/db_gallery.php index f47a21e..c7d4c22 100644 --- a/lib/db_gallery.php +++ b/lib/db_gallery.php @@ -155,3 +155,21 @@ function commentsLatest(int $limit = 100): array LIMIT ' . (int)$limit; return db()->query($sql)->fetchAll(); } + +function settingGet(string $key, string $default = ''): string +{ + try { + $st = db()->prepare('SELECT `value` FROM site_settings WHERE `key`=:k'); + $st->execute(['k' => $key]); + $v = $st->fetchColumn(); + return is_string($v) ? $v : $default; + } catch (Throwable) { + return $default; + } +} + +function settingSet(string $key, string $value): void +{ + $st = db()->prepare('INSERT INTO site_settings(`key`,`value`) VALUES (:k,:v) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)'); + $st->execute(['k' => $key, 'v' => $value]); +} diff --git a/migrations/002_site_settings.sql b/migrations/002_site_settings.sql new file mode 100644 index 0000000..aace77c --- /dev/null +++ b/migrations/002_site_settings.sql @@ -0,0 +1,5 @@ +CREATE TABLE IF NOT EXISTS site_settings ( + `key` VARCHAR(191) PRIMARY KEY, + `value` TEXT NULL, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;