public function showObservation($LOid)
 {
     global $objUtil, $dateformat, $myList, $listname, $listname_ss, $baseURL, $objAstroCalc, $objEyepiece, $objObserver, $objInstrument, $loggedUser, $objObject, $objLens, $objFilter, $objPresentations, $objDatabase, $objLocation, $instDir;
     $link = $baseURL . "index.php?";
     $linkamp = "";
     reset($_GET);
     while (list($key, $value) = each($_GET)) {
         $linkamp .= $key . "=" . urlencode($value) . "&";
     }
     $inst = $objInstrument->getInstrumentPropertyFromId($this->getDsObservationProperty($LOid, 'instrumentid'), 'name');
     if ($inst == "Naked eye") {
         $inst = InstrumentsNakedEye;
     }
     $dateTimeText = "";
     // $date=sscanf($this->getDsObservationProperty($LOid,'date'),"%4d%2d%2d");
     if ($loggedUser && !$objObserver->getObserverProperty($loggedUser, 'UT')) {
         $date = sscanf($this->getDsObservationLocalDate($LOid), "%4d%2d%2d");
     } else {
         $date = sscanf($this->getDsObservationProperty($LOid, 'date'), "%4d%2d%2d");
     }
     $time = "";
     $dateTimeLabelText = "";
     $dateTimeText = date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0]));
     if ($this->getDsObservationProperty($LOid, 'time') >= 0) {
         if ($loggedUser && !$objObserver->getObserverProperty($loggedUser, 'UT')) {
             $date = sscanf($this->getDsObservationLocalDate($LOid), "%4d%2d%2d");
             $dateTimeLabelText = " " . LangViewObservationField9lt;
             $time = $this->getDsObservationLocalTime($LOid);
         } else {
             $dateTimeLabelText = " " . LangViewObservationField9;
             $time = $this->getDsObservationProperty($LOid, 'time');
         }
     }
     if ($time) {
         $time = sscanf(sprintf("%04d", $time), "%2d%2d");
         $dateTimeText .= " " . $time[0] . ":" . sprintf("%02d", $time[1]);
     }
     if ($this->getDsObservationProperty($LOid, 'time') >= 0) {
         if ($time == 0) {
             $time = sscanf(sprintf("%04d", $time), "%2d%2d");
             $dateTimeText .= " 00:00";
         }
     }
     $seeing = $this->getDsObservationProperty($LOid, 'seeing');
     if ($seeing < 0 || $seeing > 5) {
         $seeing = 0;
     }
     $diameterText = '';
     if ($largeDiameter = $this->getDsObservationProperty($LOid, 'largeDiameter')) {
         if ($largeDiameter > 60) {
             $diameterText = sprintf("%.1f ", $largeDiameter / 60.0) . (($smallDiameter = $this->getDsObservationProperty($LOid, 'smalldiameter')) ? sprintf("x %.1f ", $smallDiameter / 60.0) : '') . LangNewObjectSizeUnits1;
         } else {
             $diameterText = sprintf("%.1f ", $largeDiameter) . (($smallDiameter = $this->getDsObservationProperty($LOid, 'smalldiameter')) ? sprintf("x %.1f ", $smallDiameter) : '') . LangNewObjectSizeUnits2;
         }
     } else {
         $diameterText = "-";
     }
     $details1Text = "";
     if ($this->getDsObservationProperty($LOid, 'stellar') > 0) {
         $details1Text .= ", " . LangViewObservationField35;
     }
     if ($this->getDsObservationProperty($LOid, 'extended') > 0) {
         $details1Text .= ", " . LangViewObservationField36;
     }
     if ($this->getDsObservationProperty($LOid, 'resolved') > 0) {
         $details1Text .= ", " . LangViewObservationField37;
     }
     if ($this->getDsObservationProperty($LOid, 'mottled') > 0) {
         $details1Text .= ", " . LangViewObservationField38;
     }
     if ($this->getDsObservationProperty($LOid, 'component1') == 1) {
         $details1Text .= ", " . LangDetailDSColor1;
     }
     if ($this->getDsObservationProperty($LOid, 'component1') == 2) {
         $details1Text .= ", " . LangDetailDSColor2;
     }
     if ($this->getDsObservationProperty($LOid, 'component1') == 3) {
         $details1Text .= ", " . LangDetailDSColor3;
     }
     if ($this->getDsObservationProperty($LOid, 'component1') == 4) {
         $details1Text .= ", " . LangDetailDSColor4;
     }
     if ($this->getDsObservationProperty($LOid, 'component1') == 5) {
         $details1Text .= ", " . LangDetailDSColor5;
     }
     if ($this->getDsObservationProperty($LOid, 'component1') == 6) {
         $details1Text .= ", " . LangDetailDSColor6;
     }
     if ($this->getDsObservationProperty($LOid, 'component2') == 1) {
         $details1Text .= "-" . LangDetailDSColor1;
     }
     if ($this->getDsObservationProperty($LOid, 'component2') == 2) {
         $details1Text .= "-" . LangDetailDSColor2;
     }
     if ($this->getDsObservationProperty($LOid, 'component2') == 3) {
         $details1Text .= "-" . LangDetailDSColor3;
     }
     if ($this->getDsObservationProperty($LOid, 'component2') == 4) {
         $details1Text .= "-" . LangDetailDSColor4;
     }
     if ($this->getDsObservationProperty($LOid, 'component2') == 5) {
         $details1Text .= "-" . LangDetailDSColor5;
     }
     if ($this->getDsObservationProperty($LOid, 'component2') == 6) {
         $details1Text .= "-" . LangDetailDSColor6;
     }
     $details1Text = substr($details1Text, 2);
     $details2Text = "";
     if ($this->getDsObservationProperty($LOid, 'unusualShape') > 0) {
         $details2Text .= ", " . LangViewObservationField41;
     }
     if ($this->getDsObservationProperty($LOid, 'partlyUnresolved') > 0) {
         $details2Text .= ", " . LangViewObservationField42;
     }
     if ($this->getDsObservationProperty($LOid, 'colorContrasts') > 0) {
         $details2Text .= ", " . LangViewObservationField43;
     }
     if ($this->getDsObservationProperty($LOid, 'equalBrightness') > 0) {
         $details2Text .= ", " . LangDetailDS1;
     }
     if ($this->getDsObservationProperty($LOid, 'niceField') > 0) {
         $details2Text .= ", " . LangDetailDS2;
     }
     $details2Text = substr($details2Text, 2);
     $charTypeText = "-";
     $object = $this->getDsObservationProperty($LOid, 'objectname');
     $object_ss = stripslashes($object);
     if (in_array($objObject->getDsoProperty($object, 'type'), array("ASTER", "CLANB", "DS", "OPNCL", "AA1STAR", "AA2STAR", "AA3STAR", "AA4STAR", "AA8STAR", "GLOCL"))) {
         $charTypeText = ($clusterType = $this->getDsObservationProperty($LOid, 'clusterType')) ? $clusterType . ': ' . $GLOBALS['ClusterType' . $clusterType] : "-";
     }
     echo "<table class=\"table\">";
     echo "<tr>";
     echo "<td>" . LangViewObservationField2 . "</td>";
     $observer = $this->getDsObservationProperty($LOid, 'observerid');
     echo "<td><a href=\"" . $baseURL . "index.php?indexAction=detail_observer&amp;user="******"&amp;back=index.php?indexAction=detail_observation\">" . $objObserver->getObserverProperty($this->getDsObservationProperty($LOid, 'observerid'), 'firstname') . "&nbsp;" . $objObserver->getObserverProperty($this->getDsObservationProperty($LOid, 'observerid'), 'name') . "</a>";
     // Show the picture of the sender
     $dir = opendir($instDir . 'common/observer_pics');
     while (FALSE !== ($file = readdir($dir))) {
         if ("." == $file or ".." == $file) {
             continue;
         }
         // skip current directory and directory above
         if (fnmatch($observer . ".gif", $file) || fnmatch($observer . ".jpg", $file) || fnmatch($observer . ".png", $file)) {
             echo "<img height=\"72\" src=\"" . $baseURL . "/common/observer_pics/" . $file . "\" class=\"img-rounded pull-right\">";
         }
     }
     echo "</td>";
     echo "<td>" . LangViewObservationField3 . "</td>";
     echo "<td><a href=\"" . $baseURL . "index.php?indexAction=detail_instrument&amp;instrument=" . urlencode($this->getDsObservationProperty($LOid, 'instrumentid')) . "\">" . $inst . "</a>";
     // Show the moon during the observation
     $year = $date[0];
     $month = $date[1];
     $day = $date[2];
     $date = $date[0] . "-" . $date[1] . "-" . $date[2];
     $realTime = $this->getDsObservationProperty($LOid, 'time');
     if ($realTime < 0) {
         $time = "23:59:59";
     } else {
         $time = $realTime;
     }
     $tzone = "GMT";
     $moondata = phase(strtotime($date . ' 23:59:59 ' . $tzone));
     $MoonIllum = $moondata[1];
     $MoonAge = $moondata[2];
     // Convert $MoonIllum to percent and round to whole percent.
     $MoonIllum = round($MoonIllum, 2);
     $MoonIllum *= 100;
     $file = "m" . round($MoonAge / SYNMONTH * 40) . ".gif";
     // Moon is above the horizon
     if ($realTime < 0) {
         $moon = "<img src=\"" . $baseURL . "/lib/moonpics/" . $file . "\" class=\"moonpic\" title=\"" . $MoonIllum . "%\" alt=\"" . $MoonIllum . "%\" />";
     } else {
         // Get location
         $longitude = $objLocation->getLocationPropertyFromId($this->getDsObservationProperty($LOid, 'locationid'), 'longitude');
         $latitude = $objLocation->getLocationPropertyFromId($this->getDsObservationProperty($LOid, 'locationid'), 'latitude');
         // Calculate altitude of the moon for this date, time and location
         // Get the julian day of the observation...
         $jd = gregoriantojd($month, $day, $year);
         $timezone = $objLocation->getLocationPropertyFromId($this->getDsObservationProperty($LOid, 'locationid'), 'timezone');
         $dateTimeZone = new DateTimeZone($timezone);
         $datestr = sprintf("%02d", $month) . "/" . sprintf("%02d", $day) . "/" . $year;
         $dateTime = new DateTime($datestr, $dateTimeZone);
         // Geeft tijdsverschil terug in seconden
         $timedifference = $dateTimeZone->getOffset($dateTime);
         $timedifference = $timedifference / 3600.0;
         if (strncmp($timezone, "Etc/GMT", 7) == 0) {
             $timedifference = -$timedifference;
         }
         // Calculate the rise and set time of the moon
         $moonCalc = $objAstroCalc->calculateMoonRiseTransitSettingTime($jd, $longitude, $latitude, $timedifference);
         // Now we know when the moon rises and sets. We have to convert the time and compare with the time of the observation.
         // $moonCalc[0] = rise
         // $moonCalc[2] = set
         $moonriseArray = sscanf($moonCalc[0], "%d:%d");
         $moonsetArray = sscanf($moonCalc[2], "%d:%d");
         $moonRise = $moonriseArray[0] * 100.0 + $moonriseArray[1];
         $moonSet = $moonsetArray[0] * 100.0 + $moonsetArray[1];
         $moonAboveHorizon = true;
         if ($moonRise > $moonSet) {
             if ($time <= $moonRise && $time >= $moonSet) {
                 $moonAboveHorizon = false;
             }
         } else {
             if ($time <= $moonRise || $time >= $moonSet) {
                 $moonAboveHorizon = false;
             }
         }
         if ($moonAboveHorizon) {
             // Moon is above the horizon
             $moon = "<img src=\"" . $baseURL . "/lib/moonpics/" . $file . "\" class=\"moonpic\" title=\"" . $MoonIllum . "%\" alt=\"" . $MoonIllum . "%\" />";
         } else {
             // Moon is under the horizon
             $moon = "<img src=\"" . $baseURL . "/lib/moonpics/below.png\" class=\"moonpic\" title=\"" . $MoonIllum . "% - " . LangUnderHorizon . "\" alt=\"" . $MoonIllum . "%\" />";
         }
     }
     echo "<td></td><td>" . $moon . "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>" . LangViewObservationField5 . $dateTimeLabelText . "</td>";
     echo "<td>" . $dateTimeText . "</td>";
     echo "<td>" . LangViewObservationField4 . "</td>";
     echo "<td>" . "<a href=\"" . $baseURL . "index.php?indexAction=detail_location&amp;location=" . urlencode($this->getDsObservationProperty($LOid, 'locationid')) . "\">" . $objLocation->getLocationPropertyFromId($this->getDsObservationProperty($LOid, 'locationid'), 'name') . "</a></td>";
     echo "<td></td>";
     echo "<td></td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>" . LangViewObservationField7 . "/" . LangViewObservationField34 . "</td>";
     echo "<td>" . (($limmag = $this->getDsObservationProperty($LOid, 'limmag')) ? sprintf("%1.1f", $limmag) : "-") . "/" . (($sqm = $this->getDsObservationProperty($LOid, 'SQM')) != -1 ? sprintf("%2.1f", $sqm) : '-') . "</td>";
     echo "<td>" . LangViewObservationField6 . "</td>";
     echo "<td>" . ($seeing ? $GLOBALS['Seeing' . $seeing] : "-") . "</td>";
     echo "<td></td>";
     echo "<td></td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>" . LangViewObservationField30 . "</td>";
     echo "<td>" . (($eyepiece = $this->getDsObservationProperty($LOid, 'eyepieceid')) == "" || $eyepiece == 0 ? "-" : "<a  href=\"" . $baseURL . "index.php?indexAction=detail_eyepiece&amp;eyepiece=" . urlencode($eyepiece) . "\">" . stripslashes($objEyepiece->getEyepiecePropertyFromId($eyepiece, 'name')) . "</a>") . (($mag = $this->getDsObservationProperty($LOid, 'magnification')) == "" ? "" : " (" . $mag . "x)") . "</td>";
     echo "<td>" . LangViewObservationField31 . "</td>";
     echo "<td>" . (($filter = $this->getDsObservationProperty($LOid, 'filterid')) == "" || $filter == 0 ? "-" : "<a  href=\"" . $baseURL . "index.php?indexAction=detail_filter&amp;filter=" . urlencode($filter) . "\">" . $objFilter->getFilterPropertyFromId($filter, 'name') . "</a>") . "</td>";
     echo "<td>" . LangViewObservationField32 . "</td>";
     echo "<td>" . (($lens = $this->getDsObservationProperty($LOid, 'lensid')) == "" || $lens == 0 ? "-" : "<a  href=\"" . $baseURL . "index.php?indexAction=detail_lens&amp;lens=" . urlencode($lens) . "\">" . $objLens->getLensPropertyFromId($lens, 'name') . "</a>") . "</td>";
     echo "</tr>";
     if (in_array($objObject->getDsoProperty($object, 'type'), array("DS", "AA2STAR"))) {
         echo "<tr>";
         echo "<td>" . LangViewObservationField22 . "</td>";
         echo "<td>" . (($visibility = $this->getDsObservationProperty($LOid, 'visibility')) ? $GLOBALS['VisibilityDS' . $visibility] : "-") . "</td>";
         echo "<td>" . LangViewObservationField33 . "</td>";
         echo "<td>" . $diameterText . "</td>";
         echo "<td>" . LangViewObservationField40 . "</td>";
         echo "<td>" . $charTypeText . "</td>";
         echo "</tr>";
         echo "</table>";
         echo $details1Text . " " . $details2Text;
     } else {
         if (in_array($objObject->getDsoProperty($object, 'type'), array("OPNCL")) && $this->getDsObservationProperty($LOid, 'resolved') > 0) {
             echo "<tr>";
             echo "<td>" . LangViewObservationField22 . "</td>";
             echo "<td>" . (($visibility = $this->getDsObservationProperty($LOid, 'visibility')) ? $GLOBALS['VisibilityOC' . $visibility] : "-") . "</td>";
             echo "<td>" . LangViewObservationField33 . "</td>";
             echo "<td>" . $diameterText . "</td>";
             echo "<td>" . LangViewObservationField40 . "</td>";
             echo "<td>" . $charTypeText . "</td>";
             echo "</tr>";
             echo "</table>";
             echo $details1Text . " " . $details2Text;
         } else {
             echo "<tr>";
             echo "<td>" . LangViewObservationField22 . "</td>";
             echo "<td>" . (($visibility = $this->getDsObservationProperty($LOid, 'visibility')) ? $GLOBALS['Visibility' . $visibility] : "-") . "</td>";
             echo "<td>" . LangViewObservationField33 . "</td>";
             echo "<td>" . $diameterText . "</td>";
             echo "<td>" . LangViewObservationField40 . "</td>";
             echo "<td>" . $charTypeText . "</td>";
             echo "</tr>";
             echo "</table>";
         }
     }
     $toClose = false;
     if ($loggedUser != "") {
         $usedLang = $objObserver->getObserverProperty($loggedUser, "language");
         if ($usedLang != $this->getDsObservationProperty($LOid, 'language')) {
             $toClose = true;
             // Make the google translate control node
             echo "<div class=\"goog-trans-section\">";
             echo "<div class=\"goog-trans-control\">";
             echo "</div>";
         }
     }
     echo $objPresentations->searchAndLinkCatalogsInText($this->getDsObservationProperty($LOid, 'description'));
     if ($toClose) {
         echo "</div>";
     }
     $title = $object . " " . LangMessageBy . $this->getDsObservationProperty($LOid, 'observerid');
     if ($this->getDsObservationProperty($LOid, 'hasDrawing')) {
         echo "<p>" . "<a  href=\"" . $baseURL . "deepsky/drawings/" . $LOid . ".jpg" . "\" data-lightbox=\"image-1\" data-title=\"\"> <img class=\"account\" src=\"" . $baseURL . "deepsky/drawings/" . $LOid . "_resized.jpg\" alt=\"" . $title . "\"></img></a></p>";
     }
     if ($copyright = $objObserver->getObserverProperty($this->getDsObservationProperty($LOid, 'observerid'), 'copyright')) {
         echo "<p class=\"copyright\">" . $copyright . "</p>";
     }
     echo "<br /><br />";
     $bottomline = "";
     if ($myList) {
         $bottomline .= "<a class=\"btn btn-success\" href=\"" . $link . $linkamp . "addObservationToList=" . urlencode($LOid) . "\"><span class=\"glyphicon glyphicon-plus\"></span> " . LangViewObservationField44 . $listname_ss . "</a>";
         if ($objDatabase->selectSingleValue("SELECT Count(observerobjectlist.objectname) As ObjCnt FROM observerobjectlist WHERE observerid = \"" . $loggedUser . "\" AND objectname=\"" . $object . "\" AND listname=\"" . $listname . "\"", 'ObjCnt', 0) > 0) {
             $bottomline .= "&nbsp;<a class=\"btn btn-danger\" href=\"" . $link . $linkamp . "removeObjectFromList=" . urlencode($object) . "&amp;showname=" . urlencode($object) . "\"><span class=\"glyphicon glyphicon-minus\"></span> " . $object_ss . LangListQueryObjectsMessage3 . $listname_ss . "</a><br /><br />";
         } else {
             $bottomline .= "&nbsp;<a class=\"btn btn-success\" href=\"" . $link . $linkamp . "addObjectToList=" . urlencode($object) . "&amp;showname=" . urlencode($object) . "\"><span class=\"glyphicon glyphicon-plus\"></span> " . $object_ss . LangListQueryObjectsMessage2 . $listname_ss . "</a><br /><br />";
         }
         echo $bottomline;
     }
     if ($objUtil->checkAdminOrUserID($this->getDsObservationProperty($LOid, 'observerid'))) {
         $bottomline = "<a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=add_observation&amp;observation=" . $LOid . "\">" . LangChangeObservationTitle . "</a>";
         $bottomline .= "&nbsp;<a class=\"btn btn-danger\" href=\"" . $baseURL . "index.php?indexAction=validate_delete_observation&amp;observationid=" . $LOid . "\">" . LangDeleteObservation . "</a>";
         echo $bottomline . "<br /><br />";
     }
 }
Exemple #2
0
<?php

include "moonphase.inc.php";
$date = time();
$fullmoon = "No";
foreach (phaselist($date - 3600 * 12, $date + 3600 * 12) as $d) {
    if ($d > 100) {
        $moondata = phase($d);
        $MoonIllum = $moondata[1];
        if (round($MoonIllum, 2) == 1) {
            $fullmoon = "Yes";
            break;
        }
    }
}
$data['status'] = $fullmoon;
function convert($test, $template)
{
    $TESTPLAN = array();
    $OUTPUT = "";
    $test["phases"] = isset($test["phases"]) ? $test["phases"] : array();
    foreach ($test["phases"] as $phase) {
        $TESTPLAN[] = phase($phase, $output);
        if ($output) {
            ob_start();
            var_dump($output);
            $OUTPUT .= ob_get_contents();
            ob_end_clean();
            $OUTPUT = str_replace('2) "%s"', '%d) "%s"', $OUTPUT);
        }
    }
    foreach ($test["tests"] as $phase) {
        $TESTPLAN[] = phase($phase, $output);
        if ($output) {
            ob_start();
            var_dump($output);
            $OUTPUT .= ob_get_contents();
            ob_end_clean();
            $OUTPUT = str_replace('2) "%s"', '%d) "%s"', $OUTPUT);
        }
    }
    $replacements = array("%DSN%" => clientSetup($test), "%DESCRIPTION%" => description($test), "%INITCONFIG%" => initConfig($test), "%URLTYPE%" => $test["type"], "%TESTPLAN%" => join("\n\n", $TESTPLAN), "%OUTPUT%" => rtrim($OUTPUT));
    return makeTest($replacements, $template);
}
function menu_moon()
{
    global $baseURL, $dateformat, $loggedUser, $menuMoon, $objAstroCalc, $objObserver, $objLocation, $objUtil;
    $theYear = $objUtil->checkSessionKey('globalYear', date("Y"));
    $theMonth = $objUtil->checkSessionKey('globalMonth', date("n"));
    $theDay = $objUtil->checkSessionKey('globalDay', date('j'));
    $theHour = "";
    $theMinute = "";
    $date = $theYear . "-" . $theMonth . "-" . $theDay;
    $time = "23:59:59";
    $tzone = "GMT";
    $dateTimeText0 = date($dateformat, mktime(0, 0, 0, $theMonth, $theDay, $theYear));
    $dateTimeText1 = date($dateformat, mktime(0, 0, 0, $theMonth, $theDay, $theYear) + 60 * 60 * 24);
    if ($dateformat == 'd-M-Y') {
        if (substr($dateTimeText0, -8) == substr($dateTimeText1, -8)) {
            $dateTimeText0 = substr($dateTimeText0, 0, 2);
        } elseif (substr($dateTimeText0, -5) == substr($dateTimeText1, -5)) {
            $dateTimeText0 = substr($dateTimeText0, 0, 5);
        }
    } elseif ($dateformat == "d/m/Y") {
        if (substr($dateTimeText0, -7) == substr($dateTimeText1, -7)) {
            $dateTimeText0 = substr($dateTimeText0, 0, 2);
        } elseif (substr($dateTimeText0, -5) == substr($dateTimeText1, -5)) {
            $dateTimeText0 = substr($dateTimeText0, 0, 5);
        }
    } elseif ($dateformat == 'd-m-Y') {
        if (substr($dateTimeText0, -7) == substr($dateTimeText1, -7)) {
            $dateTimeText0 = substr($dateTimeText0, 0, 2);
        } elseif (substr($dateTimeText0, -5) == substr($dateTimeText1, -5)) {
            $dateTimeText0 = substr($dateTimeText0, 0, 5);
        }
    } elseif ($dateformat == 'M-d-Y') {
        if (substr($dateTimeText0, 0, 3) == substr($dateTimeText1, 0, 3)) {
            $dateTimeText0 = substr($dateTimeText0, 0, 6);
            $dateTimeText1 = substr($dateTimeText1, -7);
        } elseif (substr($dateTimeText0, -5) == substr($dateTimeText1, -5)) {
            $dateTimeText0 = substr($dateTimeText0, 0, 6);
        }
    }
    $moondata = phase(strtotime($date . ' ' . $time . ' ' . $tzone));
    $MoonIllum = $moondata[1];
    $MoonAge = $moondata[2];
    $nextNewMoonText = LangMoonMenuNewMoon . ": ";
    $phases = array();
    $phases = phasehunt(strtotime($date));
    $nextNewMoonText .= date("j M", $phases[4]);
    // Convert $MoonIllum to percent and round to whole percent.
    $MoonIllum = round($MoonIllum, 2);
    $MoonIllum *= 100;
    // 1) Check if logged in
    if ($loggedUser && $objObserver->getObserverProperty($loggedUser, 'stdLocation')) {
        // 2) Get the julian day of today...
        $jd = gregoriantojd($theMonth, $theDay, $theYear);
        // 3) Get the standard location of the observer
        $longitude = $objLocation->getLocationPropertyFromId($objObserver->getObserverProperty($loggedUser, 'stdLocation'), 'longitude');
        $latitude = $objLocation->getLocationPropertyFromId($objObserver->getObserverProperty($loggedUser, 'stdLocation'), 'latitude');
        if (!$objUtil->checkSessionKey('efemerides') || $_SESSION['efemerides']['base'] != $jd . "/" . $longitude . "/" . $latitude) {
            if ($longitude > -199) {
                $timezone = $objLocation->getLocationPropertyFromId($objObserver->getObserverProperty($loggedUser, 'stdLocation'), 'timezone');
                $dateTimeZone = new DateTimeZone($timezone);
                $datestr = sprintf("%02d", $_SESSION['globalMonth']) . "/" . sprintf("%02d", $_SESSION['globalDay']) . "/" . $_SESSION['globalYear'];
                $dateTime = new DateTime($datestr, $dateTimeZone);
                // Geeft tijdsverschil terug in seconden
                $timedifference = $dateTimeZone->getOffset($dateTime);
                $timedifference = $timedifference / 3600.0;
                if (strncmp($timezone, "Etc/GMT", 7) == 0) {
                    $timedifference = -$timedifference;
                }
                // Calculate the rise and set time of the moon
                $moon = $objAstroCalc->calculateMoonRiseTransitSettingTime($jd, $longitude, $latitude, $timedifference);
                // SUNRISE and SET, TWILIGHT...
                date_default_timezone_set("UTC");
                $timestr = $theYear . "-" . $theMonth . "-" . $theDay;
                $sun_info = date_sun_info(strtotime($timestr), $latitude, $longitude);
                $srise = $sun_info["sunrise"];
                if ($srise > 1) {
                    $srise = date("H:i", $srise + $timedifference * 60 * 60);
                } else {
                    $srise = "-";
                }
                $sset = $sun_info["sunset"];
                if ($sset > 1) {
                    $sset = date("H:i", $sset + $timedifference * 60 * 60);
                } else {
                    $sset = "-";
                }
                $nautb = $sun_info["nautical_twilight_begin"];
                if ($nautb > 1) {
                    $nautb = date("H:i", $nautb + $timedifference * 60 * 60);
                } else {
                    $nautb = "-";
                }
                $naute = $sun_info["nautical_twilight_end"];
                if ($naute > 1) {
                    $naute = date("H:i", $naute + $timedifference * 60 * 60);
                } else {
                    $naute = "-";
                }
                $astrob = $sun_info["astronomical_twilight_begin"];
                if ($astrob > 1) {
                    $astrob = date("H:i", $astrob + $timedifference * 60 * 60);
                } else {
                    $astrob = "-";
                }
                $astroe = $sun_info["astronomical_twilight_end"];
                if ($astroe > 1) {
                    $astroe = date("H:i", $astroe + $timedifference * 60 * 60);
                } else {
                    $astroe = "-";
                }
                $_SESSION['efemerides']['base'] = $jd . "/" . $longitude . "/" . $latitude;
                $_SESSION['efemerides']['astrob'] = $astrob;
                $_SESSION['efemerides']['astroe'] = $astroe;
                $_SESSION['efemerides']['nautb'] = $nautb;
                $_SESSION['efemerides']['naute'] = $naute;
                $_SESSION['efemerides']['srise'] = $srise;
                $_SESSION['efemerides']['sset'] = $sset;
                $_SESSION['efemerides']['moon0'] = $moon[0];
                $_SESSION['efemerides']['moon2'] = $moon[2];
            }
        }
    }
    echo "<li>";
    reset($_GET);
    $link = "";
    while (list($key, $value) = each($_GET)) {
        if ($key != "menuMoon") {
            $link .= "&amp;" . $key . "=" . urlencode($value);
        }
    }
    reset($_GET);
    echo "<p><br /><h4>";
    echo ($loggedUser && $objObserver->getObserverProperty($loggedUser, 'stdLocation') ? LangMoonSunMenuTitle : LangMoonMenuTitle) . "<br />";
    echo "</h4>";
    echo "<span style=\"font-weight:normal;\">" . LangOn . " " . $dateTimeText0 . "&gt;&lt;" . $dateTimeText1 . "</span>";
    echo "</p>";
    if ($loggedUser && $objObserver->getObserverProperty($loggedUser, 'stdLocation')) {
        echo "<table class=\"table table-condensed\">";
        if (isset($_SESSION['efemerides'])) {
            echo "<tr>";
            echo "<td>" . LangMoon . "</td>" . "<td>" . $_SESSION['efemerides']['moon0'] . "</td>" . "<td>" . $_SESSION['efemerides']['moon2'] . "</td>";
            echo "</tr>";
            echo "<tr>";
            echo "<td>" . LangMoonSun . "</td>" . "<td>" . $_SESSION['efemerides']['sset'] . "</td>" . "<td>" . $_SESSION['efemerides']['srise'] . "</td>";
            echo "</tr>";
            echo "<tr>";
            echo "<td>" . LangMoonNaut . "</td>" . "<td>" . $_SESSION['efemerides']['naute'] . "</td>" . "<td>" . $_SESSION['efemerides']['nautb'] . "</td>";
            echo "</tr>";
            echo "<tr>";
            echo "<td>" . LangMoonAstro . "</td>" . "<td>" . $_SESSION['efemerides']['astroe'] . "</td>" . "<td>" . $_SESSION['efemerides']['astrob'] . "</td>";
            echo "</tr>";
        }
        echo "</table>";
    }
    $file = "m" . round($MoonAge / SYNMONTH * 40) . ".gif";
    echo "<p><img src=\"" . $baseURL . "/lib/moonpics/" . $file . "\" title=\"" . $MoonIllum . "%\" height=\"100px\" width=\"100px\" alt=\"" . $MoonIllum . "%\" /></p>";
    echo $nextNewMoonText . "<br />";
    echo "</li>";
}
function getMoonPic($date, $realTime, $latitude, $longitude, $timezone)
{
    global $objAstroCalc;
    // Show the moon during the observation
    $date = explode("-", $date);
    $year = $date[0];
    $month = $date[1];
    $day = $date[2];
    $date = $date[0] . "-" . $date[1] . "-" . $date[2];
    if ($realTime < 0) {
        $time = "23:59:59";
    } else {
        $time = $realTime;
    }
    $tzone = "GMT";
    $moondata = phase(strtotime($date . ' 23:59:59 ' . $tzone));
    $MoonIllum = $moondata[1];
    $MoonAge = $moondata[2];
    // Convert $MoonIllum to percent and round to whole percent.
    $MoonIllum = round($MoonIllum, 2);
    $MoonIllum *= 100;
    $file = "m" . round($MoonAge / SYNMONTH * 40) . ".gif";
    // Moon is above the horizon
    if ($realTime < 0) {
        $moon = "<img src=\"/lib/moonpics/" . $file . "\" class=\"moonpic\" title=\"" . $MoonIllum . "%\" alt=\"" . $MoonIllum . "%\" />";
    } else {
        // Calculate altitude of the moon for this date, time and location
        // Get the julian day of the observation...
        $jd = gregoriantojd($month + 0, $day + 0, $year + 0);
        $dateTimeZone = new DateTimeZone($timezone);
        $datestr = sprintf("%02d", $month) . "/" . sprintf("%02d", $day) . "/" . $year;
        $dateTime = new DateTime($datestr, $dateTimeZone);
        // Geeft tijdsverschil terug in seconden
        $timedifference = $dateTimeZone->getOffset($dateTime);
        $timedifference = $timedifference / 3600.0;
        if (strncmp($timezone, "Etc/GMT", 7) == 0) {
            $timedifference = -$timedifference;
        }
        // Calculate the rise and set time of the moon
        $moonCalc = $objAstroCalc->calculateMoonRiseTransitSettingTime($jd, $longitude, $latitude, $timedifference);
        // Now we know when the moon rises and sets. We have to convert the time and compare with the time of the observation.
        // $moonCalc[0] = rise
        // $moonCalc[2] = set
        $moonriseArray = sscanf($moonCalc[0], "%d:%d");
        $moonsetArray = sscanf($moonCalc[2], "%d:%d");
        $moonRise = $moonriseArray[0] * 100.0 + $moonriseArray[1];
        $moonSet = $moonsetArray[0] * 100.0 + $moonsetArray[1];
        $moonAboveHorizon = true;
        if ($moonRise > $moonSet) {
            if ($time <= $moonRise && $time >= $moonSet) {
                $moonAboveHorizon = false;
            }
        } else {
            if ($time <= $moonRise || $time >= $moonSet) {
                $moonAboveHorizon = false;
            }
        }
        $ext = "";
        if (!$moonAboveHorizon) {
            $file = "below.png";
            $ext = " - " . LangUnderHorizon;
        }
        $moon = $moon = "<img src=\"/lib/moonpics/" . $file . "\" class=\"moonpic\" title=\"" . $MoonIllum . "% " . $ext . "\" alt=\"" . $MoonIllum . "%\" />";
    }
    return $moon;
}
Exemple #6
0
<?php

/**
 * Created by PhpStorm.
 * User: benjaminstockard
 * Date: 7/17/15
 * Time: 4:33 PM
 */
require 'moonphase.inc.php';
$date = '2008-05-05';
$time = '20:36:00';
$tzone = 'PST';
// Usage: $data = phase( seconds_since_1970 );
$moondata = phase(strtotime($date . ' ' . $time . ' ' . $tzone));
$MoonPhase = $moondata[0];
$MoonIllum = $moondata[1];
$MoonAge = $moondata[2];
$MoonDist = $moondata[3];
$MoonAng = $moondata[4];
$SunDist = $moondata[5];
$SunAng = $moondata[6];
$phase = 'Waxing';
if ($MoonAge > SYNMONTH / 2) {
    $phase = 'Waning';
}
print "{$phase}\n";
"<br>";
$city = "SanAntonio";
$country = "US";
//Two digit country code
$url = "http://api.openweathermap.org/data/2.5/weather?q=" . $city . "," . $country . "&units=metric&cnt=7&lang=en";