| 1 | <?php
|
|---|
| 2 | {
|
|---|
| 3 | function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
|
|---|
| 4 | {
|
|---|
| 5 | $fromtable="Sequences";
|
|---|
| 6 |
|
|---|
| 7 | $groups = 0;
|
|---|
| 8 | foreach ($checkgroup as $element)
|
|---|
| 9 | if ($element==-1)
|
|---|
| 10 | $groups++;
|
|---|
| 11 |
|
|---|
| 12 | $statusgroups = 0;
|
|---|
| 13 | foreach ($checkstatusgroup as $element)
|
|---|
| 14 | if ($element==-1)
|
|---|
| 15 | $statusgroups++;
|
|---|
| 16 |
|
|---|
| 17 | $query0 = "SELECT ";
|
|---|
| 18 |
|
|---|
| 19 | if ($groups>0)
|
|---|
| 20 | {
|
|---|
| 21 | foreach ($checkgroup as $key => $element)
|
|---|
| 22 | if ($element==-1)
|
|---|
| 23 | $query0 .= $key . " as '" . $alias[$key] . "' " . ", ";
|
|---|
| 24 | //--------------------------------------------------
|
|---|
| 25 | $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
|
|---|
| 26 | //--------------------------------------------------
|
|---|
| 27 | $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
|
|---|
| 28 | $query0 .= " Min(fZenithDistanceMin) as '" . $alias["Min(fZenithDistanceMin)"] . "', ";
|
|---|
| 29 | $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', ";
|
|---|
| 30 | $query0 .= " COUNT(*) as '# Sequ' ";
|
|---|
| 31 | }
|
|---|
| 32 | else
|
|---|
| 33 | {
|
|---|
| 34 | if ($statusgroups>0)
|
|---|
| 35 | {
|
|---|
| 36 | foreach ($checkstatusgroup as $key => $element)
|
|---|
| 37 | if ($element==-1)
|
|---|
| 38 | $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] . "', ";
|
|---|
| 39 | // $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
|
|---|
| 40 |
|
|---|
| 41 | $query0 .= " COUNT(*) as '# Sequ'";
|
|---|
| 42 |
|
|---|
| 43 | }
|
|---|
| 44 | else
|
|---|
| 45 | {
|
|---|
| 46 | $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
|
|---|
| 47 | if (!empty($_GET["fLinks"]))
|
|---|
| 48 | {
|
|---|
| 49 | $query0 .= ", CONCAT('<A&ws;HREF=\"runinfo-aio.php?', 'fRunStart=On', '&fZenithDistance=On', '&fRunMin=', Sequences.fSequenceFirst, '&fMeanTriggerRate=On', '&fTest=On', '&fRunTypeName=On', '&fRunMax=', fSequenceLast, '&fNumEvents=On', '&fSourceName=On&', 'fExcludedFDAKEY=1', '&fSequenceFirst=On', '&fRawFileAvail=On', '&fCCFileAvail=On', '&fCaCoFileAvail=On', '&fNumResults=500\">r</A>' ";
|
|---|
| 50 | // $query0 .= " as " . $alias["fSequenceFirst"];
|
|---|
| 51 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'callisto', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">cl</A>'";
|
|---|
| 52 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">c</A>'";
|
|---|
| 53 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'star', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">sl</A>'";
|
|---|
| 54 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">s</A>'";
|
|---|
| 55 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/sequences/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/sequence', LPAD(CONCAT(Sequences.fSequenceFirst , '.txt'), 12,'0') , '\">', 'f </A>' ";
|
|---|
| 56 | $query0 .= ", ' <A&ws;HREF=\"sequence.php?fSequenceNo=', Sequences.fSequenceFirst , '&fAll=On\">i</A>') ";
|
|---|
| 57 | $query0 .= " as 'Links'";
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | foreach ($_GET as $key => $element)
|
|---|
| 61 | if ($_GET[$key]=="On")
|
|---|
| 62 | if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff")
|
|---|
| 63 | if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
|
|---|
| 64 | $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | $query0 .= " FROM " . $fromtable;
|
|---|
| 69 |
|
|---|
| 70 | $query0 .= " LEFT JOIN SequenceProcessStatus ON Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst ";
|
|---|
| 71 | $query0 .= " LEFT JOIN Calibration ON Sequences.fSequenceFirst=Calibration.fSequenceFirst ";
|
|---|
| 72 | $query0 .= " LEFT JOIN Star ON Sequences.fSequenceFirst=Star.fSequenceFirst ";
|
|---|
| 73 |
|
|---|
| 74 | foreach ($_GET as $key => $element)
|
|---|
| 75 | if (($_GET[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key)))
|
|---|
| 76 | $query0 .= GetJoin($fromtable,$key);
|
|---|
| 77 |
|
|---|
| 78 | if ($_GET["fTest"]!="On")
|
|---|
| 79 | {
|
|---|
| 80 | if ($_GET["fSourceName"]!="On")
|
|---|
| 81 | $query0 .= " LEFT JOIN Source ON Sequences.fSourceKEY=Source.fSourceKEY ";
|
|---|
| 82 | $query0 .= " WHERE fTest='no'";
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | if ($_GET["fOff"]=="Off")
|
|---|
| 86 | {
|
|---|
| 87 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 88 | $query0 .= " WHERE ";
|
|---|
| 89 | else
|
|---|
| 90 | $query0 .= " AND ";
|
|---|
| 91 |
|
|---|
| 92 | $query0 .= " NOT (fSourceName like '%Off%')";
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | if ($_GET["fOnlyOff"]=="On")
|
|---|
| 96 | {
|
|---|
| 97 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 98 | $query0 .= " WHERE ";
|
|---|
| 99 | else
|
|---|
| 100 | $query0 .= " AND ";
|
|---|
| 101 |
|
|---|
| 102 | $query0 .= " fSourceName like '%Off%'";
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | foreach ($checkwhere as $key => $element)
|
|---|
| 106 | {
|
|---|
| 107 | if (empty($element) || $element<=0)
|
|---|
| 108 | continue;
|
|---|
| 109 |
|
|---|
| 110 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 111 | $query0 .= " WHERE ";
|
|---|
| 112 | else
|
|---|
| 113 | if ($element!=-1)
|
|---|
| 114 | if (strrpos($query0, " AND ")!=strlen($query0)-5)
|
|---|
| 115 | $query0 .= " AND ";
|
|---|
| 116 |
|
|---|
| 117 | if ($element!=-1)
|
|---|
| 118 | $query0 .= GetCheck($fromtable, $key) . "=" . $element;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 122 | $query0 .= " WHERE ";
|
|---|
| 123 | else
|
|---|
| 124 | $query0 .= " AND ";
|
|---|
| 125 |
|
|---|
| 126 | $query0 .= StatusQuery("fSequenceFileWritten", $needs);
|
|---|
| 127 | $query0 .= StatusQuery("fAllFilesAvail", $needs);
|
|---|
| 128 | $query0 .= StatusQuery("fCallisto", $needs);
|
|---|
| 129 | $query0 .= StatusQuery("fFillCallisto", $needs);
|
|---|
| 130 | $query0 .= StatusQuery("fStar", $needs);
|
|---|
| 131 | $query0 .= StatusQuery("fFillStar", $needs);
|
|---|
| 132 |
|
|---|
| 133 | if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
|
|---|
| 134 | $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
|
|---|
| 135 | else
|
|---|
| 136 | $query0 = substr($query0, 0, -4);
|
|---|
| 137 |
|
|---|
| 138 | if (!empty($_GET["fZDMin"]) && !empty($_GET["fZDMax"]))
|
|---|
| 139 | $query0 .= "AND (fZenithDistanceMin > " . $_GET["fZDMin"] . " AND fZenithDistanceMax < " . $_GET["fZDMax"] . ") ";
|
|---|
| 140 |
|
|---|
| 141 | if (!empty($_GET["fSourceN"]))
|
|---|
| 142 | $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
|
|---|
| 143 |
|
|---|
| 144 | if (!empty($_GET["fStartDate"]))
|
|---|
| 145 | {
|
|---|
| 146 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
|---|
| 147 | $query0 .= " AND ";
|
|---|
| 148 |
|
|---|
| 149 | $startdate=substr($_GET["fStartDate"], 0, 10);
|
|---|
| 150 | if ($startdate=="0000-00-00")
|
|---|
| 151 | $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
|
|---|
| 152 | else
|
|---|
| 153 | $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | if (!empty($_GET["fStopDate"]))
|
|---|
| 157 | {
|
|---|
| 158 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
|---|
| 159 | $query0 .= " AND ";
|
|---|
| 160 |
|
|---|
| 161 | $stopdate=substr($_GET["fStopDate"], 0, 10);
|
|---|
| 162 | $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | if (!empty($_GET["fStarStart"]))
|
|---|
| 166 | {
|
|---|
| 167 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
|---|
| 168 | $query0 .= " AND ";
|
|---|
| 169 |
|
|---|
| 170 | $starstart=substr($_GET["fStarStart"], 0, 10);
|
|---|
| 171 | $query0 .=" fStar >= '" . $starstart . " 00:00:00' ";
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | if (!empty($_GET["fStarStop"]))
|
|---|
| 175 | {
|
|---|
| 176 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
|---|
| 177 | $query0 .= " AND ";
|
|---|
| 178 |
|
|---|
| 179 | $starstop=substr($_GET["fStarStop"], 0, 10);
|
|---|
| 180 | $query0 .= " fStar < '" . $starstop . " 23:59:59' ";
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | if ($groups>0)
|
|---|
| 184 | {
|
|---|
| 185 | $query0 .= " GROUP BY ";
|
|---|
| 186 | $num = $groups;
|
|---|
| 187 | foreach ($checkgroup as $key => $element)
|
|---|
| 188 | if ($element==-1)
|
|---|
| 189 | {
|
|---|
| 190 | $query0 .= GetCheck($fromtable,$key);
|
|---|
| 191 | if ($num-->1)
|
|---|
| 192 | $query0 .= ", ";
|
|---|
| 193 | }
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | if ($statusgroups>0)
|
|---|
| 197 | {
|
|---|
| 198 | $query0 .= " GROUP BY ";
|
|---|
| 199 | $num = $statusgroups;
|
|---|
| 200 | foreach ($checkstatusgroup as $key => $element)
|
|---|
| 201 | if ($element==-1)
|
|---|
| 202 | {
|
|---|
| 203 | $query0 .= $alias[$key];
|
|---|
| 204 | if ($num-->1)
|
|---|
| 205 | $query0 .= ", ";
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | if (!empty($_GET["fSortBy"]))
|
|---|
| 210 | {
|
|---|
| 211 | $val=substr($_GET["fSortBy"], 0, -1);
|
|---|
| 212 | $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
|
|---|
| 213 | if (substr($_GET["fSortBy"], -1)=="-")
|
|---|
| 214 | $query0 .= "DESC";
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
|
|---|
| 218 | $query0 .= "ORDER BY Sequences.fSequenceFirst DESC ";
|
|---|
| 219 |
|
|---|
| 220 | if (empty($_GET["fNumStart"]))
|
|---|
| 221 | $_GET["fNumStart"]=0;
|
|---|
| 222 |
|
|---|
| 223 | if (empty($_GET["fSendTxt"]))
|
|---|
| 224 | $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
|
|---|
| 225 |
|
|---|
| 226 | return $query0;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | function InitGet($_GET)
|
|---|
| 230 | {
|
|---|
| 231 | // Find out whether it is the first call to the php script
|
|---|
| 232 | $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
|
|---|
| 233 |
|
|---|
| 234 | if (empty($_GET["fNumResults"]))
|
|---|
| 235 | $_GET["fNumResults"]="100";
|
|---|
| 236 |
|
|---|
| 237 | if (empty($_GET["fRunStart"]))
|
|---|
| 238 | $_GET["fRunStart"]=$first?"On":"";
|
|---|
| 239 |
|
|---|
| 240 | if (empty($_GET["fRunTime/60"]))
|
|---|
| 241 | $_GET["fRunTime/60"]=$first?"On":"";
|
|---|
| 242 |
|
|---|
| 243 | if (empty($_GET["fZenithDistanceMin"]))
|
|---|
| 244 | $_GET["fZenithDistanceMin"]=$first?"On":"";
|
|---|
| 245 |
|
|---|
| 246 | if (empty($_GET["fZenithDistanceMax"]))
|
|---|
| 247 | $_GET["fZenithDistanceMax"]=$first?"On":"";
|
|---|
| 248 |
|
|---|
| 249 | if (empty($_GET["fSourceName"]))
|
|---|
| 250 | $_GET["fSourceName"]=$first?"On":"";
|
|---|
| 251 |
|
|---|
| 252 | if (empty($_GET["fObservationModeName"]))
|
|---|
| 253 | $_GET["fObservationModeName"]=$first?"On":"";
|
|---|
| 254 |
|
|---|
| 255 | if (empty($_GET["fUnsuitableInner"]))
|
|---|
| 256 | $_GET["fUnsuitableInner"]=$first?"On":"";
|
|---|
| 257 |
|
|---|
| 258 | if (empty($_GET["fUnsInLimit1"]))
|
|---|
| 259 | $_GET["fUnsInLimit1"]=$first?"12":"";
|
|---|
| 260 |
|
|---|
| 261 | if (empty($_GET["fUnsInLimit2"]))
|
|---|
| 262 | $_GET["fUnsInLimit2"]=$first?"20":"";
|
|---|
| 263 |
|
|---|
| 264 | // if (empty($_GET["fRunTimeLimit1"]))
|
|---|
| 265 | // $_GET["fRunTimeLimit1"]=$first?"5":"";
|
|---|
| 266 |
|
|---|
| 267 | // if (empty($_GET["fRunTimeLimit2"]))
|
|---|
| 268 | // $_GET["fRunTimeLimit2"]=$first?"2":"";
|
|---|
| 269 |
|
|---|
| 270 | if (empty($_GET["fIMCLimit1"]))
|
|---|
| 271 | $_GET["fIMCLimit1"]=$first?"00":"";
|
|---|
| 272 |
|
|---|
| 273 | if (empty($_GET["fIsoInLimit1"]))
|
|---|
| 274 | $_GET["fIsoInLimit1"]=$first?"00":"";
|
|---|
| 275 |
|
|---|
| 276 | if (empty($_GET["fInhomLimitMean"]))
|
|---|
| 277 | $_GET["fInhomLimitMean"]=$first?"10":"";
|
|---|
| 278 |
|
|---|
| 279 | if (empty($_GET["fInhomLimitRms"]))
|
|---|
| 280 | $_GET["fInhomLimitRms"]=$first?"3":"";
|
|---|
| 281 |
|
|---|
| 282 | if (empty($_GET["fImgRateLimitMean"]))
|
|---|
| 283 | $_GET["fImgRateLimitMean"]=$first?"180":"";
|
|---|
| 284 |
|
|---|
| 285 | if (empty($_GET["fImgRateLimitRms"]))
|
|---|
| 286 | $_GET["fImgRateLimitRms"]=$first?"30":"";
|
|---|
| 287 |
|
|---|
| 288 | if (empty($_GET["fMuonRateLimitMean"]))
|
|---|
| 289 | $_GET["fMuonRateLimitMean"]=$first?"1":"";
|
|---|
| 290 |
|
|---|
| 291 | if (empty($_GET["fMuonRateLimitRms"]))
|
|---|
| 292 | $_GET["fMuonRateLimitRms"]=$first?"0.2":"";
|
|---|
| 293 |
|
|---|
| 294 | if (empty($_GET["fMuonNumLimit1"]))
|
|---|
| 295 | $_GET["fMuonNumLimit1"]=$first?"180":"";
|
|---|
| 296 |
|
|---|
| 297 | if (empty($_GET["fMuonNumLimit2"]))
|
|---|
| 298 | $_GET["fMuonNumLimit2"]=$first?"120":"";
|
|---|
| 299 |
|
|---|
| 300 | if (empty($_GET["fNumStarsLimit1"]))
|
|---|
| 301 | $_GET["fNumStarsLimit1"]=$first?"30":"";
|
|---|
| 302 |
|
|---|
| 303 | if (empty($_GET["fNumStarsLimit2"]))
|
|---|
| 304 | $_GET["fNumStarsLimit2"]=$first?"20":"";
|
|---|
| 305 |
|
|---|
| 306 | if (empty($_GET["fNumStarsCorLimit1"]))
|
|---|
| 307 | $_GET["fNumStarsCorLimit1"]=$first?"10":"";
|
|---|
| 308 |
|
|---|
| 309 | if (empty($_GET["fNumStarsCorLimit2"]))
|
|---|
| 310 | $_GET["fNumStarsCorLimit2"]=$first?"5":"";
|
|---|
| 311 |
|
|---|
| 312 | if (empty($_GET["fUnreliableInner"]))
|
|---|
| 313 | $_GET["fUnreliableInner"]=$first?"On":"";
|
|---|
| 314 |
|
|---|
| 315 | if (empty($_GET["fIsolatedInner"]))
|
|---|
| 316 | $_GET["fIsolatedInner"]=$first?"On":"";
|
|---|
| 317 |
|
|---|
| 318 | if (empty($_GET["fIsolatedMaxCluster"]))
|
|---|
| 319 | $_GET["fIsolatedMaxCluster"]=$first?"On":"";
|
|---|
| 320 |
|
|---|
| 321 | if (empty($_GET["fArrTimeMeanInner"]))
|
|---|
| 322 | $_GET["fArrTimeMeanInner"]=$first?"On":"";
|
|---|
| 323 |
|
|---|
| 324 | if (empty($_GET["fArrTimeRmsInner"]))
|
|---|
| 325 | $_GET["fArrTimeRmsInner"]=$first?"On":"";
|
|---|
| 326 |
|
|---|
| 327 | if (empty($_GET["fMeanPedRmsInner"]))
|
|---|
| 328 | $_GET["fMeanPedRmsInner"]=$first?"On":"";
|
|---|
| 329 |
|
|---|
| 330 | if (empty($_GET["fPulsePosMean"]))
|
|---|
| 331 | $_GET["fPulsePosMean"]=$first?"On":"";
|
|---|
| 332 |
|
|---|
| 333 | if (empty($_GET["fConvFactorInner"]))
|
|---|
| 334 | $_GET["fConvFactorInner"]=$first?"On":"";
|
|---|
| 335 |
|
|---|
| 336 | if (empty($_GET["fInhomogeneity"]))
|
|---|
| 337 | $_GET["fInhomogeneity"]=$first?"On":"";
|
|---|
| 338 |
|
|---|
| 339 | if (empty($_GET["fPSF"]))
|
|---|
| 340 | $_GET["fPSF"]=$first?"On":"";
|
|---|
| 341 |
|
|---|
| 342 | if (empty($_GET["fMuonNumber"]))
|
|---|
| 343 | $_GET["fMuonNumber"]=$first?"On":"";
|
|---|
| 344 |
|
|---|
| 345 | if (empty($_GET["fEffOnTime/fRunTime"]))
|
|---|
| 346 | $_GET["fEffOnTime/fRunTime"]=$first?"On":"";
|
|---|
| 347 |
|
|---|
| 348 | if (empty($_GET["fMuonRate"]))
|
|---|
| 349 | $_GET["fMuonRate"]=$first?"On":"";
|
|---|
| 350 |
|
|---|
| 351 | if (empty($_GET["fDataRate"]))
|
|---|
| 352 | $_GET["fDataRate"]=$first?"On":"";
|
|---|
| 353 |
|
|---|
| 354 | if (empty($_GET["fMaxHumidity"]))
|
|---|
| 355 | $_GET["fMaxHumidity"]=$first?"On":"";
|
|---|
| 356 |
|
|---|
| 357 | if (empty($_GET["fBrightnessMed"]))
|
|---|
| 358 | $_GET["fBrightnessMed"]=$first?"On":"";
|
|---|
| 359 |
|
|---|
| 360 | if (empty($_GET["fNumStarsMed"]))
|
|---|
| 361 | $_GET["fNumStarsMed"]=$first?"On":"";
|
|---|
| 362 |
|
|---|
| 363 | if (empty($_GET["fNumStarsCorMed"]))
|
|---|
| 364 | $_GET["fNumStarsCorMed"]=$first?"On":"";
|
|---|
| 365 |
|
|---|
| 366 | if (empty($_GET["fOff"]))
|
|---|
| 367 | $_GET["fOff"]=$first?"On":"";
|
|---|
| 368 |
|
|---|
| 369 | if (empty($_GET["fLinks"]))
|
|---|
| 370 | $_GET["fLinks"]=$first?"On":"";
|
|---|
| 371 |
|
|---|
| 372 | if (empty($_GET["fOnlyOff"]))
|
|---|
| 373 | $_GET["fOnlyOff"]=$first?"Off":"";
|
|---|
| 374 |
|
|---|
| 375 | InitSequInfo($_GET);
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | function PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias)
|
|---|
| 379 | {
|
|---|
| 380 | printf("<center>\n");
|
|---|
| 381 | printf("<form action='builddatasets.php' METHOD='GET'>\n");
|
|---|
| 382 | printf("<input id='sh' type='hidden' name='fShowHide' value='");
|
|---|
| 383 | if (!empty($_GET["fShowHide"]))
|
|---|
| 384 | printf("%s", $_GET["fShowHide"]);
|
|---|
| 385 | else
|
|---|
| 386 | printf("1000000000");
|
|---|
| 387 | printf("'>\n");
|
|---|
| 388 | printf("<img id='allbutton' src='../minus.png' alt='-' onclick='showhide(\"all\")'> Menu \n");
|
|---|
| 389 | printf("<img id='infobutton' src='../plus.png' alt='+' onClick='showhide(\"info\");showhide(\"info2\")'>SequInfo \n");
|
|---|
| 390 | printf("<img id='statbutton' src='../plus.png' alt='+' onClick='showhide(\"stat\");showhide(\"fail\")'> StatusInfo \n");
|
|---|
| 391 | printf("<img id='calbutton' src='../plus.png' alt='+' onClick='showhide(\"cal\")'> CalInfo \n");
|
|---|
| 392 | printf("<img id='starbutton' src='../plus.png' alt='+' onClick='showhide(\"star\")'> StarInfo \n");
|
|---|
| 393 | printf("<img id='rangesbutton' src='../plus.png' alt='+' onClick='showhide(\"ranges\")'> Ranges \n");
|
|---|
| 394 | printf("<img id='limitsbutton' src='../plus.png' alt='+' onClick='showhide(\"limits\")'> Limits \n");
|
|---|
| 395 |
|
|---|
| 396 | printf(" <div id='all' style='display:block'>");
|
|---|
| 397 |
|
|---|
| 398 | PrintSequInfo2Menu($host,$user,$pw,$db);
|
|---|
| 399 | PrintSequInfoMenu();
|
|---|
| 400 | PrintSequStatMenu();
|
|---|
| 401 | PrintFailMenu();
|
|---|
| 402 | PrintCalMenu();
|
|---|
| 403 | PrintStarMenu();
|
|---|
| 404 | PrintLimitsMenu($limitsmean, $limitsmin, $limitsmax, $alias, "");
|
|---|
| 405 |
|
|---|
| 406 | printf(" <div id='ranges' style='display:none'>");
|
|---|
| 407 | PrintZdRangeMenu($host,$user,$pw,$db);
|
|---|
| 408 | PrintSequRangeMenu($host,$user,$pw,$db);
|
|---|
| 409 | printf("<p>");
|
|---|
| 410 | PrintSourceMenu($host,$user,$pw,$db);
|
|---|
| 411 | PrintNightRangeMenu($host,$user,$pw,$db);
|
|---|
| 412 | PrintStarRangeMenu($host,$user,$pw,$db);
|
|---|
| 413 | printf("<p>");
|
|---|
| 414 | printf("</div>");
|
|---|
| 415 |
|
|---|
| 416 | printf("</div>");
|
|---|
| 417 | printf(" <P>\n");
|
|---|
| 418 |
|
|---|
| 419 | PrintNumResPullDown();
|
|---|
| 420 |
|
|---|
| 421 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 422 | ini_set("display_errors", "Off");
|
|---|
| 423 |
|
|---|
| 424 | PrintButtons("builddatasets.php");
|
|---|
| 425 |
|
|---|
| 426 | $sequon=" ";
|
|---|
| 427 | $sequoff=" ";
|
|---|
| 428 | foreach($_POST as $key => $val)
|
|---|
| 429 | if ($val=="On")
|
|---|
| 430 | {
|
|---|
| 431 | if (ereg("ON$", $key))
|
|---|
| 432 | $sequon.=str_replace("ON", " ", $key);
|
|---|
| 433 | if (ereg("Off$", $key))
|
|---|
| 434 | $sequoff.=str_replace("Off", " ", $key);
|
|---|
| 435 | }
|
|---|
| 436 | printf("<input name='Set' type='hidden' value='%s'>\n", $sequon);
|
|---|
| 437 | printf("<input name='Set2' type='hidden' value='%s'>\n", $sequoff);
|
|---|
| 438 | printf("<input name='name' type='hidden' value='%s'>\n", $_POST["name"]);
|
|---|
| 439 | printf("<input name='comment' type='hidden' value='%s'>\n", $_POST["comment"]);
|
|---|
| 440 | printf("<input name='obsmode' type='hidden' value='%s'>\n", $_POST["fObservationModeKEY"]);
|
|---|
| 441 | printf("</form>\n");
|
|---|
| 442 | printf("</center>\n");
|
|---|
| 443 | printf("</td>\n");
|
|---|
| 444 | printf("</tr>\n");
|
|---|
| 445 | printf("<tr class='Block'>\n");
|
|---|
| 446 | printf("<td>\n");
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs)
|
|---|
| 450 | {
|
|---|
| 451 | $db_id = mysql_pconnect($host, $user, $pw);
|
|---|
| 452 | if ($db_id==FALSE)
|
|---|
| 453 | {
|
|---|
| 454 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
|---|
| 455 | die("");
|
|---|
| 456 | }
|
|---|
| 457 | mysql_select_db($db);
|
|---|
| 458 |
|
|---|
| 459 | $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
|---|
| 460 |
|
|---|
| 461 | $result0 = mysql_query($query0, $db_id);
|
|---|
| 462 |
|
|---|
| 463 | if ($result0)
|
|---|
| 464 | {
|
|---|
| 465 | if ($html=="1" || $html=="2")
|
|---|
| 466 | {
|
|---|
| 467 | PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, "yes", $_GET);
|
|---|
| 468 | foreach($_POST as $key => $val)
|
|---|
| 469 | if ($val=="On")
|
|---|
| 470 | {
|
|---|
| 471 | if (ereg("ON$", $key))
|
|---|
| 472 | $sequon.=str_replace("ON", " ", $key);
|
|---|
| 473 | if (ereg("Off$", $key))
|
|---|
| 474 | $sequoff.=str_replace("Off", " ", $key);
|
|---|
| 475 | }
|
|---|
| 476 | printf("<input type='submit' value='Get Dataset'><br><br>\n");
|
|---|
| 477 | printf("<input name='submit' type='hidden' value='post'>\n");
|
|---|
| 478 |
|
|---|
| 479 | $on=str_replace(" ", ",", trim($sequon));
|
|---|
| 480 | $off=str_replace(" ", ",", trim($sequoff));
|
|---|
| 481 |
|
|---|
| 482 | $values=array("Sum(fRunTime)/60" => $runtime,
|
|---|
| 483 | "Min(fRunTime)/60" => $runtimemin,
|
|---|
| 484 | "Max(fUnsuitableInner)" => $unsuitablemax,
|
|---|
| 485 | "Max(fUnreliableInner)" => $unreliablemax,
|
|---|
| 486 | "Max(fIsolatedInner)" => $isolatedmax,
|
|---|
| 487 | "Max(fIsolatedMaxCluster)" => $imcmax,
|
|---|
| 488 | "Max(fArrTimeMeanInner)" => $arrtimemax,
|
|---|
| 489 | "Min(fArrTimeMeanInner)" => $arrtimemin,
|
|---|
| 490 | "Max(fArrTimeRmsInner)" => $arrtimermsmax,
|
|---|
| 491 | "Avg(fMeanPedRmsInner)" => $pedrmsmean,
|
|---|
| 492 | "Std(fMeanPedRmsInner)" => $pedrmsrms,
|
|---|
| 493 | "Min(fMeanPedRmsInner)" => $pedrmsmin,
|
|---|
| 494 | "Max(fMeanPedRmsInner)" => $pedrmsmax,
|
|---|
| 495 | "Min(fPulsePosMean)" => $pulseposmin,
|
|---|
| 496 | "Max(fPulsePosMean)" => $pulseposmax,
|
|---|
| 497 | "Max(fPulsePosRms)" => $pulseposrmsmax,
|
|---|
| 498 | "Max(fMaxHumidity)" => $hummax,
|
|---|
| 499 | "Max(fInhomogeneity)" => $inhommax,
|
|---|
| 500 | "Avg(fInhomogeneity)" => $inhommean,
|
|---|
| 501 | "Std(fInhomogeneity)" => $inhomrms,
|
|---|
| 502 | "Min(fMeanNumberIslands)" => $numislmin,
|
|---|
| 503 | "Max(fMeanNumberIslands)" => $numislmax,
|
|---|
| 504 | "Min(fDataRate)" => $clratemin,
|
|---|
| 505 | "Max(fDataRate)" => $clratemax,
|
|---|
| 506 | "Min(fMuonRate)" => $muonratemin,
|
|---|
| 507 | "Max(fMuonRate)" => $muonratemax,
|
|---|
| 508 | "Min(fMuonNumber)" => $muonnumbermin,
|
|---|
| 509 | "Avg(fPSF)" => $psfmean,
|
|---|
| 510 | "Std(fPSF)" => $psfrms,
|
|---|
| 511 | "Min(fPSF)" => $psfmin,
|
|---|
| 512 | "Max(fPSF)" => $psfmax,
|
|---|
| 513 | "Min(fEffOnTime/fRunTime)" => $relontimemin,
|
|---|
| 514 | "Max(fEffOnTime/fRunTime)" => $relontimemax,
|
|---|
| 515 | "Min(fBrightnessMed)" => $brightmin,
|
|---|
| 516 | "Max(fBrightnessMed)" => $brightmax,
|
|---|
| 517 | "Min(fNumStarsMed)" => $idstarsmin,
|
|---|
| 518 | "Max(fNumStarsMed)" => $idstarsmax,
|
|---|
| 519 | "Min(fNumStarsCorMed)" => $corstarsmin,
|
|---|
| 520 | "Max(fNumStarsCorMed)" => $corstarsmax,
|
|---|
| 521 | "Min(fZenithDistanceMin)" => $zdmin,
|
|---|
| 522 | "Max(fZenithDistanceMax)" => $zdmax,
|
|---|
| 523 | "Min(fRunStart)" => $starttime,
|
|---|
| 524 | "Max(fRunStop)" => $stoptime,
|
|---|
| 525 | );
|
|---|
| 526 | //get runtimes of dataset
|
|---|
| 527 | function GetSequenceValues($db_id, $sequences, $txt,&$values)
|
|---|
| 528 | {
|
|---|
| 529 | $query="SELECT COUNT(*) ";
|
|---|
| 530 | foreach($values as $name => $varname)
|
|---|
| 531 | $query.=", " . $name;
|
|---|
| 532 | $query.=" FROM Sequences ";
|
|---|
| 533 | $query.=" LEFT JOIN Calibration ON Calibration.fSequenceFirst=Sequences.fSequenceFirst ";
|
|---|
| 534 | $query.=" LEFT JOIN Star ON Star.fSequenceFirst=Sequences.fSequenceFirst ";
|
|---|
| 535 | $query.=" WHERE Sequences.fSequenceFirst IN (" . $sequences . ")";
|
|---|
| 536 | $result = mysql_query($query, $db_id);
|
|---|
| 537 | $row = mysql_fetch_assoc($result);
|
|---|
| 538 | foreach($values as $name => $varname)
|
|---|
| 539 | $values[$name][$txt]=$row[$name];
|
|---|
| 540 | mysql_free_result($result);
|
|---|
| 541 | }
|
|---|
| 542 |
|
|---|
| 543 | //get next dataset#
|
|---|
| 544 | $query="SELECT fDataSetNumber+1 FROM DataSets ORDER BY fDataSetNumber DESC LIMIT 0,1";
|
|---|
| 545 | $result = mysql_query($query, $db_id);
|
|---|
| 546 | $row = mysql_fetch_assoc($result);
|
|---|
| 547 | $dataset=$row["fDataSetNumber+1"];
|
|---|
| 548 | if (empty($dataset))
|
|---|
| 549 | $dataset=1;
|
|---|
| 550 | mysql_free_result($result);
|
|---|
| 551 |
|
|---|
| 552 | //get sourcenames
|
|---|
| 553 | function GetSources($db_id, $sequences)
|
|---|
| 554 | {
|
|---|
| 555 | $query="SELECT fSourceName FROM Source LEFT JOIN Sequences ON Sequences.fSourceKEY=Source.fSourceKEY ";
|
|---|
| 556 | $query.="WHERE fSequenceFirst IN (" . $sequences . ") GROUP BY fSourceName";
|
|---|
| 557 | $result = mysql_query($query, $db_id);
|
|---|
| 558 | while ($row = mysql_fetch_assoc($result))
|
|---|
| 559 | $sources.=" " . $row["fSourceName"];
|
|---|
| 560 | mysql_free_result($result);
|
|---|
| 561 | return $sources;
|
|---|
| 562 | }
|
|---|
| 563 | $sourceson=GetSources($db_id, $on);
|
|---|
| 564 | $sourcesoff=GetSources($db_id, $off);
|
|---|
| 565 |
|
|---|
| 566 | //get sourcename for dataset
|
|---|
| 567 | $son=str_replace(" ", "','", trim($sourceson));
|
|---|
| 568 | $query="SELECT fRealSourceKEY, Count(*) FROM Source where fSourcename IN ('" . $son . "') GROUP BY fRealSourceKEY";
|
|---|
| 569 | // printf("q: %s <br>", $query);
|
|---|
| 570 | $result = mysql_query($query, $db_id);
|
|---|
| 571 | $row = mysql_fetch_assoc($result);
|
|---|
| 572 | $numsources=$row["Count(*)"];
|
|---|
| 573 | $numrealkeys=mysql_num_rows($result);
|
|---|
| 574 | $realsourcekey=$row["fRealSourceKEY"];
|
|---|
| 575 | mysql_free_result($result);
|
|---|
| 576 | // printf("found %s sources with real sourcekey %s", $numsources, $realsourcekey);
|
|---|
| 577 | // printf("found %s keys", $numrealkeys);
|
|---|
| 578 |
|
|---|
| 579 |
|
|---|
| 580 | $runtimelimit=5;
|
|---|
| 581 | $unsuitablemaxlimit=15;
|
|---|
| 582 | $isolatedlimit=0;
|
|---|
| 583 | $imclimit=0;
|
|---|
| 584 | $pedrmsrms=0.09;
|
|---|
| 585 | $scalelimit=1.3;
|
|---|
| 586 | $inhomlimit=13;
|
|---|
| 587 | $numstarslimit=20;
|
|---|
| 588 | $numstarscorlimit=10;
|
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 | $numerr=0;
|
|---|
| 592 | if (!empty($on))
|
|---|
| 593 | {
|
|---|
| 594 | $color=array("INFO" => "#000000",
|
|---|
| 595 | "WARN" => "#FF9900",
|
|---|
| 596 | "ERROR" => "#FF0000");
|
|---|
| 597 | printf("<div align='left'><font><ul>\n");
|
|---|
| 598 | $vals=array("on", "off");
|
|---|
| 599 | foreach($vals as $num => $val)
|
|---|
| 600 | {
|
|---|
| 601 | if (empty(${$val}))
|
|---|
| 602 | continue;
|
|---|
| 603 | GetSequenceValues($db_id, ${$val}, $val, $values);
|
|---|
| 604 |
|
|---|
| 605 | if ($values["Min(fNumStarsCorMed)"][$val]<$numstarscorlimit)
|
|---|
| 606 | printf("<li style='color:%s'>%s: one of your %s-sequences has less than %s identified stars (%s)</li>",
|
|---|
| 607 | $color["WARN"], "WARN", $val, $numstarscorlimit, $values["Min(fNumStarsCorMed)"][$val]);
|
|---|
| 608 | if ($values["Min(fNumStarsMed)"][$val]<$numstarslimit)
|
|---|
| 609 | printf("<li style='color:%s'>%s: one of your %s-sequences has less than %s identified stars (%s)</li>",
|
|---|
| 610 | $color["WARN"], "WARN", $val, $numstarslimit, $values["Min(fNumStarsMed)"][$val]);
|
|---|
| 611 | if ($values["Min(fRunTime)/60"][$val]<$runtimelimit)
|
|---|
| 612 | printf("<li style='color:%s'>%s: one of your %s-sequences is shorter than %s min (%s min)</li>",
|
|---|
| 613 | $color["INFO"], "INFO", $val, $runtimelimit, $values["Min(fRunTime)/60"][$val]);
|
|---|
| 614 | if ($values["Max(fInhomogeneity)"][$val]>$inhomlimit)
|
|---|
| 615 | printf("<li style='color:%s'>%s: one of your %s-sequences has an inhomogeneity larger than %s (%s)</li>",
|
|---|
| 616 | $color["WARN"], "WARN", $val, $inhomlimit, $values["Max(fInhomogeneity)"][$val]);
|
|---|
| 617 | if ($values["Max(fUnsuitableInner)"][$val]>$unsuitablemaxlimit)
|
|---|
| 618 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s unsuitable inner pixel (%s)</li>",
|
|---|
| 619 | $color["WARN"], "WARN", $val, $unsuitablemaxlimit, $values["Max(fUnsuitableInner)"][$val]);
|
|---|
| 620 | if ($values["Max(fIsolatedInner)"][$val]>$isolatedlimit)
|
|---|
| 621 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s isolated inner pixel (%s)</li>",
|
|---|
| 622 | $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]);
|
|---|
| 623 | if ($values["Max(fIsolatedMaxCluster)"][$val]>$imclimit)
|
|---|
| 624 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s isolated max cluster (%s)</li>",
|
|---|
| 625 | $color["WARN"], "WARN", $val, $imclimit, $values["Max(fIsolatedMaxCluster)"][$val]);
|
|---|
| 626 | }
|
|---|
| 627 | if (!empty($on) && $values["Max(fMeanPedRmsInner)"]["on"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
|
|---|
| 628 | printf("<li style='color:%s'>%s: one of your on-sequences has a PedRms larger than %s (%s)</li>",
|
|---|
| 629 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["on"]);
|
|---|
| 630 | if (!empty($off) && $values["Max(fMeanPedRmsInner)"]["off"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
|
|---|
| 631 | printf("<li style='color:%s'>%s: one of your off-sequences has a PedRms larger than %s (%s)</li>",
|
|---|
| 632 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["off"]);
|
|---|
| 633 | if (!empty($off) && $values["Min(fMeanPedRmsInner)"]["off"]<$values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms)
|
|---|
| 634 | printf("<li style='color:%s'>%s: one of your off-sequences has a PedRms smaller than %s (%s)</li>",
|
|---|
| 635 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms, $values["Min(fMeanPedRmsInner)"]["off"]);
|
|---|
| 636 | $scale=$values["Sum(fRunTime)/60"]["on"]/$values["Sum(fRunTime)/60"]["off"];
|
|---|
| 637 | if ($scale > $scalelimit)
|
|---|
| 638 | printf("<li style='color:%s'>%s: Your scale factor is larger than %s (%0.2f). Try to find more offdata!",
|
|---|
| 639 | $color["WARN"], "WARN", $scalelimit, $scale);
|
|---|
| 640 | /*
|
|---|
| 641 | if (str_word_count($sourceson) > 1)
|
|---|
| 642 | printf("<li style='color:%s'>%s: You have selected more than one (%s) on source",
|
|---|
| 643 | $color["WARN"], "WARN", str_word_count($sourceson));
|
|---|
| 644 | */
|
|---|
| 645 | if ($numrealkeys>1)
|
|---|
| 646 | {
|
|---|
| 647 | printf("<li style='color:%s'>%s: You have selected more than one (%s) on source",
|
|---|
| 648 | $color["ERROR"], "ERROR", $numrealkeays);
|
|---|
| 649 | $numerr=$numerr+1;
|
|---|
| 650 | }
|
|---|
| 651 | if (empty($realsourcekey))
|
|---|
| 652 | {
|
|---|
| 653 | printf("<li style='color:%s'>%s: The source you selected doesn't have real sourceskeys yet.",
|
|---|
| 654 | $color["ERROR"], "ERROR");
|
|---|
| 655 | $numerr=$numerr+1;
|
|---|
| 656 | }
|
|---|
| 657 | if (empty($_POST["fObservationModeKEY"]))
|
|---|
| 658 | {
|
|---|
| 659 | printf("<li style='color:%s'>%s: You have to choose an observation mode.",
|
|---|
| 660 | $color["ERROR"], "ERROR");
|
|---|
| 661 | $numerr=$numerr+1;
|
|---|
| 662 | }
|
|---|
| 663 | if (empty($_POST["name"]))
|
|---|
| 664 | {
|
|---|
| 665 | printf("<li style='color:%s'>%s: You have to choose a name.",
|
|---|
| 666 | $color["ERROR"], "ERROR");
|
|---|
| 667 | $numerr=$numerr+1;
|
|---|
| 668 | }
|
|---|
| 669 | if (empty($_POST["comment"]))
|
|---|
| 670 | {
|
|---|
| 671 | printf("<li style='color:%s'>%s: You have to comment your dataset.",
|
|---|
| 672 | $color["ERROR"], "ERROR");
|
|---|
| 673 | $numerr=$numerr+1;
|
|---|
| 674 | }
|
|---|
| 675 | // printf("<li></li>");
|
|---|
| 676 | printf("</ul></font>\n");
|
|---|
| 677 |
|
|---|
| 678 | printf("<div align='left'>");
|
|---|
| 679 | printf("SequencesOn: %s<br>", $sequon);
|
|---|
| 680 | printf("SequencesOff: %s<br>", $sequoff);
|
|---|
| 681 | $insquery[0]="INSERT DataSets SET fDataSetNumber=" . $dataset;
|
|---|
| 682 | $insquery[0].=", fComment='" . $_POST["comment"] . "', fObservationModeKEY=" . $_POST["fObservationModeKEY"];
|
|---|
| 683 | $insquery[0].=", fDataSetName='" . $_POST["name"] . "', fSourceKEY= " . $realsourcekey;
|
|---|
| 684 | $insquery[0].=", fRunStart='" . $values["Min(fRunStart)"]["on"];
|
|---|
| 685 | $insquery[0].="', fRunStop='" . $values["Max(fRunStop)"]["on"];
|
|---|
| 686 | $insquery[0].="', fZenithDistanceMin=" . $values["Min(fZenithDistanceMin)"]["on"];
|
|---|
| 687 | $insquery[0].=", fZenithDistanceMax=" . $values["Max(fZenithDistanceMax)"]["on"];
|
|---|
| 688 | $insquery[0].=", fRunTime=" . $values["Sum(fRunTime)/60"]["on"];
|
|---|
| 689 | $insquery[1]="INSERT DataSetProcessStatus SET fDataSetNumber=" . $dataset . ", fDataSetInserted=Now()";
|
|---|
| 690 | $i=2;
|
|---|
| 691 | foreach(explode(" ", trim($sequon)) as $key => $sequ)
|
|---|
| 692 | {
|
|---|
| 693 | $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset;
|
|---|
| 694 | $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=1";
|
|---|
| 695 | $i=$i+1;
|
|---|
| 696 | }
|
|---|
| 697 | if (!empty($off))
|
|---|
| 698 | {
|
|---|
| 699 | foreach(explode(" ", trim($sequoff)) as $key => $sequ)
|
|---|
| 700 | {
|
|---|
| 701 | $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset;
|
|---|
| 702 | $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=2";
|
|---|
| 703 | $i=$i+1;
|
|---|
| 704 | }
|
|---|
| 705 | }
|
|---|
| 706 | foreach($insquery as $num => $q)
|
|---|
| 707 | {
|
|---|
| 708 | if (!empty($_POST["insert"]) && $numerr==0)
|
|---|
| 709 | {
|
|---|
| 710 | printf("Inserted Query #%s: %s<br>", $num, $q);
|
|---|
| 711 | $insresult=mysql_query($q);
|
|---|
| 712 | if (mysql_errno()>0)
|
|---|
| 713 | printf(" Errorno: %s <br>", mysql_errno());
|
|---|
| 714 | if (mysql_error()!="")
|
|---|
| 715 | printf(" Errormsg: %s <br>", mysql_error());
|
|---|
| 716 | if (mysql_info()!="")
|
|---|
| 717 | printf(" Info: %s <br>", mysql_info());
|
|---|
| 718 | printf(" Affected Rows: %s <br>", mysql_affected_rows());
|
|---|
| 719 | mysql_free_result($insresult);
|
|---|
| 720 | if (mysql_errno()>0)
|
|---|
| 721 | {
|
|---|
| 722 | printf("ERROR => stop inserting");
|
|---|
| 723 | break;
|
|---|
| 724 | }
|
|---|
| 725 | }
|
|---|
| 726 | }
|
|---|
| 727 | printf("</div>");
|
|---|
| 728 | if (empty($_POST["name"]) && !empty($_GET["name"]))
|
|---|
| 729 | $_POST["name"]=$_GET["name"];
|
|---|
| 730 | if (empty($_POST["comment"]) && !empty($_GET["comment"]))
|
|---|
| 731 | $_POST["comment"]=$_GET["comment"];
|
|---|
| 732 | if (empty($_POST["fObservationModeKEY"]) && !empty($_GET["obsmode"]))
|
|---|
| 733 | $_POST["fObservationModeKEY"]=$_GET["obsmode"];
|
|---|
| 734 | printf("Name: <input name='name' type='text' size='20' maxlength='20' value='%s'><br>\n", $_POST["name"]);
|
|---|
| 735 | printf("Comment: <input name='comment' type='text' size='50' maxlength='255' value='%s'><br>\n", $_POST["comment"]);
|
|---|
| 736 |
|
|---|
| 737 | $query = "SELECT fObservationModeKEY, fObservationModeName FROM ObservationMode ORDER BY fObservationModeName";
|
|---|
| 738 | $result = mysql_query($query);
|
|---|
| 739 | if (!$result)
|
|---|
| 740 | printf("-N/A-");
|
|---|
| 741 |
|
|---|
| 742 | $numrows = mysql_num_rows($result);
|
|---|
| 743 |
|
|---|
| 744 | printf("ObservationMode <select name='fObservationModeKEY' size='1' class='Width'>\n");
|
|---|
| 745 | while ($row = mysql_fetch_row($result))
|
|---|
| 746 | {
|
|---|
| 747 | if (!empty($_POST["fObservationModeKEY"]) && $_POST["fObservationModeKEY"]==$row[0])
|
|---|
| 748 | printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]);
|
|---|
| 749 | else
|
|---|
| 750 | printf("<option value='%s'>%s</option>\n", $row[0], $row[1]);
|
|---|
| 751 | }
|
|---|
| 752 | printf("</select><br>\n");
|
|---|
| 753 | mysql_free_result($result);
|
|---|
| 754 |
|
|---|
| 755 | printf("Remark: only datasets without errors can be inserted.<br>");
|
|---|
| 756 | if ($numerr!=0)
|
|---|
| 757 | printf("Your dataset has %s error(s).<br>", $numerr);
|
|---|
| 758 | printf("<input type='checkbox' name='insert' value='On'>insert\n");
|
|---|
| 759 |
|
|---|
| 760 | printf("<table><tr><td colspan='2' align='center'>Dataset</td></tr>");
|
|---|
| 761 | printf("<tr><td>proposed DataSet#: </td><td>%s</td></tr>", $dataset);
|
|---|
| 762 | printf("<tr><td>SequencesOn:</td><td> %s</td></tr>", $sequon);
|
|---|
| 763 | if (!empty($sequoff))
|
|---|
| 764 | printf("<tr><td>SequencesOff:</td><td> %s</td></tr>", $sequoff);
|
|---|
| 765 | printf("<tr><td>Scale: </td><td>%0.2f</td></tr>", $scale);
|
|---|
| 766 | printf("<tr><td>SourcenamesOn[%s]: </td><td>%s</td></tr>", str_word_count($sourceson), $sourceson);
|
|---|
| 767 | printf("<tr><td>SourcenamesOff[%s]: </td><td>%s</td></tr>", str_word_count($sourcesoff), $sourcesoff);
|
|---|
| 768 | printf("</table>\n");
|
|---|
| 769 |
|
|---|
| 770 | printf("<table border='1'>\n");
|
|---|
| 771 | printf("<tr><td>Value</td><td>On</td>");
|
|---|
| 772 | if (!empty($off))
|
|---|
| 773 | printf("<td>Off</td></tr>\n");
|
|---|
| 774 | foreach($values as $name => $varname)
|
|---|
| 775 | {
|
|---|
| 776 | printf("<tr><td>%s</td>\n", $name);
|
|---|
| 777 | foreach($vals as $num => $val)
|
|---|
| 778 | if (!empty(${$val}))
|
|---|
| 779 | printf("<td>%s</td>\n", $varname[$val]);
|
|---|
| 780 | printf("</tr>\n");
|
|---|
| 781 | }
|
|---|
| 782 | printf("</table>\n");
|
|---|
| 783 | }
|
|---|
| 784 |
|
|---|
| 785 | printf("</div>\n");
|
|---|
| 786 | /*
|
|---|
| 787 | printf("<table border='1'><tr>\n");
|
|---|
| 788 | printf("<td>--</td>\n");
|
|---|
| 789 | foreach($values as $name => $varname)
|
|---|
| 790 | printf("<td>%s</td>\n", $name);
|
|---|
| 791 | $vals=array("on", "off");
|
|---|
| 792 | foreach($vals as $num => $val)
|
|---|
| 793 | {
|
|---|
| 794 | GetSequenceValues($db_id, ${$val}, $val, $values);
|
|---|
| 795 | printf("</tr><tr>\n");
|
|---|
| 796 | printf("<td>On</td>\n");
|
|---|
| 797 | foreach($values as $name => $varname)
|
|---|
| 798 | printf("<td>%s</td>\n", $varname[$val]);
|
|---|
| 799 | }
|
|---|
| 800 | printf("</tr></table>\n");
|
|---|
| 801 | */
|
|---|
| 802 |
|
|---|
| 803 | printf("</center>\n");
|
|---|
| 804 | printf("</td>\n");
|
|---|
| 805 | printf("</tr>\n");
|
|---|
| 806 |
|
|---|
| 807 | printf("</form>\n");
|
|---|
| 808 | }
|
|---|
| 809 | else
|
|---|
| 810 | PrintText($result0);
|
|---|
| 811 |
|
|---|
| 812 | mysql_free_result($result0);
|
|---|
| 813 | }
|
|---|
| 814 | mysql_close($db_id);
|
|---|
| 815 |
|
|---|
| 816 | PrintSubmittedQuery($query0, $html, $db, "");
|
|---|
| 817 | }
|
|---|
| 818 |
|
|---|
| 819 | include ("include.php");
|
|---|
| 820 | include ("menu.php");
|
|---|
| 821 | include ("db.php");
|
|---|
| 822 | include ("magicdefs.php");
|
|---|
| 823 |
|
|---|
| 824 | ini_set("display_errors", "On");
|
|---|
| 825 | ini_set("mysql.trace_mode", "On");
|
|---|
| 826 |
|
|---|
| 827 | $sitepw="\$1\$ml/Gld67\$zOvhC4vFrLCkbAzQs2swo1";
|
|---|
| 828 | $siteuser="dcdb";
|
|---|
| 829 |
|
|---|
| 830 | if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER']!=$siteuser)
|
|---|
| 831 | {
|
|---|
| 832 | header('WWW-Authenticate: Basic realm="My Realm"');
|
|---|
| 833 | header('HTTP/1.0 401 Unauthorized');
|
|---|
| 834 | echo 'Text to send if user hits Cancel button';
|
|---|
| 835 | return;
|
|---|
| 836 | }
|
|---|
| 837 | else
|
|---|
| 838 | {
|
|---|
| 839 | // echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
|
|---|
| 840 | // echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
|
|---|
| 841 | // printf("pw: %s", crypt($_SERVER['PHP_AUTH_PW']));
|
|---|
| 842 | if (crypt($_SERVER['PHP_AUTH_PW'], $sitepw)!=$sitepw || $_SERVER['PHP_AUTH_USER']!=$siteuser)
|
|---|
| 843 | {
|
|---|
| 844 | printf("<br>pw or user incorrect<br>");
|
|---|
| 845 | return;
|
|---|
| 846 | }
|
|---|
| 847 | }
|
|---|
| 848 |
|
|---|
| 849 | if (!empty($_GET["fSendTxt"]))
|
|---|
| 850 | {
|
|---|
| 851 | header("Content-type: application/octet");
|
|---|
| 852 | header("Content-Disposition: attachment; filename=query-result.txt");
|
|---|
| 853 |
|
|---|
| 854 | PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
|---|
| 855 | }
|
|---|
| 856 | else
|
|---|
| 857 | {
|
|---|
| 858 | echo (file_get_contents("index-header.html"));
|
|---|
| 859 |
|
|---|
| 860 | $environment = sizeof($_GET);
|
|---|
| 861 |
|
|---|
| 862 | InitGet($_GET);
|
|---|
| 863 | if (empty($_GET["fPrintTable"]))
|
|---|
| 864 | PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias);
|
|---|
| 865 |
|
|---|
| 866 | if ($environment==0)
|
|---|
| 867 | printf("No query submitted yet.<BR>");
|
|---|
| 868 | else
|
|---|
| 869 | {
|
|---|
| 870 | if (empty($_GET["fPrintTable"]))
|
|---|
| 871 | PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
|---|
| 872 | else
|
|---|
| 873 | PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
|---|
| 874 | }
|
|---|
| 875 |
|
|---|
| 876 | echo (file_get_contents("index-footer.html"));
|
|---|
| 877 | }
|
|---|
| 878 |
|
|---|
| 879 | ini_set("display_errors", "Off");
|
|---|
| 880 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 881 | }
|
|---|
| 882 | ?>
|
|---|