version_compare(PHP_VERSION, '7.4.0', '>='), 'value' => PHP_VERSION, 'msg' => 'PHP 7.4 ou supérieur recommandé.' ]; $reqs['allow_url_fopen'] = [ 'status' => ini_get('allow_url_fopen'), 'value' => ini_get('allow_url_fopen') ? 'Activé' : 'Désactivé', 'msg' => 'Requis pour communiquer avec l\'API distante.' ]; $reqs['Permissions Dossier'] = [ 'status' => is_writable(__DIR__), 'value' => is_writable(__DIR__) ? 'Écriture OK' : 'Lecture seule', 'msg' => 'Requis pour créer le fichier cache.json.' ]; return $reqs; } function test_tcp_connection($host, $port) { $start = microtime(true); $fp = @fsockopen($host, $port, $errno, $errstr, 2); $time = round((microtime(true) - $start) * 1000); if (!$fp) { return ['status' => false, 'msg' => "Connexion refusée ({$errstr})", 'time' => '-']; } else { fclose($fp); return ['status' => true, 'msg' => 'Port ouvert et accessible', 'time' => $time . ' ms']; } } function test_endpoint($url, $api_key, $endpoint_name) { $options = [ 'http' => [ 'header' => "x-api-key: {$api_key}\r\n", 'method' => 'GET', 'timeout' => 3, 'ignore_errors' => true ] ]; $context = stream_context_create($options); $start_time = microtime(true); $response = @file_get_contents($url, false, $context); $ping = round((microtime(true) - $start_time) * 1000); $http_code = "Inconnu"; if (isset($http_response_header) && is_array($http_response_header)) { if (preg_match('#HTTP/[0-9\.]+\s+([0-9]+)#', $http_response_header[0], $matches)) { $http_code = intval($matches[1]); } } $html = "
Impossible de récupérer les données HTTP.
" . htmlspecialchars($pretty_json) . "Veuillez créer votre fichier config.php avant de lancer le diagnostic.