Kleinigkeiten und Monatsvoschrau angefangen

This commit is contained in:
2026-04-03 11:31:01 +02:00
parent f4bc622c47
commit dfd65b16e3
16 changed files with 5922 additions and 23 deletions
+34 -17
View File
@@ -97,6 +97,7 @@ $skyData = null;
$planetData = null;
$satData = null;
$pyError = null;
$satError = null;
if ($loggedIn) {
// header.php lädt $currentLocation – wir brauchen ihn vorab
@@ -120,15 +121,17 @@ if ($loggedIn) {
$lon = (float)$defaultLocation['longitude'];
$elev = (float)($defaultLocation['elevation'] ?? 0);
$tz = $defaultLocation['timezone'] ?? 'Europe/Berlin';
$date = date('Y-m-d');
$date = (new DateTimeImmutable('now', new DateTimeZone($tz)))->format('Y-m-d');
$scriptPath = realpath(__DIR__ . '/py/api.py');
if (file_exists('/usr/bin/python3')) {
if (PHP_OS_FAMILY === 'Windows') {
$pythonBin = 'python';
} elseif (file_exists('/usr/bin/python3')) {
$pythonBin = '/usr/bin/python3';
} elseif (file_exists('/usr/bin/python')) {
$pythonBin = '/usr/bin/python';
} else {
$pythonBin = 'C:\\Users\\HP\\AppData\\Local\\Python\\bin\\python.exe';
$pythonBin = 'python';
}
putenv('PYTHONUTF8=1');
putenv('PYTHONIOENCODING=utf-8');
@@ -146,12 +149,14 @@ if ($loggedIn) {
];
$cmd = implode(' ', $args) . ' 2>&1';
$out = [];
exec($cmd, $out);
$raw = json_decode(implode('', $out), true);
$resultCode = 0;
exec($cmd, $out, $resultCode);
$rawText = trim(implode("\n", $out));
$raw = json_decode($rawText, true);
if (is_array($raw) && ($raw['ok'] ?? false)) {
$skyData = $raw;
} else {
$pyError = $raw['error'] ?? 'Fehler beim Berechnen der Aufgangszeiten.';
$pyError = $raw['error'] ?? ($rawText !== '' ? $rawText : 'Fehler beim Berechnen der Aufgangszeiten.');
}
// Planeten
@@ -167,12 +172,14 @@ if ($loggedIn) {
];
$cmd2 = implode(' ', $args2) . ' 2>&1';
$out2 = [];
exec($cmd2, $out2);
$raw2 = json_decode(implode('', $out2), true);
$resultCode2 = 0;
exec($cmd2, $out2, $resultCode2);
$rawText2 = trim(implode("\n", $out2));
$raw2 = json_decode($rawText2, true);
if (is_array($raw2) && ($raw2['ok'] ?? false)) {
$planetData = $raw2;
} elseif ($pyError === null) {
$pyError = $raw2['error'] ?? 'Fehler beim Berechnen der Planetenzeiten.';
$pyError = $raw2['error'] ?? ($rawText2 !== '' ? $rawText2 : 'Fehler beim Berechnen der Planetenzeiten.');
}
// Satelliten-Überflüge heute — Favorit zuerst, dann alle gemerkten
@@ -209,6 +216,7 @@ if ($loggedIn) {
'tle_line2' => buildTleLine2($r, $r),
'is_favorite' => (bool)$r['is_favorite'],
], $userSats), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$satsPayload = base64_encode((string) $satsJson);
$args3 = [
$pythonBin,
@@ -220,14 +228,18 @@ if ($loggedIn) {
escapeshellarg($tz),
escapeshellarg($dayStart->format('Y-m-d\TH:i:s\Z')),
escapeshellarg($dayEnd->format('Y-m-d\TH:i:s\Z')),
escapeshellarg($satsJson),
escapeshellarg($satsPayload),
];
$cmd3 = implode(' ', $args3) . ' 2>&1';
$out3 = [];
exec($cmd3, $out3);
$raw3 = json_decode(implode('', $out3), true);
$resultCode3 = 0;
exec($cmd3, $out3, $resultCode3);
$rawText3 = trim(implode("\n", $out3));
$raw3 = json_decode($rawText3, true);
if (is_array($raw3) && ($raw3['ok'] ?? false)) {
$satData = $raw3;
} else {
$satError = $raw3['error'] ?? ($rawText3 !== '' ? $rawText3 : 'Fehler beim Berechnen der Satellitenüberflüge.');
}
}
}
@@ -250,14 +262,14 @@ if ($loggedIn) {
<?php if (!$defaultLocation): ?>
<p class="hint">Noch kein Standort hinterlegt. <a href="settings.php">Jetzt anlegen</a></p>
<?php elseif ($pyError): ?>
<ul class="msg-error"><li><?= h($pyError) ?></li></ul>
<?php else: ?>
<?php elseif ($pyError): ?>
<ul class="msg-error"><li><?= h($pyError) ?></li></ul>
<?php else: ?>
<p class="hint rise-set-location">
Aufgangs- und Untergangszeiten für
<strong><?= h($defaultLocation['name']) ?></strong>
&mdash; <?= h(date('d.m.Y')) ?>
&mdash; <?= h((new DateTimeImmutable('now', new DateTimeZone($tz)))->format('d.m.Y')) ?>
</p>
<?php $ev = $skyData['events'] ?? []; ?>
@@ -296,7 +308,12 @@ if ($loggedIn) {
</div>
</div>
<?php if ($satData): ?>
<?php if ($satError): ?>
<div class="card riseset-card">
<h2>☆ Satellit</h2>
<p class="hint"><?= h($satError) ?></p>
</div>
<?php elseif ($satData): ?>
<?php
$favName = '';
$favPasses = [];