null, 'refAngle' => 0, 'calibratedAt' => null, 'calibratedBy' => null]); exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!$isAdmin) { http_response_code(403); echo json_encode(['error' => 'Nicht autorisiert']); exit; } $body = json_decode(file_get_contents('php://input'), true); if (!$body || !isset($body['refDate'], $body['refAngle'])) { http_response_code(400); echo json_encode(['error' => 'Ungültige Daten']); exit; } $existing = []; if (file_exists($dataFile)) { $existing = json_decode(file_get_contents($dataFile), true) ?? []; } $history = $existing['history'] ?? []; $history[] = [ 'refDate' => (string) $body['refDate'], 'refAngle' => (float) $body['refAngle'], 'calibratedAt' => date('c'), 'calibratedBy' => $_SESSION['username'] ?? 'admin', ]; usort($history, fn($a, $b) => strcmp((string) $a['refDate'], (string) $b['refDate'])); $latest = end($history); $data = [ 'refDate' => $latest['refDate'], 'refAngle' => $latest['refAngle'], 'calibratedAt' => $latest['calibratedAt'], 'calibratedBy' => $latest['calibratedBy'], 'history' => $history, ]; $written = file_put_contents($dataFile, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); echo $written !== false ? json_encode(['ok' => true]) : json_encode(['error' => 'Schreibfehler – Dateiberechtigung prüfen']); exit; } http_response_code(405); echo json_encode(['error' => 'Methode nicht erlaubt']); exit; } $pageTitle = 'Jupitersystem - AstroTools'; $bodyClass = 'solarsystem-page jupitersystem-page'; ?>
Initialisiere Visualisierung...