From ec9e44d96ada35c3a0a83d304a799d6fc738c1f1 Mon Sep 17 00:00:00 2001 From: Guraz Date: Thu, 14 May 2026 17:43:41 +0200 Subject: Add files via upload --- debug.php | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 debug.php diff --git a/debug.php b/debug.php new file mode 100644 index 0000000..5f8e39c --- /dev/null +++ b/debug.php @@ -0,0 +1,231 @@ + 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 = "
"; + $html .= "

➔ /{$endpoint_name}

"; + + if ($response === false) { + $html .= "Échec HTTP (Timeout)
"; + $html .= "

Impossible de récupérer les données HTTP.

"; + } else { + $data = json_decode($response, true); + $ts_code = isset($data['status']['code']) ? $data['status']['code'] : 'N/A'; + + if ($http_code == 200 && $ts_code === 0) { + $html .= "HTTP 200 TS Code: 0 (OK)"; + } elseif ($ts_code === 5120) { + $html .= "HTTP {$http_code} TS Code: 5120 (Out of Scope)"; + } elseif ($http_code == 401 || $ts_code === 2568) { + $html .= "HTTP {$http_code} TS Code: {$ts_code} (Clé Invalide)"; + } else { + $html .= "HTTP {$http_code} TS Code: {$ts_code}"; + } + $html .= "{$ping} ms
"; + + if ($ts_code === 5120 && $endpoint_name == 'serverinfo') { + $html .= "
ℹ️ Note : Erreur 5120 normale si votre clé API est configurée en lecture seule (scope=read).
"; + } + + $pretty_json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); + $html .= "
" . htmlspecialchars($pretty_json) . "
"; + } + $html .= ""; + return $html; +} +?> + + + + + + Diagnostic API TS6 + + + + +
+
+ ⚠️ DANGER : NE LAISSEZ JAMAIS CE FICHIER SUR VOTRE SERVEUR WEB PUBLIC.
+ Supprimez 'debug.php' de votre hébergement après utilisation. +
+ + +
+

❌ Fichier config.php introuvable

+

Veuillez créer votre fichier config.php avant de lancer le diagnostic.

+
+ + +

🔍 Diagnostic de l'Environnement

+ +
+
+

⚙️ Configuration Détectée

+
Hôte API
+
Port API
+
ID Serveur
+
Clé API
+
+ +
+

💻 Serveur Web (PHP)

+ $req): ?> +
+ + + + +
+ +
+ +
+

📡 Réseau & Cache

+ +
+ Ping TCP () + + + +
+
+ Fichier Cache + + + +
+ +
+ Âge du Cache + +
+
+ Taille du Cache + +
+ +
+
+ +

🔌 Tests de l'API TeamSpeak

+ + + + +
+ + + \ No newline at end of file -- cgit v1.2.3