コード例 #1
0
function validate_delete_observation()
{
    global $objObserver, $loggedUser;
    $util = new Utils();
    $cometobservations = new CometObservations();
    if (!$_GET['observationid']) {
        unset($_SESSION['deepskylog_id']);
        header("Location:../index.php");
    } elseif ($_GET['observationid']) {
        // only admins may delete a comet observation
        $role = $objObserver->getObserverProperty($_SESSION['deepskylog_id'], 'role', 2);
        if ($role == RoleAdmin || $role == RoleCometAdmin || $loggedUser == $cometobservations->getObserverId($_GET['observationid'])) {
            $cometobservations->deleteObservation($_GET['observationid']);
            unset($_SESSION['deepskylog_id']);
            $_GET['indexAction'] = 'default_action';
        } else {
            unset($_SESSION['deepskylog_id']);
            header("Location: ../index.php");
            // back to entrance page
        }
    }
}
コード例 #2
0
ファイル: util.php プロジェクト: Hermannhaf/DeepskyLog
 public function rssObservations()
 {
     global $objObservation, $objInstrument, $objLocation, $objPresentations, $objObserver, $baseURL, $objUtil;
     $dom = new DomDocument('1.0', 'US-ASCII');
     // add root fcga -> The header
     $rssInfo = $dom->createElement('rss');
     $rssDom = $dom->appendChild($rssInfo);
     $attr = $dom->createAttribute("version");
     $rssInfo->appendChild($attr);
     $attrText = $dom->createTextNode("2.0");
     $attr->appendChild($attrText);
     $attr = $dom->createAttribute("xmlns:content");
     $rssInfo->appendChild($attr);
     $attrText = $dom->createTextNode("http://purl.org/rss/1.0/modules/content/");
     $attr->appendChild($attrText);
     $attr = $dom->createAttribute("xmlns:dc");
     $rssInfo->appendChild($attr);
     $attrText = $dom->createTextNode("http://purl.org/dc/elements/1.1/");
     $attr->appendChild($attrText);
     $attr = $dom->createAttribute("xmlns:atom");
     $rssInfo->appendChild($attr);
     $attrText = $dom->createTextNode("http://www.w3.org/2005/Atom");
     $attr->appendChild($attrText);
     // add root - <channel>
     $channelDom = $rssDom->appendChild($dom->createElement('channel'));
     // add root - <channel> - <title>
     $titleDom = $channelDom->appendChild($dom->createElement('title'));
     $titleDom->appendChild($dom->createTextNode("DeepskyLog"));
     // add root - <channel> - <description>
     $descDom = $channelDom->appendChild($dom->createElement('description'));
     $descDom->appendChild($dom->createTextNode("DeepskyLog - visual deepsky and comets observations"));
     // add root - <channel> - <atom>
     $atomDom = $channelDom->appendChild($dom->createElement('atom:link'));
     $attr = $dom->createAttribute("href");
     $atomDom->appendChild($attr);
     $attrText = $dom->createTextNode($baseURL . "observations.rss");
     $attr->appendChild($attrText);
     $attr = $dom->createAttribute("rel");
     $atomDom->appendChild($attr);
     $attrText = $dom->createTextNode("self");
     $attr->appendChild($attrText);
     $attr = $dom->createAttribute("type");
     $atomDom->appendChild($attr);
     $attrText = $dom->createTextNode("application/rss+xml");
     $attr->appendChild($attrText);
     // add root - <channel> - <link>
     $linkDom = $channelDom->appendChild($dom->createElement('link'));
     $linkDom->appendChild($dom->createTextNode("http://www.deepskylog.org/"));
     $theDate = date('r');
     // add root - <channel> - <link>
     $lbdDom = $channelDom->appendChild($dom->createElement('lastBuildDate'));
     $lbdDom->appendChild($dom->createTextNode($theDate));
     // Get the new deepsky observations of the last month
     $theDate = date('Ymd', strtotime('-1 month'));
     $_GET['minyear'] = substr($theDate, 0, 4);
     $_GET['minmonth'] = substr($theDate, 4, 2);
     $_GET['minday'] = substr($theDate, 6, 2);
     $query = array("catalog" => '%', "mindate" => $objUtil->checkGetDate('minyear', 'minmonth', 'minday'));
     $result = $objObservation->getObservationFromQuery($query, 'A');
     while (list($key, $value) = each($result)) {
         // add root - <channel> - <item>
         $itemDom = $channelDom->appendChild($dom->createElement('item'));
         $titleDom = $itemDom->appendChild($dom->createElement('title'));
         $titleDom->appendChild($dom->createTextNode($value['observername'] . " : " . $value['objectname'] . " with " . htmlspecialchars_decode($objInstrument->getInstrumentPropertyFromId($value['instrumentid'], 'name')) . " from " . $objLocation->getLocationPropertyFromId($objObservation->getDsObservationProperty($value['observationid'], 'locationid'), 'name')));
         $linkDom = $itemDom->appendChild($dom->createElement('link'));
         $linkDom->appendChild($dom->createCDATASection($baseURL . "index.php?indexAction=detail_observation&observation=" . $value['observationid'] . "&QobsKey=0&dalm=D"));
         $descDom = $itemDom->appendChild($dom->createElement('description'));
         $descDom->appendChild($dom->createCDATASection($objPresentations->br2nl(utf8_encode($value['observationdescription']))));
         $authorDom = $itemDom->appendChild($dom->createElement('dc:creator'));
         $authorDom->appendChild($dom->createCDATASection($value['observername']));
         $guidDom = $itemDom->appendChild($dom->createElement('guid'));
         $guidDom->appendChild($dom->createTextNode("deepsky" . $value['observationid']));
         $attr = $dom->createAttribute("isPermaLink");
         $guidDom->appendChild($attr);
         $attrText = $dom->createTextNode("false");
         $attr->appendChild($attrText);
         $pubDateDom = $itemDom->appendChild($dom->createElement('pubDate'));
         date_default_timezone_set('UTC');
         $time = -999;
         $obs = $objObservation->getAllInfoDsObservation($value['observationid']);
         $time = $obs['time'];
         if ($time >= "0") {
             $hour = (int) ($time / 100);
             $minute = $time - 100 * $hour;
         } else {
             $hour = 0;
             $minute = 0;
         }
         $date = $value['observationdate'];
         $year = substr($date, 0, 4);
         $month = substr($date, 4, 2);
         $day = substr($date, 6, 2);
         $pubDateDom->appendChild($dom->createTextNode(date("r", mktime($hour, $minute, 0, $month, $day, $year))));
     }
     include_once "cometobjects.php";
     include_once "observers.php";
     include_once "instruments.php";
     include_once "locations.php";
     include_once "cometobservations.php";
     include_once "icqmethod.php";
     include_once "icqreferencekey.php";
     global $instDir, $objCometObject;
     $objects = new CometObjects();
     $observer = new Observers();
     $instrument = new Instruments();
     $observation = new CometObservations();
     $location = new Locations();
     $util = $this;
     $ICQMETHODS = new ICQMETHOD();
     $ICQREFERENCEKEYS = new ICQREFERENCEKEY();
     $cometsResult = $observation->getObservationFromQuery($query);
     while (list($key, $value) = each($cometsResult)) {
         $objectname = $objCometObject->getName($observation->getObjectId($value));
         // add root - <channel> - <item>
         $itemDom = $channelDom->appendChild($dom->createElement('item'));
         $title = htmlspecialchars_decode($objectname);
         // Location and instrument
         if ($observation->getLocationId($value) != 0 && $observation->getLocationId($value) != 1) {
             $title = $title . " from " . htmlspecialchars_decode($location->getLocationPropertyFromId($observation->getLocationId($value), 'name'));
         }
         if ($observation->getInstrumentId($value) != 0) {
             $title = $title . " with " . htmlspecialchars_decode($instrument->getInstrumentPropertyFromId($observation->getInstrumentId($value), 'name'));
         }
         $titleDom = $itemDom->appendChild($dom->createElement('title'));
         $titleDom->appendChild($dom->createTextNode($title));
         $linkDom = $itemDom->appendChild($dom->createElement('link'));
         $linkDom->appendChild($dom->createCDATASection($baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $value));
         // Description
         $description = $observation->getDescription($value);
         if (strcmp($description, "") != 0) {
             $descDom = $itemDom->appendChild($dom->createElement('description'));
             $descDom->appendChild($dom->createCDATASection($objPresentations->br2nl(utf8_encode($description))));
         } else {
             $descDom = $itemDom->appendChild($dom->createElement('description'));
             $descDom->appendChild($dom->createCDATASection(""));
         }
         $observerid = $observation->getObserverId($value);
         $observername = $observer->getObserverProperty($observerid, 'firstname') . " " . $observer->getObserverProperty($observerid, 'name');
         $authorDom = $itemDom->appendChild($dom->createElement('dc:creator'));
         $authorDom->appendChild($dom->createCDATASection($observername));
         $guidDom = $itemDom->appendChild($dom->createElement('guid'));
         $guidDom->appendChild($dom->createTextNode("comet" . $value));
         $attr = $dom->createAttribute("isPermaLink");
         $guidDom->appendChild($attr);
         $attrText = $dom->createTextNode("false");
         $attr->appendChild($attrText);
         $pubDateDom = $itemDom->appendChild($dom->createElement('pubDate'));
         date_default_timezone_set('UTC');
         $date = sscanf($observation->getLocalDate($value), "%4d%2d%2d");
         $time = $observation->getLocalTime($value);
         $hour = (int) ($time / 100);
         $minute = $time - $hour * 100;
         $pubDateDom->appendChild($dom->createTextNode(date("r", mktime($hour, $minute, 0, $date[1], $date[2], $date[0]))));
     }
     // generate xml
     $dom->formatOutput = true;
     // set the formatOutput attribute of
     // domDocument to true
     // save XML as string or file
     $test1 = $dom->saveXML();
     // put string in test1
     print $test1;
 }
コード例 #3
0
function selected_observation()
{
    global $instDir, $baseURL, $dateformat, $step, $loggedUser, $objUtil, $objPresentations;
    // creation of objects
    $observations = new CometObservations();
    $instruments = new Instruments();
    $observers = new Observers();
    $objects = new CometObjects();
    $util = $objUtil;
    // selection of all observations of one object
    echo "<div id=\"main\">";
    if (isset($_GET['objectname'])) {
        $queries = array("object" => $objects->getName($_GET['objectname']));
        // sql query
        $sort = "id";
        // standard sort on insertion date
        $obs = $observations->getObservationFromQuery($queries);
        if (sizeof($obs) > 0) {
            krsort($obs);
        }
        // save $obs as a session variable
        $_SESSION['obs'] = $obs;
        $_SESSION['observation_query'] = $obs;
        $count = 0;
        // counter for altering table colors
        $link = "" . $baseURL . "index.php?indexAction=comets_result_query_observations&amp;objectname=" . $_GET['objectname'];
        echo "<h4>" . LangSelectedObservationsTitle . $objects->getName($_GET['objectname']) . "</h4>";
        echo "<hr />";
        if (sizeof($obs) > 0) {
            echo "<table class=\"table sort-tablecometobservations table-condensed table-striped table-hover tablesorter custom-popup\">\n\t      <thead>\n\t\t  <tr>\n\t      <th>" . LangOverviewObservationsHeader1 . "</th>\n\t      <th>" . LangOverviewObservationsHeader2 . "</th>\n\t      <th>" . LangOverviewObservationsHeader4 . "</th>\n\t      <th>" . LangNewComet1 . "</th>\n\t      <th>" . LangViewObservationField3 . "</th>\n\t      <th>" . LangViewObservationField19 . "</th>\n\t      <th>" . LangViewObservationField18b . "</th>\n\t      <th>" . LangViewObservationField20b . "</th>\n\t      <th class=\"filter-false columnSelector-disable\" data-sorter=\"false\"></th>\n\t      </tr>\n\t      </thead>";
            while (list($key, $value) = each($obs)) {
                // OBJECT
                $object = $observations->getObjectId($value);
                // overhead as this is every time the same object?!
                // OUTPUT
                echo "<tr>\n\t            <td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_object&amp;object=" . urlencode($object) . "\">" . $objects->getName($object) . "</a></td>";
                // OBSERVER
                $observer = $observations->getObserverId($value);
                echo "<td>";
                echo "<a href=\"" . $baseURL . "index.php?indexAction=detail_observer&amp;user="******"\">" . $observers->getObserverProperty($observer, 'firstname') . "&nbsp;" . $observers->getObserverProperty($observer, 'name') . "</a>";
                echo "</td>";
                // DATE
                if ($observers->getObserverProperty($loggedUser, 'UT')) {
                    $date = sscanf($observations->getDate($value), "%4d%2d%2d");
                } else {
                    $date = sscanf($observations->getLocalDate($value), "%4d%2d%2d");
                }
                echo "<td>";
                echo date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0]));
                // TIME
                echo " (";
                if ($observers->getObserverProperty($loggedUser, 'UT')) {
                    $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d");
                } else {
                    $time = sscanf(sprintf("%04d", $observations->getLocalTime($value)), "%2d%2d");
                }
                printf("%02d", $time[0]);
                echo ":";
                printf("%02d", $time[1]);
                $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d");
                echo ")</td>";
                // INSTRUMENT
                $temp = $observations->getInstrumentId($value);
                $instrument = $instruments->getInstrumentPropertyFromId($temp, 'name');
                $instrumentsize = $instruments->getInstrumentPropertyFromId($temp, 'diameter');
                if ($instrument == "Naked eye") {
                    $instrument = InstrumentsNakedEye;
                }
                // MAGNITUDE
                $mag = $observations->getMagnitude($value);
                if ($mag < -90) {
                    $mag = '';
                } else {
                    $mag = sprintf("%01.1f", $observations->getMagnitude($value));
                }
                // COMA
                $coma = $observations->getComa($value);
                if ($coma < -90) {
                    $coma = '';
                } else {
                    $coma = $coma . "'";
                }
                // DC
                $dc = $observations->getDc($value);
                if ($dc < -90) {
                    $dc = '';
                }
                // TAIL
                $tail = $observations->getTail($value);
                if ($tail < -90) {
                    $tail = '';
                } else {
                    $tail = $tail . "'";
                }
                if ($instrument != InstrumentsNakedEye && $instrument != "") {
                    $instrument = $instrument . " (" . $instrumentsize . "&nbsp;mm" . ")";
                }
                echo " <td>{$mag}</td>\n\t            <td>{$instrument}</td>\n\t            <td>{$coma}</td>\n\t            <td>{$dc}</td>\n\t            <td>{$tail}</td>";
                // DETAILS
                echo "<td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_observation&amp;observation=" . $value . "\">details";
                // LINK TO DRAWING (IF AVAILABLE)
                echo "</a></td></tr>";
            }
            echo "</table>";
            $objUtil->addPager("cometobservations", sizeof($obs));
            echo "<hr />";
            echo "<a class=\"btn btn-success\" href=\"" . $baseURL . "cometobservations.pdf.php\" rel=\"external\"><span class=\"glyphicon glyphicon-download\"></span> " . LangExecuteQueryObjectsMessage4a . "</a>";
            echo "<br /><br />";
        } else {
            echo LangNoObservations;
        }
        echo "</div>";
    } elseif ($_GET['user']) {
        $query = array("observer" => $_GET['user']);
        $sort = "id";
        // standard sort on date
        $obs = $observations->getObservationFromQuery($query, $sort);
        if (sizeof($obs) > 0) {
            krsort($obs);
        }
        // save $obs as a session variable
        $_SESSION['obs'] = $obs;
        $_SESSION['observation_query'] = $obs;
        $link = "" . $baseURL . "index.php?indexAction=comets_result_query_observations&amp;user="******"<h4>" . LangSelectedObservationsTitle . $observers->getObserverProperty($_GET['user'], 'firstname') . "&nbsp;" . $observers->getObserverProperty($_GET['user'], 'name') . "</h4>";
        echo "<hr />";
        // NEW BEGIN
        if (sizeof($obs) > 0) {
            // OBJECT TABLE HEADERS
            echo "<table class=\"table sort-tablecometobservations table-condensed table-striped table-hover tablesorter custom-popup\">\n\t\t\t      <thead>\n\t\t\t\t  <tr>\n\t\t\t      <th>" . LangOverviewObservationsHeader1 . "</th>\n\t\t\t      <th>" . LangOverviewObservationsHeader4 . "</th>\n\t\t\t      <th>" . LangNewComet1 . "</th>\n\t\t\t      <th>" . LangViewObservationField3 . "</th>\n\t\t\t      <th>" . LangViewObservationField19 . "</th>\n\t\t\t      <th>" . LangViewObservationField18b . "</th>\n\t\t\t      <th>" . LangViewObservationField20b . "</th>\n\t\t\t      <th class=\"filter-false columnSelector-disable\" data-sorter=\"false\"></th>\n\t\t\t      </thead>\n\t\t\t      </tr>";
            while (list($key, $value) = each($obs)) {
                // OBJECT
                $object = $observations->getObjectId($value);
                // OUTPUT
                echo "<tr>\n\t\t\t            <td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_object&amp;object=" . urlencode($object) . "\">" . $objects->getName($object) . "</a></td>\n\t\t\t            <td>";
                // DATE
                if ($observers->getObserverProperty($loggedUser, 'UT')) {
                    $date = sscanf($observations->getDate($value), "%4d%2d%2d");
                } else {
                    $date = sscanf($observations->getLocalDate($value), "%4d%2d%2d");
                }
                echo date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0]));
                // TIME
                echo "&nbsp;(";
                if ($observers->getObserverProperty($loggedUser, 'UT')) {
                    $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d");
                } else {
                    $time = sscanf(sprintf("%04d", $observations->getLocalTime($value)), "%2d%2d");
                }
                printf("%02d", $time[0]);
                echo ":";
                printf("%02d", $time[1]);
                echo ")</td>";
                // INSTRUMENT
                $temp = $observations->getInstrumentId($value);
                $instrument = $instruments->getInstrumentPropertyFromId($temp, 'name');
                if ($instrument == "Naked eye") {
                    $instrument = InstrumentsNakedEye;
                }
                // MAGNITUDE
                $mag = $observations->getMagnitude($value);
                if ($mag < -90) {
                    $mag = '';
                }
                // COMA
                $coma = $observations->getComa($value);
                if ($coma < -90) {
                    $coma = '';
                } else {
                    $coma = $coma . "'";
                }
                // DC
                $dc = $observations->getDc($value);
                if ($dc < -90) {
                    $dc = '';
                }
                // TAIL
                $tail = $observations->getTail($value);
                if ($tail < -90) {
                    $tail = '';
                } else {
                    $tail = $tail . "'";
                }
                echo " <td>{$mag}</td>\n\t\t\t            <td>{$instrument}</td>\n\t\t\t            <td>{$coma}</td>\n\t\t\t            <td>{$dc}</td>\n\t\t\t            <td>{$tail}</td>";
                // DETAILS
                echo "<td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_observation&amp;observation=" . $value . "\">details";
                // LINK TO DRAWING (IF AVAILABLE)
                $upload_dir = 'cometdrawings';
                $dir = opendir($instDir . "comets/" . $upload_dir);
                while (FALSE !== ($file = readdir($dir))) {
                    if ("." == $file or ".." == $file) {
                        continue;
                        // skip current directory and directory above
                    }
                    if (fnmatch($value . "_resized.gif", $file) || fnmatch($value . "_resized.jpg", $file) || fnmatch($value . "_resized.png", $file)) {
                        echo "&nbsp;+&nbsp;";
                        echo LangDrawing;
                    }
                }
                echo "</a></td></tr>";
            }
            echo "</table>";
            $objUtil->addPager("cometobservations", sizeof($obs));
            echo "<hr />";
            $_SESSION['observation_query'] = $obs;
            echo "<a class=\"btn btn-success\" href=\"" . $baseURL . "cometobservations.pdf.php\" rel=\"external\"><span class=\"glyphicon glyphicon-download\"></span> " . LangExecuteQueryObjectsMessage4a . "</a>";
        }
        echo "<br /><br />";
        echo "</div>";
    }
}
コード例 #4
0
function selected_observations()
{
    global $instDir, $baseURL, $loggedUser, $step, $dateformat, $objPresentations, $objUtil;
    $observations = new CometObservations();
    $instruments = new Instruments();
    $observers = new Observers();
    $objects = new CometObjects();
    $util = $objUtil;
    // TITLE
    echo "<div id=\"main\">";
    $mindate = '';
    $maxdate = '';
    if ($_GET['observer'] || $_GET['instrument'] || $_GET['site'] || $_GET['minyear'] || $_GET['maxyear'] || $_GET['mindiameter'] && $_GET['mindiameterunits'] || $_GET['maxdiameter'] && $_GET['maxdiameterunits'] || $_GET['minmag'] || $_GET['maxmag'] || $_GET['description'] || $_GET['mindc'] || $_GET['maxdc'] || $_GET['mincoma'] || $_GET['maxcoma'] || $_GET['mintail'] || $_GET['maxtail'] || $_GET['object']) {
        if ($_GET['minyear'] && $_GET['minmonth'] && $_GET['minday']) {
            $mindate = $_GET['minyear'] . sprintf("%02d", $_GET['minmonth']) . sprintf("%02d", $_GET['minday']);
        } elseif ($_GET['minyear'] && $_GET['minmonth']) {
            $mindate = $_GET['minyear'] . sprintf("%02d", $_GET['minmonth']) . "00";
        } elseif ($_GET['minyear']) {
            $mindate = $_GET['minyear'] . "0000";
        }
        if ($_GET['maxyear'] && $_GET['maxmonth'] && $_GET['maxday']) {
            $maxdate = $_GET['maxyear'] . sprintf("%02d", $_GET['maxmonth']) . sprintf("%02d", $_GET['maxday']);
        } elseif ($_GET['maxyear'] && $_GET['maxmonth']) {
            $maxdate = $_GET['maxyear'] . sprintf("%02d", $_GET['maxmonth']) . "31";
        } elseif ($_GET['maxyear']) {
            $maxdate = $_GET['maxyear'] . "1231";
        }
        if ($_GET['mindiameter'] && $_GET['mindiameterunits'] == "inch") {
            $mindiam = $_GET['mindiameter'] * 25.4;
        } else {
            $mindiam = $_GET['mindiameter'];
        }
        if ($_GET['maxdiameter'] && $_GET['maxdiameterunits'] == "inch") {
            $maxdiam = $_GET['maxdiameter'] * 25.4;
        } else {
            $maxdiam = $_GET['maxdiameter'];
        }
        $maxmag = $_GET['maxmag'];
        $minmag = $_GET['minmag'];
        $description = $_GET['description'];
        $object = $_GET['object'];
        $mintail = $_GET['mintail'];
        $maxtail = $_GET['maxtail'];
        $mincoma = $_GET['mincoma'];
        $maxcoma = $_GET['maxcoma'];
        $mindc = $_GET['mindc'];
        $maxdc = $_GET['maxdc'];
        $observer = $_GET['observer'];
        if (array_key_exists('instrument', $_GET) && $_GET['instrument'] != "") {
            $instrument = $_GET['instrument'];
            $name = $instruments->getInstrumentPropertyFromId($instrument, 'name');
            $instrument = $instruments->getId($name, $loggedUser);
        } else {
            $instrument = '';
        }
        if (array_key_exists('site', $_GET) && $_GET['site'] != "") {
            $site = $_GET['site'];
            $name = $objLocation->getLocationPropertyFromId($site, 'name');
            $site = $objLocation->getLocationId($name, $loggedUser);
        } else {
            $site = '';
        }
        // QUERY
        $query = array("object" => $object, "observer" => $observer, "instrument" => $instrument, "location" => $site, "mindate" => $mindate, "maxdate" => $maxdate, "maxdiameter" => $maxdiam, "mindiameter" => $mindiam, "maxmag" => $maxmag, "minmag" => $minmag, "description" => $description, "mintail" => $mintail, "maxtail" => $maxtail, "mincoma" => $mincoma, "maxcoma" => $maxcoma, "mindc" => $mindc, "maxdc" => $maxdc);
        if (!$observers->getObserverProperty($loggedUser, 'UT')) {
            if ($mindate != "") {
                $mindate = $mindate - 1;
            }
            if ($maxdate != "") {
                $maxdate = $maxdate + 1;
            }
        }
        $sort = "date";
        if (isset($catalogsearch)) {
            if ($catalogsearch == "yes") {
                $obs = $observations->getObservationFromQuery($query, $sort, 0);
                // LIKE
            } else {
                $obs = $observations->getObservationFromQuery($query, $sort);
                // EXACT MATCH
            }
        } else {
            $obs = $observations->getObservationFromQuery($query, $sort);
            // EXACT MATCH
        }
        // Dates can changes when we use local time!
        if (!$observers->getObserverProperty($loggedUser, 'UT')) {
            if ($mindate != "" || $maxdate != "") {
                if ($mindate != "") {
                    $mindate = $mindate + 1;
                }
                if ($maxdate != "") {
                    $maxdate = $maxdate - 1;
                }
                $newkey = 0;
                $new_obs = array();
                while (list($key, $value) = each($obs)) {
                    $newdate = $observations->getLocalDate($value);
                    if ($mindate != "" && $maxdate != "") {
                        if ($newdate >= $mindate && $newdate <= $maxdate) {
                            $new_obs[$newkey] = $value;
                            $newkey++;
                        }
                    } else {
                        if ($maxdate != "") {
                            if ($newdate <= $maxdate) {
                                $new_obs[$newkey] = $value;
                                $newkey++;
                            }
                        } else {
                            if ($mindate != "") {
                                if ($newdate >= $mindate) {
                                    $new_obs[$newkey] = $value;
                                    $newkey++;
                                }
                            }
                        }
                    }
                }
                $obs = $new_obs;
            }
        }
        if (sizeof($obs) > 0) {
            $link = $baseURL . "index.php?indexAction=comets_result_selected_observations" . "&amp;object=" . urlencode($_GET['object']) . "&amp;instrument=" . urlencode($_GET['instrument']) . "&amp;observer=" . urlencode($_GET['observer']) . "&amp;site=" . urlencode($_GET['site']) . "&amp;minyear=" . $_GET['minyear'] . "&amp;minmonth=" . $_GET['minmonth'] . "&amp;minday=" . $_GET['minday'] . "&amp;maxyear=" . $_GET['maxyear'] . "&amp;maxmonth=" . $_GET['maxmonth'] . "&amp;maxday=" . $_GET['maxday'] . "&amp;maxdiameter=" . $_GET['maxdiameter'] . "&amp;maxdiameterunits=" . urlencode($_GET['maxdiameterunits']) . "&amp;mindiameter=" . $_GET['mindiameter'] . "&amp;mindiameterunits=" . urlencode($_GET['mindiameterunits']) . "&amp;maxmag=" . $_GET['maxmag'] . "&amp;minmag=" . $_GET['minmag'] . "&amp;description=" . $_GET['description'] . "&amp;mindc=" . $_GET['mindc'] . "&amp;maxdc=" . $_GET['maxdc'] . "&amp;mincoma=" . $_GET['mincoma'] . "&amp;maxcoma=" . $_GET['maxcoma'] . "&amp;mintail=" . $_GET['mintail'] . "&amp;maxtail=" . $_GET['maxtail'];
            echo "<h4>" . LangSelectedObservationsTitle2 . "</h4>";
            echo "<hr />";
            echo "<table class=\"table sort-tablecometobservations table-condensed table-striped table-hover tablesorter custom-popup\">";
            echo "<thead><tr>";
            // OBJECT NAME
            echo "<th>" . LangOverviewObservationsHeader1 . "</th>";
            // OBSERVER
            echo "<th>" . LangOverviewObservationsHeader2 . "</th>";
            // DATE
            echo "<th>" . LangOverviewObservationsHeader4 . "</th>";
            // MAGNITUDE
            echo "<th>" . LangNewComet1 . "</th>";
            // INSTRUMENT
            echo "<th>" . LangViewObservationField3 . "</th>";
            // COMA
            echo "<th>" . LangViewObservationField19 . "</th>";
            // DC
            echo "<th>" . LangViewObservationField18b . "</th>";
            // TAIL
            echo "<th>" . LangViewObservationField20b . "</td>";
            echo "<th class=\"filter-false columnSelector-disable\" data-sorter=\"false\"></th></tr></thead>";
            $count = 0;
            while (list($key, $value) = each($obs)) {
                // OBJECT
                $object = $observations->getObjectId($value);
                // OBSERVER
                $observer = $observations->getObserverId($value);
                // INSTRUMENT
                $temp = $observations->getInstrumentId($value);
                $instrument = $instruments->getInstrumentPropertyFromId($temp, 'name');
                $instrumentsize = $instruments->getInstrumentPropertyFromId($temp, 'diameter');
                if ($instrument == "Naked eye") {
                    $instrument = InstrumentsNakedEye;
                }
                // MAGNITUDE
                $mag = $observations->getMagnitude($value);
                if ($mag < -90) {
                    $mag = '';
                } else {
                    $mag = sprintf("%2.01f", $mag);
                }
                // COMA
                $coma = $observations->getComa($value);
                if ($coma < -90) {
                    $coma = '';
                } else {
                    $coma = $coma . "'";
                }
                // DC
                $dc = $observations->getDc($value);
                if ($dc < -90) {
                    $dc = '';
                }
                // TAIL
                $tail = $observations->getTail($value);
                if ($tail > -90) {
                    $tail = $tail . "'";
                } else {
                    $tail = '';
                }
                // OUTPUT
                echo "<tr>\n\t            <td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_object&amp;object=" . urlencode($object) . "\">" . $objects->getName($object) . "</a></td>\n\t            <td><a href=\"" . $baseURL . "index.php?indexAction=detail_observer&amp;user="******"\">" . $observers->getObserverProperty($observer, 'firstname') . "&nbsp;" . $observers->getObserverProperty($observer, 'name') . "</a></td>\n\t            <td>";
                if ($instrument != InstrumentsNakedEye && $instrument != "") {
                    $instrument = $instrument . " (" . $instrumentsize . "&nbsp;mm" . ")";
                }
                if (!$observers->getObserverProperty($loggedUser, 'UT')) {
                    $date = sscanf($observations->getLocalDate($value), "%4d%2d%2d");
                } else {
                    $date = sscanf($observations->getDate($value), "%4d%2d%2d");
                }
                echo date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0]));
                // TIME
                if (!$observers->getObserverProperty($loggedUser, 'UT')) {
                    $time = sscanf(sprintf("%04d", $observations->getLocalTime($value)), "%2d%2d");
                } else {
                    $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d");
                }
                echo "&nbsp;(";
                printf("%02d", $time[0]);
                echo ":";
                printf("%02d", $time[1]);
                $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d");
                echo ")";
                echo "</td>\n\t            <td>{$mag}</td>\n\t            <td>{$instrument}</td>\n\t            <td>{$coma}</td>\n\t            <td>{$dc}</td>\n\t            <td>{$tail}</td>\n\t            <td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_observation&amp;observation=" . $value . "\">details";
                // LINK TO DRAWING (IF AVAILABLE)
                $upload_dir = 'cometdrawings';
                $dir = opendir($instDir . "comets/" . $upload_dir);
                while (FALSE !== ($file = readdir($dir))) {
                    if ("." == $file or ".." == $file) {
                        continue;
                        // skip current directory and directory above
                    }
                    if (fnmatch($value . "_resized.gif", $file) || fnmatch($value . "_resized.jpg", $file) || fnmatch($value . "_resized.png", $file)) {
                        echo "&nbsp;+&nbsp;";
                        echo LangDrawing;
                    }
                }
                echo "</a></td></tr>";
                $count++;
            }
            echo "</table>";
            $objUtil->addPager("cometobservations", $count);
            echo "<hr />";
            $_SESSION['observation_query'] = $obs;
            echo "<p><a class=\"btn btn-primary\" href=\"" . $baseURL . "cometobservations.pdf.php\" rel=\"external\"><span class=\"glyphicon glyphicon-download\"></span> " . LangExecuteQueryObjectsMessage4a . "</a>";
            echo "  <a class=\"btn btn-primary\" href=\"" . $baseURL . "cometobservations.icq\" rel=\"external\"><span class=\"glyphicon glyphicon-download\"></span> " . LangExecuteQueryObjectsMessage7 . "</a></p>";
        } else {
            echo "<p>" . LangObservationNoResults . "</p>";
        }
        echo "<p><a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=comets_query_observations\">" . LangObservationQueryError2 . "</a></p>";
    } else {
        echo "<p>" . LangObservationQueryError1 . "</p>";
        echo "<p><a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=comets_query_observations\">" . LangObservationQueryError2 . "</a>";
        echo " " . LangObservationOR . " ";
        echo "<a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=comets_all_observations\">" . LangObservationQueryError3 . "</a></p>";
    }
    echo "</div>";
}