Sindbad~EG File Manager
<?php
require_once 'config/database.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo "<h2>🔧 Fix Events Status</h2>";
try {
$database = new CopMadinaDB();
$pdo = $database->getConnection();
if (!$pdo) {
throw new Exception("Database connection failed");
}
// Fix 1: Set all events to 'active' status (they currently have empty status)
$stmt = $pdo->prepare("UPDATE events SET status = 'active' WHERE status = '' OR status IS NULL");
$result1 = $stmt->execute();
$affected1 = $stmt->rowCount();
echo "✅ Updated {$affected1} events to 'active' status<br>";
// Fix 2: Also handle any 'published' status
$stmt = $pdo->prepare("UPDATE events SET status = 'active' WHERE status = 'published'");
$result2 = $stmt->execute();
$affected2 = $stmt->rowCount();
echo "✅ Updated {$affected2} 'published' events to 'active'<br>";
// Check final count
$stmt = $pdo->prepare("SELECT COUNT(*) as count FROM events WHERE status = 'active' AND start_date >= CURDATE()");
$stmt->execute();
$count = $stmt->fetch(PDO::FETCH_ASSOC);
echo "<br><h3>📊 Final Result:</h3>";
echo "Active upcoming events: <strong style='color: green;'>{$count['count']}</strong><br>";
// Show updated events
$stmt = $pdo->prepare("SELECT id, title, status, start_date FROM events ORDER BY start_date");
$stmt->execute();
$events = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<br><h3>📅 Updated Events:</h3>";
echo "<table border='1' style='border-collapse: collapse;'>";
echo "<tr><th style='padding: 8px;'>ID</th><th style='padding: 8px;'>Title</th><th style='padding: 8px;'>Status</th><th style='padding: 8px;'>Date</th></tr>";
foreach ($events as $event) {
$color = ($event['status'] == 'active') ? 'green' : 'red';
echo "<tr>";
echo "<td style='padding: 8px;'>{$event['id']}</td>";
echo "<td style='padding: 8px;'>" . htmlspecialchars($event['title']) . "</td>";
echo "<td style='padding: 8px; color: {$color};'>{$event['status']}</td>";
echo "<td style='padding: 8px;'>{$event['start_date']}</td>";
echo "</tr>";
}
echo "</table>";
echo "<br><a href='index.php' style='background: #28a745; color: white; padding: 12px 24px; text-decoration: none; border-radius: 8px; font-weight: bold;'>🏠 View Landing Page</a>";
} catch (Exception $e) {
echo "❌ Error: " . $e->getMessage();
}
?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists