265 lines
7.3 KiB
PHP
265 lines
7.3 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/auth.php';
|
|
require_once __DIR__ . '/../includes/functions.php';
|
|
|
|
requireLogin();
|
|
|
|
$user = getCurrentUser();
|
|
$db = getDB();
|
|
|
|
// Statystyki
|
|
$stats = [
|
|
'pages' => $db->query("SELECT COUNT(*) as count FROM pages")->fetch()['count'],
|
|
'published' => $db->query("SELECT COUNT(*) as count FROM pages WHERE status = 'published'")->fetch()['count'],
|
|
'users' => $db->query("SELECT COUNT(*) as count FROM users")->fetch()['count'],
|
|
'media' => $db->query("SELECT COUNT(*) as count FROM media")->fetch()['count']
|
|
];
|
|
|
|
// Ostatnie strony
|
|
$recentPages = getAllPages('published', 5);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="pl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Panel administracyjny - CMS</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: #f5f5f5;
|
|
}
|
|
|
|
.header {
|
|
background: #2c3e50;
|
|
color: white;
|
|
padding: 0 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
height: 60px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 20px;
|
|
}
|
|
|
|
.user-menu {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 15px;
|
|
}
|
|
|
|
.sidebar {
|
|
position: fixed;
|
|
left: 0;
|
|
top: 60px;
|
|
width: 250px;
|
|
background: white;
|
|
height: calc(100vh - 60px);
|
|
border-right: 1px solid #e0e0e0;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.sidebar nav a {
|
|
display: block;
|
|
padding: 15px 20px;
|
|
color: #333;
|
|
text-decoration: none;
|
|
border-left: 3px solid transparent;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.sidebar nav a:hover {
|
|
background: #f5f5f5;
|
|
border-left-color: #667eea;
|
|
}
|
|
|
|
.sidebar nav a.active {
|
|
background: #f0f4ff;
|
|
border-left-color: #667eea;
|
|
color: #667eea;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.main-content {
|
|
margin-left: 250px;
|
|
padding: 30px;
|
|
min-height: calc(100vh - 60px);
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.stat-card {
|
|
background: white;
|
|
padding: 25px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
|
}
|
|
|
|
.stat-card h3 {
|
|
color: #666;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.stat-card .number {
|
|
font-size: 32px;
|
|
font-weight: 700;
|
|
color: #667eea;
|
|
}
|
|
|
|
.card {
|
|
background: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.card-header {
|
|
padding: 20px;
|
|
border-bottom: 1px solid #e0e0e0;
|
|
}
|
|
|
|
.card-header h2 {
|
|
font-size: 18px;
|
|
color: #333;
|
|
}
|
|
|
|
.card-body {
|
|
padding: 20px;
|
|
}
|
|
|
|
.page-list {
|
|
list-style: none;
|
|
}
|
|
|
|
.page-item {
|
|
padding: 15px 0;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
|
|
.page-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.page-item h4 {
|
|
color: #333;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.page-item small {
|
|
color: #999;
|
|
}
|
|
|
|
.btn {
|
|
display: inline-block;
|
|
padding: 10px 20px;
|
|
background: #667eea;
|
|
color: white;
|
|
text-decoration: none;
|
|
border-radius: 5px;
|
|
font-weight: 500;
|
|
transition: background 0.3s;
|
|
}
|
|
|
|
.btn:hover {
|
|
background: #5568d3;
|
|
}
|
|
|
|
.btn-sm {
|
|
padding: 6px 12px;
|
|
font-size: 13px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1>🚀 Panel CMS</h1>
|
|
<div class="user-menu">
|
|
<span>Witaj, <strong><?php echo escape($user['username']); ?></strong></span>
|
|
<a href="logout.php" class="btn btn-sm">Wyloguj</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="sidebar">
|
|
<nav>
|
|
<a href="index.php" class="active">📊 Dashboard</a>
|
|
<a href="pages.php">📄 Strony</a>
|
|
<a href="media.php">🖼️ Media</a>
|
|
<a href="menus.php">🔗 Menu</a>
|
|
<a href="categories.php">📁 Kategorie</a>
|
|
<?php if (hasRole('admin')): ?>
|
|
<a href="users.php">👥 Użytkownicy</a>
|
|
<a href="settings.php">⚙️ Ustawienia</a>
|
|
<?php endif; ?>
|
|
</nav>
|
|
</div>
|
|
|
|
<div class="main-content">
|
|
<h1 style="margin-bottom: 30px;">Dashboard</h1>
|
|
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<h3>Wszystkie strony</h3>
|
|
<div class="number"><?php echo $stats['pages']; ?></div>
|
|
</div>
|
|
|
|
<div class="stat-card">
|
|
<h3>Opublikowane</h3>
|
|
<div class="number"><?php echo $stats['published']; ?></div>
|
|
</div>
|
|
|
|
<div class="stat-card">
|
|
<h3>Użytkownicy</h3>
|
|
<div class="number"><?php echo $stats['users']; ?></div>
|
|
</div>
|
|
|
|
<div class="stat-card">
|
|
<h3>Pliki</h3>
|
|
<div class="number"><?php echo $stats['media']; ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2>Ostatnie strony</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
<?php if (empty($recentPages)): ?>
|
|
<p style="color: #999;">Brak opublikowanych stron</p>
|
|
<?php else: ?>
|
|
<ul class="page-list">
|
|
<?php foreach ($recentPages as $page): ?>
|
|
<li class="page-item">
|
|
<h4><?php echo escape($page['title']); ?></h4>
|
|
<small>
|
|
Autor: <?php echo escape($page['author_name']); ?> |
|
|
Data: <?php echo formatDate($page['created_at']); ?>
|
|
</small>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
|
|
<div style="margin-top: 20px;">
|
|
<a href="pages.php" class="btn">Zobacz wszystkie strony</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|