cms/index.php

244 lines
6.1 KiB
PHP

<?php
require_once __DIR__ . '/includes/functions.php';
// Pobierz slug z URL
$slug = $_GET['page'] ?? 'home';
// Pobierz stronę
$page = getPageBySlug($slug);
// Jeśli strona nie istnieje, pokaż 404
if (!$page) {
http_response_code(404);
$pageTitle = 'Strona nie znaleziona';
$pageContent = '<h1>404 - Strona nie znaleziona</h1><p>Przepraszamy, ale szukana strona nie istnieje.</p>';
} else {
$pageTitle = $page['title'];
$pageContent = $page['content'];
$metaDescription = $page['meta_description'] ?? '';
}
// Pobierz ustawienia
$siteName = getSetting('site_name', 'Moja Strona');
$menu = getMenu('header');
?>
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo escape($pageTitle . ' - ' . $siteName); ?></title>
<?php if ($metaDescription): ?>
<meta name="description" content="<?php echo escape($metaDescription); ?>">
<?php endif; ?>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
line-height: 1.6;
color: #333;
}
/* Nagłówek */
header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 0;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.header-top {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-size: 28px;
font-weight: 700;
text-decoration: none;
color: white;
}
nav {
background: rgba(0,0,0,0.1);
}
nav ul {
list-style: none;
display: flex;
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
nav ul li a {
display: block;
padding: 15px 20px;
color: white;
text-decoration: none;
transition: background 0.3s;
}
nav ul li a:hover {
background: rgba(255,255,255,0.1);
}
/* Główna treść */
main {
max-width: 1200px;
margin: 40px auto;
padding: 0 20px;
}
.content {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.content h1 {
color: #2c3e50;
margin-bottom: 20px;
font-size: 36px;
}
.content h2 {
color: #34495e;
margin: 30px 0 15px;
font-size: 28px;
}
.content h3 {
color: #34495e;
margin: 25px 0 12px;
font-size: 22px;
}
.content p {
margin-bottom: 15px;
line-height: 1.8;
}
.content img {
max-width: 100%;
height: auto;
border-radius: 8px;
margin: 20px 0;
}
.content ul, .content ol {
margin: 15px 0 15px 30px;
}
.content li {
margin-bottom: 8px;
}
/* Stopka */
footer {
background: #2c3e50;
color: white;
text-align: center;
padding: 30px 20px;
margin-top: 60px;
}
footer p {
margin-bottom: 10px;
}
footer a {
color: #667eea;
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}
/* Responsywność */
@media (max-width: 768px) {
.header-top {
flex-direction: column;
gap: 15px;
}
nav ul {
flex-direction: column;
}
nav ul li a {
padding: 12px 20px;
border-bottom: 1px solid rgba(255,255,255,0.1);
}
.content {
padding: 20px;
}
.content h1 {
font-size: 28px;
}
}
/* Strona 404 */
.error-404 {
text-align: center;
padding: 60px 20px;
}
.error-404 h1 {
font-size: 72px;
color: #667eea;
margin-bottom: 20px;
}
</style>
</head>
<body>
<header>
<div class="header-top">
<a href="/" class="logo"><?php echo escape($siteName); ?></a>
<div>
<a href="<?php echo ADMIN_URL; ?>/login.php" style="color: white; text-decoration: none; padding: 10px 20px; background: rgba(255,255,255,0.2); border-radius: 5px;">
Panel administracyjny
</a>
</div>
</div>
<?php if (!empty($menu)): ?>
<nav>
<ul>
<?php foreach ($menu as $item): ?>
<li>
<a href="<?php echo escape($item['url'] ?? '?page=' . $item['page_id']); ?>">
<?php echo escape($item['title']); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</nav>
<?php endif; ?>
</header>
<main>
<div class="content <?php echo !$page ? 'error-404' : ''; ?>">
<?php echo $pageContent; ?>
</div>
</main>
<footer>
<p>&copy; <?php echo date('Y'); ?> <?php echo escape($siteName); ?>. Wszystkie prawa zastrzeżone.</p>
<p>Powered by Custom CMS</p>
</footer>
</body>
</html>