test mutualisé 1

This commit is contained in:
Flatlogic Bot 2026-02-21 20:41:25 +00:00
parent 3481ca8c26
commit 03858ddec9
2 changed files with 136 additions and 0 deletions

47
diagnostic.php Normal file
View File

@ -0,0 +1,47 @@
<?php
require_once __DIR__ . '/db/config.php';
header('Content-Type: text/html; charset=utf-8');
echo "<h1>Diagnostic du Projet Corvara</h1>";
// 1. Test de la connexion
try {
$pdo = db();
echo "<p style='color:green;'>✅ Connexion à la base de données réussie.</p>";
} catch (Exception $e) {
echo "<p style='color:red;'>❌ Erreur de connexion : " . htmlspecialchars($e->getMessage()) . "</p>";
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 "<h2>Vérification des tables :</h2><ul>";
foreach ($required_tables as $table) {
try {
$pdo->query("SELECT 1 FROM `$table` LIMIT 1");
echo "<li>$table : <span style='color:green;'>OK</span></li>";
} catch (Exception $e) {
echo "<li>$table : <span style='color:red;'>MANQUANTE</span> (C'est probablement la cause de l'erreur 500)</li>";
}
}
echo "</ul>";
// 3. Extensions PHP
echo "<h2>Extensions PHP :</h2><ul>";
$exts = ['pdo_mysql', 'mbstring', 'curl', 'gd'];
foreach ($exts as $ext) {
if (extension_loaded($ext)) {
echo "<li>$ext : <span style='color:green;'>Installée</span></li>";
} else {
echo "<li>$ext : <span style='color:red;'>Absente</span></li>";
}
}
echo "</ul>";
echo "<hr><p>Si des tables sont manquantes, exécutez <b>fix_db.php</b>.</p>";

89
fix_db.php Normal file
View File

@ -0,0 +1,89 @@
<?php
require_once __DIR__ . '/db/config.php';
header('Content-Type: text/html; charset=utf-8');
echo "<h1>Réparation de la base de données</h1>";
try {
$pdo = db();
} catch (Exception $e) {
die("<p style='color:red;'>Erreur de connexion : " . $e->getMessage() . "</p>");
}
$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 "<p>✅ Exécution réussie d'une requête de création.</p>";
} catch (Exception $e) {
echo "<p style='color:orange;'>⚠️ Info : " . $e->getMessage() . " (Peut-être que la table existe déjà)</p>";
}
}
echo "<h2>Vérification finale des colonnes (Correction Erreur 500 courante)</h2>";
// 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 "<p>✅ Mise à jour des colonnes 'channels' terminée.</p>";
} catch (Exception $e) {
echo "<p> Colonnes déjà présentes dans 'channels'.</p>";
}
echo "<hr><p style='color:green;'>Terminé ! Essayez de rafraîchir votre page index.php.</p>";
echo "<p style='color:red;'><b>IMPORTANT : Supprimez ce fichier (fix_db.php) après usage.</b></p>";