function validate_change_object()
{
    global $entryMessage, $objObserver;
    $util = new Utils();
    $objects = new CometObjects();
    if (!$_POST['name']) {
        // error
        $entryMessage = LangValidateObservationMessage1;
        $_GET['indexAction'] = 'default_action';
    } else {
        if ($_POST['object']) {
            // only admins may change a comet
            $role = $objObserver->getObserverProperty($loggedUser, 'role', 2);
            if ($role == RoleAdmin || $role == RoleCometAdmin) {
                $name = $_POST['name'];
                $icqname = $_POST['icqname'];
                $objects->setName($_POST['object'], $name);
                $objects->setIcqName($_POST['object'], $icqname);
                $_GET['object'] = $_POST['object'];
                $_GET['indexAction'] = "default_action";
            } else {
                $_GET['object'] = $_POST['object'];
                $_GET['indexAction'] = 'default_action';
            }
        } else {
            $_GET['object'] = $_POST['object'];
            $_GET['indexAction'] = 'default_action';
        }
    }
}
function validate_object()
{
    global $entryMessage, $objUtil;
    $util = new Utils();
    if ($objUtil->checkPostKey('newobject')) {
        // check if required fields are filled in
        if (!$objUtil->checkPostKey('name')) {
            $entryMessage = LangValidateObjectMessage1;
            $_GET['indexAction'] = 'default_action';
        } else {
            $objects = new CometObjects();
            // control if object doesn't exist yet
            $name = $_POST['name'];
            $query1 = array("name" => $name);
            if (count($objects->getObjectFromQuery($query1, "name")) > 0) {
                $entryMessage = LangValidateObjectMessage2;
                $_GET['indexAction'] = 'default_action';
            } else {
                // fill database
                $id = $objects->addObject($name);
                if ($_POST['icqname']) {
                    $objects->setIcqName($id, $_POST['icqname']);
                }
                $_GET['indexAction'] = 'comets_detail_object';
                $_GET['object'] = $id;
            }
        }
    } elseif ($objUtil->checkPostKey('clearfields')) {
        $_GET['indexAction'] = 'comets_add_object';
    }
}
Ejemplo n.º 3
0
 function getObservationFromQuery($queries, $sort = "", $exactmatch = "1", $clubOnly = "True")
 {
     global $objDatabase;
     $observers = new Observers();
     $objects = new CometObjects();
     $locations = new Locations();
     $object = "";
     $sqland = 0;
     if (array_key_exists("object", $queries) && $queries["object"] != "") {
         if ($exactmatch == "1") {
             $alternative = $objects->getName($queries["object"]);
         } else {
             $objectList = $objects->getNameList($queries["object"]);
         }
         if ($object == "") {
             $object = $queries["object"];
         }
     }
     $sql = "SELECT cometobservations.* FROM cometobservations LEFT JOIN instruments on cometobservations.instrumentid=instruments.id LEFT JOIN cometobjects on cometobservations.objectid=cometobjects.id LEFT JOIN observers on cometobservations.observerid=observers.id where";
     if ($object != "") {
         if ($exactmatch == "1") {
             $sql = $sql . " (cometobjects.name = \"{$object}\")";
         } else {
             $sql = $sql . " (cometobjects.name like \"%{$object}%\"";
             if ($objectList == "") {
                 $sql = $sql . ")";
             } else {
                 while (list($key, $value) = each($objectList)) {
                     $sql = $sql . " or cometobjects.name = \"{$value}\"";
                 }
                 $sql = $sql . ")";
             }
         }
         $sqland = 1;
     }
     if (isset($queries["observer"]) && $queries["observer"] != "") {
         $observer = $queries["observer"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.observerid = \"{$observer}\"";
         $sqland = 1;
     }
     if (array_key_exists("instrument", $queries) && $queries["instrument"] != "") {
         $inst = $queries["instrument"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.instrumentid = \"{$inst}\"";
         $sqland = 1;
     }
     if (array_key_exists("mindiameter", $queries) && $queries["mindiameter"] != "") {
         $diam = $queries["mindiameter"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " instruments.diameter >= \"{$diam}\"";
         $sqland = 1;
     }
     if (array_key_exists("maxdiameter", $queries) && $queries["maxdiameter"] != "") {
         $diam = $queries["maxdiameter"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " instruments.diameter <= \"{$diam}\"";
         $sqland = 1;
     }
     if (isset($queries["location"]) && $queries["location"] != "") {
         $locs = $locations->getAllLocationsIds($queries["location"]);
         $loc = $queries["location"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " (cometobservations.locationid = \"{$locs['0']}\"";
         $i = 1;
         while ($i < count($locs)) {
             $sql = $sql . " || cometobservations.locationid = \"{$locs[$i]}\"";
             $i = $i + 1;
         }
         $sql = $sql . ") ";
         $sqland = 1;
     }
     if (array_key_exists("maxdate", $queries) && $queries["maxdate"] != "") {
         $date = $queries["maxdate"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.date <= \"{$date}\"";
         $sqland = 1;
     }
     if (array_key_exists("mindate", $queries) && $queries["mindate"] != "") {
         $date = $queries["mindate"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.date >= \"{$date}\"";
         $sqland = 1;
     }
     if (array_key_exists("description", $queries) && $queries["description"] != "") {
         $description = $queries["description"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.description like \"%{$description}%\"";
         $sqland = 1;
     }
     if (array_key_exists("minmag", $queries) && strcmp($queries["minmag"], "") != 0) {
         $mag = $queries["minmag"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " (cometobservations.mag > {$mag} or cometobservations.mag like {$mag})";
         $sqland = 1;
     }
     if (array_key_exists("maxmag", $queries) && strcmp($queries["maxmag"], "") != 0) {
         $mag = $queries["maxmag"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " (cometobservations.mag < {$mag} or cometobservations.mag like {$mag})";
         $sqland = 1;
     }
     if (array_key_exists("maxdc", $queries) && $queries["maxdc"] != "") {
         $dc = $queries["maxdc"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.dc <= {$dc}";
         $sqland = 1;
     }
     if (array_key_exists("mindc", $queries) && $queries["mindc"] != "") {
         $dc = $queries["mindc"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.dc >= {$dc}";
         $sqland = 1;
     }
     if (array_key_exists("maxcoma", $queries) && $queries["maxcoma"] != "") {
         $coma = $queries["maxcoma"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.coma <= {$coma}";
         $sqland = 1;
     }
     if (array_key_exists("mincoma", $queries) && $queries["mincoma"] != "") {
         $coma = $queries["mincoma"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.coma >= {$coma}";
         $sqland = 1;
     }
     if (array_key_exists("maxtail", $queries) && $queries["maxtail"] != "") {
         $tail = $queries["maxtail"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.tail <= {$tail}";
         $sqland = 1;
     }
     if (array_key_exists("mintail", $queries) && $queries["mintail"] != "") {
         $tail = $queries["mintail"];
         if ($sqland == 1) {
             $sql = $sql . " and";
         }
         $sql = $sql . " cometobservations.tail >= {$tail}";
         $sqland = 1;
     }
     if ($sort != "") {
         if ($sort == "inst") {
             $sort = "instruments.diameter, instruments.id";
         }
         if ($sort == "observerid") {
             $sort = "observers.name, observers.firstname";
         }
         if ($sort == "date") {
             $sort = $sort . ", time";
         } else {
             if ($sort == "objectid") {
                 $sort = "cometobjects.name";
             }
         }
         $sql = $sql . " order by {$sort}";
     }
     $sql = $sql . ";";
     $obs = $objDatabase->selectSingleArray($sql, "id");
     if (isset($obs)) {
         return $obs;
     } else {
         return null;
     }
 }
Ejemplo n.º 4
0
<?php

require_once "lib/cometobjects.php";
$obj = new CometObjects();
$observations = new CometObservations();
// Reading the file with the country codes.
$filename = "mycomsql.sql";
$fh = fopen($filename, "r") or die("Could not open comets file");
while (!feof($fh)) {
    $data = fgets($fh);
    $vars = explode("', '", $data);
    if ($vars[13] == "ADIE") {
        // Alfons Diepvens
        $observerid = 'vvs00346';
    } else {
        if ($vars[13] == "FLOO") {
            // Frans van Loo
            $observerid = 'vvs00824';
        } else {
            if ($vars[13] == "DVST") {
                // David Vansteelant
                $observerid = 'ambetanterik';
            } else {
                if ($vars[13] == "KVDA") {
                    // Koen Van der Auwera
                    $observerid = 'kvda';
                } else {
                    if ($vars[13] == "PSCH") {
                        // Peter De Schrijver
                        $observerid = 'vvs03972';
                    } else {
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=" . urlencode($observer) . "\">" . $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=" . $_GET['user'];
        echo "<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>";
    }
}
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=" . urlencode($observer) . "\">" . $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>";
}