From f136d58b20b6aee4e03bde4f399638feb6125cf9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?=
Date: Fri, 10 Apr 2026 10:05:43 +0200
Subject: [PATCH] Deep Sky auf der Stertseite eingebaut
---
public/index.php | 70 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 1 deletion(-)
diff --git a/public/index.php b/public/index.php
index 806799b..7bd0dd9 100644
--- a/public/index.php
+++ b/public/index.php
@@ -17,6 +17,20 @@ if (!function_exists('fmtLocalTime')) {
if (!function_exists('azDir')) {
function azDir(float $az): string { $dirs = ['N','NO','O','SO','S','SW','W','NW']; return $dirs[(int)round($az / 45) % 8]; }
}
+if (!function_exists('formatDurationHoursMinutes')) {
+ function formatDurationHoursMinutes(int $minutes): string {
+ $minutes = max(0, $minutes);
+ $hours = intdiv($minutes, 60);
+ $restMinutes = $minutes % 60;
+ if ($hours > 0 && $restMinutes > 0) {
+ return sprintf('%d Stunden %d Minuten', $hours, $restMinutes);
+ }
+ if ($hours > 0) {
+ return sprintf('%d Stunden', $hours);
+ }
+ return sprintf('%d Minuten', $restMinutes);
+ }
+}
function idx_tleChecksum(string $line): int
{
@@ -94,6 +108,7 @@ function buildTleLine2(array $sat, array $tle): string
// Standort und astronomische Daten nur wenn eingeloggt und Standort vorhanden
$skyData = null;
+$skyDataNext = null;
$planetData = null;
$satData = null;
$pyError = null;
@@ -155,6 +170,26 @@ if ($loggedIn) {
$raw = json_decode($rawText, true);
if (is_array($raw) && ($raw['ok'] ?? false)) {
$skyData = $raw;
+ $nextDate = (new DateTimeImmutable($date, new DateTimeZone($tz)))->modify('+1 day')->format('Y-m-d');
+ $argsNext = [
+ $pythonBin,
+ escapeshellarg($scriptPath),
+ escapeshellarg('sun_moon_rise_set'),
+ escapeshellarg((string)$lat),
+ escapeshellarg((string)$lon),
+ escapeshellarg((string)$elev),
+ escapeshellarg($nextDate),
+ escapeshellarg($tz),
+ ];
+ $cmdNext = implode(' ', $argsNext) . ' 2>&1';
+ $outNext = [];
+ $resultCodeNext = 0;
+ exec($cmdNext, $outNext, $resultCodeNext);
+ $rawTextNext = trim(implode("\n", $outNext));
+ $rawNext = json_decode($rawTextNext, true);
+ if (is_array($rawNext) && ($rawNext['ok'] ?? false)) {
+ $skyDataNext = $rawNext;
+ }
} else {
$pyError = $raw['error'] ?? ($rawText !== '' ? $rawText : 'Fehler beim Berechnen der Aufgangszeiten.');
}
@@ -272,7 +307,19 @@ if ($loggedIn) {
— = h((new DateTimeImmutable('now', new DateTimeZone($tz)))->format('d.m.Y')) ?>
-
+ $deepSkyStart)
+ ? (int) floor(($deepSkyEnd->getTimestamp() - $deepSkyStart->getTimestamp()) / 60)
+ : null;
+ ?>
Heute
@@ -308,6 +355,27 @@ if ($loggedIn) {
+
+
Deep Sky
+
+
Keine vollstaendige astronomische Nacht im berechneten Zeitraum.
+
+
+ Beginn
+ = h($deepSkyStart->format('H:i')) ?>
+ = h($deepSkyStart->format('d.m.')) ?>
+
+ Ende
+ = h($deepSkyEnd->format('H:i')) ?>
+ = h($deepSkyEnd->format('d.m.')) ?>
+
+ Dauer
+ = h(formatDurationHoursMinutes($deepSkyDurationMinutes)) ?>
+ astronomische Nacht
+
+
+
+
☆ Satellit