353 lines
13 KiB
PHP
353 lines
13 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/auth.php';
|
|
require_once __DIR__ . '/../includes/functions.php';
|
|
|
|
requireRole('admin'); // Tylko administrator
|
|
|
|
$message = '';
|
|
$db = getDB();
|
|
|
|
// Obsługa zapisu ustawień
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['save_settings'])) {
|
|
foreach ($_POST as $key => $value) {
|
|
if ($key !== 'save_settings' && $key !== 'csrf_token') {
|
|
updateSetting($key, $value);
|
|
}
|
|
}
|
|
|
|
logActivity('settings_updated');
|
|
$message = 'Ustawienia zostały zapisane';
|
|
}
|
|
|
|
// Pobierz wszystkie ustawienia
|
|
$stmt = $db->query("SELECT setting_key, setting_value FROM settings ORDER BY setting_key");
|
|
$settings = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="pl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Ustawienia - Panel 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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.sidebar nav a:hover, .sidebar nav a.active {
|
|
background: #f0f4ff;
|
|
border-left-color: #667eea;
|
|
color: #667eea;
|
|
}
|
|
|
|
.main-content {
|
|
margin-left: 250px;
|
|
padding: 30px;
|
|
}
|
|
|
|
.btn {
|
|
display: inline-block;
|
|
padding: 10px 20px;
|
|
background: #667eea;
|
|
color: white;
|
|
text-decoration: none;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.btn:hover { background: #5568d3; }
|
|
.btn-sm { padding: 6px 12px; font-size: 13px; }
|
|
|
|
.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-body { padding: 20px; }
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
font-weight: 500;
|
|
color: #333;
|
|
}
|
|
|
|
.form-group input, .form-group select, .form-group textarea {
|
|
width: 100%;
|
|
padding: 10px;
|
|
border: 2px solid #e1e8ed;
|
|
border-radius: 5px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.form-group small {
|
|
display: block;
|
|
margin-top: 5px;
|
|
color: #666;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.settings-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 20px;
|
|
}
|
|
|
|
.message {
|
|
padding: 12px 20px;
|
|
background: #d4edda;
|
|
color: #155724;
|
|
border-radius: 5px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.settings-section {
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.settings-section h3 {
|
|
color: #2c3e50;
|
|
margin-bottom: 20px;
|
|
padding-bottom: 10px;
|
|
border-bottom: 2px solid #667eea;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.settings-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1>Panel CMS</h1>
|
|
<a href="index.php" class="btn btn-sm">← Powrót</a>
|
|
</div>
|
|
|
|
<div class="sidebar">
|
|
<nav>
|
|
<a href="index.php">📊 Dashboard</a>
|
|
<a href="pages.php">📄 Strony</a>
|
|
<a href="media.php">🖼️ Media</a>
|
|
<a href="settings.php" class="active">⚙️ Ustawienia</a>
|
|
</nav>
|
|
</div>
|
|
|
|
<div class="main-content">
|
|
<h1 style="margin-bottom: 30px;">Ustawienia systemu</h1>
|
|
|
|
<?php if ($message): ?>
|
|
<div class="message"><?php echo escape($message); ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<input type="hidden" name="save_settings" value="1">
|
|
|
|
<!-- Ogólne -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2>Ogólne ustawienia</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="settings-section">
|
|
<h3>Podstawowe informacje</h3>
|
|
|
|
<div class="settings-grid">
|
|
<div class="form-group">
|
|
<label>Nazwa strony</label>
|
|
<input type="text" name="site_name"
|
|
value="<?php echo escape($settings['site_name'] ?? ''); ?>">
|
|
<small>Nazwa wyświetlana w nagłówku i tytule strony</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Email kontaktowy</label>
|
|
<input type="email" name="site_email"
|
|
value="<?php echo escape($settings['site_email'] ?? ''); ?>">
|
|
<small>Główny adres email strony</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Opis strony</label>
|
|
<textarea name="site_description" rows="3"><?php echo escape($settings['site_description'] ?? ''); ?></textarea>
|
|
<small>Krótki opis strony (używany w meta tagach)</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="settings-section">
|
|
<h3>Regionalne</h3>
|
|
|
|
<div class="settings-grid">
|
|
<div class="form-group">
|
|
<label>Strefa czasowa</label>
|
|
<select name="timezone">
|
|
<option value="Europe/Warsaw" <?php echo ($settings['timezone'] ?? '') === 'Europe/Warsaw' ? 'selected' : ''; ?>>
|
|
Europe/Warsaw (UTC+1/+2)
|
|
</option>
|
|
<option value="UTC" <?php echo ($settings['timezone'] ?? '') === 'UTC' ? 'selected' : ''; ?>>
|
|
UTC (UTC+0)
|
|
</option>
|
|
<option value="Europe/London" <?php echo ($settings['timezone'] ?? '') === 'Europe/London' ? 'selected' : ''; ?>>
|
|
Europe/London (UTC+0/+1)
|
|
</option>
|
|
<option value="America/New_York" <?php echo ($settings['timezone'] ?? '') === 'America/New_York' ? 'selected' : ''; ?>>
|
|
America/New_York (UTC-5/-4)
|
|
</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Format daty</label>
|
|
<select name="date_format">
|
|
<option value="Y-m-d H:i:s" <?php echo ($settings['date_format'] ?? '') === 'Y-m-d H:i:s' ? 'selected' : ''; ?>>
|
|
2025-01-15 14:30:00
|
|
</option>
|
|
<option value="d.m.Y H:i" <?php echo ($settings['date_format'] ?? '') === 'd.m.Y H:i' ? 'selected' : ''; ?>>
|
|
15.01.2025 14:30
|
|
</option>
|
|
<option value="d/m/Y" <?php echo ($settings['date_format'] ?? '') === 'd/m/Y' ? 'selected' : ''; ?>>
|
|
15/01/2025
|
|
</option>
|
|
<option value="M d, Y" <?php echo ($settings['date_format'] ?? '') === 'M d, Y' ? 'selected' : ''; ?>>
|
|
Jan 15, 2025
|
|
</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Wyświetlanie -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2>Wyświetlanie treści</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="settings-grid">
|
|
<div class="form-group">
|
|
<label>Elementów na stronę</label>
|
|
<input type="number" name="items_per_page" min="5" max="100"
|
|
value="<?php echo escape($settings['items_per_page'] ?? '10'); ?>">
|
|
<small>Liczba elementów wyświetlanych na jednej stronie w listach</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Użytkownicy -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2>Użytkownicy i bezpieczeństwo</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-group">
|
|
<label style="display: flex; align-items: center; gap: 10px;">
|
|
<input type="checkbox" name="allow_registration" value="1"
|
|
<?php echo ($settings['allow_registration'] ?? '0') == '1' ? 'checked' : ''; ?>
|
|
style="width: auto;">
|
|
Zezwól na rejestrację nowych użytkowników
|
|
</label>
|
|
<small>Gdy wyłączone, tylko administrator może tworzyć konta</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- System -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2>Informacje systemowe</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="settings-grid">
|
|
<div>
|
|
<strong>Wersja PHP:</strong> <?php echo phpversion(); ?>
|
|
</div>
|
|
<div>
|
|
<strong>Wersja MySQL:</strong>
|
|
<?php
|
|
$version = $db->query('SELECT VERSION()')->fetchColumn();
|
|
echo $version;
|
|
?>
|
|
</div>
|
|
<div>
|
|
<strong>Zainstalowane strony:</strong>
|
|
<?php echo $db->query('SELECT COUNT(*) FROM pages')->fetchColumn(); ?>
|
|
</div>
|
|
<div>
|
|
<strong>Zarejestrowani użytkownicy:</strong>
|
|
<?php echo $db->query('SELECT COUNT(*) FROM users')->fetchColumn(); ?>
|
|
</div>
|
|
</div>
|
|
|
|
<hr style="margin: 20px 0; border: none; border-top: 1px solid #e0e0e0;">
|
|
|
|
<div class="settings-grid">
|
|
<div>
|
|
<strong>Ścieżka do uploadu:</strong><br>
|
|
<code style="font-size: 12px; color: #666;"><?php echo UPLOAD_DIR; ?></code>
|
|
</div>
|
|
<div>
|
|
<strong>Max rozmiar pliku:</strong>
|
|
<?php echo round(MAX_UPLOAD_SIZE / 1024 / 1024, 2); ?> MB
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="position: sticky; bottom: 20px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 -2px 10px rgba(0,0,0,0.1);">
|
|
<button type="submit" class="btn" style="font-size: 16px; padding: 12px 30px;">
|
|
💾 Zapisz wszystkie ustawienia
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|