From 03858ddec9f3876e8381ed7ef81d181f09572962 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 21 Feb 2026 20:41:25 +0000 Subject: [PATCH] =?UTF-8?q?test=20mutualis=C3=A9=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- diagnostic.php | 47 ++++++++++++++++++++++++++ fix_db.php | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 diagnostic.php create mode 100644 fix_db.php 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 "

Vérification des tables :

"; + +// 3. Extensions PHP +echo "

Extensions PHP :

"; + +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 "

Vérification finale des colonnes (Correction Erreur 500 courante)

"; +// Ajout de colonnes si manquantes (exemple pour channels) +try { + $pdo->exec("ALTER TABLE `channels` ADD COLUMN IF NOT EXISTS `message_limit` int(11) DEFAULT NULL;"); + $pdo->exec("ALTER TABLE `channels` ADD COLUMN IF NOT EXISTS `theme_color` varchar(20) DEFAULT NULL;"); + 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.

";