From 48ffd7df2ffcb55e5d5531aab163b3cda1a50134 Mon Sep 17 00:00:00 2001 From: "manuel.maier" Date: Tue, 28 Jul 2026 00:15:00 +0200 Subject: [PATCH] =?UTF-8?q?v2/index.php=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2/index.php | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 v2/index.php diff --git a/v2/index.php b/v2/index.php new file mode 100644 index 0000000..2294798 --- /dev/null +++ b/v2/index.php @@ -0,0 +1,145 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +// Tabelle erstellen, falls nicht existent +$pdo->exec("CREATE TABLE IF NOT EXISTS nodes ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + server TEXT, + client TEXT, + status TEXT, + handshake TEXT, + last_seen DATETIME DEFAULT CURRENT_TIMESTAMP, + UNIQUE(server, client) +)"); + +// --- TEIL 1: API (Daten empfangen) --- +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $data = json_decode(file_get_contents('php://input'), true); + + if ($data && isset($data['server']) && isset($data['client'])) { + $stmt = $pdo->prepare(" + INSERT INTO nodes (server, client, status, handshake, last_seen) + VALUES (:server, :client, :status, :handshake, datetime('now')) + ON CONFLICT(server, client) + DO UPDATE SET status=:status, handshake=:handshake, last_seen=datetime('now') + "); + $stmt->execute([ + ':server' => $data['server'], + ':client' => $data['client'], + ':status' => $data['status'], + ':handshake' => $data['handshake'] + ]); + echo json_encode(["success" => true]); + } else { + http_response_code(400); + echo json_encode(["error" => "Invalid payload"]); + } + exit; +} + +// --- TEIL 2: API (Daten für Frontend ausliefern) --- +if (isset($_GET['api'])) { + header('Content-Type: application/json'); + $stmt = $pdo->query("SELECT * FROM nodes ORDER BY server, client"); + echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC)); + exit; +} + +// --- TEIL 3: HTML FRONTEND --- +?> + + + + + + Gateway Status Dashboard + + + +

🟢 Gateway Status Overview

+
+

Lade Status-Daten...

+
+ + + + \ No newline at end of file