From 7f0aaf81ec6d0a95a650d0d837d8bc31d1625018 Mon Sep 17 00:00:00 2001 From: Pingu Date: Fri, 17 Jul 2026 20:08:20 +0000 Subject: [PATCH] =?UTF-8?q?discord/Discord-notify.php=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- discord/Discord-notify.php | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 discord/Discord-notify.php diff --git a/discord/Discord-notify.php b/discord/Discord-notify.php new file mode 100644 index 0000000..1cc47b9 --- /dev/null +++ b/discord/Discord-notify.php @@ -0,0 +1,48 @@ + 'error', 'message' => 'KRITISCHER FEHLER: cURL ist nicht aktiviert!']); + exit; +} +$jsonInput = file_get_contents('php://input'); +$data = json_decode($jsonInput, true); +if ($data) { + $wantsRole = $data['discord_role'] ?? false; + if ($wantsRole) { + $botApiUrl = 'Discord-Bot API Url'; + $apiSecretToken = 'TOKEN'; + $ch = curl_init($botApiUrl); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonInput); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json', + 'Authorization: ' . $apiSecretToken + ]); + $response = curl_exec($ch); + $curl_error = curl_error($ch); + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + if ($curl_error) { + header('Content-Type: application/json'); + echo json_encode(['status' => 'error', 'message' => 'Verbindungsfehler zum Bot: ' . $curl_error]); + exit; + } + if ($http_code !== 200) { + header('Content-Type: application/json'); + echo json_encode(['status' => 'error', 'message' => 'Bot meldet HTTP-Code: ' . $http_code, 'bot_response' => $response]); + exit; + } + } + header('Content-Type: application/json'); + echo json_encode(['status' => 'success', 'message' => 'Verarbeitet.']); +} else { + http_response_code(400); + echo json_encode(['status' => 'error', 'message' => 'Keine gültigen JSON-Daten empfangen.']); +} +?> \ No newline at end of file