Files
cmspro.it/index.php
2026-01-29 21:07:02 +01:00

133 lines
3.8 KiB
PHP

<?php
session_start();
require_once __DIR__ . '/app/controllers/AuthController.php';
require_once __DIR__ . '/app/controllers/NoteController.php';
require_once __DIR__ . '/app/controllers/EventController.php';
// Pobranie ścieżki URL
$route = $_GET['route'] ?? '';
$route = trim($route, '/');
$authController = new AuthController();
$noteController = new NoteController();
$eventController = new EventController();
// Routing z przyjaznymi linkami
switch (true) {
// Strona główna / logowanie
case $route === '':
case $route === 'logowanie':
$authController->loginForm();
break;
case $route === 'zaloguj':
$authController->login();
break;
case $route === 'weryfikacja':
$authController->verifyForm();
break;
case $route === 'zweryfikuj':
$authController->verify();
break;
case $route === 'panel':
$authController->dashboard();
break;
case $route === 'wyloguj-sie':
$authController->logout();
break;
// Notatnik
case $route === 'notatnik':
$noteController->index();
break;
case $route === 'notatnik/nowa':
$noteController->create();
break;
case $route === 'notatnik/dodaj':
$noteController->store();
break;
case preg_match('#^notatnik/edytuj/(\d+)$#', $route, $matches) === 1:
$noteController->edit((int) $matches[1]);
break;
case preg_match('#^notatnik/zapisz/(\d+)$#', $route, $matches) === 1:
$noteController->update((int) $matches[1]);
break;
case preg_match('#^notatnik/usun/(\d+)$#', $route, $matches) === 1:
$noteController->delete((int) $matches[1]);
break;
// Kalendarz
case $route === 'kalendarz':
$eventController->index();
break;
case $route === 'kalendarz/nowe':
$eventController->create();
break;
case preg_match('#^kalendarz/nowe/(\d{4}-\d{2}-\d{2})$#', $route, $matches) === 1:
$eventController->create($matches[1]);
break;
case $route === 'kalendarz/dodaj':
$eventController->store();
break;
case preg_match('#^kalendarz/dzien/(\d{4}-\d{2}-\d{2})$#', $route, $matches) === 1:
$eventController->dayEvents($matches[1]);
break;
case preg_match('#^kalendarz/edytuj/(\d+)$#', $route, $matches) === 1:
$eventController->edit((int) $matches[1]);
break;
case preg_match('#^kalendarz/zapisz/(\d+)$#', $route, $matches) === 1:
$eventController->update((int) $matches[1]);
break;
case preg_match('#^kalendarz/usun/(\d+)$#', $route, $matches) === 1:
$eventController->delete((int) $matches[1]);
break;
default:
// Strona 404
http_response_code(404);
echo '<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>404 - Nie znaleziono</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
</style>
</head>
<body>
<div class="text-center text-white">
<h1 class="display-1">404</h1>
<p class="lead">Strona nie została znaleziona</p>
<a href="/" class="btn btn-light btn-lg mt-3">Wróć do strony głównej</a>
</div>
</body>
</html>';
break;
}