0) { foreach ($checkgroup as $key => $element) if ($element==-1) $query0 .= $key . " as '" . $alias[$key] . "' " . ", "; //-------------------------------------------------- $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', "; //-------------------------------------------------- $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', "; $query0 .= " Min(fZenithDistanceMin) as '" . $alias["Min(fZenithDistanceMin)"] . "', "; $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', "; $query0 .= " COUNT(*) as '# Sequ' "; } else { if ($statusgroups>0) { foreach ($checkstatusgroup as $key => $element) if ($element==-1) $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', "; $query0 .= " COUNT(*) as '# Sequ'"; } else { $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' "; if (!empty($_SESSION["fLinks"])) { $query0 .= ", CONCAT('r' "; //$query0 .= " as " . $alias["fSequenceFirst"]; $query0 .= ", ' cl'"; $query0 .= ", ' c'"; $query0 .= ", ' sl'"; $query0 .= ", ' s'"; $query0 .= ", ' ', 'f ' "; $query0 .= ", ' i') "; $query0 .= " as 'Links'"; } foreach ($_SESSION as $key => $element) if ($_SESSION[$key]=="On") if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff") if (!(ereg("^DSSeq[0-9]*$", $key))) if (empty($checkwhere[$key]) || $checkwhere[$key]==0) $query0 .= ", " . $key . " as '" . $alias[$key] . "' "; } } $query0 .= " FROM " . $fromtable; $query0 .= " LEFT JOIN SequenceProcessStatus USING(fSequenceFirst,fTelescopeNumber) "; $query0 .= " LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) "; $query0 .= " LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) "; foreach ($_SESSION as $key => $element) if (($_SESSION[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key))) $query0 .= GetJoin($fromtable,$key); if ($_SESSION["DisplaySelected"]!="yes" || ($_SESSION["sequon"]==" " && $_SESSION["sequoff"]==" ")) { if ($_SESSION["fTest"]!="On") { if ($_SESSION["fSourceName"]!="On") $query0 .= " LEFT JOIN Source USING(fSourceKEY) "; $query0 .= " WHERE fTest='no'"; } if ($_SESSION["fOff"]=="Off") { if (strpos($query0, " WHERE ")==FALSE) $query0 .= " WHERE "; else $query0 .= " AND "; $query0 .= " NOT (fSourceName like '%Off%')"; } if ($_SESSION["fOnlyOff"]=="On") { if (strpos($query0, " WHERE ")==FALSE) $query0 .= " WHERE "; else $query0 .= " AND "; $query0 .= " fSourceName like '%Off%'"; } foreach ($checkwhere as $key => $element) { if (empty($element) || $element<=0) continue; if (strpos($query0, " WHERE ")==FALSE) $query0 .= " WHERE "; else if ($element!=-1) if (strrpos($query0, " AND ")!=strlen($query0)-5) $query0 .= " AND "; if ($element!=-1) $query0 .= GetCheck($fromtable, $key) . "=" . $element; } if (strpos($query0, " WHERE ")==FALSE) $query0 .= " WHERE "; else $query0 .= " AND "; $query0 .= StatusQuery("fSequenceFileWritten", $needs, $timelimits); $query0 .= StatusQuery("fAllFilesAvail", $needs, $timelimits); $query0 .= StatusQuery("fCallisto", $needs, $timelimits); $query0 .= StatusQuery("fFillCallisto", $needs, $timelimits); $query0 .= StatusQuery("fStar", $needs, $timelimits); $query0 .= StatusQuery("fFillStar", $needs, $timelimits); if (!empty($_SESSION["fRunMin"]) && !empty($_SESSION["fRunMax"])) $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_SESSION["fRunMin"] . " AND " . $_SESSION["fRunMax"] . " "; else $query0 = substr($query0, 0, -4); if ((!empty($_SESSION["fZDMin"]) || $_SESSION["fZDMin"]==0) && !empty($_SESSION["fZDMax"])) $query0 .= "AND (fZenithDistanceMin >= " . $_SESSION["fZDMin"] . " AND fZenithDistanceMax <= " . $_SESSION["fZDMax"] . ") "; if (!empty($_SESSION["fSourceN"])) $query0 .= " AND fSourceName REGEXP \"^" . $_SESSION["fSourceN"] . "\" "; if (!empty($_SESSION["fStartDate"])) { if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) $query0 .= " AND "; $startdate=substr($_SESSION["fStartDate"], 0, 10); if ($startdate=="0000-00-00") $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' "; else $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) "; } if (!empty($_SESSION["fStopDate"])) { if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) $query0 .= " AND "; $stopdate=substr($_SESSION["fStopDate"], 0, 10); $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' "; } if (!empty($_SESSION["fStarStart"])) { if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) $query0 .= " AND "; $starstart=substr($_SESSION["fStarStart"], 0, 10); $query0 .=" fStar >= '" . $starstart . " 00:00:00' "; } if (!empty($_SESSION["fStarStop"])) { if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) $query0 .= " AND "; $starstop=substr($_SESSION["fStarStop"], 0, 10); $query0 .= " fStar < '" . $starstop . " 23:59:59' "; } if ($_SESSION["DisplaySelected"]=="inverse") { $displsequ=str_replace(" ", " ", $_SESSION["sequon"].$_SESSION["sequoff"]); $displsequ=ereg_replace("^ ", "(", $displsequ); $displsequ=ereg_replace("$", ")", $displsequ); $displsequ=str_replace(" ", ",", $displsequ); if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) $query0 .= " AND "; $query0 .= " fSequenceFirst NOT IN " . $displsequ; } if ($groups>0) { $query0 .= " GROUP BY "; $num = $groups; foreach ($checkgroup as $key => $element) if ($element==-1) { $query0 .= GetCheck($fromtable,$key); if ($num-->1) $query0 .= ", "; } } if ($statusgroups>0) { $query0 .= " GROUP BY "; $num = $statusgroups; foreach ($checkstatusgroup as $key => $element) if ($element==-1) { $query0 .= $alias[$key]; if ($num-->1) $query0 .= ", "; } } } else { $displsequ=str_replace(" ", " ", $_SESSION["sequon"].$_SESSION["sequoff"]); $displsequ=ereg_replace("^ ", "(", $displsequ); $displsequ=ereg_replace("$", ")", $displsequ); $displsequ=str_replace(" ", ",", $displsequ); $query0 .= "WHERE fSequenceFirst IN " . $displsequ; } if (!empty($_SESSION["fSortBy"])) { $val=substr($_SESSION["fSortBy"], 0, -1); $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " "; if (substr($_SESSION["fSortBy"], -1)=="-") $query0 .= "DESC"; } if (empty($_SESSION["fSortBy"]) && $groups==0 && $statusgroups==0) $query0 .= " ORDER BY Sequences.fSequenceFirst DESC "; if (empty($_SESSION["fNumStart"])) $start=0; else $start=$_SESSION["fNumStart"]; if (empty($_SESSION["fSendTxt"])) $query0 .= " LIMIT " . $start . ", " . $_SESSION["fNumResults"]; return $query0; } function PrintForm($host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias) { printf("
\n"); printf("
\n"); printf("\n"); printf("- Menu    \n"); printf("  + SequInfo \n"); printf("  + StatusInfo \n"); printf("  + CalInfo \n"); printf("  + StarInfo \n"); printf("  + Limits \n"); printf("  + Ranges \n"); printf("
"); PrintSequInfo2Menu($host,$user,$pw,$db); PrintSequInfoMenu(); PrintSequStatMenu(); PrintFailMenu(); PrintCalMenu(); PrintStarMenu(); PrintLimitsMenu($limitsmean, $limitsmin, $limitsmax, $alias, ""); printf(" "); printf("
"); printf("

\n"); PrintNumResPullDown(); ini_set("mysql.trace_mode", "Off"); ini_set("display_errors", "Off"); PrintButtons("builddatasets.php"); printf("

\n"); printf("
\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); } function InsertDataSet($values, $dataset) { $insquery[0]="INSERT DataSets SET fDataSetNumber=" . $dataset . ", fUserKEY=" . $_SESSION["user"]; $insquery[0].=", fComment='" . $_SESSION["comment"] . "', fObservationModeKEY=" . $_SESSION["obsmode"]; $insquery[0].=", fDataSetName='" . $_SESSION["name"] . "', fSourceKEY= " . $_SESSION["realsourcekey"]; $insquery[0].=", fRunStart='" . $values["Min(fRunStart)"]["on"]; $insquery[0].="', fRunStop='" . $values["Max(fRunStop)"]["on"]; $insquery[0].="', fZenithDistanceMin=" . $values["Min(fZenithDistanceMin)"]["on"]; $insquery[0].=", fZenithDistanceMax=" . $values["Max(fZenithDistanceMax)"]["on"]; $insquery[0].=", fRunTime=" . $_SESSION["runtime"]; $insquery[1]="INSERT DataSetProcessStatus SET fDataSetNumber=" . $dataset . ", fDataSetInserted=Now()"; $i=2; foreach(explode(" ", trim($_SESSION["sequon"])) as $key => $sequ) { $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset; $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=1"; $i=$i+1; } if (!empty($off)) { foreach(explode(" ", trim($_SESSION["sequoff"])) as $key => $sequ) { $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset; $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=2"; $i=$i+1; } } // insert if (!empty($_SESSION["insert"]) && $numerr==0) { printf("

\n"); foreach($insquery as $num => $q) { printf("Inserted Query #%s: %s
\n", $num, $q); $insresult=mysql_query($q); if (mysql_errno()>0) printf("  Errorno: %s
\n", mysql_errno()); if (mysql_error()!="") printf("  Errormsg: %s
\n", mysql_error()); if (mysql_info()!="") printf("  Info: %s
\n", mysql_info()); printf("  Affected Rows: %s

\n", mysql_affected_rows()); mysql_free_result($insresult); if (mysql_errno()>0) { printf("ERROR => stop inserting.

\n"); break; } } // reset after insert unset($_SESSION["insert"]); unset($_SESSION["name"]); unset($_SESSION["comment"]); } else printf("   \n", GetClearedURL()); } function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs) { $db_id = mysql_pconnect($host, $user, $pw); if ($db_id==FALSE) { printf("mysql_connect returned the following error: %s\n", mysql_error()); die(""); } mysql_select_db($db); $query0 = CreateQuery($alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs); $result0 = mysql_query($query0, $db_id); $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); if ($result0) { if ($html=="1" || $html=="2") { PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, "yes"); if (!(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"]))) { printf("
\n"); printf("Remark: To store your selection you have to press 'Update Data Set'
\n"); printf("
\n"); printf("Your Data Set:
\n"); $on=str_replace(" ", ",", trim($_SESSION["sequon"])); $off=str_replace(" ", ",", trim($_SESSION["sequoff"])); //set observation mode if ($_SESSION["sequoff"]=="") $obsmode="Wobble"; else $obsmode="On"; //get key from db for insert query $query = "SELECT fObservationModeKEY FROM ObservationMode WHERE fObservationModeName='".$obsmode."'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $_SESSION["obsmode"] = $row["fObservationModeKEY"]; mysql_free_result($result); $values=array("Sum(fRunTime)/60" => $runtime, "Min(fRunTime)/60" => $runtimemin, "Max(fUnsuitableInner)" => $unsuitablemax, "Max(fUnreliableInner)" => $unreliablemax, "Max(fIsolatedInner)" => $isolatedmax, "Max(fIsolatedMaxCluster)" => $imcmax, "Max(fArrTimeMeanInner)" => $arrtimemax, "Min(fArrTimeMeanInner)" => $arrtimemin, "Max(fArrTimeRmsInner)" => $arrtimermsmax, "Avg(fMeanPedRmsInner)" => $pedrmsmean, "Std(fMeanPedRmsInner)" => $pedrmsrms, "Min(fMeanPedRmsInner)" => $pedrmsmin, "Max(fMeanPedRmsInner)" => $pedrmsmax, "Min(fPulsePosMean)" => $pulseposmin, "Max(fPulsePosMean)" => $pulseposmax, "Max(fPulsePosRms)" => $pulseposrmsmax, "Max(fMaxHumidity)" => $hummax, "Max(fInhomogeneity)" => $inhommax, "Avg(fInhomogeneity)" => $inhommean, "Std(fInhomogeneity)" => $inhomrms, "Min(fMeanNumberIslands)" => $numislmin, "Max(fMeanNumberIslands)" => $numislmax, "Avg(fDataRate)" => $clratemean, "Min(fDataRate)" => $clratemin, "Max(fDataRate)" => $clratemax, "Min(fMuonRate)" => $muonratemin, "Max(fMuonRate)" => $muonratemax, "Min(fMuonNumber)" => $muonnumbermin, "Avg(fPSF)" => $psfmean, "Std(fPSF)" => $psfrms, "Min(fPSF)" => $psfmin, "Max(fPSF)" => $psfmax, "Min(fEffOnTime/fRunTime)" => $relontimemin, "Max(fEffOnTime/fRunTime)" => $relontimemax, "Min(fBrightnessMed)" => $brightmin, "Max(fBrightnessMed)" => $brightmax, "Min(fNumStarsMed)" => $idstarsmin, "Max(fNumStarsMed)" => $idstarsmax, "Min(fNumStarsCorMed)" => $corstarsmin, "Max(fNumStarsCorMed)" => $corstarsmax, "Min(fZenithDistanceMin)" => $zdmin, "Max(fZenithDistanceMax)" => $zdmax, "Min(fRunStart)" => $starttime, "Max(fRunStop)" => $stoptime, ); //get runtimes of dataset function GetSequenceValues($db_id, $sequences, $txt, &$values) { $query="SELECT COUNT(*) "; foreach($values as $name => $varname) $query.=", " . $name; $query.=" FROM Sequences "; $query.=" LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) "; $query.=" LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) "; $query.=" WHERE Sequences.fSequenceFirst IN (" . $sequences . ")"; $result = mysql_query($query, $db_id); $row = mysql_fetch_assoc($result); foreach($values as $name => $varname) $values[$name][$txt]=$row[$name]; mysql_free_result($result); } //get next dataset# $query="SELECT fDataSetNumber+1 FROM DataSets ORDER BY fDataSetNumber DESC LIMIT 0,1"; $result = mysql_query($query, $db_id); $row = mysql_fetch_assoc($result); $dataset=$row["fDataSetNumber+1"]; if (empty($dataset)) $dataset=1; mysql_free_result($result); //get sourcenames function GetSources($db_id, $sequences) { $query="SELECT fSourceName FROM Source LEFT JOIN Sequences USING(fSourceKEY) "; $query.="WHERE fSequenceFirst IN (" . $sequences . ") GROUP BY fSourceName"; $result = mysql_query($query, $db_id); while ($row = mysql_fetch_assoc($result)) $sources.=" " . $row["fSourceName"]; mysql_free_result($result); return $sources; } $sourceson=GetSources($db_id, $on); $sourcesoff=GetSources($db_id, $off); //get sourcename for dataset $son=str_replace(" ", "','", trim($sourceson)); $query="SELECT fRealSourceKEY, Count(*), fSourceName FROM Source where fSourceName IN ('" . $son . "') GROUP BY fRealSourceKEY"; $result = mysql_query($query, $db_id); $row = mysql_fetch_assoc($result); $numsources=$row["Count(*)"]; $numrealkeys=mysql_num_rows($result); $_SESSION["realsourcekey"]=$row["fRealSourceKEY"]; $_SESSION["realsourcename"]=$row["fSourceName"]; mysql_free_result($result); //printf("found %s sources with real sourcekey %s", $numsources, $realsourcekey); //printf("found %s keys", $numrealkeys); //check observationmode for on-sequences $query="SELECT fObservationModeKEY FROM Sequences where fSequenceFirst IN (" . $on . ") GROUP BY fObservationModeKEY"; $result = mysql_query($query, $db_id); $row = mysql_fetch_assoc($result); $obskey=$row["fObservationModeKEY"]; $numobskeys=mysql_num_rows($result); mysql_free_result($result); //check dt for on-sequences $query="SELECT fDiscriminatorThresholdTableKEY FROM Sequences where fSequenceFirst IN (" . $on . ") GROUP BY fDiscriminatorThresholdTableKEY"; $result = mysql_query($query, $db_id); $numdtkeys=mysql_num_rows($result); mysql_free_result($result); //set limit $runtimelimit=5; $unsuitablemaxlimit=15; $isolatedlimit=0; $imclimit=0; $pedrmsrms=0.09; $scalelimit=1.3; $inhomlimit=13; $numstarslimit=20; $numstarscorlimit=10; //check values for infos, warnings and errors $numerr=0; if (!empty($on)) { $color=array("INFO" => "#000000", "WARN" => "#FF9900", "ERROR" => "#FF0000"); printf("
    \n"); $vals=array("on", "off"); foreach($vals as $num => $val) { if (empty(${$val})) continue; //get information from the database GetSequenceValues($db_id, ${$val}, $val, $values); if ($values["Min(fNumStarsCorMed)"][$val]<$numstarscorlimit) printf("
  • %s: At least one of your %s-sequences has less than %s correlated stars (%s).
  • \n", $color["WARN"], "WARN", $val, $numstarscorlimit, $values["Min(fNumStarsCorMed)"][$val]); if ($values["Min(fNumStarsMed)"][$val]<$numstarslimit) printf("
  • %s: At least one of your %s-sequences has less than %s identified stars (%s).
  • \n", $color["WARN"], "WARN", $val, $numstarslimit, $values["Min(fNumStarsMed)"][$val]); if ($values["Min(fRunTime)/60"][$val]<$runtimelimit) printf("
  • %s: At least one of your %s-sequences is shorter than %s min (%s min).
  • \n", $color["INFO"], "INFO", $val, $runtimelimit, $values["Min(fRunTime)/60"][$val]); if ($values["Max(fInhomogeneity)"][$val]>$inhomlimit) printf("
  • %s: At least one of your %s-sequences has an inhomogeneity larger than %s (%s).
  • \n", $color["WARN"], "WARN", $val, $inhomlimit, $values["Max(fInhomogeneity)"][$val]); if ($values["Max(fUnsuitableInner)"][$val]>$unsuitablemaxlimit) printf("
  • %s: At least one of your %s-sequences has more than %s unsuitable inner pixel (%s).
  • \n", $color["WARN"], "WARN", $val, $unsuitablemaxlimit, $values["Max(fUnsuitableInner)"][$val]); if ($values["Max(fIsolatedInner)"][$val]>$isolatedlimit) printf("
  • %s: At least one of your %s-sequences has more than %s isolated inner pixel (%s).
  • \n", $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]); if ($values["Max(fIsolatedMaxCluster)"][$val]>$imclimit) printf("
  • %s: At least one of your %s-sequences has more than %s isolated max cluster (%s).
  • \n", $color["WARN"], "WARN", $val, $imclimit, $values["Max(fIsolatedMaxCluster)"][$val]); } //check selected dataset for errors if (!empty($on) && $values["Max(fMeanPedRmsInner)"]["on"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms) printf("
  • %s: At least one of your on-sequences has a PedRms larger than %s (%s).
  • \n", $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["on"]); if (!empty($off) && $values["Max(fMeanPedRmsInner)"]["off"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms) printf("
  • %s: At least one of your off-sequences has a PedRms larger than %s (%s).
  • \n", $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["off"]); if (!empty($off) && $values["Min(fMeanPedRmsInner)"]["off"]<$values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms) printf("
  • %s: At least one of your off-sequences has a PedRms smaller than %s (%s).
  • \n", $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms, $values["Min(fMeanPedRmsInner)"]["off"]); $scale=$values["Sum(fRunTime)/60"]["on"]/$values["Sum(fRunTime)/60"]["off"]; if ($scale > $scalelimit) printf("
  • %s: Your scale factor is larger than %s (%0.2f). Try to find more offdata!
  • \n", $color["WARN"], "WARN", $scalelimit, $scale); $doubleseq=0; foreach(explode(" ", $_SESSION["sequon"]) as $n => $s) { if (ereg($s, $_SESSION["sequoff"])) $doubleseq++; } if ($obskey!=$_SESSION["obsmode"]) { printf("
  • %s: You have a mistake in your observation mode. %s - %s
  • \n", $color["ERROR"], "ERROR", $obskey, $_SESSION["obsmode"]); $numerr=$numerr+1; } if ($doubleseq>0) { printf("
  • %s: You have selected sequences (%s) as On AND Off.
  • \n", $color["ERROR"], "ERROR", $doubleseq); $numerr=$numerr+1; } if ($numrealkeys>1) { printf("
  • %s: You have selected more than one (%s) on source.
  • \n", $color["ERROR"], "ERROR", $numrealkeys); $numerr=$numerr+1; } if ($numobskeys>1) { printf("
  • %s: You have selected more than one (%s) different observation modes in your on sequences.
  • \n", $color["ERROR"], "WARN", $numobskeys); //$numerr=$numerr+1; } if ($numdtkeys>1) { printf("
  • %s: Your selected on sequences have more than one (%s) different discriminator threshold tables.
  • \n", $color["ERROR"], "WARN", $numdtkeys); } if (empty($_SESSION["realsourcekey"])) { printf("
  • %s: The source you selected does not have a real sourcekey, yet. Please insert fRealSourceKEY in the DB for %s (contact: datacenter@astro.uni-wuerzburg.de).
  • \n", $color["ERROR"], "ERROR", $sourceson); $numerr=$numerr+1; } if (empty($_SESSION["name"])) { printf("
  • %s: You have to choose a name.
  • \n", $color["ERROR"], "ERROR"); $numerr=$numerr+1; } if (empty($_SESSION["comment"])) { printf("
  • %s: You have to comment your data set.
  • \n", $color["ERROR"], "ERROR"); $numerr=$numerr+1; } printf("
\n"); printf("
"); //set runtime in session (has to be after calling GetSequenceValues()) $_SESSION["runtime"] = $values["Sum(fRunTime)/60"]["on"]; $_SESSION["zdmin"] = $values["Min(fZenithDistanceMin)"]["on"]; $_SESSION["zdmax"] = $values["Max(fZenithDistanceMax)"]["on"]; $_SESSION["meanrate"] = $values["Avg(fDataRate)"]["on"]; $_SESSION["psfmean"] = $values["Avg(fPSF)"]["on"]; $_SESSION["psfmin"] = $values["Min(fPSF)"]["on"]; $_SESSION["psfmax"] = $values["Max(fPSF)"]["on"]; printf("SequencesOn: %s
\n", $_SESSION["sequon"]); if ($_SESSION["sequoff"]!="") printf("SequencesOff: %s
\n", $_SESSION["sequoff"]); printf("Observation mode: %s
\n", $obsmode); printf("RunTime: %s min
\n", $_SESSION["runtime"]); printf("Mean Rate after cleaning: %s Hz
\n", $_SESSION["meanrate"]); printf("Zd: %s - %s deg
\n", $_SESSION["zdmin"], $_SESSION["zdmax"]); printf("PSF: %s (%s - %s) mm
\n", $_SESSION["psfmean"], $_SESSION["psfmin"], $_SESSION["psfmax"]); //user name printf("User name: %s

\n", $_SERVER['PHP_AUTH_USER']); // data set name and comment: to be inserted by the user printf("Data set name:  
\n", $_SESSION["name"]); printf("Comment:  

\n", $_SESSION["comment"]); //PrintUpdateDataSetButton() has to be called before InsertDataSet() // to ensure that there are no problem with insert and $_SESSION["insert"] //allow 'insert/get dataset' in case no error is found if ($numerr!=0) { printf("Remark: Only data sets without errors can be inserted.
"); printf("Your data set has %s error(s).

", $numerr); PrintUpdateDataSetButton(); } else { PrintUpdateDataSetButton(); if ($_SERVER['PHP_AUTH_USER']=="MAGIC") printf("

\n Remark: As user MAGIC you are not allowed to insert data sets into the database. For an own account, please contact datacenter@astro.uni-wuerzburg.de

\n"); else InsertDataSet($values, $dataset); printf("   \n", GetClearedURL()); } //print table with more information on dataset printf("


\n"); printf(""); printf("", $dataset); printf("", $_SESSION["sequon"]); if ($_SESSION["sequoff"]!="") { printf("", $_SESSION["sequoff"]); printf("", $scale); } printf("", str_word_count($sourceson, 0, "1234567890+"), $sourceson); if ($_SESSION["sequoff"]!="") printf("", str_word_count($sourcesoff, 0, "1234567890+"), $sourcesoff); printf("
More Information on Your Data Set:
Next DataSet# in DB: %s
SequencesOn: %s
SequencesOff: %s
Scale factor (On/Off): %0.2f
SourcenamesOn [%s]: %s
SourcenamesOff [%s]: %s
\n"); printf("\n"); printf(""); if (!empty($off)) printf("\n"); foreach($values as $name => $varname) { printf("\n", $name); foreach($vals as $num => $val) if (!empty(${$val})) printf("\n", $varname[$val]); printf("\n"); } printf("
ValueOnOff
%s%s
\n"); } } else { printf("

\n"); printf("Remark: To store your selection you have to press 'Get Data Set'
\n"); } printf("
\n"); printf("\n"); printf("\n"); printf("\n"); } else PrintText($result0); mysql_free_result($result0); mysql_free_result($result1); } mysql_close($db_id); PrintSubmittedQuery($query0, $html, $db, ""); } include ("include.php"); include ("menu.php"); include ("db.php"); include ("magicdefs.php"); // $debug="yes"; session_start(); if ($debug) { echo "GET: "; print_r($_GET); echo "
"; echo "POST: "; print_r($_POST); echo "
"; } // set values given by $_GET foreach ($_GET as $element => $value) $_SESSION[$element]=$value; // unset values in case of 'Reset' if (empty($_GET)) foreach($_SESSION as $element => $value) unset($_SESSION[$element]); // set values given by $_POST if (!empty($_POST)) foreach ($_POST as $element => $value) $_SESSION[$element]=$value; if ($debug) print_r($_SESSION); if ($_SESSION["DisplaySelected"]=="yes") { unset($_SESSION["fNumStart"]); $_GET["fNumStart"]=0; } $_SESSION["sequon"]=""; $_SESSION["sequoff"]=""; foreach($_SESSION as $key => $val) { if ($val=="ON" && ereg("^DSSeq[0-9]*$", $key)) $_SESSION["sequon"].=str_replace("DSSeq", " ", $key); if ($val=="Off" && ereg("^DSSeq[0-9]*$", $key)) $_SESSION["sequoff"].=str_replace("DSSeq", " ", $key); if ($val=="Not" && ereg("^DSSeq[0-9]*$", $key)) unset($_SESSION[$key]); } ini_set("display_errors", "On"); ini_set("mysql.trace_mode", "On"); if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Build Datasets"'); header('HTTP/1.0 401 Unauthorized'); return; } else { $db_id = mysql_connect($host, $user, $pw); if ($db_id==FALSE) { printf("mysql_connect returned the following error:
"); printf("%s
", mysql_error()); die(""); } $userquery = "SELECT fUserName, fPassword, fUserKEY FROM " . $db . ".User ORDER BY fUserKEY"; $userresult = mysql_query($userquery); if (!$userresult) echo "query failed"; $validuser="no"; while ($userrow = mysql_fetch_assoc($userresult)) { // echo crypt($_SERVER['PHP_AUTH_PW']). "
"; // echo "with crypt: " . crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"]) . " for user " . $userrow["fUserName"]. "
"; if (crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"])==$userrow["fPassword"] && $_SERVER['PHP_AUTH_USER']==$userrow["fUserName"]) { $validuser="yes"; $_SESSION["user"]=$userrow["fUserKEY"]; } } mysql_free_result($userresult); if ($validuser=="no") { printf("
Password or username incorrect
"); return; } } if (!empty($_SESSION["fSendTxt"])) { header("Content-Type: application/octet"); switch($_SESSION["fSendTxt"]) { case 1: header("Content-Disposition: attachment; filename=query-result.txt"); PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs); break; case 2: header("Content-Disposition: attachment; filename=dataset_".str_replace(" ", "_", $_SESSION["name"]).".txt"); PrintDataSetFile(); } unset($_SESSION["fSendTxt"]); } else { echo (file_get_contents("index-header.html")); $environment = sizeof($_GET); // Find out whether it is the first call to the php script $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]); InitBuildDataSets($first); if (empty($_SESSION["fPrintTable"])) PrintForm($host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias); if ($environment==0) printf("No query submitted yet.
"); else { if (empty($_SESSION["fPrintTable"])) PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs); else PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs); } echo (file_get_contents("index-footer.html")); } ini_set("display_errors", "Off"); ini_set("mysql.trace_mode", "Off"); ?>