96 lines
4.2 KiB
PHP
96 lines
4.2 KiB
PHP
<?php
|
|
require_once '../includes/db.php';
|
|
require_once '../includes/auth.php';
|
|
requireAdmin();
|
|
|
|
$success = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
if (isset($_POST['restore_defaults'])) {
|
|
$defaults = [
|
|
'site_title' => 'ChurchTube',
|
|
'primary_color' => '#7c4dff',
|
|
'secondary_color' => '#ff4081',
|
|
'logo_url' => '',
|
|
'footer_text' => '© 2024 ChurchTube. All rights reserved.'
|
|
];
|
|
$stmt = $pdo->prepare("UPDATE settings SET setting_value = ? WHERE setting_key = ?");
|
|
foreach ($defaults as $k => $v) {
|
|
$stmt->execute([$v, $k]);
|
|
}
|
|
$success = "Defaults restored!";
|
|
} else {
|
|
$keys = ['site_title', 'primary_color', 'secondary_color', 'logo_url', 'footer_text'];
|
|
$stmt = $pdo->prepare("UPDATE settings SET setting_value = ? WHERE setting_key = ?");
|
|
foreach ($keys as $key) {
|
|
$stmt->execute([$_POST[$key], $key]);
|
|
}
|
|
$success = "Settings updated!";
|
|
}
|
|
}
|
|
|
|
// Get current settings
|
|
$settings = [];
|
|
$res = $pdo->query("SELECT * FROM settings")->fetchAll();
|
|
foreach ($res as $r) {
|
|
$settings[$r['setting_key']] = $r['setting_value'];
|
|
}
|
|
|
|
ob_start();
|
|
require_once '../includes/header.php';
|
|
$header = ob_get_clean();
|
|
echo str_replace(['assets/', 'index.php', 'login.php', 'logout.php', 'admin/'], ['../assets/', '../index.php', '../login.php', '../logout.php', './'], $header);
|
|
?>
|
|
|
|
<div style="max-width: 800px; margin: 40px auto; padding: 0 24px;">
|
|
<div style="background: var(--bg-card); padding: 32px; border-radius: 16px; border: 1px solid var(--glass-border);">
|
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;">
|
|
<h2>Site Settings & Branding</h2>
|
|
<form method="POST" onsubmit="return confirm('Restore all settings to default?')">
|
|
<button type="submit" name="restore_defaults" class="btn" style="background: rgba(255,255,255,0.1); font-size: 0.8rem;">Restore Defaults</button>
|
|
</form>
|
|
</div>
|
|
|
|
<?php if ($success): ?>
|
|
<div style="background: rgba(76,175,80,0.1); color: #4caf50; padding: 16px; border-radius: 8px; margin-bottom: 24px; border: 1px solid rgba(76,175,80,0.2);">
|
|
<?= $success ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<div class="form-group">
|
|
<label class="form-label">Site Title</label>
|
|
<input type="text" name="site_title" class="form-control" value="<?= htmlspecialchars($settings['site_title'] ?? '') ?>">
|
|
</div>
|
|
|
|
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
|
|
<div class="form-group">
|
|
<label class="form-label">Primary Color</label>
|
|
<input type="color" name="primary_color" class="form-control" style="height: 50px; padding: 5px;" value="<?= htmlspecialchars($settings['primary_color'] ?? '#7c4dff') ?>">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Secondary Color</label>
|
|
<input type="color" name="secondary_color" class="form-control" style="height: 50px; padding: 5px;" value="<?= htmlspecialchars($settings['secondary_color'] ?? '#ff4081') ?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">Logo URL</label>
|
|
<input type="url" name="logo_url" class="form-control" value="<?= htmlspecialchars($settings['logo_url'] ?? '') ?>" placeholder="https://example.com/logo.png">
|
|
<small style="color: var(--text-muted);">Leave empty to use text title as logo.</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">Footer Text</label>
|
|
<textarea name="footer_text" class="form-control" style="min-height: 80px;"><?= htmlspecialchars($settings['footer_text'] ?? '') ?></textarea>
|
|
</div>
|
|
|
|
<div style="margin-top: 32px;">
|
|
<button type="submit" class="btn btn-primary" style="width: 100%;">Save Branding</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once '../includes/footer.php'; ?>
|