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; }