Files
ms1inscription-v5/diag.php
stephan be68e4f21e Add MySQL connection diagnostics to diag.php
This commit introduces a new section in diag.php to test MySQL connections for different environments (Main, Prod, PreProd) and outputs the connection status along with error messages if applicable. Additionally, it removes the previous promoteur file check and enhances the overall diagnostic output for better clarity. This aims to improve troubleshooting capabilities for database connectivity issues.
2026-06-17 13:36:39 -04:00

86 lines
2.4 KiB
PHP

<?php
/**
* Diagnostic temporaire — trouver quel include casse /compte.
* Supprimer ce fichier apres usage.
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
header('Content-Type: text/plain; charset=utf-8');
echo "=== MS1 diagnostic compte ===\n";
echo 'Date: ' . date('Y-m-d H:i:s') . "\n";
echo 'PHP: ' . PHP_VERSION . "\n";
echo 'HTTP_HOST: ' . ($_SERVER['HTTP_HOST'] ?? '(vide)') . "\n";
echo 'DOCUMENT_ROOT: ' . ($_SERVER['DOCUMENT_ROOT'] ?? '(vide)') . "\n";
echo '__DIR__: ' . __DIR__ . "\n\n";
echo "--- Test connexions MySQL (avant inc_fonctions) ---\n";
require_once __DIR__ . '/php/inc_settings.php';
$connections = array(
'Main' => $arrConDatabaseMain,
'Prod' => $arrConDatabaseProd,
'PreProd' => $arrConDatabasePreProd,
);
foreach ($connections as $label => $cfg) {
echo $label . ' → host=' . $cfg['host'] . ' db=' . $cfg['db'] . ' user=' . $cfg['user'] . ' ... ';
$link = @mysqli_connect($cfg['host'], $cfg['user'], $cfg['pass'], $cfg['db'], 3306);
if ($link) {
echo "OK\n";
mysqli_close($link);
} else {
echo "ECHEC\n";
echo ' mysqli_error: ' . mysqli_connect_error() . "\n";
}
}
echo "\n--- Etapes (meme ordre que compte.php) ---\n";
function diag_step($label, $callback) {
echo $label . ' ... ';
flush();
try {
$callback();
echo "OK\n";
return true;
} catch (Throwable $e) {
echo "ERREUR (exception)\n";
echo ' ' . get_class($e) . ': ' . $e->getMessage() . "\n";
echo ' fichier: ' . $e->getFile() . ':' . $e->getLine() . "\n";
return false;
}
}
$ok = true;
$ok = $ok && diag_step('1 inc_start_time', function () {
require_once __DIR__ . '/php/inc_start_time.php';
});
$ok = $ok && diag_step('2 inc_fonctions', function () {
require_once __DIR__ . '/php/inc_fonctions.php';
});
$ok = $ok && diag_step('3 inc_fx_messages', function () {
require_once __DIR__ . '/php/inc_fx_messages.php';
});
$ok = $ok && diag_step('4 inc_fx_compte', function () {
require_once __DIR__ . '/php/inc_fx_compte.php';
});
$ok = $ok && diag_step('5 inc_manager', function () {
require_once __DIR__ . '/superadm/php/inc_manager.php';
});
if ($ok) {
echo "\nToutes les etapes OK.\n";
} else {
echo "\nArret au premier echec ci-dessus.\n";
}
echo "\n=== Fin diagnostic — supprimer diag.php ===\n";