Sindbad~EG File Manager
<?php
require_once '../../config/config.php';
checkLogin();
$pageTitle = "Manage Page Content - " . APP_NAME;
$db = Database::getInstance()->getConnection();
// Handle form submission
$successMessage = '';
$errorMessage = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action'])) {
try {
if ($_POST['action'] == 'update_content') {
// Update all content items
foreach ($_POST['content'] as $contentId => $newValue) {
$stmt = $db->prepare("UPDATE page_content SET content_value = :value, updated_by = :user_id, updated_at = NOW() WHERE id = :id");
$stmt->execute([
'value' => $newValue,
'user_id' => $_SESSION['user_id'],
'id' => $contentId
]);
}
$successMessage = "Content updated successfully!";
}
} catch (Exception $e) {
$errorMessage = "Error: " . $e->getMessage();
}
}
// Get current page to display
$currentPage = $_GET['page'] ?? 'about';
// Get all content for the selected page
$stmt = $db->prepare("SELECT * FROM page_content WHERE page_name = :page ORDER BY display_order ASC");
$stmt->execute(['page' => $currentPage]);
$content = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Group content by section
$sections = [];
foreach ($content as $item) {
$sections[$item['section_name']][] = $item;
}
include '../../includes/header.php';
?>
<style>
.gradient-bg {
background: linear-gradient(135deg, #1E40AF 0%, #9333EA 50%, #F97316 100%);
}
.card-gradient {
background: linear-gradient(135deg, rgba(30, 64, 175, 0.05) 0%, rgba(249, 115, 22, 0.05) 100%);
}
.text-gradient {
background: linear-gradient(135deg, #1E40AF 0%, #F97316 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.section-card {
transition: all 0.3s ease;
}
.section-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}
</style>
<?php include '../../includes/sidebar.php'; ?>
<!-- Main Content -->
<main class="flex-1 md:ml-64 mt-16 min-h-screen bg-gray-50">
<div class="container mx-auto px-4 py-8">
<!-- Page Header -->
<div class="gradient-bg rounded-2xl shadow-2xl p-8 mb-8 text-white">
<div class="flex items-center justify-between">
<div>
<h1 class="text-4xl font-bold mb-2">
<i class="fas fa-edit mr-3"></i>Manage Page Content
</h1>
<p class="text-white/90 text-lg">Edit content for About, Features, and Contact pages</p>
</div>
<div class="hidden md:block">
<i class="fas fa-file-alt text-white/20 text-8xl"></i>
</div>
</div>
</div>
<!-- Success/Error Messages -->
<?php if ($successMessage): ?>
<div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 rounded-lg mb-6 animate-fadeInUp">
<div class="flex items-center">
<i class="fas fa-check-circle text-2xl mr-3"></i>
<p class="font-semibold"><?php echo $successMessage; ?></p>
</div>
</div>
<?php endif; ?>
<?php if ($errorMessage): ?>
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 rounded-lg mb-6 animate-fadeInUp">
<div class="flex items-center">
<i class="fas fa-exclamation-circle text-2xl mr-3"></i>
<p class="font-semibold"><?php echo $errorMessage; ?></p>
</div>
</div>
<?php endif; ?>
<!-- Page Selector -->
<div class="bg-white rounded-2xl shadow-lg p-6 mb-8">
<div class="flex items-center space-x-4 mb-4">
<i class="fas fa-file-alt text-3xl text-gradient"></i>
<h2 class="text-2xl font-bold text-gray-800">Select Page to Edit</h2>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<a href="?page=about" class="group relative overflow-hidden rounded-xl p-6 text-center transition <?php echo $currentPage == 'about' ? 'bg-gradient-to-r from-blue-500 to-purple-600 text-white' : 'bg-gray-100 hover:bg-gray-200 text-gray-700'; ?>">
<i class="fas fa-info-circle text-4xl mb-3 <?php echo $currentPage == 'about' ? 'text-white' : 'text-blue-600'; ?>"></i>
<h3 class="text-xl font-bold">About Us</h3>
<p class="text-sm <?php echo $currentPage == 'about' ? 'text-white/80' : 'text-gray-500'; ?>">Mission, stats, features</p>
</a>
<a href="?page=features" class="group relative overflow-hidden rounded-xl p-6 text-center transition <?php echo $currentPage == 'features' ? 'bg-gradient-to-r from-orange-500 to-yellow-500 text-white' : 'bg-gray-100 hover:bg-gray-200 text-gray-700'; ?>">
<i class="fas fa-star text-4xl mb-3 <?php echo $currentPage == 'features' ? 'text-white' : 'text-orange-600'; ?>"></i>
<h3 class="text-xl font-bold">Features</h3>
<p class="text-sm <?php echo $currentPage == 'features' ? 'text-white/80' : 'text-gray-500'; ?>">System capabilities</p>
</a>
<a href="?page=contact" class="group relative overflow-hidden rounded-xl p-6 text-center transition <?php echo $currentPage == 'contact' ? 'bg-gradient-to-r from-purple-500 to-orange-500 text-white' : 'bg-gray-100 hover:bg-gray-200 text-gray-700'; ?>">
<i class="fas fa-envelope text-4xl mb-3 <?php echo $currentPage == 'contact' ? 'text-white' : 'text-purple-600'; ?>"></i>
<h3 class="text-xl font-bold">Contact</h3>
<p class="text-sm <?php echo $currentPage == 'contact' ? 'text-white/80' : 'text-gray-500'; ?>">Contact information</p>
</a>
</div>
</div>
<!-- Content Editor Form -->
<form method="POST" class="space-y-6">
<input type="hidden" name="action" value="update_content">
<?php foreach ($sections as $sectionName => $items): ?>
<div class="section-card bg-white rounded-2xl shadow-lg overflow-hidden">
<!-- Section Header -->
<div class="card-gradient p-6 border-l-4" style="border-color:
<?php
if ($currentPage == 'about') echo '#1E40AF';
elseif ($currentPage == 'features') echo '#F97316';
else echo '#9333EA';
?>">
<h3 class="text-2xl font-bold text-gray-800 capitalize">
<i class="fas fa-layer-group mr-2" style="color:
<?php
if ($currentPage == 'about') echo '#1E40AF';
elseif ($currentPage == 'features') echo '#F97316';
else echo '#9333EA';
?>"></i>
<?php echo ucfirst(str_replace('_', ' ', $sectionName)); ?> Section
</h3>
</div>
<!-- Section Content -->
<div class="p-6 space-y-6">
<?php foreach ($items as $item): ?>
<div class="group">
<label class="block text-sm font-bold text-gray-700 mb-2 flex items-center">
<i class="fas fa-pen-fancy mr-2 text-gray-400"></i>
<?php echo ucfirst(str_replace('_', ' ', $item['content_key'])); ?>
</label>
<?php if ($item['content_type'] == 'textarea'): ?>
<textarea
name="content[<?php echo $item['id']; ?>]"
rows="4"
class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:border-blue-500 focus:ring-2 focus:ring-blue-200 transition duration-200"
placeholder="Enter <?php echo $item['content_key']; ?>..."
><?php echo htmlspecialchars($item['content_value']); ?></textarea>
<?php else: ?>
<input
type="<?php echo $item['content_type']; ?>"
name="content[<?php echo $item['id']; ?>]"
value="<?php echo htmlspecialchars($item['content_value']); ?>"
class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:border-blue-500 focus:ring-2 focus:ring-blue-200 transition duration-200"
placeholder="Enter <?php echo $item['content_key']; ?>..."
>
<?php endif; ?>
<p class="text-xs text-gray-500 mt-1 italic">Last updated: <?php echo date('M d, Y h:i A', strtotime($item['updated_at'])); ?></p>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
<!-- Submit Button -->
<div class="flex items-center justify-between bg-white rounded-2xl shadow-lg p-6">
<div class="flex items-center text-gray-600">
<i class="fas fa-info-circle mr-2"></i>
<span class="text-sm">Changes will be visible immediately on the <?php echo ucfirst($currentPage); ?> page</span>
</div>
<button
type="submit"
class="px-8 py-4 rounded-full text-white font-bold text-lg shadow-xl hover:shadow-2xl transition duration-300 transform hover:scale-105"
style="background: linear-gradient(135deg, #1E40AF 0%, #F97316 100%);"
>
<i class="fas fa-save mr-2"></i>Save All Changes
</button>
</div>
</form>
<!-- Preview Link -->
<div class="bg-gradient-to-r from-blue-500 to-purple-600 rounded-2xl shadow-lg p-6 text-white text-center">
<h3 class="text-xl font-bold mb-3">
<i class="fas fa-eye mr-2"></i>Preview Your Changes
</h3>
<p class="mb-4 text-white/90">View how your content looks on the live page</p>
<a
href="../../<?php echo $currentPage; ?>.php"
target="_blank"
class="inline-block px-8 py-3 bg-white text-blue-600 rounded-full font-bold hover:bg-gray-100 transition"
>
<i class="fas fa-external-link-alt mr-2"></i>Open <?php echo ucfirst($currentPage); ?> Page
</a>
</div>
</div>
</main>
<?php include '../../includes/footer.php'; ?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists