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["fPSFLimitRms"]))
|
---|
271 | $_GET["fPSFLimitRms"]=$first?"1.0":"";
|
---|
272 |
|
---|
273 | if (empty($_GET["fPedRmsInLimitRms"]))
|
---|
274 | $_GET["fPedRmsInLimitRms"]=$first?"0.08":"";
|
---|
275 |
|
---|
276 | if (empty($_GET["fNumIslLimitMean"]))
|
---|
277 | $_GET["fNumIslLimitMean"]=$first?"1.230":"";
|
---|
278 |
|
---|
279 | if (empty($_GET["fNumIslLimitRms"]))
|
---|
280 | $_GET["fNumIslLimitRms"]=$first?"0.013":"";
|
---|
281 |
|
---|
282 | if (empty($_GET["fMuonCalLimitMean"]))
|
---|
283 | $_GET["fMuonCalLimitMean"]=$first?"100.0":"";
|
---|
284 |
|
---|
285 | if (empty($_GET["fMuonCalLimitRms"]))
|
---|
286 | $_GET["fMuonCalLimitRms"]=$first?"1.6":"";
|
---|
287 |
|
---|
288 | if (empty($_GET["fRelTimeMaxLimit1"]))
|
---|
289 | $_GET["fRelTimeMaxLimit1"]=$first?"1.0":"";
|
---|
290 |
|
---|
291 | if (empty($_GET["fRelTimeMaxLimit2"]))
|
---|
292 | $_GET["fRelTimeMaxLimit2"]=$first?"1.02":"";
|
---|
293 |
|
---|
294 | if (empty($_GET["fRelTimeMinLimit1"]))
|
---|
295 | $_GET["fRelTimeMinLimit1"]=$first?"0.97":"";
|
---|
296 |
|
---|
297 | if (empty($_GET["fRelTimeMinLimit2"]))
|
---|
298 | $_GET["fRelTimeMinLimit2"]=$first?"0.93":"";
|
---|
299 |
|
---|
300 | if (empty($_GET["fIMCLimit1"]))
|
---|
301 | $_GET["fIMCLimit1"]=$first?"00":"";
|
---|
302 |
|
---|
303 | if (empty($_GET["fIsoInLimit1"]))
|
---|
304 | $_GET["fIsoInLimit1"]=$first?"00":"";
|
---|
305 |
|
---|
306 | if (empty($_GET["fInhomLimitMean"]))
|
---|
307 | $_GET["fInhomLimitMean"]=$first?"10":"";
|
---|
308 |
|
---|
309 | if (empty($_GET["fInhomLimitRms"]))
|
---|
310 | $_GET["fInhomLimitRms"]=$first?"3":"";
|
---|
311 |
|
---|
312 | if (empty($_GET["fImgRateLimitMean"]))
|
---|
313 | $_GET["fImgRateLimitMean"]=$first?"180":"";
|
---|
314 |
|
---|
315 | if (empty($_GET["fImgRateLimitRms"]))
|
---|
316 | $_GET["fImgRateLimitRms"]=$first?"30":"";
|
---|
317 |
|
---|
318 | if (empty($_GET["fMuonRateLimitMean"]))
|
---|
319 | $_GET["fMuonRateLimitMean"]=$first?"1":"";
|
---|
320 |
|
---|
321 | if (empty($_GET["fMuonRateLimitRms"]))
|
---|
322 | $_GET["fMuonRateLimitRms"]=$first?"0.1":"";
|
---|
323 |
|
---|
324 | if (empty($_GET["fMuonNumLimit1"]))
|
---|
325 | $_GET["fMuonNumLimit1"]=$first?"180":"";
|
---|
326 |
|
---|
327 | if (empty($_GET["fMuonNumLimit2"]))
|
---|
328 | $_GET["fMuonNumLimit2"]=$first?"120":"";
|
---|
329 |
|
---|
330 | if (empty($_GET["fPulsePosLimit1"]))
|
---|
331 | $_GET["fPulsePosLimit1"]=$first?"3.5":"";
|
---|
332 |
|
---|
333 | if (empty($_GET["fPulsePosLimit2"]))
|
---|
334 | $_GET["fPulsePosLimit2"]=$first?"2.5":"";
|
---|
335 |
|
---|
336 | if (empty($_GET["fNumStarsLimit1"]))
|
---|
337 | $_GET["fNumStarsLimit1"]=$first?"30":"";
|
---|
338 |
|
---|
339 | if (empty($_GET["fNumStarsLimit2"]))
|
---|
340 | $_GET["fNumStarsLimit2"]=$first?"20":"";
|
---|
341 |
|
---|
342 | if (empty($_GET["fNumStarsCorLimit1"]))
|
---|
343 | $_GET["fNumStarsCorLimit1"]=$first?"10":"";
|
---|
344 |
|
---|
345 | if (empty($_GET["fNumStarsCorLimit2"]))
|
---|
346 | $_GET["fNumStarsCorLimit2"]=$first?"5":"";
|
---|
347 |
|
---|
348 | if (empty($_GET["fUnreliableInner"]))
|
---|
349 | $_GET["fUnreliableInner"]=$first?"On":"";
|
---|
350 |
|
---|
351 | if (empty($_GET["fIsolatedInner"]))
|
---|
352 | $_GET["fIsolatedInner"]=$first?"On":"";
|
---|
353 |
|
---|
354 | if (empty($_GET["fIsolatedMaxCluster"]))
|
---|
355 | $_GET["fIsolatedMaxCluster"]=$first?"On":"";
|
---|
356 |
|
---|
357 | // if (empty($_GET["fArrTimeMeanInner"]))
|
---|
358 | // $_GET["fArrTimeMeanInner"]=$first?"On":"";
|
---|
359 |
|
---|
360 | if (empty($_GET["fArrTimeRmsInner"]))
|
---|
361 | $_GET["fArrTimeRmsInner"]=$first?"On":"";
|
---|
362 |
|
---|
363 | if (empty($_GET["fMeanPedRmsInner"]))
|
---|
364 | $_GET["fMeanPedRmsInner"]=$first?"On":"";
|
---|
365 |
|
---|
366 | if (empty($_GET["fPulsePosMean"]))
|
---|
367 | $_GET["fPulsePosMean"]=$first?"On":"";
|
---|
368 |
|
---|
369 | if (empty($_GET["fConvFactorInner"]))
|
---|
370 | $_GET["fConvFactorInner"]=$first?"On":"";
|
---|
371 |
|
---|
372 | if (empty($_GET["fInhomogeneity"]))
|
---|
373 | $_GET["fInhomogeneity"]=$first?"On":"";
|
---|
374 |
|
---|
375 | if (empty($_GET["fPSF"]))
|
---|
376 | $_GET["fPSF"]=$first?"On":"";
|
---|
377 |
|
---|
378 | if (empty($_GET["fMuonNumber"]))
|
---|
379 | $_GET["fMuonNumber"]=$first?"On":"";
|
---|
380 |
|
---|
381 | if (empty($_GET["fEffOnTime/fRunTime"]))
|
---|
382 | $_GET["fEffOnTime/fRunTime"]=$first?"On":"";
|
---|
383 |
|
---|
384 | if (empty($_GET["fMuonRate"]))
|
---|
385 | $_GET["fMuonRate"]=$first?"On":"";
|
---|
386 |
|
---|
387 | if (empty($_GET["fDataRate"]))
|
---|
388 | $_GET["fDataRate"]=$first?"On":"";
|
---|
389 |
|
---|
390 | // if (empty($_GET["fMaxHumidity"]))
|
---|
391 | // $_GET["fMaxHumidity"]=$first?"On":"";
|
---|
392 |
|
---|
393 | if (empty($_GET["fBrightnessMed"]))
|
---|
394 | $_GET["fBrightnessMed"]=$first?"On":"";
|
---|
395 |
|
---|
396 | if (empty($_GET["fNumStarsMed"]))
|
---|
397 | $_GET["fNumStarsMed"]=$first?"On":"";
|
---|
398 |
|
---|
399 | if (empty($_GET["fNumStarsCorMed"]))
|
---|
400 | $_GET["fNumStarsCorMed"]=$first?"On":"";
|
---|
401 |
|
---|
402 | if (empty($_GET["fOff"]))
|
---|
403 | $_GET["fOff"]=$first?"On":"";
|
---|
404 |
|
---|
405 | if (empty($_GET["fLinks"]))
|
---|
406 | $_GET["fLinks"]=$first?"On":"";
|
---|
407 |
|
---|
408 | if (empty($_GET["fOnlyOff"]))
|
---|
409 | $_GET["fOnlyOff"]=$first?"Off":"";
|
---|
410 |
|
---|
411 | InitSequInfo($_GET);
|
---|
412 | }
|
---|
413 |
|
---|
414 | function PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias)
|
---|
415 | {
|
---|
416 | printf("<center>\n");
|
---|
417 | printf("<form action='builddatasets.php' METHOD='GET'>\n");
|
---|
418 | printf("<input id='sh' type='hidden' name='fShowHide' value='");
|
---|
419 | if (!empty($_GET["fShowHide"]))
|
---|
420 | printf("%s", $_GET["fShowHide"]);
|
---|
421 | else
|
---|
422 | printf("1000000000");
|
---|
423 | printf("'>\n");
|
---|
424 | printf("<img id='allbutton' src='../minus.png' alt='-' onclick='showhide(\"all\")'> <b>Menu</b> \n");
|
---|
425 | printf(" <img id='infobutton' src='../plus.png' alt='+' onClick='showhide(\"info\");showhide(\"info2\")'> SequInfo \n");
|
---|
426 | printf(" <img id='statbutton' src='../plus.png' alt='+' onClick='showhide(\"stat\");showhide(\"fail\")'> StatusInfo \n");
|
---|
427 | printf(" <img id='calbutton' src='../plus.png' alt='+' onClick='showhide(\"cal\")'> CalInfo \n");
|
---|
428 | printf(" <img id='starbutton' src='../plus.png' alt='+' onClick='showhide(\"star\")'> StarInfo \n");
|
---|
429 | printf(" <img id='limitsbutton' src='../plus.png' alt='+' onClick='showhide(\"limits\")'> Limits \n");
|
---|
430 | printf(" <img id='rangesbutton' src='../plus.png' alt='+' onClick='showhide(\"ranges\")'> Ranges \n");
|
---|
431 |
|
---|
432 | printf(" <div id='all' style='display:block'>");
|
---|
433 |
|
---|
434 | PrintSequInfo2Menu($host,$user,$pw,$db);
|
---|
435 | PrintSequInfoMenu();
|
---|
436 | PrintSequStatMenu();
|
---|
437 | PrintFailMenu();
|
---|
438 | PrintCalMenu();
|
---|
439 | PrintStarMenu();
|
---|
440 | PrintLimitsMenu($limitsmean, $limitsmin, $limitsmax, $alias, "");
|
---|
441 |
|
---|
442 | printf(" <div id='ranges' style='display:none'>");
|
---|
443 | PrintZdRangeMenu($host,$user,$pw,$db);
|
---|
444 | PrintSequRangeMenu($host,$user,$pw,$db);
|
---|
445 | printf("<p>");
|
---|
446 | PrintSourceMenu($host,$user,$pw,$db);
|
---|
447 | PrintNightRangeMenu($host,$user,$pw,$db);
|
---|
448 | PrintStarRangeMenu($host,$user,$pw,$db);
|
---|
449 | printf("<p>");
|
---|
450 | printf("</div>");
|
---|
451 |
|
---|
452 | printf("</div>");
|
---|
453 | printf(" <P>\n");
|
---|
454 |
|
---|
455 | PrintNumResPullDown();
|
---|
456 |
|
---|
457 | ini_set("mysql.trace_mode", "Off");
|
---|
458 | ini_set("display_errors", "Off");
|
---|
459 |
|
---|
460 | PrintButtons("builddatasets.php");
|
---|
461 |
|
---|
462 | $sequon=" ";
|
---|
463 | $sequoff=" ";
|
---|
464 | foreach($_POST as $key => $val)
|
---|
465 | if ($val=="On")
|
---|
466 | {
|
---|
467 | if (ereg("ON$", $key))
|
---|
468 | $sequon.=str_replace("ON", " ", $key);
|
---|
469 | if (ereg("Off$", $key))
|
---|
470 | $sequoff.=str_replace("Off", " ", $key);
|
---|
471 | }
|
---|
472 | printf("<input name='Set' type='hidden' value='%s'>\n", $sequon);
|
---|
473 | printf("<input name='Set2' type='hidden' value='%s'>\n", $sequoff);
|
---|
474 | printf("<input name='name' type='hidden' value='%s'>\n", $_POST["name"]);
|
---|
475 | printf("<input name='comment' type='hidden' value='%s'>\n", $_POST["comment"]);
|
---|
476 | printf("<input name='obsmode' type='hidden' value='%s'>\n", $_POST["fObservationModeKEY"]);
|
---|
477 | printf("<input name='username' type='hidden' value='%s'>\n", $_POST["fUserKEY"]);
|
---|
478 | printf("</form>\n");
|
---|
479 | printf("</center>\n");
|
---|
480 | printf("</td>\n");
|
---|
481 | printf("</tr>\n");
|
---|
482 | printf("<tr class='Block'>\n");
|
---|
483 | printf("<td>\n");
|
---|
484 | }
|
---|
485 |
|
---|
486 | function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs)
|
---|
487 | {
|
---|
488 | $db_id = mysql_pconnect($host, $user, $pw);
|
---|
489 | if ($db_id==FALSE)
|
---|
490 | {
|
---|
491 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
492 | die("");
|
---|
493 | }
|
---|
494 | mysql_select_db($db);
|
---|
495 |
|
---|
496 | $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
497 |
|
---|
498 | $result0 = mysql_query($query0, $db_id);
|
---|
499 |
|
---|
500 | if ($result0)
|
---|
501 | {
|
---|
502 | if ($html=="1" || $html=="2")
|
---|
503 | {
|
---|
504 | PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, "yes", $_GET);
|
---|
505 | foreach($_POST as $key => $val)
|
---|
506 | if ($val=="On")
|
---|
507 | {
|
---|
508 | if (ereg("ON$", $key))
|
---|
509 | $sequon.=str_replace("ON", " ", $key);
|
---|
510 | if (ereg("Off$", $key))
|
---|
511 | $sequoff.=str_replace("Off", " ", $key);
|
---|
512 | }
|
---|
513 |
|
---|
514 | printf("<input type='submit' value='Get Dataset'><br><br>\n");
|
---|
515 | printf("<input name='submit' type='hidden' value='post'>\n");
|
---|
516 |
|
---|
517 | $on=str_replace(" ", ",", trim($sequon));
|
---|
518 | $off=str_replace(" ", ",", trim($sequoff));
|
---|
519 |
|
---|
520 | $values=array("Sum(fRunTime)/60" => $runtime,
|
---|
521 | "Min(fRunTime)/60" => $runtimemin,
|
---|
522 | "Max(fUnsuitableInner)" => $unsuitablemax,
|
---|
523 | "Max(fUnreliableInner)" => $unreliablemax,
|
---|
524 | "Max(fIsolatedInner)" => $isolatedmax,
|
---|
525 | "Max(fIsolatedMaxCluster)" => $imcmax,
|
---|
526 | "Max(fArrTimeMeanInner)" => $arrtimemax,
|
---|
527 | "Min(fArrTimeMeanInner)" => $arrtimemin,
|
---|
528 | "Max(fArrTimeRmsInner)" => $arrtimermsmax,
|
---|
529 | "Avg(fMeanPedRmsInner)" => $pedrmsmean,
|
---|
530 | "Std(fMeanPedRmsInner)" => $pedrmsrms,
|
---|
531 | "Min(fMeanPedRmsInner)" => $pedrmsmin,
|
---|
532 | "Max(fMeanPedRmsInner)" => $pedrmsmax,
|
---|
533 | "Min(fPulsePosMean)" => $pulseposmin,
|
---|
534 | "Max(fPulsePosMean)" => $pulseposmax,
|
---|
535 | "Max(fPulsePosRms)" => $pulseposrmsmax,
|
---|
536 | "Max(fMaxHumidity)" => $hummax,
|
---|
537 | "Max(fInhomogeneity)" => $inhommax,
|
---|
538 | "Avg(fInhomogeneity)" => $inhommean,
|
---|
539 | "Std(fInhomogeneity)" => $inhomrms,
|
---|
540 | "Min(fMeanNumberIslands)" => $numislmin,
|
---|
541 | "Max(fMeanNumberIslands)" => $numislmax,
|
---|
542 | "Min(fDataRate)" => $clratemin,
|
---|
543 | "Max(fDataRate)" => $clratemax,
|
---|
544 | "Min(fMuonRate)" => $muonratemin,
|
---|
545 | "Max(fMuonRate)" => $muonratemax,
|
---|
546 | "Min(fMuonNumber)" => $muonnumbermin,
|
---|
547 | "Avg(fPSF)" => $psfmean,
|
---|
548 | "Std(fPSF)" => $psfrms,
|
---|
549 | "Min(fPSF)" => $psfmin,
|
---|
550 | "Max(fPSF)" => $psfmax,
|
---|
551 | "Min(fEffOnTime/fRunTime)" => $relontimemin,
|
---|
552 | "Max(fEffOnTime/fRunTime)" => $relontimemax,
|
---|
553 | "Min(fBrightnessMed)" => $brightmin,
|
---|
554 | "Max(fBrightnessMed)" => $brightmax,
|
---|
555 | "Min(fNumStarsMed)" => $idstarsmin,
|
---|
556 | "Max(fNumStarsMed)" => $idstarsmax,
|
---|
557 | "Min(fNumStarsCorMed)" => $corstarsmin,
|
---|
558 | "Max(fNumStarsCorMed)" => $corstarsmax,
|
---|
559 | "Min(fZenithDistanceMin)" => $zdmin,
|
---|
560 | "Max(fZenithDistanceMax)" => $zdmax,
|
---|
561 | "Min(fRunStart)" => $starttime,
|
---|
562 | "Max(fRunStop)" => $stoptime,
|
---|
563 | );
|
---|
564 | //get runtimes of dataset
|
---|
565 | function GetSequenceValues($db_id, $sequences, $txt,&$values)
|
---|
566 | {
|
---|
567 | $query="SELECT COUNT(*) ";
|
---|
568 | foreach($values as $name => $varname)
|
---|
569 | $query.=", " . $name;
|
---|
570 | $query.=" FROM Sequences ";
|
---|
571 | $query.=" LEFT JOIN Calibration ON Calibration.fSequenceFirst=Sequences.fSequenceFirst ";
|
---|
572 | $query.=" LEFT JOIN Star ON Star.fSequenceFirst=Sequences.fSequenceFirst ";
|
---|
573 | $query.=" WHERE Sequences.fSequenceFirst IN (" . $sequences . ")";
|
---|
574 | $result = mysql_query($query, $db_id);
|
---|
575 | $row = mysql_fetch_assoc($result);
|
---|
576 | foreach($values as $name => $varname)
|
---|
577 | $values[$name][$txt]=$row[$name];
|
---|
578 | mysql_free_result($result);
|
---|
579 | }
|
---|
580 |
|
---|
581 | //get next dataset#
|
---|
582 | $query="SELECT fDataSetNumber+1 FROM DataSets ORDER BY fDataSetNumber DESC LIMIT 0,1";
|
---|
583 | $result = mysql_query($query, $db_id);
|
---|
584 | $row = mysql_fetch_assoc($result);
|
---|
585 | $dataset=$row["fDataSetNumber+1"];
|
---|
586 | if (empty($dataset))
|
---|
587 | $dataset=1;
|
---|
588 | mysql_free_result($result);
|
---|
589 |
|
---|
590 | //get sourcenames
|
---|
591 | function GetSources($db_id, $sequences)
|
---|
592 | {
|
---|
593 | $query="SELECT fSourceName FROM Source LEFT JOIN Sequences ON Sequences.fSourceKEY=Source.fSourceKEY ";
|
---|
594 | $query.="WHERE fSequenceFirst IN (" . $sequences . ") GROUP BY fSourceName";
|
---|
595 | $result = mysql_query($query, $db_id);
|
---|
596 | while ($row = mysql_fetch_assoc($result))
|
---|
597 | $sources.=" " . $row["fSourceName"];
|
---|
598 | mysql_free_result($result);
|
---|
599 | return $sources;
|
---|
600 | }
|
---|
601 | $sourceson=GetSources($db_id, $on);
|
---|
602 | $sourcesoff=GetSources($db_id, $off);
|
---|
603 |
|
---|
604 | //get sourcename for dataset
|
---|
605 | $son=str_replace(" ", "','", trim($sourceson));
|
---|
606 | $query="SELECT fRealSourceKEY, Count(*) FROM Source where fSourcename IN ('" . $son . "') GROUP BY fRealSourceKEY";
|
---|
607 | // printf("q: %s <br>", $query);
|
---|
608 | $result = mysql_query($query, $db_id);
|
---|
609 | $row = mysql_fetch_assoc($result);
|
---|
610 | $numsources=$row["Count(*)"];
|
---|
611 | $numrealkeys=mysql_num_rows($result);
|
---|
612 | $realsourcekey=$row["fRealSourceKEY"];
|
---|
613 | mysql_free_result($result);
|
---|
614 | // printf("found %s sources with real sourcekey %s", $numsources, $realsourcekey);
|
---|
615 | // printf("found %s keys", $numrealkeys);
|
---|
616 |
|
---|
617 | //check observationmode for on-sequences
|
---|
618 | $query="SELECT fObservationModeKEY FROM Sequences where fSequenceFirst IN ('" . $sequences . "') GROUP BY fObservationModeKEY";
|
---|
619 | // printf("q: %s <br>", $query);
|
---|
620 | $result = mysql_query($query, $db_id);
|
---|
621 | $numobskeys=mysql_num_rows($result);
|
---|
622 | mysql_free_result($result);
|
---|
623 |
|
---|
624 |
|
---|
625 | $runtimelimit=5;
|
---|
626 | $unsuitablemaxlimit=15;
|
---|
627 | $isolatedlimit=0;
|
---|
628 | $imclimit=0;
|
---|
629 | $pedrmsrms=0.09;
|
---|
630 | $scalelimit=1.3;
|
---|
631 | $inhomlimit=13;
|
---|
632 | $numstarslimit=20;
|
---|
633 | $numstarscorlimit=10;
|
---|
634 |
|
---|
635 |
|
---|
636 | $numerr=0;
|
---|
637 | if (!empty($on))
|
---|
638 | {
|
---|
639 | $color=array("INFO" => "#000000",
|
---|
640 | "WARN" => "#FF9900",
|
---|
641 | "ERROR" => "#FF0000");
|
---|
642 | printf("<div align='left'><font><ul>\n");
|
---|
643 | $vals=array("on", "off");
|
---|
644 | foreach($vals as $num => $val)
|
---|
645 | {
|
---|
646 | if (empty(${$val}))
|
---|
647 | continue;
|
---|
648 | GetSequenceValues($db_id, ${$val}, $val, $values);
|
---|
649 |
|
---|
650 | if ($values["Min(fNumStarsCorMed)"][$val]<$numstarscorlimit)
|
---|
651 | printf("<li style='color:%s'>%s: one of your %s-sequences has less than %s identified stars (%s)</li>",
|
---|
652 | $color["WARN"], "WARN", $val, $numstarscorlimit, $values["Min(fNumStarsCorMed)"][$val]);
|
---|
653 | if ($values["Min(fNumStarsMed)"][$val]<$numstarslimit)
|
---|
654 | printf("<li style='color:%s'>%s: one of your %s-sequences has less than %s identified stars (%s)</li>",
|
---|
655 | $color["WARN"], "WARN", $val, $numstarslimit, $values["Min(fNumStarsMed)"][$val]);
|
---|
656 | if ($values["Min(fRunTime)/60"][$val]<$runtimelimit)
|
---|
657 | printf("<li style='color:%s'>%s: one of your %s-sequences is shorter than %s min (%s min)</li>",
|
---|
658 | $color["INFO"], "INFO", $val, $runtimelimit, $values["Min(fRunTime)/60"][$val]);
|
---|
659 | if ($values["Max(fInhomogeneity)"][$val]>$inhomlimit)
|
---|
660 | printf("<li style='color:%s'>%s: one of your %s-sequences has an inhomogeneity larger than %s (%s)</li>",
|
---|
661 | $color["WARN"], "WARN", $val, $inhomlimit, $values["Max(fInhomogeneity)"][$val]);
|
---|
662 | if ($values["Max(fUnsuitableInner)"][$val]>$unsuitablemaxlimit)
|
---|
663 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s unsuitable inner pixel (%s)</li>",
|
---|
664 | $color["WARN"], "WARN", $val, $unsuitablemaxlimit, $values["Max(fUnsuitableInner)"][$val]);
|
---|
665 | if ($values["Max(fIsolatedInner)"][$val]>$isolatedlimit)
|
---|
666 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s isolated inner pixel (%s)</li>",
|
---|
667 | $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]);
|
---|
668 | if ($values["Max(fIsolatedMaxCluster)"][$val]>$imclimit)
|
---|
669 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s isolated max cluster (%s)</li>",
|
---|
670 | $color["WARN"], "WARN", $val, $imclimit, $values["Max(fIsolatedMaxCluster)"][$val]);
|
---|
671 | }
|
---|
672 | if (!empty($on) && $values["Max(fMeanPedRmsInner)"]["on"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
|
---|
673 | printf("<li style='color:%s'>%s: one of your on-sequences has a PedRms larger than %s (%s)</li>",
|
---|
674 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["on"]);
|
---|
675 | if (!empty($off) && $values["Max(fMeanPedRmsInner)"]["off"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
|
---|
676 | printf("<li style='color:%s'>%s: one of your off-sequences has a PedRms larger than %s (%s)</li>",
|
---|
677 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["off"]);
|
---|
678 | if (!empty($off) && $values["Min(fMeanPedRmsInner)"]["off"]<$values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms)
|
---|
679 | printf("<li style='color:%s'>%s: one of your off-sequences has a PedRms smaller than %s (%s)</li>",
|
---|
680 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms, $values["Min(fMeanPedRmsInner)"]["off"]);
|
---|
681 | $scale=$values["Sum(fRunTime)/60"]["on"]/$values["Sum(fRunTime)/60"]["off"];
|
---|
682 | if ($scale > $scalelimit)
|
---|
683 | printf("<li style='color:%s'>%s: Your scale factor is larger than %s (%0.2f). Try to find more offdata!",
|
---|
684 | $color["WARN"], "WARN", $scalelimit, $scale);
|
---|
685 | /*
|
---|
686 | if (str_word_count($sourceson) > 1)
|
---|
687 | printf("<li style='color:%s'>%s: You have selected more than one (%s) on source",
|
---|
688 | $color["WARN"], "WARN", str_word_count($sourceson));
|
---|
689 | */
|
---|
690 | $doubleseq=0;
|
---|
691 | // printf("finding: %s<br>", $sequon);
|
---|
692 | foreach(explode(" ", $sequon) as $n => $s)
|
---|
693 | {
|
---|
694 | // printf("finding %s in %s <br>", $s, $sequoff);
|
---|
695 | if (ereg($s, $sequoff))
|
---|
696 | $doubleseq++;
|
---|
697 | }
|
---|
698 | if ($doubleseq>0)
|
---|
699 | {
|
---|
700 | printf("<li style='color:%s'>%s: You have selected sequences (%s) as On AND Off",
|
---|
701 | $color["ERROR"], "ERROR", $doubleseq);
|
---|
702 | $numerr=$numerr+1;
|
---|
703 | }
|
---|
704 | if ($numrealkeys>1)
|
---|
705 | {
|
---|
706 | printf("<li style='color:%s'>%s: You have selected more than one (%s) on source",
|
---|
707 | $color["ERROR"], "ERROR", $numrealkeys);
|
---|
708 | $numerr=$numerr+1;
|
---|
709 | }
|
---|
710 | if ($numobskeys>1)
|
---|
711 | {
|
---|
712 | printf("<li style='color:%s'>%s: You have selected more than one (%s) different observation modes for your on sequences",
|
---|
713 | $color["ERROR"], "ERROR", $numobskeys);
|
---|
714 | $numerr=$numerr+1;
|
---|
715 | }
|
---|
716 | if (empty($realsourcekey))
|
---|
717 | {
|
---|
718 | printf("<li style='color:%s'>%s: The source you selected doesn't have a real sourcekey yet. Please insert fRealSourceKEY in the DB for %s",
|
---|
719 | $color["ERROR"], "ERROR", $sourceson);
|
---|
720 | $numerr=$numerr+1;
|
---|
721 | }
|
---|
722 | if (empty($_POST["fObservationModeKEY"]))
|
---|
723 | {
|
---|
724 | printf("<li style='color:%s'>%s: You have to choose an observation mode.",
|
---|
725 | $color["ERROR"], "ERROR");
|
---|
726 | $numerr=$numerr+1;
|
---|
727 | }
|
---|
728 | if (empty($_POST["fUserKEY"]))
|
---|
729 | {
|
---|
730 | printf("<li style='color:%s'>%s: You have to choose your username.",
|
---|
731 | $color["ERROR"], "ERROR");
|
---|
732 | $numerr=$numerr+1;
|
---|
733 | }
|
---|
734 | if (empty($_POST["name"]))
|
---|
735 | {
|
---|
736 | printf("<li style='color:%s'>%s: You have to choose a name.",
|
---|
737 | $color["ERROR"], "ERROR");
|
---|
738 | $numerr=$numerr+1;
|
---|
739 | }
|
---|
740 | if (empty($_POST["comment"]))
|
---|
741 | {
|
---|
742 | printf("<li style='color:%s'>%s: You have to comment your dataset.",
|
---|
743 | $color["ERROR"], "ERROR");
|
---|
744 | $numerr=$numerr+1;
|
---|
745 | }
|
---|
746 | // printf("<li></li>");
|
---|
747 | printf("</ul></font>\n");
|
---|
748 |
|
---|
749 | printf("<div align='left'>");
|
---|
750 | printf("SequencesOn: %s<br>", $sequon);
|
---|
751 | printf("SequencesOff: %s<br>", $sequoff);
|
---|
752 | $insquery[0]="INSERT DataSets SET fDataSetNumber=" . $dataset . ", fUserKEY=" . $_POST["fUserKEY"];
|
---|
753 | $insquery[0].=", fComment='" . $_POST["comment"] . "', fObservationModeKEY=" . $_POST["fObservationModeKEY"];
|
---|
754 | $insquery[0].=", fDataSetName='" . $_POST["name"] . "', fSourceKEY= " . $realsourcekey;
|
---|
755 | $insquery[0].=", fRunStart='" . $values["Min(fRunStart)"]["on"];
|
---|
756 | $insquery[0].="', fRunStop='" . $values["Max(fRunStop)"]["on"];
|
---|
757 | $insquery[0].="', fZenithDistanceMin=" . $values["Min(fZenithDistanceMin)"]["on"];
|
---|
758 | $insquery[0].=", fZenithDistanceMax=" . $values["Max(fZenithDistanceMax)"]["on"];
|
---|
759 | $insquery[0].=", fRunTime=" . $values["Sum(fRunTime)/60"]["on"];
|
---|
760 | $insquery[1]="INSERT DataSetProcessStatus SET fDataSetNumber=" . $dataset . ", fDataSetInserted=Now()";
|
---|
761 | $i=2;
|
---|
762 | foreach(explode(" ", trim($sequon)) as $key => $sequ)
|
---|
763 | {
|
---|
764 | $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset;
|
---|
765 | $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=1";
|
---|
766 | $i=$i+1;
|
---|
767 | }
|
---|
768 | if (!empty($off))
|
---|
769 | {
|
---|
770 | foreach(explode(" ", trim($sequoff)) as $key => $sequ)
|
---|
771 | {
|
---|
772 | $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset;
|
---|
773 | $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=2";
|
---|
774 | $i=$i+1;
|
---|
775 | }
|
---|
776 | }
|
---|
777 | foreach($insquery as $num => $q)
|
---|
778 | {
|
---|
779 | if (!empty($_POST["insert"]) && $numerr==0)
|
---|
780 | {
|
---|
781 | printf("Inserted Query #%s: %s<br>", $num, $q);
|
---|
782 | $insresult=mysql_query($q);
|
---|
783 | if (mysql_errno()>0)
|
---|
784 | printf(" Errorno: %s <br>", mysql_errno());
|
---|
785 | if (mysql_error()!="")
|
---|
786 | printf(" Errormsg: %s <br>", mysql_error());
|
---|
787 | if (mysql_info()!="")
|
---|
788 | printf(" Info: %s <br>", mysql_info());
|
---|
789 | printf(" Affected Rows: %s <br>", mysql_affected_rows());
|
---|
790 | mysql_free_result($insresult);
|
---|
791 | if (mysql_errno()>0)
|
---|
792 | {
|
---|
793 | printf("ERROR => stop inserting");
|
---|
794 | break;
|
---|
795 | }
|
---|
796 | }
|
---|
797 | }
|
---|
798 | printf("</div>");
|
---|
799 | if (empty($_POST["name"]) && !empty($_GET["name"]))
|
---|
800 | $_POST["name"]=$_GET["name"];
|
---|
801 | if (empty($_POST["comment"]) && !empty($_GET["comment"]))
|
---|
802 | $_POST["comment"]=$_GET["comment"];
|
---|
803 | if (empty($_POST["fObservationModeKEY"]) && !empty($_GET["obsmode"]))
|
---|
804 | $_POST["fObservationModeKEY"]=$_GET["obsmode"];
|
---|
805 | if (empty($_POST["fUserKEY"]) && !empty($_GET["username"]))
|
---|
806 | $_POST["fUserKEY"]=$_GET["username"];
|
---|
807 | printf("Name: <input name='name' type='text' size='20' maxlength='20' value='%s'><br>\n", $_POST["name"]);
|
---|
808 | printf("Comment: <input name='comment' type='text' size='50' maxlength='255' value='%s'><br>\n", $_POST["comment"]);
|
---|
809 |
|
---|
810 | $query = "SELECT fObservationModeKEY, fObservationModeName FROM ObservationMode ORDER BY fObservationModeName";
|
---|
811 | $result = mysql_query($query);
|
---|
812 | if (!$result)
|
---|
813 | printf("-N/A-");
|
---|
814 |
|
---|
815 | $numrows = mysql_num_rows($result);
|
---|
816 |
|
---|
817 | printf("ObservationMode <select name='fObservationModeKEY' size='1' class='Width'>\n");
|
---|
818 | while ($row = mysql_fetch_row($result))
|
---|
819 | {
|
---|
820 | if (!empty($_POST["fObservationModeKEY"]) && $_POST["fObservationModeKEY"]==$row[0])
|
---|
821 | printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]);
|
---|
822 | else
|
---|
823 | printf("<option value='%s'>%s</option>\n", $row[0], $row[1]);
|
---|
824 | }
|
---|
825 | printf("</select><br>\n");
|
---|
826 | mysql_free_result($result);
|
---|
827 |
|
---|
828 | $query = "SELECT fUserKEY, fUserName FROM User ORDER BY fUserKEY";
|
---|
829 | $result = mysql_query($query);
|
---|
830 | if (!$result)
|
---|
831 | printf("-N/A-");
|
---|
832 |
|
---|
833 | $numrows = mysql_num_rows($result);
|
---|
834 |
|
---|
835 | printf("UserName <select name='fUserKEY' size='1' class='Width'>\n");
|
---|
836 | while ($row = mysql_fetch_row($result))
|
---|
837 | {
|
---|
838 | if (!empty($_POST["fUserKEY"]) && $_POST["fUserKEY"]==$row[0])
|
---|
839 | printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]);
|
---|
840 | else
|
---|
841 | printf("<option value='%s'>%s</option>\n", $row[0], $row[1]);
|
---|
842 | }
|
---|
843 | printf("</select><br>\n");
|
---|
844 | mysql_free_result($result);
|
---|
845 |
|
---|
846 | printf("Remark: only datasets without errors can be inserted.<br>");
|
---|
847 | if ($numerr!=0)
|
---|
848 | printf("Your dataset has %s error(s).<br>", $numerr);
|
---|
849 | printf("<input type='checkbox' name='insert' value='On'>insert\n");
|
---|
850 |
|
---|
851 | printf("<table><tr><td colspan='2' align='center'>Dataset</td></tr>");
|
---|
852 | printf("<tr><td>proposed DataSet#: </td><td>%s</td></tr>", $dataset);
|
---|
853 | printf("<tr><td>SequencesOn:</td><td> %s</td></tr>", $sequon);
|
---|
854 | if (!empty($sequoff))
|
---|
855 | printf("<tr><td>SequencesOff:</td><td> %s</td></tr>", $sequoff);
|
---|
856 | printf("<tr><td>Scale: </td><td>%0.2f</td></tr>", $scale);
|
---|
857 | printf("<tr><td>SourcenamesOn[%s]: </td><td>%s</td></tr>", str_word_count($sourceson), $sourceson);
|
---|
858 | printf("<tr><td>SourcenamesOff[%s]: </td><td>%s</td></tr>", str_word_count($sourcesoff), $sourcesoff);
|
---|
859 | printf("</table>\n");
|
---|
860 |
|
---|
861 | printf("<table border='1'>\n");
|
---|
862 | printf("<tr><td>Value</td><td>On</td>");
|
---|
863 | if (!empty($off))
|
---|
864 | printf("<td>Off</td></tr>\n");
|
---|
865 | foreach($values as $name => $varname)
|
---|
866 | {
|
---|
867 | printf("<tr><td>%s</td>\n", $name);
|
---|
868 | foreach($vals as $num => $val)
|
---|
869 | if (!empty(${$val}))
|
---|
870 | printf("<td>%s</td>\n", $varname[$val]);
|
---|
871 | printf("</tr>\n");
|
---|
872 | }
|
---|
873 | printf("</table>\n");
|
---|
874 | }
|
---|
875 |
|
---|
876 | printf("</div>\n");
|
---|
877 | /*
|
---|
878 | printf("<table border='1'><tr>\n");
|
---|
879 | printf("<td>--</td>\n");
|
---|
880 | foreach($values as $name => $varname)
|
---|
881 | printf("<td>%s</td>\n", $name);
|
---|
882 | $vals=array("on", "off");
|
---|
883 | foreach($vals as $num => $val)
|
---|
884 | {
|
---|
885 | GetSequenceValues($db_id, ${$val}, $val, $values);
|
---|
886 | printf("</tr><tr>\n");
|
---|
887 | printf("<td>On</td>\n");
|
---|
888 | foreach($values as $name => $varname)
|
---|
889 | printf("<td>%s</td>\n", $varname[$val]);
|
---|
890 | }
|
---|
891 | printf("</tr></table>\n");
|
---|
892 | */
|
---|
893 |
|
---|
894 | printf("</center>\n");
|
---|
895 | printf("</td>\n");
|
---|
896 | printf("</tr>\n");
|
---|
897 |
|
---|
898 | printf("</form>\n");
|
---|
899 | }
|
---|
900 | else
|
---|
901 | PrintText($result0);
|
---|
902 |
|
---|
903 | mysql_free_result($result0);
|
---|
904 | }
|
---|
905 | mysql_close($db_id);
|
---|
906 |
|
---|
907 | PrintSubmittedQuery($query0, $html, $db, "");
|
---|
908 | }
|
---|
909 |
|
---|
910 | include ("include.php");
|
---|
911 | include ("menu.php");
|
---|
912 | include ("db.php");
|
---|
913 | include ("magicdefs.php");
|
---|
914 |
|
---|
915 | ini_set("display_errors", "On");
|
---|
916 | ini_set("mysql.trace_mode", "On");
|
---|
917 |
|
---|
918 | $sitepw="\$1\$ml/Gld67\$zOvhC4vFrLCkbAzQs2swo1";
|
---|
919 | $siteuser="dcdb";
|
---|
920 |
|
---|
921 | if (!isset($_SERVER['PHP_AUTH_USER']) || crypt($_SERVER['PHP_AUTH_PW'], $sitepw)!=$sitepw || $_SERVER['PHP_AUTH_USER']!=$siteuser)
|
---|
922 | {
|
---|
923 | header('WWW-Authenticate: Basic realm="Build Datasets"');
|
---|
924 | header('HTTP/1.0 401 Unauthorized');
|
---|
925 | echo 'Cancelled.';
|
---|
926 | return;
|
---|
927 | }
|
---|
928 | else
|
---|
929 | {
|
---|
930 | // echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
|
---|
931 | // echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
|
---|
932 | // printf("pw: %s", crypt($_SERVER['PHP_AUTH_PW']));
|
---|
933 |
|
---|
934 | if (crypt($_SERVER['PHP_AUTH_PW'], $sitepw)!=$sitepw || $_SERVER['PHP_AUTH_USER']!=$siteuser)
|
---|
935 | {
|
---|
936 | printf("<br>pw or user incorrect<br>");
|
---|
937 | return;
|
---|
938 | }
|
---|
939 | }
|
---|
940 |
|
---|
941 | if (!empty($_GET["fSendTxt"]))
|
---|
942 | {
|
---|
943 | header("Content-type: application/octet");
|
---|
944 | header("Content-Disposition: attachment; filename=query-result.txt");
|
---|
945 |
|
---|
946 | PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
---|
947 | }
|
---|
948 | else
|
---|
949 | {
|
---|
950 | echo (file_get_contents("index-header.html"));
|
---|
951 |
|
---|
952 | $environment = sizeof($_GET);
|
---|
953 |
|
---|
954 | InitGet($_GET);
|
---|
955 | if (empty($_GET["fPrintTable"]))
|
---|
956 | PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias);
|
---|
957 |
|
---|
958 | if ($environment==0)
|
---|
959 | printf("No query submitted yet.<BR>");
|
---|
960 | else
|
---|
961 | {
|
---|
962 | if (empty($_GET["fPrintTable"]))
|
---|
963 | PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
---|
964 | else
|
---|
965 | PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
---|
966 | }
|
---|
967 |
|
---|
968 | echo (file_get_contents("index-footer.html"));
|
---|
969 | }
|
---|
970 |
|
---|
971 | ini_set("display_errors", "Off");
|
---|
972 | ini_set("mysql.trace_mode", "Off");
|
---|
973 | }
|
---|
974 | ?>
|
---|