예제 #1
0
 public function valideAccount()
 {
     global $entryMessage, $objUtil, $objLanguage, $developversion, $loggedUser, $allLanguages, $mailTo, $mailFrom, $objMessages, $baseURL;
     if (!$_POST['email'] || !$_POST['firstname'] || !$_POST['name'] || !$_POST['passwd'] || !$_POST['passwd_again']) {
         $entryMessage .= LangValidateAccountMessage1;
         if ($objUtil->checkPostKey('change')) {
             $_GET['indexAction'] = 'change_account';
         } else {
             $_GET['indexAction'] = 'subscribe';
         }
     } elseif ($_POST['passwd'] != $_POST['passwd_again']) {
         $entryMessage .= LangValidateAccountMessage2;
         if ($objUtil->checkPostKey('change')) {
             $_GET['indexAction'] = 'change_account';
         } else {
             $_GET['indexAction'] = 'subscribe';
         }
     } elseif ($_POST['firstname'] == $_POST['name']) {
         $entryMessage .= LangValidateAccountMessage6;
         if ($objUtil->checkPostKey('change')) {
             $_GET['indexAction'] = 'change_account';
         } else {
             $_GET['indexAction'] = 'subscribe';
         }
     } elseif (array_key_exists('motivation', $_POST) && $_POST['motivation'] == '' && !$loggedUser) {
         $entryMessage .= LangValidateAccountMessage7;
         if ($objUtil->checkPostKey('change')) {
             $_GET['indexAction'] = 'change_account';
         } else {
             $_GET['indexAction'] = 'subscribe';
         }
     } elseif (!preg_match("/.*@.*..*/", $_POST['email']) | preg_match("/(<|>)/", $_POST['email'])) {
         $entryMessage .= LangValidateAccountMessage3;
         // check if email address is legal (contains @ symbol)
         if ($objUtil->checkPostKey('change')) {
             $_GET['indexAction'] = 'change_account';
         } else {
             $_GET['indexAction'] = 'subscribe';
         }
     } elseif (array_key_exists('register', $_POST) && array_key_exists('deepskylog_id', $_POST) && $_POST['register'] && $_POST['deepskylog_id']) {
         if ($this->getObserverProperty($_POST['deepskylog_id'], 'name')) {
             $entryMessage .= LangValidateAccountMessage4;
             // check if email address is legal (contains @ symbol)
             if ($objUtil->checkPostKey('change')) {
                 $_GET['indexAction'] = 'change_account';
             } else {
                 $_GET['indexAction'] = 'subscribe';
             }
         } else {
             $this->addObserver($_POST['deepskylog_id'], $_POST['name'], $_POST['firstname'], $_POST['email'], md5($_POST['passwd']));
             $allLanguages = $objLanguage->getAllLanguages($_SESSION['lang']);
             // READ ALL THE LANGUAGES FROM THE CHECKBOXES
             while (list($key, $value) = each($allLanguages)) {
                 if (array_key_exists($key, $_POST)) {
                     $usedLanguages[] = $key;
                 }
             }
             $this->setUsedLanguages($_POST['deepskylog_id'], $usedLanguages);
             $this->setObserverProperty($_POST['deepskylog_id'], 'copyright', $_POST['copyright']);
             $this->setObserverProperty($_POST['deepskylog_id'], 'observationlanguage', $_POST['description_language']);
             $this->setObserverProperty($_POST['deepskylog_id'], 'language', $_POST['language']);
             $this->setObserverProperty($_POST['deepskylog_id'], 'registrationDate', date("Ymd H:i"));
             $body = LangValidateAccountEmailLine1 . "\n" . "\n" . LangValidateAccountEmailLine1bis . $_POST['deepskylog_id'] . "\n" . LangValidateAccountEmailLine2 . $_POST['email'] . "\n" . LangValidateAccountEmailLine3 . html_entity_decode($_POST['firstname']) . " " . html_entity_decode($_POST['name']) . "\n\n" . LangValidateAccountEmailLine4 . "\n\n" . html_entity_decode($_POST['motivation']);
             if (isset($developversion) && $developversion == true) {
                 $entryMessage .= "On the live server, a mail would be sent with the subject: " . LangValidateAccountEmailTitle . ".<p>";
             } else {
                 mail($mailTo, LangValidateAccountEmailTitle, $body, "From:" . $mailFrom);
             }
             $entryMessage = LangAccountSubscribed1 . LangAccountSubscribed2 . LangAccountSubscribed3 . LangAccountSubscribed4 . LangAccountSubscribed5 . LangAccountSubscribed6 . LangAccountSubscribed7 . LangAccountSubscribed8 . LangAccountSubscribed9;
             $_GET['user'] = $_POST['deepskylog_id'];
             $_GET['indexAction'] = 'detail_observer';
         }
     } elseif ($objUtil->checkPostKey('change')) {
         if (!$loggedUser) {
             $entryMessage .= LangValidateAccountMessage1;
             $_GET['indexAction'] = 'change_account';
         } else {
             $usedLanguages = array();
             while (list($key, $value) = each($allLanguages)) {
                 if (array_key_exists($key, $_POST)) {
                     $usedLanguages[] = $key;
                 }
             }
             $this->setUsedLanguages($loggedUser, $usedLanguages);
             $this->setObserverProperty($loggedUser, 'name', $_POST['name']);
             $this->setObserverProperty($loggedUser, 'firstname', $_POST['firstname']);
             $this->setObserverProperty($loggedUser, 'email', $_POST['email']);
             $this->setObserverProperty($loggedUser, 'password', md5($_POST['passwd']));
             $this->setObserverProperty($loggedUser, 'language', $_POST['language']);
             $this->setObserverProperty($loggedUser, 'observationlanguage', $_POST['description_language']);
             $this->setObserverProperty($loggedUser, 'stdlocation', $_POST['site']);
             $this->setObserverProperty($loggedUser, 'stdtelescope', $_POST['instrument']);
             $this->setObserverProperty($loggedUser, 'standardAtlasCode', $_POST['atlas']);
             $this->setObserverProperty($loggedUser, 'fstOffset', $_POST['fstOffset']);
             $this->setObserverProperty($loggedUser, 'overviewFoV', $_POST['overviewFoV']);
             $this->setObserverProperty($loggedUser, 'lookupFoV', $_POST['lookupFoV']);
             $this->setObserverProperty($loggedUser, 'detailFoV', $_POST['detailFoV']);
             $this->setObserverProperty($loggedUser, 'overviewdsos', $_POST['overviewdsos']);
             $this->setObserverProperty($loggedUser, 'lookupdsos', $_POST['lookupdsos']);
             $this->setObserverProperty($loggedUser, 'detaildsos', $_POST['detaildsos']);
             $this->setObserverProperty($loggedUser, 'overviewstars', $_POST['overviewstars']);
             $this->setObserverProperty($loggedUser, 'lookupstars', $_POST['lookupstars']);
             $this->setObserverProperty($loggedUser, 'detailstars', $_POST['detailstars']);
             $this->setObserverProperty($loggedUser, 'atlaspagefont', $_POST['atlaspagefont']);
             $this->setObserverProperty($loggedUser, 'photosize1', $_POST['photosize1']);
             $this->setObserverProperty($loggedUser, 'photosize2', $_POST['photosize2']);
             $this->setObserverProperty($loggedUser, 'copyright', $_POST['copyright']);
             $this->setObserverProperty($loggedUser, 'UT', array_key_exists('local_time', $_POST) && $_POST['local_time'] == "on" ? "0" : "1");
             $this->setObserverProperty($loggedUser, 'sendMail', array_key_exists('send_mail', $_POST) && $_POST['send_mail'] == "on" ? "1" : "0");
             if ($_POST['icq_name'] != "") {
                 $this->setObserverProperty($loggedUser, 'icqname', $_POST['icq_name']);
             }
             $_SESSION['lang'] = $_POST['language'];
             if ($_FILES['picture']['tmp_name'] != "") {
                 $upload_dir = 'common/observer_pics';
                 $dir = opendir($upload_dir);
                 require_once $instDir . "common/control/resize.php";
                 // resize code
                 $original_image = $_FILES['picture']['tmp_name'];
                 $destination_image = $upload_dir . "/" . $loggedUser . ".jpg";
                 $new_image = image_createThumb($original_image, $destination_image, 300, 300, 75);
             }
             $entryMessage .= LangValidateAccountMessage5;
             $_GET['user'] = $loggedUser;
             $_GET['indexAction'] = 'change_account';
         }
     }
 }
예제 #2
0
 public function validateChangeSession()
 {
     global $loggedUser, $objUtil, $objLocation;
     if (!$loggedUser) {
         throw new Exception(LangMessageNotLoggedIn);
     }
     $sessionid = $objUtil->checkRequestKey('sessionid');
     // The observers
     $observers = array();
     $count = array_count_values($_POST['addedObserver']);
     if (isset($_POST['deletedObserver'])) {
         $countRemoved = array_count_values($_POST['deletedObserver']);
     } else {
         $countRemoved = array();
     }
     foreach ($count as $k => $v) {
         $val = $v;
         $val2 = 0;
         if (array_key_exists($k, $countRemoved)) {
             $val2 = $countRemoved[$k];
         }
         if ($val - $val2 == 1) {
             $observers[] = $k;
         }
     }
     // Add the new location if needed
     // Location of the session
     $sites = $objLocation->getSortedLocationsList("name", $loggedUser, 1);
     $theLoc = $this->getSessionPropertyFromId($objUtil->checkRequestKey('sessionid'), 'locationid');
     $theLocName = $objLocation->getLocationPropertyFromId($theLoc, "name");
     $found = 1;
     // Check if the number is owned by the loggedUser
     if ($objLocation->getLocationPropertyFromId($theLoc, "observer") != $loggedUser) {
         $found = 0;
         for ($i = 0; $i < count($sites); $i++) {
             if (strcmp($sites[$i][1], $theLocName) == 0) {
                 $theLoc = $sites[$i][0];
                 $found = 1;
             }
         }
     }
     if ($found == 0) {
         $id = $objLocation->addLocation($theLocName, $objLocation->getLocationPropertyFromId($theLoc, "longitude"), $objLocation->getLocationPropertyFromId($theLoc, "latitude"), $objLocation->getLocationPropertyFromId($theLoc, "country"), $objLocation->getLocationPropertyFromId($theLoc, "timezone"));
         $objLocation->setLocationProperty($id, "limitingMagnitude", $objLocation->getLocationPropertyFromId($theLoc, "limitingMagnitude"));
         $objLocation->setLocationProperty($id, "skyBackground", $objLocation->getLocationPropertyFromId($theLoc, "skyBackground"));
         $objLocation->setLocationProperty($id, "observer", $loggedUser);
         $objLocation->setLocationProperty($id, "locationactive", 1);
         $site = $id;
     } else {
         $site = $_POST['site'];
     }
     $current_session = $this->addSession($_POST['sessionname'], $_POST['beginday'], $_POST['beginmonth'], $_POST['beginyear'], $_POST['beginhours'], $_POST['beginminutes'], $_POST['endday'], $_POST['endmonth'], $_POST['endyear'], $_POST['endhours'], $_POST['endminutes'], $site, $_POST['weather'], $_POST['equipment'], $_POST['comments'], $_POST['description_language'], $observers, $sessionid);
     if ($_FILES['picture']['tmp_name'] != "") {
         $upload_dir = $instDir . 'deepsky/sessions';
         $dir = opendir($upload_dir);
         $original_image = $_FILES['picture']['tmp_name'];
         $destination_image = $upload_dir . "/" . $current_session . "_resized.jpg";
         require_once $instDir . "common/control/resize.php";
         // resize code
         $new_image = image_createThumb($original_image, $destination_image, 490, 490, 100);
         move_uploaded_file($_FILES['picture']['tmp_name'], $upload_dir . "/" . $current_session . ".jpg");
     }
 }
function validate_observation()
{
    global $instDir, $entryMessage, $loggedUser, $maxFileSize, $objObserver, $objCometObservation, $objCometObject, $objUtil;
    if ($loggedUser) {
        if ($_POST['addobservation']) {
            if (!$_POST['day'] || !$_POST['month'] || !$_POST['year'] || !$_POST['comet'] || !$_POST['hours'] && strcmp($_POST['hours'], 0) != "0" || !$_POST['minutes'] && strcmp($_POST['minutes'], 0) != "0") {
                // user forgot required field
                $entryMessage = LangValidateObservationMessage1;
                $_GET['indexAction'] = 'default_action';
            } else {
                if ($_FILES['drawing']['size'] > $maxFileSize) {
                    $entryMessage = LangValidateObservationMessage6;
                    $_GET['indexAction'] = 'default_action';
                } else {
                    $date = $_POST['year'] . sprintf("%02d", $_POST['month']) . sprintf("%02d", $_POST['day']);
                    if ($_POST['hours'] != "") {
                        if (isset($_POST['minutes'])) {
                            $time = $_POST['hours'] * 100 + $_POST['minutes'];
                        } else {
                            $time = $_POST['hours'] * 100;
                        }
                    }
                    // add observation to database
                    $current_observation = $objCometObservation->addObservation($objCometObject->getId($_POST['comet']), $loggedUser, $date, $time);
                    $objCometObservation->setLocationId($current_observation, $_POST['site']);
                    if (!$objObserver->getObserverProperty($loggedUser, 'UT')) {
                        $objCometObservation->setLocalDateAndTime($current_observation, $date, $time);
                    }
                    $objCometObservation->setDescription($current_observation, nl2br(htmlentities($_POST['description'])));
                    $objCometObservation->setInstrumentId($current_observation, $_POST['instrument']);
                    $objCometObservation->setComa($current_observation, $objUtil->checkRequestKey('coma', -99));
                    $objCometObservation->setTail($current_observation, $objUtil->checkRequestKey('tail_length', -99));
                    $objCometObservation->setPa($current_observation, $objUtil->checkRequestKey('position_angle', -99));
                    // MAGNITUDE AND RELATED FIELDS
                    if (array_key_exists('mag', $_POST)) {
                        if (preg_match('/^([0-9]{1,2})[.,]{0,1}([0-9]{0,1})$/', $_POST['mag'], $matches)) {
                            $magnitude = "" . $matches[1] . ".";
                            if ($matches[2] != "") {
                                $magnitude = $magnitude . $matches[2];
                            } else {
                                $magnitude = $magnitude . "0";
                            }
                            $objCometObservation->setMagnitude($current_observation, $magnitude);
                            if (array_key_exists('uncertain', $_POST)) {
                                $objCometObservation->setMagnitudeUncertain($current_observation, 1);
                            } else {
                                $objCometObservation->setMagnitudeUncertain($current_observation, 0);
                            }
                            $objCometObservation->setMagnitudeWeakerThan($current_observation, $_POST['smaller']);
                        } else {
                            $objCometObservation->setMagnitude($current_observation, -99.90000000000001);
                            $objCometObservation->setMagnitudeUncertain($current_observation, 0);
                            $objCometObservation->setMagnitudeWeakerThan($current_observation, 0);
                        }
                    } else {
                        $objCometObservation->setMagnitude($current_observation, -99.90000000000001);
                        $objCometObservation->setMagnitudeUncertain($current_observation, 0);
                        $objCometObservation->setMagnitudeWeakerThan($current_observation, 0);
                    }
                    $objCometObservation->setChart($current_observation, $_POST['icq_reference_key']);
                    $objCometObservation->setMagnification($current_observation, $_POST['magnification']);
                    $objCometObservation->setMethode($current_observation, $_POST['icq_method']);
                    $objCometObservation->setDc($current_observation, $_POST['condensation']);
                    if ($_FILES['drawing']['tmp_name'] != "") {
                        $upload_dir = 'cometdrawings';
                        $dir = opendir($instDir . "comets/" . $upload_dir);
                        // resize code
                        require_once "common/control/resize.php";
                        $original_image = $_FILES['drawing']['tmp_name'];
                        $destination_image = $instDir . 'comets/' . $upload_dir . "/" . $current_observation . "_resized.jpg";
                        $new_image = image_createThumb($original_image, $destination_image, 490, 490, 100);
                        move_uploaded_file($_FILES['drawing']['tmp_name'], $instDir . 'comets/' . $upload_dir . "/" . $current_observation . ".jpg");
                        $objCometObservation->setDrawing($current_observation);
                    }
                    // save current details for faster submission of multiple observations
                    $_SESSION['year'] = $_POST['year'];
                    // save current year
                    $_SESSION['month'] = $_POST['month'];
                    // save current month
                    $_SESSION['day'] = $_POST['day'];
                    // save current day
                    $_SESSION['instrument'] = $_POST['instrument'];
                    // save current instrument for new observations
                    $_SESSION['location'] = $_POST['site'];
                    // save current location
                    $_SESSION['savedata'] = "yes";
                    // session variable to tag multiple observations
                    $_SESSION['observation_query'] = "";
                    $_GET['indexAction'] = 'comets_detail_observation';
                    $_GET['observation'] = $current_observation;
                    $_GET['new'] = "yes";
                }
            }
        } elseif ($_POST['clearfields']) {
            $_SESSION['savedata'] = "no";
            $_GET['indexAction'] = "add_observation";
        }
    } else {
        $_GET['indexAction'] = "default_action";
    }
}
예제 #4
0
 public function validateObservation()
 {
     global $loggedUser, $objUtil, $objObservation, $objObserver, $maxFileSize, $entryMessage, $objPresentations, $inIndex, $instDir, $objSession, $objAccomplishments;
     if (!$loggedUser) {
         throw new Exception(LangException002b);
     } elseif ($objUtil->checkSessionKey('addObs', 0) != $objUtil->checkPostKey('timestamp', -1)) {
         $_GET['indexAction'] = "default_action";
         $_GET['dalm'] = 'D';
         // $_GET['observation']=$current_observation;
     } elseif (!$_POST['day'] || !$_POST['month'] || !$_POST['year'] || $_POST['site'] == "1" || !$_POST['instrument'] || !$_POST['description']) {
         if ($objUtil->checkPostKey('limit')) {
             if (ereg('([0-9]{1})[.,]{0,1}([0-9]{0,1})', $_POST['limit'], $matches)) {
                 // limiting magnitude like X.X or X,X with X a number between 0 and 9
                 $_POST['limit'] = $matches[1] . "." . ($matches[2] ? $matches[2] : "0");
             } else {
                 $_POST['limit'] = 0;
             }
         } else {
             if ($objUtil->checkPostKey('sqm')) {
                 if (ereg('([0-9]{1})([0-9]{1})[.,]{0,1}([0-9]{0,1})', $_POST['sqm'], $matches)) {
                     // sqm value
                     $_POST['sqm'] = $matches[1] . $matches[2] . "." . ($matches[3] ? $matches[3] : "0");
                 } else {
                     $_POST['sqm'] = -1;
                 }
             } else {
                 $_POST['limit'] = 0;
                 $_POST['sqm'] = -1;
             }
         }
         $entryMessage .= LangValidateObservationMessage1;
         $_GET['indexAction'] = 'add_observation';
     } else {
         $time = -9999;
         if (strlen($_POST['hours'])) {
             if (isset($_POST['minutes'])) {
                 $time = $_POST['hours'] * 100 + $_POST['minutes'];
             } else {
                 $time = $_POST['hours'] * 100;
             }
         }
         if ($_FILES['drawing']['size'] > $maxFileSize) {
             $entryMessage .= LangValidateObservationMessage6;
             $_GET['indexAction'] = 'add_observation';
         } elseif (!is_numeric($_POST['month']) || !is_numeric($_POST['day']) || !is_numeric($_POST['year']) || !checkdate($_POST['month'], $_POST['day'], $_POST['year']) || sprintf("%04d", $_POST['year']) . sprintf("%02d", $_POST['month']) . sprintf("%02d", $_POST['day']) < '19500000' || sprintf("%04d", $_POST['year']) . sprintf("%02d", $_POST['month']) . sprintf("%02d", $_POST['day']) > date('Ymd', strtotime('+1 day'))) {
             $entryMessage .= LangValidateObservationMessage2;
             $_GET['indexAction'] = 'add_observation';
         } elseif (($date = $_POST['year'] . sprintf("%02d", $_POST['month']) . sprintf("%02d", $_POST['day'])) > date('Ymd')) {
             $entryMessage .= LangValidateObservationMessage3;
             $_GET['indexAction'] = 'add_observation';
         } elseif ($time > -9999 && (!is_numeric($_POST['hours']) || !is_numeric($_POST['minutes']) || $_POST['hours'] < 0 || $_POST['hours'] > 23 || $_POST['minutes'] < 0 || $_POST['minutes'] > 59)) {
             $entryMessage .= LangValidateObservationMessage4;
             $_GET['indexAction'] = 'add_observation';
         } else {
             if ($objUtil->checkPostKey('limit')) {
                 if (ereg('([0-9]{1})[.,]{0,1}([0-9]{0,1})', $_POST['limit'], $matches)) {
                     // limiting magnitude like X.X or X,X with X a number between 0 and 9
                     $_POST['limit'] = $matches[1] . "." . ($matches[2] ? $matches[2] : "0");
                 } else {
                     // clear current magnitude limit
                     $_POST['limit'] = "";
                 }
             }
             if ($_POST['observationid']) {
                 $current_observation = $_POST['observationid'];
                 if (!$objUtil->checkAdminOrUserID($objObservation->getDsObservationProperty($current_observation, 'observerid'))) {
                     $indexAction = '';
                     return;
                 } else {
                     $objObservation->setDsObservationProperty($current_observation, 'instrumentid', $_POST['instrument']);
                     $objObservation->setDsObservationProperty($current_observation, 'locationid', $_POST['site']);
                     $objObservation->setDsObservationProperty($current_observation, 'date', $date);
                     $objObservation->setDsObservationProperty($current_observation, 'time', $time);
                     $objObservation->setDsObservationProperty($current_observation, 'description', nl2br($_POST['description']));
                     $objObservation->setDsObservationProperty($current_observation, 'seeing', $_POST['seeing']);
                     $objObservation->setDsObservationProperty($current_observation, 'limmag', $objUtil->checkPostKey('limit', 0));
                     $objObservation->setDsObservationProperty($current_observation, 'visibility', $objUtil->checkPostKey('visibility'));
                     $objObservation->setDsObservationProperty($current_observation, 'language', $_POST['description_language']);
                 }
             } else {
                 $current_observation = $objObservation->addDSObservation($_POST['object'], $loggedUser, $_POST['instrument'], $_POST['site'], $date, $time, nl2br($_POST['description']), $_POST['seeing'], $_POST['limit'], $objUtil->checkPostKey('visibility'), $_POST['description_language']);
             }
             $_SESSION['addObs'] = '';
             $_SESSION['Qobs'] = array();
             $_SESSION['QobsParams'] = array();
             if ($objUtil->checkPostKey('sqm')) {
                 if (ereg('([0-9]{1})([0-9]{0,1})[.,]{0,1}([0-9]{0,1})', $_POST['sqm'], $matches)) {
                     // sqm value
                     $_POST['sqm'] = $matches[1] . $matches[2] . "." . ($matches[3] ? $matches[3] : "0");
                 } else {
                     $_POST['sqm'] = "";
                 }
             }
             // clear current magnitude limit
             if ($objUtil->checkPostKey('largeDiam')) {
                 if (ereg('([0-9]+)[.,]{0,1}([0-9]{0,1})', $_POST['largeDiam'], $matches)) {
                     // large diameter
                     $_POST['largeDiam'] = ($matches[1] ? $matches[1] : "0") . "." . ($matches[2] ? $matches[2] : "0");
                 } else {
                     // clear current large diameter
                     $_POST['largeDiam'] = "";
                 }
             }
             if ($objUtil->checkPostKey('smallDiam')) {
                 if (ereg('([0-9]+)[.,]{0,1}([0-9]{0,1})', $_POST['smallDiam'], $matches)) {
                     // large diameter
                     $_POST['smallDiam'] = ($matches[1] ? $matches[1] : "0") . "." . ($matches[2] ? $matches[2] : "0");
                 } else {
                     // clear current large diameter
                     $_POST['smallDiam'] = "";
                 }
             }
             if ($_POST['smallDiam'] > $_POST['largeDiam']) {
                 $tmp = $_POST['largeDiam'];
                 $_POST['largeDiam'] = $_POST['smallDiam'];
                 $_POST['smallDiam'] = $tmp;
             }
             if ($objUtil->checkPostKey('size_units') == "min") {
                 $_POST['smallDiam'] = $_POST['smallDiam'] * 60.0;
                 $_POST['largeDiam'] = $_POST['largeDiam'] * 60.0;
             }
             if ($_POST['sqm']) {
                 $objObservation->setDsObservationProperty($current_observation, 'SQM', preg_replace("/,/", ".", $objUtil->checkPostKey('sqm', -1)));
             }
             if ($_POST['smallDiam']) {
                 $objObservation->setDsObservationProperty($current_observation, 'smallDiameter', $_POST['smallDiam']);
             }
             if ($_POST['largeDiam']) {
                 $objObservation->setDsObservationProperty($current_observation, 'largeDiameter', $_POST['largeDiam']);
             }
             if (array_key_exists('stellarextended', $_POST) && $_POST['stellarextended'] == "stellar") {
                 $objObservation->setDsObservationProperty($current_observation, 'stellar', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'stellar', -1);
             }
             if (array_key_exists('stellarextended', $_POST) && $_POST['stellarextended'] == "extended") {
                 $objObservation->setDsObservationProperty($current_observation, 'extended', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'extended', -1);
             }
             if (array_key_exists('resolved', $_POST)) {
                 $objObservation->setDsObservationProperty($current_observation, 'resolved', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'resolved', -1);
             }
             if (array_key_exists('mottled', $_POST)) {
                 $objObservation->setDsObservationProperty($current_observation, 'mottled', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'mottled', -1);
             }
             if (array_key_exists('unusualShape', $_POST)) {
                 $objObservation->setDsObservationProperty($current_observation, 'unusualShape', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'unusualShape', -1);
             }
             if (array_key_exists('partlyUnresolved', $_POST)) {
                 $objObservation->setDsObservationProperty($current_observation, 'partlyUnresolved', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'partlyUnresolved', -1);
             }
             if (array_key_exists('colorContrasts', $_POST)) {
                 $objObservation->setDsObservationProperty($current_observation, 'colorContrasts', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'colorContrasts', -1);
             }
             if (array_key_exists('equalBrightness', $_POST)) {
                 $objObservation->setDsObservationProperty($current_observation, 'equalBrightness', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'equalBrightness', -1);
             }
             if (array_key_exists('niceField', $_POST)) {
                 $objObservation->setDsObservationProperty($current_observation, 'niceField', 1);
             } else {
                 $objObservation->setDsObservationProperty($current_observation, 'niceField', -1);
             }
             if ($_POST['filter']) {
                 $objObservation->setDsObservationProperty($current_observation, 'filterid', $_POST['filter']);
             }
             if ($_POST['lens']) {
                 $objObservation->setDsObservationProperty($current_observation, 'lensid', $_POST['lens']);
             }
             if ($_POST['eyepiece']) {
                 $objObservation->setDsObservationProperty($current_observation, 'eyepieceid', $_POST['eyepiece']);
             }
             if ($_POST['magnification']) {
                 $objObservation->setDsObservationProperty($current_observation, 'magnification', $_POST['magnification']);
             }
             if (!$objObserver->getObserverProperty($loggedUser, 'UT')) {
                 $objObservation->setLocalDateAndTime($current_observation, $date, $time);
             }
             $objObservation->setDsObservationProperty($current_observation, 'clusterType', $objUtil->checkPostKey('clusterType'));
             $objObservation->setDsObservationProperty($current_observation, 'component1', $objUtil->checkPostKey('component1', -1));
             $objObservation->setDsObservationProperty($current_observation, 'component2', $objUtil->checkPostKey('component2', -1));
             if ($_FILES['drawing']['tmp_name'] != "") {
                 $upload_dir = $instDir . 'deepsky/drawings';
                 $dir = opendir($upload_dir);
                 $original_image = $_FILES['drawing']['tmp_name'];
                 $destination_image = $upload_dir . "/" . $current_observation . "_resized.jpg";
                 require_once $instDir . "common/control/resize.php";
                 // resize code
                 $new_image = image_createThumb($original_image, $destination_image, 490, 490, 100);
                 move_uploaded_file($_FILES['drawing']['tmp_name'], $upload_dir . "/" . $current_observation . ".jpg");
                 $objObservation->setDsObservationProperty($current_observation, 'hasDrawing', 1);
             }
             // Add the observation to all the sessions
             $objSession->addObservationToSessions($current_observation);
             // Recalculate the accomplishments
             $objAccomplishments->recalculateDeepsky($loggedUser);
             $_SESSION['newObsYear'] = $_POST['year'];
             // save current details for faster submission of multiple observations
             $_SESSION['newObsMonth'] = $_POST['month'];
             $_SESSION['newObsDay'] = $_POST['day'];
             $_SESSION['newObsInstrument'] = $_POST['instrument'];
             $_SESSION['newObsLocation'] = $_POST['site'];
             $_SESSION['newObsLimit'] = $_POST['limit'];
             $_SESSION['newObsSqm'] = $_POST['sqm'];
             $_SESSION['newObsSQM'] = $_POST['sqm'];
             $_SESSION['newObsSeeing'] = $_POST['seeing'];
             $_SESSION['newObsLanguage'] = $_POST['description_language'];
             $_SESSION['newObsSavedata'] = "yes";
             $_GET['indexAction'] = "detail_observation";
             $_GET['dalm'] = 'D';
             $_GET['observation'] = $current_observation;
         }
     }
 }
function validate_change_observation()
{
    global $instDir, $entryMessage, $maxFileSize, $loggedUser, $objObserver, $objCometObservation, $objUtil;
    if (!$_POST['day'] || !$_POST['month'] || !$_POST['year'] || !$_POST['hours'] && strcmp($_POST['hours'], 0) != "0" || !$_POST['minutes'] && strcmp($_POST['minutes'], 0) != "0") {
        $entryMessage = LangValidateObservationMessage1;
        $_GET['indexAction'] = 'default_action';
    } elseif ($_FILES['drawing']['size'] > $maxFileSize) {
        $entryMessage = LangValidateObservationMessage6;
        $_GET['indexAction'] = 'default_action';
    } elseif ($_POST['observation']) {
        // only admins may change a comet observation
        $role = $objObserver->getObserverProperty($loggedUser, 'role', 2);
        if ($role == RoleAdmin || $role == RoleCometAdmin) {
            $date = $_POST['year'] . sprintf("%02d", $_POST['month']) . sprintf("%02d", $_POST['day']);
            $time = $_POST['hours'] * 100 + $_POST['minutes'];
            $objCometObservation->setDescription($_POST['observation'], nl2br(htmlentities($_POST['description'])));
            $objCometObservation->setLocationId($_POST['observation'], $_POST['site']);
            if (!$objObserver->getObserverProperty($loggedUser, 'UT')) {
                $objCometObservation->setLocalDateAndTime($_POST['observation'], $date, $time);
            } else {
                $objCometObservation->setTime($_POST['observation'], $time);
                $objCometObservation->setDate($_POST['observation'], $date);
            }
            $objCometObservation->setInstrumentId($_POST['observation'], $_POST['instrument']);
            $objCometObservation->setComa($_POST['observation'], $objUtil('coma', -99));
            $objCometObservation->setTail($_POST['observation'], $objUtil->checkRequestKey('tail_length', -99));
            $objCometObservation->setPa($_POST['observation'], $objUtil->checkRequestKey('position_angle', -99));
            $objCometObservation->setChart($_POST['observation'], $objUtil->checkRequestKey('icq_reference_key'));
            $objCometObservation->setMagnification($_POST['observation'], $objUtil->checkRequestKey('magnification'));
            $objCometObservation->setMethode($_POST['observation'], $objUtil->checkRequestKey('icq_method'));
            $objCometObservation->setDc($_POST['observation'], $objUtil->checkRequestKey('condensation'));
            if ($_POST['mag']) {
                if (ereg('^([0-9]{1,2})[.,]{0,1}([0-9]{0,1})$', $_POST['mag'], $matches)) {
                    $magnitude = "" . $matches[1] . ".";
                    if ($matches[2] != "") {
                        $magnitude = $magnitude . $matches[2];
                    } else {
                        $magnitude = $magnitude . "0";
                    }
                    $objCometObservation->setMagnitude($_POST['observation'], $magnitude);
                    if ($_POST['uncertain']) {
                        $objCometObservation->setMagnitudeUncertain($_POST['observation'], 1);
                    } else {
                        $objCometObservation->setMagnitudeUncertain($_POST['observation'], 0);
                    }
                    $objCometObservation->setMagnitudeWeakerThan($_POST['observation'], $_POST['smaller']);
                } else {
                    $objCometObservation->setMagnitude($_POST['observation'], -99.90000000000001);
                    $objCometObservation->setMagnitudeUncertain($_POST['observation'], 0);
                    $objCometObservation->setMagnitudeWeakerThan($_POST['observation'], 0);
                }
            } else {
                $objCometObservation->setMagnitude($_POST['observation'], -99.90000000000001);
                $objCometObservation->setMagnitudeUncertain($_POST['observation'], 0);
                $objCometObservation->setMagnitudeWeakerThan($_POST['observation'], 0);
            }
            if ($_FILES['drawing']['tmp_name'] != "") {
                $upload_dir = 'cometdrawings';
                $dir = opendir($instDir . "comets/" . $upload_dir);
                // resize code
                require_once "common/control/resize.php";
                $original_image = $_FILES['drawing']['tmp_name'];
                $destination_image = $instDir . "comets/" . $upload_dir . "/" . $_POST['observation'] . "_resized.jpg";
                $new_image = image_createThumb($original_image, $destination_image, 490, 490, 100);
                move_uploaded_file($_FILES['drawing']['tmp_name'], $instDir . "comets/" . $upload_dir . "/" . $_POST['observation'] . ".jpg");
                $objCometObservation->setDrawing($current_observation);
            }
            // save current details for faster submission of multiple observations
            $_SESSION['year'] = $_POST['year'];
            // save current year
            $_SESSION['month'] = $_POST['month'];
            // save current month
            $_SESSION['day'] = $_POST['day'];
            // save current day
            $_SESSION['instrument'] = $_POST['instrument'];
            // save current instrument for new observations
            $_SESSION['location'] = $_POST['site'];
            // save current location
            $_SESSION['seeing'] = $_POST['seeing'];
            // save current seeing
            $_SESSION['savedata'] = "yes";
            // session variable to tag multiple observations
            $_GET['indexAction'] = 'comets_detail_observation';
            $_GET['observation'] = $_POST['observation'];
            $_GET['new'] = "yes";
        } else {
            unset($_SESSION['deepskylog_id']);
            $_GET['indexAction'] = 'default_action';
        }
    } else {
        unset($_SESSION['deepskylog_id']);
        $_GET['indexAction'] = 'default_action';
    }
}