Ephemeriden verbessert
This commit is contained in:
+33
-47
@@ -334,15 +334,6 @@ $intervalOptions = [
|
|||||||
'43200' => '30 Tage',
|
'43200' => '30 Tage',
|
||||||
];
|
];
|
||||||
|
|
||||||
$rangeUnitOptions = [
|
|
||||||
'minutes' => 'Minuten',
|
|
||||||
'hours' => 'Stunden',
|
|
||||||
'days' => 'Tage',
|
|
||||||
'weeks' => 'Wochen',
|
|
||||||
'months' => 'Monate',
|
|
||||||
'years' => 'Jahre',
|
|
||||||
];
|
|
||||||
|
|
||||||
$selectedBody = (string) ($_POST['body'] ?? 'Mercury');
|
$selectedBody = (string) ($_POST['body'] ?? 'Mercury');
|
||||||
if (!isset($bodyOptions[$selectedBody])) {
|
if (!isset($bodyOptions[$selectedBody])) {
|
||||||
$selectedBody = 'Mercury';
|
$selectedBody = 'Mercury';
|
||||||
@@ -353,22 +344,16 @@ if (!isset($intervalOptions[$selectedInterval])) {
|
|||||||
$selectedInterval = '1440';
|
$selectedInterval = '1440';
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectedRangeUnit = (string) ($_POST['range_unit'] ?? 'days');
|
|
||||||
if (!isset($rangeUnitOptions[$selectedRangeUnit])) {
|
|
||||||
$selectedRangeUnit = 'days';
|
|
||||||
}
|
|
||||||
|
|
||||||
$rangeValueInput = trim((string) ($_POST['range_value'] ?? '7'));
|
|
||||||
if ($rangeValueInput === '') {
|
|
||||||
$rangeValueInput = '7';
|
|
||||||
}
|
|
||||||
|
|
||||||
$startDtInput = trim((string) ($_POST['start_dt'] ?? ''));
|
$startDtInput = trim((string) ($_POST['start_dt'] ?? ''));
|
||||||
// Validierung: muss leer sein (= jetzt) oder dem Format YYYY-MM-DDTHH:MM entsprechen
|
|
||||||
if ($startDtInput !== '' && !preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/', $startDtInput)) {
|
if ($startDtInput !== '' && !preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/', $startDtInput)) {
|
||||||
$startDtInput = '';
|
$startDtInput = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$endDtInput = trim((string) ($_POST['end_dt'] ?? ''));
|
||||||
|
if ($endDtInput !== '' && !preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/', $endDtInput)) {
|
||||||
|
$endDtInput = '';
|
||||||
|
}
|
||||||
|
|
||||||
function ephemeriden_h(mixed $value): string
|
function ephemeriden_h(mixed $value): string
|
||||||
{
|
{
|
||||||
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
||||||
@@ -449,9 +434,21 @@ $exportFormat = (string) ($_POST['export_format'] ?? '');
|
|||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
if ($pageLocation === null || $pageLocation['latitude'] === null || $pageLocation['longitude'] === null) {
|
if ($pageLocation === null || $pageLocation['latitude'] === null || $pageLocation['longitude'] === null) {
|
||||||
$errorMessage = 'Kein gültiger Standard-Standort verfügbar. Bitte zuerst in den Einstellungen einen Standard-Standort setzen.';
|
$errorMessage = 'Kein gültiger Standard-Standort verfügbar. Bitte zuerst in den Einstellungen einen Standard-Standort setzen.';
|
||||||
} elseif (!ctype_digit($rangeValueInput) || (int) $rangeValueInput < 1 || (int) $rangeValueInput > 100) {
|
} elseif ($endDtInput === '') {
|
||||||
$errorMessage = 'Der Zeitraum muss als ganze Zahl zwischen 1 und 100 angegeben werden.';
|
$errorMessage = 'Bitte ein Enddatum angeben.';
|
||||||
} else {
|
} else {
|
||||||
|
$tz = new DateTimeZone($pageLocation['timezone']);
|
||||||
|
$startDt = $startDtInput !== ''
|
||||||
|
? DateTimeImmutable::createFromFormat('Y-m-d\TH:i', $startDtInput, $tz)
|
||||||
|
: new DateTimeImmutable('now', $tz);
|
||||||
|
$endDt = DateTimeImmutable::createFromFormat('Y-m-d\TH:i', $endDtInput, $tz);
|
||||||
|
|
||||||
|
if ($startDt === false || $endDt === false) {
|
||||||
|
$errorMessage = 'Start- oder Enddatum ist ungültig.';
|
||||||
|
} elseif ($endDt <= $startDt) {
|
||||||
|
$errorMessage = 'Das Enddatum muss nach dem Startdatum liegen.';
|
||||||
|
} else {
|
||||||
|
$rangeMinutes = (string) (int) round(($endDt->getTimestamp() - $startDt->getTimestamp()) / 60);
|
||||||
$pythonAction = 'planet_ephemeris';
|
$pythonAction = 'planet_ephemeris';
|
||||||
$pythonArgs = [
|
$pythonArgs = [
|
||||||
(string) $pageLocation['latitude'],
|
(string) $pageLocation['latitude'],
|
||||||
@@ -460,8 +457,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
(string) $pageLocation['timezone'],
|
(string) $pageLocation['timezone'],
|
||||||
$selectedBody,
|
$selectedBody,
|
||||||
$selectedInterval,
|
$selectedInterval,
|
||||||
$rangeValueInput,
|
$rangeMinutes,
|
||||||
$selectedRangeUnit,
|
'minutes',
|
||||||
$startDtInput,
|
$startDtInput,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -475,8 +472,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
'minorplanet',
|
'minorplanet',
|
||||||
base64_encode(json_encode($minorplanetPayloads[$selectedBody], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: '{}'),
|
base64_encode(json_encode($minorplanetPayloads[$selectedBody], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: '{}'),
|
||||||
$selectedInterval,
|
$selectedInterval,
|
||||||
$rangeValueInput,
|
$rangeMinutes,
|
||||||
$selectedRangeUnit,
|
'minutes',
|
||||||
$startDtInput,
|
$startDtInput,
|
||||||
];
|
];
|
||||||
} elseif (isset($cometPayloads[$selectedBody])) {
|
} elseif (isset($cometPayloads[$selectedBody])) {
|
||||||
@@ -489,8 +486,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
'comet',
|
'comet',
|
||||||
base64_encode(json_encode($cometPayloads[$selectedBody], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: '{}'),
|
base64_encode(json_encode($cometPayloads[$selectedBody], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: '{}'),
|
||||||
$selectedInterval,
|
$selectedInterval,
|
||||||
$rangeValueInput,
|
$rangeMinutes,
|
||||||
$selectedRangeUnit,
|
'minutes',
|
||||||
$startDtInput,
|
$startDtInput,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -545,6 +542,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ephemerisRows !== []) {
|
if ($ephemerisRows !== []) {
|
||||||
@@ -781,33 +779,21 @@ require __DIR__ . '/header.php';
|
|||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
id="ephemeridenStartDt"
|
id="ephemeridenStartDt"
|
||||||
name="start_dt"
|
name="start_dt"
|
||||||
value="<?= ephemeriden_h($startDtInput) ?>"
|
value="<?= ephemeriden_h($startDtInput !== '' ? $startDtInput : (new DateTimeImmutable('now', new DateTimeZone($pageLocation['timezone'] ?? 'Europe/Berlin')))->format('Y-m-d\TH:i')) ?>"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="ephemeridenRangeValue">Zeitraum</label>
|
<label for="ephemeridenEndDt">Enddatum & Uhrzeit</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="datetime-local"
|
||||||
id="ephemeridenRangeValue"
|
id="ephemeridenEndDt"
|
||||||
name="range_value"
|
name="end_dt"
|
||||||
min="1"
|
value="<?= ephemeriden_h($endDtInput !== '' ? $endDtInput : (new DateTimeImmutable('+7 days', new DateTimeZone($pageLocation['timezone'] ?? 'Europe/Berlin')))->format('Y-m-d\TH:i')) ?>"
|
||||||
max="100"
|
required
|
||||||
step="1"
|
|
||||||
value="<?= ephemeriden_h($rangeValueInput) ?>"
|
|
||||||
inputmode="numeric"
|
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ephemeridenRangeUnit">Einheit</label>
|
|
||||||
<select id="ephemeridenRangeUnit" name="range_unit">
|
|
||||||
<?php foreach ($rangeUnitOptions as $rangeUnitValue => $rangeUnitLabel): ?>
|
|
||||||
<option value="<?= ephemeriden_h($rangeUnitValue) ?>"<?= $rangeUnitValue === $selectedRangeUnit ? ' selected' : '' ?>><?= ephemeriden_h($rangeUnitLabel) ?></option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ephemeriden-submit-group">
|
<div class="ephemeriden-submit-group">
|
||||||
<button type="submit" class="btn btn-primary">Berechnen</button>
|
<button type="submit" class="btn btn-primary">Berechnen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user