110 lines
5.2 KiB
PHP
110 lines
5.2 KiB
PHP
<?php
|
|
require_once '../includes/db.php';
|
|
require_once '../includes/functions.php';
|
|
requireRole('admin');
|
|
|
|
$success = '';
|
|
$error = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
if (isset($_POST['update_site'])) {
|
|
updateSetting($pdo, 'site_title', $_POST['site_title']);
|
|
updateSetting($pdo, 'footer_copyright', $_POST['footer_copyright']);
|
|
updateSetting($pdo, 'footer_powered_by', $_POST['footer_powered_by']);
|
|
updateSetting($pdo, 'theme_primary_color', $_POST['theme_primary_color']);
|
|
updateSetting($pdo, 'theme_bg_color', $_POST['theme_bg_color']);
|
|
updateSetting($pdo, 'theme_text_color', $_POST['theme_text_color']);
|
|
$success = "Site settings updated!";
|
|
}
|
|
|
|
if (isset($_FILES['banner_image']) && $_FILES['banner_image']['error'] === 0) {
|
|
$fileName = uploadImage($_FILES['banner_image']);
|
|
if ($fileName) {
|
|
updateSetting($pdo, 'banner_image', $fileName);
|
|
$success = "Banner image updated!";
|
|
} else {
|
|
$error = "Invalid image format.";
|
|
}
|
|
}
|
|
}
|
|
|
|
$site_title = getSetting($pdo, 'site_title');
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Site Settings - <?php echo $site_title; ?></title>
|
|
<link rel="stylesheet" href="../assets/css/style.css">
|
|
</head>
|
|
<body>
|
|
<nav>
|
|
<a href="<?php echo PROJECT_ROOT_URL; ?>/" class="logo">Admin Dashboard</a>
|
|
<div class="nav-links">
|
|
<a href="dashboard.php">Episodes</a>
|
|
<a href="upload.php">Upload New</a>
|
|
<a href="settings.php" style="color: var(--primary-color);">Site Settings</a>
|
|
<a href="users.php">Manage Users</a>
|
|
<a href="system.php">System</a>
|
|
<a href="logout.php">Logout</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="form-container">
|
|
<h2>Site Settings</h2>
|
|
<?php if ($success): ?>
|
|
<p style="color: #10b981; margin-bottom: 1rem;"><?php echo $success; ?></p>
|
|
<?php endif; ?>
|
|
<?php if ($error): ?>
|
|
<p style="color: #ef4444; margin-bottom: 1rem;"><?php echo $error; ?></p>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<div class="form-group">
|
|
<label for="site_title">Site Title</label>
|
|
<input type="text" id="site_title" name="site_title" value="<?php echo htmlspecialchars($site_title); ?>" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="footer_copyright">Footer Copyright Text</label>
|
|
<input type="text" id="footer_copyright" name="footer_copyright" value="<?php echo htmlspecialchars(getSetting($pdo, 'footer_copyright')); ?>" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="footer_powered_by">Other</label>
|
|
<input type="text" id="footer_powered_by" name="footer_powered_by" value="<?php echo htmlspecialchars(getSetting($pdo, 'footer_powered_by')); ?>" required>
|
|
</div>
|
|
|
|
<h3 style="margin: 2rem 0 1rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 0.5rem;">Theme Colors</h3>
|
|
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem;">
|
|
<div class="form-group">
|
|
<label for="theme_primary_color">Primary Color</label>
|
|
<input type="color" id="theme_primary_color" name="theme_primary_color" value="<?php echo htmlspecialchars(getSetting($pdo, 'theme_primary_color') ?: '#6366f1'); ?>" style="height: 45px; cursor: pointer;">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="theme_bg_color">Background Color</label>
|
|
<input type="color" id="theme_bg_color" name="theme_bg_color" value="<?php echo htmlspecialchars(getSetting($pdo, 'theme_bg_color') ?: '#0f172a'); ?>" style="height: 45px; cursor: pointer;">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="theme_text_color">Text Color</label>
|
|
<input type="color" id="theme_text_color" name="theme_text_color" value="<?php echo htmlspecialchars(getSetting($pdo, 'theme_text_color') ?: '#f8fafc'); ?>" style="height: 45px; cursor: pointer;">
|
|
</div>
|
|
</div>
|
|
<button type="submit" name="update_site" class="btn btn-primary" style="width: 100%;">Update Settings</button>
|
|
</form>
|
|
|
|
<hr style="margin: 2rem 0; border: none; border-top: 1px solid var(--glass-border);">
|
|
|
|
<form method="POST" enctype="multipart/form-data">
|
|
<div class="form-group">
|
|
<label for="banner_image">Banner Image</label>
|
|
<input type="file" id="banner_image" name="banner_image" accept="image/*" required>
|
|
<p style="font-size: 0.8rem; color: var(--text-muted); mt-1">Recommended size: 1920x400px</p>
|
|
</div>
|
|
<button type="submit" name="update_banner" class="btn btn-primary" style="width: 100%;">Update Banner</button>
|
|
</form>
|
|
</div>
|
|
|
|
<?php include '../includes/footer.php'; ?>
|
|
</body>
|
|
</html>
|