шаг 5 завершен

This commit is contained in:
Alisa
2026-06-04 19:19:35 +03:00
parent 238831ad3a
commit 6216c1ee4f
34 changed files with 1859 additions and 36 deletions
+3
View File
@@ -3,7 +3,10 @@
declare(strict_types=1);
use App\Controllers\Admin\CategoryAdminController;
use App\Core\Auth;
require_once dirname(__DIR__, 2) . '/app/bootstrap.php';
Auth::requireAdmin();
(new CategoryAdminController())->index();
+50
View File
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
use App\Core\Auth;
use App\Repositories\AdminRepository;
require_once dirname(__DIR__, 2) . '/app/bootstrap.php';
$repository = new AdminRepository();
$needsSetup = $repository->activeCount() === 0;
if ($needsSetup) {
header('Location: /admin/setup.php?token=' . rawurlencode((string) app_env('INSTALL_TOKEN', '')));
exit;
}
$error = null;
$next = admin_safe_next((string) ($_GET['next'] ?? '/admin/'));
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$next = admin_safe_next((string) ($_POST['next'] ?? '/admin/'));
if (Auth::attempt((string) ($_POST['email'] ?? ''), (string) ($_POST['password'] ?? ''))) {
header('Location: ' . ($next !== '' ? $next : '/admin/'));
exit;
}
$error = 'Неверный email или пароль.';
}
view('admin/login', [
'title' => 'Вход в админку - Рыбсток',
'breadcrumbs' => [
['title' => 'Главная', 'url' => '/'],
['title' => 'Админка', 'url' => '/admin/'],
['title' => 'Вход'],
],
'error' => $error,
'next' => $next,
]);
function admin_safe_next(string $next): string
{
if ($next === '' || !str_starts_with($next, '/') || str_starts_with($next, '//')) {
return '/admin/';
}
return $next;
}
+12
View File
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
use App\Core\Auth;
require_once dirname(__DIR__, 2) . '/app/bootstrap.php';
Auth::logout();
header('Location: /admin/login.php');
exit;
+3
View File
@@ -3,7 +3,10 @@
declare(strict_types=1);
use App\Controllers\Admin\ProductAdminController;
use App\Core\Auth;
require_once dirname(__DIR__, 2) . '/app/bootstrap.php';
Auth::requireAdmin();
(new ProductAdminController())->index();
+51
View File
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
use App\Repositories\AdminRepository;
require_once dirname(__DIR__, 2) . '/app/bootstrap.php';
$repository = new AdminRepository();
$isLocal = app_env('APP_ENV', 'production') === 'local';
$expectedToken = (string) app_env('INSTALL_TOKEN', '');
$actualToken = (string) ($_GET['token'] ?? $_POST['token'] ?? '');
$canRun = $isLocal && $expectedToken !== '' && hash_equals($expectedToken, $actualToken);
$hasAdmin = $repository->activeCount() > 0;
$message = null;
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!$canRun || $hasAdmin) {
http_response_code(403);
$error = 'Создание администратора недоступно.';
} else {
try {
$repository->createOwner(
(string) ($_POST['name'] ?? ''),
(string) ($_POST['email'] ?? ''),
(string) ($_POST['password'] ?? '')
);
$message = 'Администратор создан. Теперь можно войти.';
$hasAdmin = true;
} catch (Throwable $exception) {
$error = app_env('APP_DEBUG', 'false') === 'true'
? $exception->getMessage()
: 'Не удалось создать администратора.';
}
}
}
view('admin/setup', [
'title' => 'Создание администратора - Рыбсток',
'breadcrumbs' => [
['title' => 'Главная', 'url' => '/'],
['title' => 'Админка', 'url' => '/admin/'],
['title' => 'Создание администратора'],
],
'canRun' => $canRun,
'hasAdmin' => $hasAdmin,
'token' => $actualToken,
'message' => $message,
'error' => $error,
]);
+788 -14
View File
@@ -10,8 +10,92 @@ body {
background: #f7f8f4;
}
.site-topbar {
position: sticky;
top: 0;
z-index: 20;
border-bottom: 1px solid #dfe5da;
background: #ffffff;
box-shadow: 0 6px 22px rgba(32, 45, 35, 0.06);
}
.site-topbar-inner {
width: min(1180px, calc(100% - 48px));
display: grid;
grid-template-columns: 220px minmax(0, 1fr) 290px;
gap: 24px;
align-items: center;
margin: 0 auto;
padding: 12px 0;
}
.brand-link {
display: flex;
gap: 10px;
align-items: center;
font-size: 22px;
font-weight: 800;
color: #18201b;
}
.brand-link:hover {
text-decoration: none;
}
.brand-link img {
display: block;
width: 126px;
height: auto;
}
.brand-link small {
max-width: 86px;
font-size: 10px;
font-weight: 700;
line-height: 1.25;
color: #1d5d3b;
}
.main-nav {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
font-size: 14px;
font-weight: 700;
}
.main-nav a {
display: inline-flex;
align-items: center;
min-height: 34px;
border-radius: 8px;
padding: 8px 10px;
color: #243229;
}
.main-nav a:hover {
background: #f0f5eb;
text-decoration: none;
}
.topbar-contacts {
display: grid;
gap: 4px;
justify-items: end;
font-size: 12px;
line-height: 1.35;
color: #687466;
}
.topbar-contacts a {
font-size: 17px;
font-weight: 800;
color: #1d5d3b;
}
.site-utility {
width: min(1080px, calc(100% - 48px));
width: min(1180px, calc(100% - 48px));
display: flex;
gap: 14px;
align-items: center;
@@ -56,9 +140,7 @@ body {
.page {
min-height: 100vh;
display: grid;
place-items: center;
padding: 24px;
padding: 24px 24px 56px;
}
.primary-link {
@@ -74,7 +156,11 @@ body {
}
.start-screen.wide {
width: min(1080px, 100%);
width: min(1180px, 100%);
margin: 0 auto;
border: 0;
padding: 0;
background: transparent;
}
.eyebrow {
@@ -150,6 +236,125 @@ a:hover {
background: #16492e;
}
.secondary-button {
appearance: none;
display: inline-flex;
align-items: center;
justify-content: center;
border: 1px solid #b9c6b1;
border-radius: 8px;
padding: 13px 16px;
font-size: 16px;
font-weight: 800;
color: #1d5d3b;
background: #ffffff;
}
.secondary-button:hover {
background: #f5f8f1;
text-decoration: none;
}
.home-hero {
position: relative;
overflow: hidden;
padding: 44px;
border-radius: 8px;
color: #ffffff;
background: #1f5e46;
}
.home-hero h1 {
margin-bottom: 12px;
color: #ffffff;
font-size: 52px;
}
.home-hero .eyebrow {
color: #d8eadc;
}
.hero-lead {
max-width: 760px;
margin: 0;
font-size: 25px;
font-weight: 700;
}
.hero-actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-top: 24px;
}
.hero-button {
display: inline-flex;
margin-top: 0;
background: #ffffff;
color: #1d5d3b;
}
.hero-button:hover {
background: #eef4ea;
}
.home-banners,
.promo-strip {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 12px;
margin-top: 18px;
}
.home-banner,
.promo-strip div,
.price-request-panel {
padding: 18px;
border: 1px solid #dfe5da;
border-radius: 8px;
background: #ffffff;
}
.home-banner {
display: grid;
gap: 8px;
min-height: 116px;
}
.home-banner strong,
.promo-strip strong {
color: #18201b;
}
.home-banner span,
.promo-strip span,
.promo-strip small {
color: #687466;
}
.promo-strip {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.promo-strip div {
display: grid;
gap: 5px;
}
.promo-strip strong {
font-size: 22px;
}
.price-request-panel {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 18px;
align-items: center;
margin-top: 18px;
background: #ffffff;
}
.content-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -161,7 +366,7 @@ a:hover {
padding: 20px;
border: 1px solid #dfe5da;
border-radius: 8px;
background: #fbfcf8;
background: #ffffff;
}
.products-panel {
@@ -195,7 +400,7 @@ a:hover {
.category-list {
display: grid;
gap: 8px;
gap: 7px;
margin: 0;
padding: 0;
list-style: none;
@@ -210,10 +415,14 @@ a:hover {
}
.category-list li {
font-size: 16px;
font-size: 15px;
font-weight: 700;
}
.category-list a {
overflow-wrap: anywhere;
}
.category-list li.is-current > a,
.category-list a.is-current-link {
display: inline-block;
@@ -224,16 +433,16 @@ a:hover {
}
.category-list.depth-1 li {
font-size: 14px;
font-size: 13px;
font-weight: 600;
}
.category-list.depth-2 {
padding-left: 10px;
padding-left: 8px;
}
.category-list.depth-2 li {
font-size: 13px;
font-size: 12px;
font-weight: 400;
}
@@ -241,9 +450,16 @@ a:hover {
display: flex;
gap: 8px;
align-items: center;
min-height: 28px;
border-radius: 7px;
padding: 2px 4px;
cursor: pointer;
}
.category-details summary:hover {
background: #eef4ea;
}
.category-details summary a {
min-width: 0;
}
@@ -357,7 +573,7 @@ a:hover {
.admin-layout {
width: min(1180px, 100%);
display: grid;
grid-template-columns: 320px minmax(0, 1fr);
grid-template-columns: 300px minmax(0, 1fr);
gap: 20px;
align-items: start;
}
@@ -369,8 +585,8 @@ a:hover {
.sticky-panel {
position: sticky;
top: 18px;
max-height: calc(100vh - 36px);
top: 98px;
max-height: calc(100vh - 116px);
overflow: auto;
}
@@ -390,6 +606,371 @@ a:hover {
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.text-page {
width: min(920px, 100%);
margin: 0 auto;
}
.info-page {
width: min(1180px, 100%);
display: grid;
gap: 18px;
margin: 0 auto;
}
.info-hero {
display: grid;
grid-template-columns: minmax(0, 1fr) 260px;
gap: 28px;
align-items: center;
border-radius: 8px;
padding: 38px;
color: #ffffff;
background: #1f5e46;
}
.info-hero h1 {
margin-bottom: 14px;
color: #ffffff;
font-size: 48px;
}
.info-hero p {
max-width: 760px;
margin: 0;
}
.info-hero .eyebrow {
color: #d8eadc;
}
.payment-hero {
background: #263b55;
}
.contacts-hero {
background: #4d392a;
}
.info-visual {
display: grid;
place-items: center;
min-height: 210px;
border: 1px solid rgba(255, 255, 255, 0.25);
border-radius: 8px;
background: rgba(255, 255, 255, 0.08);
text-align: center;
}
.info-visual span {
display: block;
width: 82px;
height: 52px;
border: 4px solid #ffffff;
border-radius: 8px;
box-shadow: 32px 36px 0 -18px #ffffff, -34px 34px 0 -20px #ffffff;
}
.info-visual strong {
display: block;
margin-top: 18px;
font-size: 32px;
line-height: 1;
}
.info-visual small {
display: block;
margin-top: 6px;
color: #dfe8dc;
}
.info-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px;
}
.info-grid.three {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.info-card {
border: 1px solid #dfe5da;
border-radius: 8px;
padding: 24px;
background: #ffffff;
}
.info-card.compact {
min-height: 190px;
}
.info-card p {
margin: 0 0 12px;
font-size: 16px;
}
.info-card p:last-child {
margin-bottom: 0;
}
.info-card-visual {
height: 118px;
margin-bottom: 18px;
border-radius: 8px;
background: #eef4ea;
}
.delivery-city {
background:
linear-gradient(90deg, rgba(29, 93, 59, 0.2), rgba(29, 93, 59, 0.04)),
repeating-linear-gradient(90deg, #dfe8dc 0 22px, transparent 22px 44px);
}
.delivery-region {
background:
linear-gradient(135deg, rgba(38, 59, 85, 0.2), rgba(38, 59, 85, 0.04)),
repeating-linear-gradient(135deg, #dfe8dc 0 20px, transparent 20px 46px);
}
.payment-cash {
background:
linear-gradient(90deg, rgba(29, 93, 59, 0.16), rgba(29, 93, 59, 0.04)),
radial-gradient(circle at 22% 50%, #1d5d3b 0 24px, transparent 25px);
}
.payment-scale {
background:
linear-gradient(90deg, rgba(77, 57, 42, 0.16), rgba(77, 57, 42, 0.04)),
linear-gradient(#dfe8dc 0 0) center 68% / 58% 10px no-repeat;
}
.clean-list {
display: grid;
gap: 10px;
margin: 0 0 14px;
padding: 0;
list-style: none;
}
.clean-list li {
position: relative;
padding-left: 20px;
font-size: 16px;
line-height: 1.45;
}
.clean-list li::before {
content: "";
position: absolute;
top: 0.65em;
left: 0;
width: 7px;
height: 7px;
border-radius: 50%;
background: #1d5d3b;
}
.delivery-calculator {
display: grid;
gap: 18px;
}
.calculator-note {
max-width: 260px;
font-size: 13px;
line-height: 1.45;
color: #687466;
text-align: right;
}
.calculator-form {
display: grid;
grid-template-columns: 1.4fr 0.75fr 1fr 0.6fr;
gap: 14px;
align-items: end;
}
.calculator-form label {
display: grid;
gap: 7px;
font-size: 14px;
font-weight: 800;
color: #394437;
}
.calculator-form input,
.calculator-form select {
width: 100%;
border: 1px solid #cfd8c9;
border-radius: 8px;
padding: 12px;
font: inherit;
background: #ffffff;
}
.calculator-form .checkbox-label {
align-self: center;
margin-top: 24px;
}
.calculator-result {
display: grid;
gap: 5px;
border-radius: 8px;
padding: 18px;
color: #ffffff;
background: #1d5d3b;
}
.calculator-result strong {
font-size: 22px;
}
.calculator-result span {
line-height: 1.45;
color: #d8eadc;
}
.contact-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px;
}
.contact-card.wide {
grid-column: 1 / -1;
}
.contact-list {
display: grid;
gap: 16px;
margin: 0;
}
.contact-list div {
display: grid;
gap: 4px;
}
.contact-list dt {
color: #687466;
}
.contact-list dd {
margin: 0;
font-size: 24px;
font-weight: 800;
}
.route-card {
display: grid;
gap: 18px;
}
.route-layout {
display: grid;
grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
gap: 20px;
align-items: stretch;
}
.map-frame {
overflow: hidden;
min-height: 360px;
border: 1px solid #dfe5da;
border-radius: 8px;
background: #eef4ea;
}
.map-frame iframe {
display: block;
width: 100%;
height: 100%;
min-height: 360px;
border: 0;
}
.route-steps {
display: grid;
align-content: start;
gap: 16px;
border-radius: 8px;
padding: 22px;
background: #f7f8f4;
}
.route-steps ol {
display: grid;
gap: 12px;
margin: 0;
padding-left: 20px;
}
.route-steps li {
font-size: 16px;
line-height: 1.45;
}
.text-page-header,
.text-page-body {
border: 1px solid #dfe5da;
border-radius: 8px;
background: #ffffff;
}
.text-page-header {
padding: 30px;
margin-bottom: 18px;
}
.text-page-header h1 {
margin-bottom: 12px;
}
.text-page-header p:last-child {
max-width: 760px;
margin-bottom: 0;
}
.text-page-body {
display: grid;
gap: 0;
padding: 8px 30px 30px;
}
.text-page-body section {
padding: 24px 0;
border-bottom: 1px solid #e5eadf;
}
.text-page-body section:last-of-type {
border-bottom: 0;
}
.text-page-body p {
margin: 0 0 12px;
font-size: 16px;
}
.text-page-body p:last-child {
margin-bottom: 0;
}
.notice-panel {
margin-top: 10px;
border: 1px solid #ead8c4 !important;
border-radius: 8px;
padding: 22px !important;
background: #fffaf2;
}
.thanks-text {
margin: 22px 0 0 !important;
font-weight: 800;
color: #1d5d3b;
}
.admin-form {
display: grid;
gap: 14px;
@@ -450,6 +1031,129 @@ a:hover {
color: #687466;
}
.site-footer {
margin-top: 28px;
color: #dfe8dc;
background: #18201b;
}
.site-footer-inner {
width: min(1180px, calc(100% - 48px));
display: grid;
grid-template-columns: 1.15fr 1.25fr 1fr 1.2fr;
gap: 34px;
margin: 0 auto;
padding: 42px 0 34px;
}
.footer-logo {
display: inline-flex;
align-items: center;
min-height: 42px;
}
.footer-logo img {
display: block;
width: 150px;
height: auto;
filter: brightness(0) invert(1);
}
.footer-logo span {
font-size: 24px;
font-weight: 800;
color: #ffffff;
}
.footer-brand p,
.footer-column p {
margin: 12px 0 0;
font-size: 14px;
line-height: 1.55;
color: #b8c5b5;
}
.footer-column h2 {
margin: 0 0 14px;
font-size: 15px;
color: #ffffff;
}
.footer-contacts {
display: grid;
gap: 12px;
margin: 0;
}
.footer-contacts div {
display: grid;
gap: 3px;
}
.footer-contacts dt {
font-size: 12px;
color: #91a08c;
}
.footer-contacts dd {
margin: 0;
font-size: 14px;
line-height: 1.45;
}
.site-footer a {
color: #ffffff;
}
.site-footer a:hover {
color: #d8eadc;
}
.footer-links {
display: grid;
align-content: start;
gap: 9px;
}
.footer-links a {
font-size: 14px;
}
.footer-action {
display: inline-flex;
width: fit-content;
margin-top: 18px;
border: 1px solid #526457;
border-radius: 8px;
padding: 11px 14px;
font-size: 14px;
font-weight: 800;
}
.footer-action:hover {
border-color: #d8eadc;
text-decoration: none;
}
.site-footer-bottom {
border-top: 1px solid #2b362f;
padding: 16px 24px 18px;
text-align: center;
}
.site-footer-bottom p {
max-width: 1180px;
margin: 6px auto 0;
font-size: 12px;
line-height: 1.5;
color: #9eaa9a;
}
.site-footer-bottom p:first-child {
margin-top: 0;
color: #c7d2c3;
}
@media (max-width: 760px) {
.site-utility {
width: calc(100% - 32px);
@@ -461,6 +1165,44 @@ a:hover {
grid-template-columns: 1fr;
}
.site-topbar-inner,
.home-banners,
.promo-strip,
.price-request-panel {
grid-template-columns: 1fr;
}
.site-topbar-inner {
width: calc(100% - 32px);
justify-items: start;
gap: 12px;
}
.brand-link {
width: 100%;
justify-content: space-between;
}
.main-nav {
justify-content: flex-start;
}
.topbar-contacts {
justify-items: start;
}
.hero-lead {
font-size: 20px;
}
.home-hero {
padding: 28px;
}
.home-hero h1 {
font-size: 40px;
}
.settings-list div {
grid-template-columns: 1fr;
gap: 2px;
@@ -475,6 +1217,38 @@ a:hover {
grid-template-columns: 1fr;
}
.info-hero,
.info-grid,
.info-grid.three,
.calculator-form,
.contact-grid,
.route-layout {
grid-template-columns: 1fr;
}
.info-hero {
padding: 28px;
}
.info-hero h1 {
font-size: 38px;
}
.info-visual {
min-height: 160px;
}
.calculator-note {
max-width: none;
text-align: left;
}
.site-footer-inner {
width: calc(100% - 32px);
grid-template-columns: 1fr;
gap: 26px;
}
.sticky-panel {
position: static;
max-height: none;
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

+11
View File
@@ -17,6 +17,17 @@ echo "db: " . app_env('DB_DATABASE', '') . "\n";
echo "home_text_expected: Каталог открывается уже на главной странице\n";
echo "schema_mtime: " . date('Y-m-d H:i:s', filemtime(base_path('database/schema.sql'))) . "\n";
echo "seed_mtime: " . date('Y-m-d H:i:s', filemtime(base_path('database/seed.sql'))) . "\n";
echo "admin_auth_files:\n";
foreach ([
'app/Core/Auth.php',
'app/Repositories/AdminRepository.php',
'public/admin/login.php',
'public/admin/setup.php',
'admin/login.php',
'admin/setup.php',
] as $path) {
echo "- {$path}: " . (is_file(base_path($path)) ? 'yes' : 'no') . "\n";
}
try {
$pdo = Database::pdo();
+5
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
use App\Controllers\CatalogController;
use App\Controllers\HomeController;
use App\Controllers\PageController;
use App\Core\Router;
require_once dirname(__DIR__) . '/app/bootstrap.php';
@@ -12,6 +13,10 @@ $router = new Router();
$router->get('/', static fn () => (new HomeController())->index());
$router->get('/catalog', static fn () => (new CatalogController())->index());
$router->get('/delivery', static fn () => (new PageController())->delivery());
$router->get('/payment', static fn () => (new PageController())->payment());
$router->get('/contacts', static fn () => (new PageController())->contacts());
$router->get('/returns', static fn () => (new PageController())->returns());
$router->get('/catalog/{slug}', static fn (string $slug) => (new CatalogController())->category($slug));
$router->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);