connect_error) { die("MySQL connection failed: " . $connection->connect_error); } // ==================== AJAX HANDLER ==================== if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'getdata') { $startUnix = (int)($_POST['start'] ?? 0); $endUnix = (int)($_POST['end'] ?? 0); if ($startUnix <= 0 || $endUnix <= 0 || $endUnix < $startUnix) { http_response_code(400); echo json_encode(['error' => 'Ungültige Zeit']); exit; } $hasBodenfeuchte = false; $colCheck = $connection->query("SHOW COLUMNS FROM `outside` LIKE 'bodenfeuchte'"); if ($colCheck && $colCheck->num_rows > 0) $hasBodenfeuchte = true; $selectCols = "temp,feucht,timestamp,bar,radio,co2,wind"; if ($hasBodenfeuchte) $selectCols .= ",bodenfeuchte"; $sql = "SELECT $selectCols FROM outside WHERE timestamp BETWEEN FROM_UNIXTIME(?) AND FROM_UNIXTIME(?) ORDER BY timestamp ASC LIMIT 150000"; $stmt = $connection->prepare($sql); $stmt->bind_param("ii", $startUnix, $endUnix); $stmt->execute(); $result = $stmt->get_result(); $temp = $feucht = $bar = $radio = $co2 = $wind = $boden = []; while ($row = $result->fetch_assoc()) { $t = strtotime($row["timestamp"]) * 1000; $temp[] = ["x" => $t, "y" => (float)$row["temp"]]; $feucht[] = ["x" => $t, "y" => (float)$row["feucht"]]; $bar[] = ["x" => $t, "y" => (float)$row["bar"]]; $radio[] = ["x" => $t, "y" => (float)$row["radio"]]; $co2[] = ["x" => $t, "y" => (float)$row["co2"]]; $wind[] = ["x" => $t, "y" => (float)$row["wind"]]; if ($hasBodenfeuchte) { $boden[] = ["x" => $t, "y" => (float)($row["bodenfeuchte"] ?? 0)]; } } $stmt->close(); header('Content-Type: application/json'); echo json_encode([ 'temp' => $temp, 'feucht' => $feucht, 'bar' => $bar, 'radio' => $radio, 'co2' => $co2, 'wind' => $wind, 'boden' => $boden ]); exit; } // ==================== INITIAL LOAD ==================== $initialLimit = 45000; $hasBodenfeuchte = false; $colCheck = $connection->query("SHOW COLUMNS FROM `outside` LIKE 'bodenfeuchte'"); if ($colCheck && $colCheck->num_rows > 0) $hasBodenfeuchte = true; $selectCols = "temp,feucht,timestamp,bar,radio,co2,wind"; if ($hasBodenfeuchte) $selectCols .= ",bodenfeuchte"; $sql = "SELECT $selectCols FROM outside ORDER BY id DESC LIMIT $initialLimit"; $temp = $feucht = $bar = $radio = $co2 = $wind = $boden = []; if ($result = $connection->query($sql)) { while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $t = strtotime($row["timestamp"]) * 1000; $temp[] = ["x" => $t, "y" => (float)$row["temp"]]; $feucht[] = ["x" => $t, "y" => (float)$row["feucht"]]; $bar[] = ["x" => $t, "y" => (float)$row["bar"]]; $radio[] = ["x" => $t, "y" => (float)$row["radio"]]; $co2[] = ["x" => $t, "y" => (float)$row["co2"]]; $wind[] = ["x" => $t, "y" => (float)$row["wind"]]; if ($hasBodenfeuchte) $boden[] = ["x" => $t, "y" => (float)($row["bodenfeuchte"] ?? 0)]; } } $connection->close(); ?>
Da die Webcam der Adlerschanze kein HTTPS unterstützt, blockiert der Browser die direkte Anzeige aus Sicherheitsgründen, da Neckcon auf absolute Sicherheit setzt.
Webcam in neuem Tab öffnen