Esempio n. 1
0
 protected function getPlottableParams()
 {
     $kinst = $_REQUEST['kinst'];
     if (!$kinst) {
         print "plottable params query failed, must specify kinst\n";
         exit(0);
     }
     // need to connect to the database here in order to run the
     // function mysql_real_escape_string
     $isconnected = $this->cedarconnect();
     if ($isconnected != "good") {
         print "{$isconnected}\n";
         exit(0);
     }
     $kinst = mysql_real_escape_string(trim($kinst));
     $query = "SELECT DISTINCT parameter_id, plot_func ";
     $query .= "FROM tbl_plotting_params ";
     $query .= "WHERE kinst='{$kinst}'";
     //print( "$query\n" ) ;
     $result = parent::dbquery($query);
     $num_rows = mysql_num_rows($result);
     if ($num_rows != 0) {
         while ($line = mysql_fetch_row($result)) {
             if ($line) {
                 $colnum = 0;
                 foreach ($line as $value) {
                     if ($colnum > 0) {
                         echo ",";
                     }
                     echo $value;
                     $colnum++;
                 }
                 echo "\n";
             }
         }
     }
     parent::dbclose($result);
 }
Esempio n. 2
0
 protected function getFiles()
 {
     $startyear = $_REQUEST['startyear'];
     if (!$startyear) {
         print "MLSO file query failed, start year not specified\n";
         exit(0);
     }
     $startdate = $_REQUEST['startdate'];
     if (!$startdate) {
         print "MLSO file query failed, start date not specified\n";
         exit(0);
     }
     $enddate = $_REQUEST['enddate'];
     if (!$enddate) {
         print "MLSO file query failed, end date not specified\n";
         exit(0);
     }
     $instrument = $_REQUEST['instrument'];
     if (!$instrument) {
         print "MLSO file query failed, instrument id not specified\n";
         exit(0);
     }
     $wavelength = $_REQUEST['wavelength'];
     if (!$wavelength) {
         print "MLSO file query failed, wave length not specified\n";
         exit(0);
     }
     $limit = $_REQUEST['limit'];
     if (!$limit) {
         print "MLSO file query failed, return limit not specified\n";
         exit(0);
     }
     // need to connect to the database here in order to run the
     // function mysql_real_escape_string
     $isconnected = $this->mlsoconnect();
     if ($isconnected != "good") {
         print "{$isconnected}\n";
         exit(0);
     }
     $startyear = mysql_real_escape_string(trim($startyear));
     $startdate = mysql_real_escape_string(trim($startdate));
     $enddate = mysql_real_escape_string(trim($enddate));
     $instrument = mysql_real_escape_string(trim($instrument));
     $wavelength = mysql_real_escape_string(trim($wavelength));
     $query = "SELECT FILE_NAME as filename, TYPE as type";
     $query .= " FROM tbl_{$startyear}";
     $query .= " WHERE (datetime_obs >= '{$startdate}')";
     $query .= " AND (datetime_obs < '{$enddate}')";
     $query .= " AND (INSTRUMENT = '{$instrument}')";
     $query .= " AND (WAVE_LENGTH = '{$wavelength}')";
     $quality = $_REQUEST['quality'];
     if ($quality) {
         $quality = mysql_real_escape_string(trim($quality));
         $query .= " AND (QUALITY = '{$quality}')";
     }
     $processing_s = $_REQUEST['processing'];
     if ($processing_s) {
         $processing_s = mysql_real_escape_string(trim($processing_s));
         $processing_a = explode(",", $processing_s);
         $query .= " AND (";
         $isfirst = true;
         foreach ($processing_a as $processing) {
             if (!$isfirst) {
                 $query .= " OR";
             }
             $isfirst = false;
             $query .= " PROCESSING = '{$processing}'";
         }
         $query .= ") ";
     }
     $query .= " ORDER BY datetime_obs ASC, type DESC";
     $query .= " LIMIT 0,{$limit}";
     //print( "$query<BR>\n" ) ;
     $result = parent::dbquery($query);
     $num_rows = mysql_num_rows($result);
     if ($num_rows != 0) {
         while ($line = mysql_fetch_row($result)) {
             if ($line) {
                 $colnum = 0;
                 foreach ($line as $value) {
                     if ($colnum > 0) {
                         echo ",";
                     }
                     echo $value;
                     $colnum++;
                 }
                 echo "\n";
             }
         }
     }
     parent::dbclose($result);
 }
Esempio n. 3
0
 protected function cedar_login()
 {
     global $auth_result;
     $auth_result = "BAD";
     $username = $_REQUEST["username"];
     if (!$username || $username == "") {
         $auth_result = "username has not been specified. Please try again";
         return;
     }
     $password = $_REQUEST["password"];
     if (!$password || $password == "") {
         $auth_result = "password has not been specified. Please try again";
         return;
     }
     // need to connect to the database here in order to run the
     // function mysql_real_escape_string
     $isconnected = $this->authconnect();
     if ($isconnected != "good") {
         $auth_result = $isconnected;
         return;
     }
     $username = mysql_real_escape_string($username);
     $cusername = ucfirst($username);
     $password = mysql_real_escape_string($password);
     $query = "SELECT u.user_password FROM user u,user_groups g,cedar_user_info c WHERE u.user_name = '{$cusername}' AND u.user_id = g.ug_user AND g.ug_group = 'Cedar' AND u.user_id = c.user_id AND c.status = 'active'";
     $result = parent::dbquery($query);
     $num_rows = mysql_num_rows($result);
     if ($num_rows != 1) {
         if ($num_rows == 0) {
             $auth_result = "User name {$username} does not exist.";
             parent::dbclose($result);
             return;
         }
         $auth_result = "User name {$username} has multiple entries.";
         parent::dbclose($result);
         return;
     }
     $dbpassword = mysql_fetch_row($result);
     $dbpassword = $dbpassword[0];
     list($salt, $realHash) = explode(':', substr($dbpassword, 3), 2);
     $totest = md5($salt . '-' . md5($password));
     if ($totest != $realHash) {
         $auth_result = "Incorrect password for user {$username}";
         parent::dbclose($result);
         return;
     }
     $auth_result = "good";
     // delete any rows for this user more that 24 hours old using
     // last_heart_beat
     $query = "DELETE FROM cedar_sessions where user_name = '{$username}' AND TIMESTAMPDIFF(SECOND,last_heart_beat,NOW()) > 86400";
     mysql_query($query);
     // Now add an entry to the session table.
     $remote_addr = $_SERVER["REMOTE_ADDR"];
     $query = "INSERT INTO cedar_sessions (user_name, client_ip ) VALUES ('{$username}', '{$remote_addr}' )";
     $insert_result = mysql_query($query);
     if (!$insert_result) {
         $auth_result = "Failed to create session entry" . mysql_error();
         parent::dbclose($result);
         return;
     }
     $auth_result = "good";
     parent::dbclose($result);
 }
Esempio n. 4
0
 protected function genOpModeParams()
 {
     // need to connect to the database here in order to run the
     // function mysql_real_escape_string
     $isconnected = $this->cedarconnect();
     if ($isconnected != "good") {
         print "Failed to connect to the database: {$isconnected}\n";
         exit(0);
     }
     $query = "SELECT DISTINCT tbl_record_type.KINST as kinst, tbl_record_type.KINDAT as kindat, tbl_record_info.PARAMETER_ID as parameter_id FROM tbl_record_type, tbl_record_info, tbl_parameter_code WHERE tbl_record_type.RECORD_TYPE_ID=tbl_record_info.RECORD_TYPE_ID AND tbl_parameter_code.PARAMETER_ID=tbl_record_info.PARAMETER_ID AND NOT (tbl_parameter_code.LONG_NAME='UNDEFINED');";
     $result = parent::dbquery($query);
     $num_rows = mysql_num_rows($result);
     if ($num_rows != 0) {
         while ($line = mysql_fetch_row($result)) {
             if ($line) {
                 $colnum = 0;
                 foreach ($line as $value) {
                     if ($colnum > 0) {
                         echo ",";
                     }
                     echo $value;
                     $colnum++;
                 }
                 echo "\n";
             }
         }
     }
     parent::dbclose($result);
 }