diff --git a/diagnostic.php b/diagnostic.php new file mode 100644 index 0000000..b83c819 --- /dev/null +++ b/diagnostic.php @@ -0,0 +1,47 @@ +Diagnostic du Projet Corvara"; + +// 1. Test de la connexion +try { + $pdo = db(); + echo "
✅ Connexion à la base de données réussie.
"; +} catch (Exception $e) { + echo "❌ Erreur de connexion : " . htmlspecialchars($e->getMessage()) . "
"; + exit; +} + +// 2. Vérification des tables +$required_tables = [ + 'users', 'servers', 'channels', 'messages', 'roles', 'server_members', + 'channel_members', 'channel_events', 'poll_votes', 'server_badges', + 'member_badges', 'custom_emotes', 'voice_sessions' +]; + +echo "Si des tables sont manquantes, exécutez fix_db.php.
"; diff --git a/fix_db.php b/fix_db.php new file mode 100644 index 0000000..4becb03 --- /dev/null +++ b/fix_db.php @@ -0,0 +1,89 @@ +Réparation de la base de données"; + +try { + $pdo = db(); +} catch (Exception $e) { + die("Erreur de connexion : " . $e->getMessage() . "
"); +} + +$tables = [ + "CREATE TABLE IF NOT EXISTS `channel_events` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `channel_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `title` varchar(255) NOT NULL, + `description` text DEFAULT NULL, + `banner_url` varchar(255) DEFAULT NULL, + `banner_color` varchar(20) DEFAULT NULL, + `start_date` date NOT NULL, + `start_time` time NOT NULL, + `end_date` date NOT NULL, + `end_time` time NOT NULL, + `frequency` varchar(50) DEFAULT NULL, + `is_permanent` tinyint(1) DEFAULT 0, + `created_at` timestamp NULL DEFAULT current_timestamp(), + `enable_reactions` tinyint(1) DEFAULT 0, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;", + + "CREATE TABLE IF NOT EXISTS `poll_votes` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `message_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `option_index` int(11) NOT NULL, + `created_at` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;", + + "CREATE TABLE IF NOT EXISTS `server_badges` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `server_id` int(11) NOT NULL, + `name` varchar(255) NOT NULL, + `image_url` text NOT NULL, + `created_at` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;", + + "CREATE TABLE IF NOT EXISTS `member_badges` ( + `server_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `badge_id` int(11) NOT NULL, + PRIMARY KEY (`server_id`,`user_id`,`badge_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;", + + "CREATE TABLE IF NOT EXISTS `event_participations` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `event_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `created_at` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `event_id` (`event_id`,`user_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;" +]; + +foreach ($tables as $sql) { + try { + $pdo->exec($sql); + echo "✅ Exécution réussie d'une requête de création.
"; + } catch (Exception $e) { + echo "⚠️ Info : " . $e->getMessage() . " (Peut-être que la table existe déjà)
"; + } +} + +echo "✅ Mise à jour des colonnes 'channels' terminée.
"; +} catch (Exception $e) { + echo "ℹ️ Colonnes déjà présentes dans 'channels'.
"; +} + +echo "Terminé ! Essayez de rafraîchir votre page index.php.
"; +echo "IMPORTANT : Supprimez ce fichier (fix_db.php) après usage.
";