diff --git a/README.md b/README.md index a2aa9dd..a0955fb 100644 --- a/README.md +++ b/README.md @@ -118,15 +118,20 @@ BRANCH=master bash scripts/deploy.sh ## Админка загрузки (по токену) -Новый контур на MySQL (этап 1): +Новый контур на MySQL: -- `admin-mysql.php?token=...` +- `admin-mysql.php?token=...` — админка +- `index-mysql.php` — публичная витрина + комментарии -Что уже есть в MySQL-админке: +Что уже есть в MySQL-контуре: - создание разделов, - загрузка фото "до" + опционально "после", - запись в таблицы `sections`, `photos`, `photo_files`, -- просмотр разделов и загруженных фото. +- просмотр разделов и загруженных фото, +- персональные комментаторы (генерация ссылок), +- плоские комментарии к фото, +- удаление комментариев админом, +- watermark на выдаче версии "после". Админка использует тот же `token`, что и `deploy.php`, из файла `deploy-config.php`. diff --git a/admin-mysql.php b/admin-mysql.php index 0f10800..6620e55 100644 --- a/admin-mysql.php +++ b/admin-mysql.php @@ -35,9 +35,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($action === 'create_section') { $name = trim((string)($_POST['name'] ?? '')); $sort = (int)($_POST['sort_order'] ?? 1000); - if ($name === '') { - throw new RuntimeException('Название раздела пустое'); - } + if ($name === '') throw new RuntimeException('Название раздела пустое'); sectionCreate($name, $sort); $message = 'Раздел создан'; } @@ -52,9 +50,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($sectionId < 1) throw new RuntimeException('Выбери раздел'); if ($codeName === '') throw new RuntimeException('Укажи код фото (например АВФ1)'); if (!isset($_FILES['before'])) throw new RuntimeException('Файл "до" обязателен'); - - $section = sectionById($sectionId); - if (!$section) throw new RuntimeException('Раздел не найден'); + if (!sectionById($sectionId)) throw new RuntimeException('Раздел не найден'); $photoId = photoCreate($sectionId, $codeName, $description, $sortOrder); @@ -68,6 +64,30 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $message = 'Фото добавлено'; } + + if ($action === 'create_commenter') { + $displayName = trim((string)($_POST['display_name'] ?? '')); + if ($displayName === '') throw new RuntimeException('Укажи имя комментатора'); + $u = commenterCreate($displayName); + $link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost') . '/index-mysql.php?viewer=' . urlencode($u['token']); + $message = 'Комментатор создан: ' . $u['display_name'] . ' | ссылка: ' . $link; + } + + if ($action === 'delete_commenter') { + $id = (int)($_POST['id'] ?? 0); + if ($id > 0) { + commenterDelete($id); + $message = 'Комментатор удалён (доступ отозван)'; + } + } + + if ($action === 'delete_comment') { + $id = (int)($_POST['id'] ?? 0); + if ($id > 0) { + commentDelete($id); + $message = 'Комментарий удалён'; + } + } } catch (Throwable $e) { $errors[] = $e->getMessage(); } @@ -76,6 +96,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $sections = sectionsAll(); $activeSectionId = (int)($_GET['section_id'] ?? ($sections[0]['id'] ?? 0)); $photos = $activeSectionId > 0 ? photosBySection($activeSectionId) : []; +$commenters = commentersAll(); +$latestComments = commentsLatest(80); function h(string $v): string { return htmlspecialchars($v, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } function assetUrl(string $path): string { $f=__DIR__ . '/' . ltrim($path,'/'); $v=is_file($f)?(string)filemtime($f):(string)time(); return $path . '?v=' . rawurlencode($v); } @@ -128,12 +150,13 @@ function uniqueName(string $dir, string $base, string $ext): string
Открыть публичную MySQL-галерею
| ID | Имя | Статус | Действие |
|---|---|---|---|
| = (int)$u['id'] ?> | += h((string)$u['display_name']) ?> | += (int)$u['is_active'] ? 'active' : 'off' ?> | ++ + | +
После создания ссылки токен показывается один раз в зелёном сообщении.
+| ID | Название | Порядок | Фото | ||
|---|---|---|---|---|---|
| = (int)$p['id'] ?> | = h((string)$p['code_name']) ?> | -= h((string)($p['description'] ?? '')) ?> | = (int)$p['sort_order'] ?> |
| ID | Фото | Пользователь | Комментарий | |
|---|---|---|---|---|
| = (int)$c['id'] ?> | += h((string)$c['code_name']) ?> | += h((string)($c['display_name'] ?? '—')) ?> | += h((string)$c['comment_text']) ?> | ++ + | +