<?php

$ID = '$Id: sunrise.php 452 2005-01-13 22:56:27Z bb $';

require '../app.inc.php';
require '../appmenu.inc.php';

$app = new Application('Sonnenaufgang und -untergang', $menu);
$app->header();

// Send the variables $lat, $lon, $tz, $year, $month and $mday.

import_request_variables('g');

require_once 'sunrise.inc.php';

$suncalc = new Astro_Sunrise();
if ($lat != '' && $lon != '')
  $suncalc->setCoords($lat, $lon);
if ($tz !== null)
  $suncalc->setTimezone($tz);
if ($year && $month && $mday)
  $suncalc->setDate($year, $month, $mday);
else
  $suncalc->setTimestamp(time());
?>

<h2><?php echo $suncalc->getDate() ?> bei <?php echo $suncalc->getCoords() ?>, <?php echo $suncalc->getTimezone() ?></h2>

<!-- pre><?php echo print_r($suncalc, true) ?></pre -->

<p>Sonnenaufgang um <?php echo $suncalc->getSunrise() ?>, <?php echo $suncalc->getLastSwatchBeat() ?></p>
<p>Sonnenuntergang um <?php echo $suncalc->getSunset() ?>, <?php echo $suncalc->getLastSwatchBeat() ?></p>

<h3>Neue Berechnung</h3>

<form class="multifield" action=""><p>

<label for="lat">Geographische Breite (-90..90)</label>
<input type="text" id="lat" name="lat" size="5" value="<?php echo $lat ?>" /><br />
<label for="lon">Geographische Länge (-180..180)</label>
<input type="text" id="lon" name="lon" size="5" value="<?php echo $lon ?>" /><br />

<label for="tz">Zeitzone (-12..12 Stunden)</label>
<input type="text" id="tz" name="tz" size="4" value="<?php echo $tz ?>" /><br />

<label for="year">Datum</label>
<input type="text" id="year" name="year" size="4" value="<?php echo $year ?>" title="Jahr" />
<input type="text" id="month" name="month" size="2" value="<?php echo $month ?>" title="Monat (1..12)" />
<input type="text" id="mday" name="mday" size="2" value="<?php echo $mday ?>" title="Tag (1..31)" />
<br />
<input type="submit" value="Berechnen!" />

</p></form>

<?php $app->footer() ?>