diff --git a/public/auth_helpers.php b/public/auth_helpers.php index a537259..abdba8c 100644 --- a/public/auth_helpers.php +++ b/public/auth_helpers.php @@ -122,6 +122,7 @@ function manageablePublicPages(): array 'mars.php' => 'Mars', 'jupitersystem.php' => 'Jupitersystem', 'tagbogen.php' => 'Tagbogen', + 'daemmerungszeiten.php' => 'Dämmerungszeiten', 'sternenhimmel.php' => 'Sternenhimmel', 'drehbare_sternkarte.php' => 'Drehbare Sternkarte', 'meteorshowers.php' => 'Meteorströme', diff --git a/public/daemmerungszeiten.php b/public/daemmerungszeiten.php new file mode 100644 index 0000000..2ded712 --- /dev/null +++ b/public/daemmerungszeiten.php @@ -0,0 +1,1614 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + ]); + + $locationStmt = $pdo->prepare( + "SELECT id, name, latitude, longitude, elevation, timezone, is_default + FROM app_user_locations + WHERE user_id = ? + ORDER BY is_default DESC, name ASC, id ASC" + ); + $locationStmt->execute([(int) $_SESSION['user_id']]); + + while ($row = $locationStmt->fetch()) { + if ($row['latitude'] === null || $row['longitude'] === null) { + continue; + } + + $availableLocations[] = [ + 'id' => $row['id'] !== null ? (int) $row['id'] : null, + 'name' => trim((string) ($row['name'] ?? 'Standort')), + 'latitude' => (float) $row['latitude'], + 'longitude' => (float) $row['longitude'], + 'elevation' => $row['elevation'] !== null ? (float) $row['elevation'] : 0.0, + 'timezone' => trim((string) ($row['timezone'] ?? 'Europe/Berlin')), + 'is_default' => !empty($row['is_default']), + ]; + } + } catch (Throwable $e) { + $availableLocations = []; + $pdo = null; + } +} + +require __DIR__ . '/header.php'; + +$initialLocation = [ + 'id' => isset($currentLocation['id']) ? (int) $currentLocation['id'] : null, + 'name' => $currentLocation['name'] ?? 'Sternwarte Sonneberg', + 'latitude' => isset($currentLocation['latitude']) ? (float) $currentLocation['latitude'] : 50.3597, + 'longitude' => isset($currentLocation['longitude']) ? (float) $currentLocation['longitude'] : 11.1907, + 'timezone' => $currentLocation['timezone'] ?? 'Europe/Berlin', +]; + +if (!$availableLocations) { + $availableLocations[] = [ + 'id' => $initialLocation['id'], + 'name' => $initialLocation['name'], + 'latitude' => $initialLocation['latitude'], + 'longitude' => $initialLocation['longitude'], + 'elevation' => isset($currentLocation['elevation']) && $currentLocation['elevation'] !== null ? (float) $currentLocation['elevation'] : 0.0, + 'timezone' => $initialLocation['timezone'], + 'is_default' => true, + ]; +} +?> + + + + + +
+ Die Grafik zeigt jeden Tag des gewählten Jahres als senkrechte Spur. Von oben nach unten läuft die lokale Uhrzeit des Standorts, farblich getrennt nach Nacht, astronomischer, nautischer und bürgerlicher Dämmerung sowie Tag. +
+