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 'Sequence' ";
|
---|
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 'Sequence'";
|
---|
42 |
|
---|
43 | }
|
---|
44 | else
|
---|
45 | {
|
---|
46 | if (!empty($_GET["fSendTxt"]))
|
---|
47 | $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
|
---|
48 | else
|
---|
49 | {
|
---|
50 | $query0 .= " CONCAT('<A&ws;HREF=\"runinfo.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\">', Sequences.fSequenceFirst, '</A>') ";
|
---|
51 | $query0 .= " as " . $alias["fSequenceFirst"];
|
---|
52 | if (!empty($_GET["fLinks"]))
|
---|
53 | {
|
---|
54 | $query0 .= ", CONCAT('<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>'";
|
---|
55 | $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>'";
|
---|
56 | $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>'";
|
---|
57 | $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>'";
|
---|
58 | $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>') ";
|
---|
59 | $query0 .= " as 'Links'";
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | foreach ($_GET as $key => $element)
|
---|
64 | if ($_GET[$key]=="On")
|
---|
65 | if ($key!="fLinks" && $key!="fTest")
|
---|
66 | if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
|
---|
67 | $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | $query0 .= " FROM " . $fromtable;
|
---|
72 |
|
---|
73 | $query0 .= " LEFT JOIN SequenceProcessStatus ON Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst ";
|
---|
74 | $query0 .= " LEFT JOIN Calibration ON Sequences.fSequenceFirst=Calibration.fSequenceFirst ";
|
---|
75 | $query0 .= " LEFT JOIN Star ON Sequences.fSequenceFirst=Star.fSequenceFirst ";
|
---|
76 |
|
---|
77 | // foreach ($_GET as $key => $element)
|
---|
78 | // if (($_GET[$key]=="On" || $groups>0) && !empty($joins[$key]))
|
---|
79 | // $query0 .= $joins[$key];
|
---|
80 |
|
---|
81 | foreach ($_GET as $key => $element)
|
---|
82 | if (($_GET[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key)))
|
---|
83 | $query0 .= GetJoin($fromtable,$key);
|
---|
84 |
|
---|
85 | if ($_GET["fTest"]!="On")
|
---|
86 | {
|
---|
87 | if ($_GET["fSource"]!="On")
|
---|
88 | $query0 .= " LEFT JOIN Source ON Sequences.fSourceKEY=Source.fSourceKEY ";
|
---|
89 | $query0 .= " WHERE fTest='no'";
|
---|
90 | }
|
---|
91 |
|
---|
92 | foreach ($checkwhere as $key => $element)
|
---|
93 | {
|
---|
94 | if (empty($element) || $element<=0)
|
---|
95 | continue;
|
---|
96 |
|
---|
97 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
98 | $query0 .= " WHERE ";
|
---|
99 | else
|
---|
100 | if ($element!=-1)
|
---|
101 | if (strrpos($query0, " AND ")!=strlen($query0)-5)
|
---|
102 | $query0 .= " AND ";
|
---|
103 |
|
---|
104 | if ($element!=-1)
|
---|
105 | $query0 .= GetCheck($fromtable, $key) . "=" . $element;
|
---|
106 | }
|
---|
107 |
|
---|
108 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
109 | $query0 .= " WHERE ";
|
---|
110 | else
|
---|
111 | $query0 .= " AND ";
|
---|
112 |
|
---|
113 | $query0 .= StatusQuery("fSequenceFileWritten", $needs);
|
---|
114 | $query0 .= StatusQuery("fAllFilesAvail", $needs);
|
---|
115 | $query0 .= StatusQuery("fCallisto", $needs);
|
---|
116 | $query0 .= StatusQuery("fFillCallisto", $needs);
|
---|
117 | $query0 .= StatusQuery("fStar", $needs);
|
---|
118 | $query0 .= StatusQuery("fFillStar", $needs);
|
---|
119 |
|
---|
120 | if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
|
---|
121 | $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
|
---|
122 | else
|
---|
123 | $query0 = substr($query0, 0, -4);
|
---|
124 |
|
---|
125 | /*
|
---|
126 | if (!empty($_GET["fDate"]))
|
---|
127 | $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
|
---|
128 | */
|
---|
129 |
|
---|
130 | if (!empty($_GET["fSourceN"]))
|
---|
131 | $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
|
---|
132 |
|
---|
133 | if (!empty($_GET["fStartDate"]))
|
---|
134 | {
|
---|
135 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
---|
136 | $query0 .= " AND ";
|
---|
137 |
|
---|
138 | $startdate=substr($_GET["fStartDate"], 0, 10);
|
---|
139 | if ($startdate=="0000-00-00")
|
---|
140 | $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
|
---|
141 | else
|
---|
142 | $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
|
---|
143 | }
|
---|
144 |
|
---|
145 | if (!empty($_GET["fStopDate"]))
|
---|
146 | {
|
---|
147 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
---|
148 | $query0 .= " AND ";
|
---|
149 |
|
---|
150 | $stopdate=substr($_GET["fStopDate"], 0, 10);
|
---|
151 | $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
|
---|
152 | }
|
---|
153 |
|
---|
154 | if ($groups>0)
|
---|
155 | {
|
---|
156 | $query0 .= " GROUP BY ";
|
---|
157 | $num = $groups;
|
---|
158 | foreach ($checkgroup as $key => $element)
|
---|
159 | if ($element==-1)
|
---|
160 | {
|
---|
161 | $query0 .= GetCheck($fromtable,$key);
|
---|
162 | if ($num-->1)
|
---|
163 | $query0 .= ", ";
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | if ($statusgroups>0)
|
---|
168 | {
|
---|
169 | $query0 .= " GROUP BY ";
|
---|
170 | $num = $statusgroups;
|
---|
171 | foreach ($checkstatusgroup as $key => $element)
|
---|
172 | if ($element==-1)
|
---|
173 | {
|
---|
174 | $query0 .= $alias[$key];
|
---|
175 | if ($num-->1)
|
---|
176 | $query0 .= ", ";
|
---|
177 | }
|
---|
178 | }
|
---|
179 |
|
---|
180 | if (!empty($_GET["fSortBy"]))
|
---|
181 | {
|
---|
182 | $val=substr($_GET["fSortBy"], 0, -1);
|
---|
183 | $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
|
---|
184 | if (substr($_GET["fSortBy"], -1)=="-")
|
---|
185 | $query0 .= "DESC";
|
---|
186 | }
|
---|
187 |
|
---|
188 | if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
|
---|
189 | $query0 .= "ORDER BY Sequences.fSequenceFirst ASC ";
|
---|
190 |
|
---|
191 | if (empty($_GET["fNumStart"]))
|
---|
192 | $_GET["fNumStart"]=0;
|
---|
193 |
|
---|
194 | if (empty($_GET["fSendTxt"]))
|
---|
195 | $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
|
---|
196 |
|
---|
197 | return $query0;
|
---|
198 | }
|
---|
199 |
|
---|
200 | function InitGet($_GET)
|
---|
201 | {
|
---|
202 | // Find out whether it is the first call to the php script
|
---|
203 | $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
|
---|
204 |
|
---|
205 | if (empty($_GET["fNumResults"]))
|
---|
206 | $_GET["fNumResults"]="20";
|
---|
207 |
|
---|
208 | if (empty($_GET["fLastUpdate"]))
|
---|
209 | $_GET["fLastUpdate"]="Off";
|
---|
210 |
|
---|
211 | if (empty($_GET["fNumEvents"]))
|
---|
212 | $_GET["fNumEvents"]=$first?"On":"";
|
---|
213 |
|
---|
214 | if (empty($_GET["fRunStart"]))
|
---|
215 | $_GET["fRunStart"]=$first?"On":"";
|
---|
216 |
|
---|
217 | if (empty($_GET["fRunTime/60"]))
|
---|
218 | $_GET["fRunTime/60"]=$first?"On":"";
|
---|
219 |
|
---|
220 | if (empty($_GET["fSequenceLast"]))
|
---|
221 | $_GET["fSequenceLast"]=$first?"On":"";
|
---|
222 |
|
---|
223 | if (empty($_GET["fLinks"]))
|
---|
224 | $_GET["fLinks"]=$first?"On":"";
|
---|
225 |
|
---|
226 | if (empty($_GET["fTest"]))
|
---|
227 | $_GET["fTest"]=$first?"On":"";
|
---|
228 |
|
---|
229 | if (empty($_GET["fAzimuthMin"]))
|
---|
230 | $_GET["fAzimuthMin"]="Off";
|
---|
231 |
|
---|
232 | if (empty($_GET["fAzimuthMax"]))
|
---|
233 | $_GET["fAzimuthMax"]="Off";
|
---|
234 |
|
---|
235 | if (empty($_GET["fZenithDistanceMin"]))
|
---|
236 | $_GET["fZenithDistanceMin"]=$first?"On":"";
|
---|
237 |
|
---|
238 | if (empty($_GET["fZenithDistanceMax"]))
|
---|
239 | $_GET["fZenithDistanceMax"]="Off";
|
---|
240 |
|
---|
241 | if (empty($_GET["fManuallyChangedName"]))
|
---|
242 | $_GET["fManuallyChangedName"]="Off";
|
---|
243 |
|
---|
244 | if (empty($_GET["fSourceName"]))
|
---|
245 | $_GET["fSourceName"]=$first?"On":"";
|
---|
246 |
|
---|
247 | if (empty($_GET["fProjectName"]))
|
---|
248 | $_GET["fProjectName"]="Off";
|
---|
249 |
|
---|
250 | if (empty($_GET["fL1TriggerTableName"]))
|
---|
251 | $_GET["fL1TriggerTableName"]="Off";
|
---|
252 |
|
---|
253 | if (empty($_GET["fL2TriggerTableName"]))
|
---|
254 | $_GET["fL2TriggerTableName"]="Off";
|
---|
255 |
|
---|
256 | if (empty($_GET["fHvSettingsName"]))
|
---|
257 | $_GET["fHvSettingsName"]="Off";
|
---|
258 |
|
---|
259 | if (empty($_GET["fDiscriminatorThresholdTableName"]))
|
---|
260 | $_GET["fDiscriminatorThresholdTableName"]="Off";
|
---|
261 |
|
---|
262 | if (empty($_GET["fTriggerDelayTableName"]))
|
---|
263 | $_GET["fTriggerDelayTableName"]="Off";
|
---|
264 |
|
---|
265 | if (empty($_GET["fLightConditionsName"]))
|
---|
266 | $_GET["fLightConditionsName"]="Off";
|
---|
267 |
|
---|
268 | if (empty($_GET["fTestFlagName"]))
|
---|
269 | $_GET["fTestFlagName"]="Off";
|
---|
270 |
|
---|
271 | if (empty($_GET["fSequenceFileWritten"]))
|
---|
272 | $_GET["fSequenceFileWritten"]="Off";
|
---|
273 |
|
---|
274 | if (empty($_GET["fSequenceFileWrittenStatus"]))
|
---|
275 | $_GET["fSequenceFileWrittenStatus"]="0";
|
---|
276 |
|
---|
277 | if (empty($_GET["fAllFilesAvail"]))
|
---|
278 | $_GET["fAllFilesAvail"]="Off";
|
---|
279 |
|
---|
280 | if (empty($_GET["fAllFilesAvailStatus"]))
|
---|
281 | $_GET["fAllFilesAvailStatus"]="0";
|
---|
282 |
|
---|
283 | if (empty($_GET["fCallisto"]))
|
---|
284 | $_GET["fCallisto"]="Off";
|
---|
285 |
|
---|
286 | if (empty($_GET["fCallistoStatus"]))
|
---|
287 | $_GET["fCallistoStatus"]="0";
|
---|
288 |
|
---|
289 | if (empty($_GET["fFillCallisto"]))
|
---|
290 | $_GET["fFillCallisto"]="Off";
|
---|
291 |
|
---|
292 | if (empty($_GET["fFillCallistoStatus"]))
|
---|
293 | $_GET["fFillCallistoStatus"]="0";
|
---|
294 |
|
---|
295 | if (empty($_GET["fStar"]))
|
---|
296 | $_GET["fStar"]=$first?"On":"";
|
---|
297 |
|
---|
298 | if (empty($_GET["fStarStatus"]))
|
---|
299 | $_GET["fStarStatus"]="0";
|
---|
300 |
|
---|
301 | if (empty($_GET["fFillStar"]))
|
---|
302 | $_GET["fFillStar"]="Off";
|
---|
303 |
|
---|
304 | if (empty($_GET["fFillStarStatus"]))
|
---|
305 | $_GET["fFillStarStatus"]="0";
|
---|
306 |
|
---|
307 | if (empty($_GET["fUnreliableInner"]))
|
---|
308 | $_GET["fUnreliableInner"]="Off";
|
---|
309 |
|
---|
310 | if (empty($_GET["fUnsuitableOuter"]))
|
---|
311 | $_GET["fUnsuitableOuter"]="Off";
|
---|
312 |
|
---|
313 | if (empty($_GET["fUnreliableOuter"]))
|
---|
314 | $_GET["fUnreliableOuter"]="Off";
|
---|
315 |
|
---|
316 | if (empty($_GET["fUnsuitableInner"]))
|
---|
317 | $_GET["fUnsuitableInner"]="Off";
|
---|
318 |
|
---|
319 | if (empty($_GET["fIsolatedInner"]))
|
---|
320 | $_GET["fIsolatedInner"]="Off";
|
---|
321 |
|
---|
322 | if (empty($_GET["fIsolatedOuter"]))
|
---|
323 | $_GET["fIsolatedOuter"]="Off";
|
---|
324 |
|
---|
325 | if (empty($_GET["fMeanPedRmsInner"]))
|
---|
326 | $_GET["fMeanPedRmsInner"]="Off";
|
---|
327 |
|
---|
328 | if (empty($_GET["fMeanPedRmsOuter"]))
|
---|
329 | $_GET["fMeanPedRmsOuter"]="Off";
|
---|
330 |
|
---|
331 | if (empty($_GET["fIsolatedMaxCluster"]))
|
---|
332 | $_GET["fIsolatedMaxCluster"]="Off";
|
---|
333 |
|
---|
334 | if (empty($_GET["fArrTimeMeanInner"]))
|
---|
335 | $_GET["fArrTimeMeanInner"]="Off";
|
---|
336 |
|
---|
337 | if (empty($_GET["fArrTimeMeanOuter"]))
|
---|
338 | $_GET["fArrTimeMeanOuter"]="Off";
|
---|
339 |
|
---|
340 | if (empty($_GET["fArrTimeRmsInner"]))
|
---|
341 | $_GET["fArrTimeRmsInner"]="Off";
|
---|
342 |
|
---|
343 | if (empty($_GET["fArrTimeRmsOuter"]))
|
---|
344 | $_GET["fArrTimeRmsOuter"]="Off";
|
---|
345 |
|
---|
346 | if (empty($_GET["fMeanSignalInner"]))
|
---|
347 | $_GET["fMeanSignalInner"]=$first?"Off":"";
|
---|
348 |
|
---|
349 | if (empty($_GET["fMeanSignalOuter"]))
|
---|
350 | $_GET["fMeanSignalOuter"]=$first?"Off":"";
|
---|
351 |
|
---|
352 | if (empty($_GET["fPulsePosMean"]))
|
---|
353 | $_GET["fPulsePosMean"]=$first?"Off":"";
|
---|
354 |
|
---|
355 | if (empty($_GET["fConvFactorInner"]))
|
---|
356 | $_GET["fConvFactorInner"]=$first?"On":"";
|
---|
357 |
|
---|
358 | if (empty($_GET["fConvFactorOuter"]))
|
---|
359 | $_GET["fConvFactorOuter"]=$first?"On":"";
|
---|
360 |
|
---|
361 | if (empty($_GET["fMeanNumberIslands"]))
|
---|
362 | $_GET["fMeanNumberIslands"]="Off";
|
---|
363 |
|
---|
364 | if (empty($_GET["fPSF"]))
|
---|
365 | $_GET["fPSF"]=$first?"On":"";
|
---|
366 |
|
---|
367 | if (empty($_GET["fRatio"]))
|
---|
368 | $_GET["fRatio"]=$first?"On":"";
|
---|
369 |
|
---|
370 | if (empty($_GET["fMuonNumber"]))
|
---|
371 | $_GET["fMuonNumber"]=$first?"On":"";
|
---|
372 |
|
---|
373 | if (empty($_GET["fEffOnTime"]))
|
---|
374 | $_GET["fEffOnTime"]="Off";
|
---|
375 |
|
---|
376 | if (empty($_GET["fMuonRate"]))
|
---|
377 | $_GET["fMuonRate"]="Off";
|
---|
378 |
|
---|
379 | if (empty($_GET["fInhomogeneity"]))
|
---|
380 | $_GET["fInhomogeneity"]="Off";
|
---|
381 |
|
---|
382 | if (empty($_GET["fDataRate"]))
|
---|
383 | $_GET["fDataRate"]="Off";
|
---|
384 |
|
---|
385 | if (empty($_GET["fMaxHumidity"]))
|
---|
386 | $_GET["fMaxHumidity"]="Off";
|
---|
387 |
|
---|
388 | if (empty($_GET["fStartTime"]))
|
---|
389 | $_GET["fStartTime"]="Off";
|
---|
390 |
|
---|
391 | if (empty($_GET["fFailedTime"]))
|
---|
392 | $_GET["fFailedTime"]="Off";
|
---|
393 |
|
---|
394 | if (empty($_GET["fReturnCode"]))
|
---|
395 | $_GET["fReturnCode"]="Off";
|
---|
396 |
|
---|
397 | if (empty($_GET["fFailedCode"]))
|
---|
398 | $_GET["fFailedCode"]="Off";
|
---|
399 |
|
---|
400 | if (empty($_GET["fFailedCodeAdd"]))
|
---|
401 | $_GET["fFailedCodeAdd"]="Off";
|
---|
402 |
|
---|
403 | }
|
---|
404 |
|
---|
405 | function PrintForm($_GET, $db)
|
---|
406 | {
|
---|
407 | printf("<center>\n");
|
---|
408 | printf("<form action=\"sequinfo.php\" METHOD=\"GET\">\n");
|
---|
409 | printf(" <table>\n");
|
---|
410 | printf(" <tr>\n");
|
---|
411 |
|
---|
412 | CheckBox("fRunStart", "Start time");
|
---|
413 | CheckBox("fAzimuthMin", "Azimuth min");
|
---|
414 | CheckBox("fAzimuthMax", "Azimuth max");
|
---|
415 | CheckBox("fZenithDistanceMin", "Zenith distance min");
|
---|
416 | CheckBox("fZenithDistanceMax", "Zenith distance max");
|
---|
417 |
|
---|
418 | printf(" </tr><tr>\n");
|
---|
419 |
|
---|
420 | CheckBox("fNumEvents", "Num of events");
|
---|
421 | CheckBox("fRunTime/60", "Duration");
|
---|
422 | CheckBox("fSequenceLast", "Last run");
|
---|
423 | CheckBox("fLinks", "Links");
|
---|
424 | CheckBox("fTest", "incl. TestSources");
|
---|
425 |
|
---|
426 | printf(" </tr></table>\n");
|
---|
427 | printf(" <p>\n");
|
---|
428 | printf(" <table><tr><td>\n");
|
---|
429 |
|
---|
430 | PrintStatusMenu("fSequenceFileWritten", "Sequfile");
|
---|
431 | printf(" </td><td>\n");
|
---|
432 | PrintStatusMenu("fAllFilesAvail", "Files avail");
|
---|
433 | printf(" </td><td>\n");
|
---|
434 | PrintStatusMenu("fCallisto", "Callisto");
|
---|
435 | printf(" </td><td>\n");
|
---|
436 | PrintStatusMenu("fStar", "Star");
|
---|
437 | printf(" </td><td>\n");
|
---|
438 | PrintStatusMenu("fFillCallisto", "Fillcallisto");
|
---|
439 | printf(" </td><td>\n");
|
---|
440 | PrintStatusMenu("fFillStar", "Fillstar");
|
---|
441 |
|
---|
442 | printf("</td></tr> </table>\n");
|
---|
443 | printf(" <p>\n");
|
---|
444 |
|
---|
445 | printf(" <table>\n");
|
---|
446 | printf(" <tr>\n");
|
---|
447 |
|
---|
448 | CheckBox("fStartTime", "StartTime");
|
---|
449 | CheckBox("fFailedTime", "FailedTime");
|
---|
450 | CheckBox("fReturnCode", "ErrCode");
|
---|
451 | CheckBox("fFailedCode", "RetCode");
|
---|
452 | CheckBox("fFailedCodeAdd", "CodeAdd");
|
---|
453 |
|
---|
454 | printf(" </tr>\n");
|
---|
455 | printf(" </table>\n");
|
---|
456 | printf(" <p>\n");
|
---|
457 |
|
---|
458 | printf(" <table>\n");
|
---|
459 | printf(" <tr>\n");
|
---|
460 |
|
---|
461 | CheckBox("fUnsuitableInner", "Unsuitable inner");
|
---|
462 | CheckBox("fUnsuitableOuter", "Unsuitable outer");
|
---|
463 | CheckBox("fUnreliableInner", "Unreliable inner");
|
---|
464 | CheckBox("fUnreliableOuter", "Unreliable outer");
|
---|
465 |
|
---|
466 | printf(" </tr><tr>\n");
|
---|
467 |
|
---|
468 | CheckBox("fIsolatedInner", "Isolated inner");
|
---|
469 | CheckBox("fIsolatedOuter", "Isolated outer");
|
---|
470 | CheckBox("fIsolatedMaxCluster", "IsolatedMaxCluster");
|
---|
471 |
|
---|
472 | printf(" </tr><tr>\n");
|
---|
473 |
|
---|
474 | CheckBox("fArrTimeMeanInner", "ArrTimeMean inner ");
|
---|
475 | CheckBox("fArrTimeMeanOuter", "ArrTimeMean outer ");
|
---|
476 | CheckBox("fArrTimeRmsInner", "ArrTimeRms inner ");
|
---|
477 | CheckBox("fArrTimeRmsOuter", "ArrTimeRms outer ");
|
---|
478 |
|
---|
479 | printf(" </tr><tr>\n");
|
---|
480 |
|
---|
481 | CheckBox("fMeanPedRmsInner", "MeanPedRms inner");
|
---|
482 | CheckBox("fMeanPedRmsOuter", "MeanPedRms outer");
|
---|
483 | CheckBox("fMeanSignalInner", "MeanSignal inner");
|
---|
484 | CheckBox("fMeanSignalOuter", "MeanSignal outer");
|
---|
485 |
|
---|
486 | printf(" </tr><tr>\n");
|
---|
487 |
|
---|
488 | CheckBox("fConvFactorInner", "Conv inner ");
|
---|
489 | CheckBox("fConvFactorOuter", "Conv outer ");
|
---|
490 | CheckBox("fPulsePosMean", "Mean PulsePos");
|
---|
491 |
|
---|
492 | printf(" </tr></table>\n");
|
---|
493 | printf(" <p>\n");
|
---|
494 |
|
---|
495 | printf(" <table>\n");
|
---|
496 | printf(" <tr>\n");
|
---|
497 |
|
---|
498 | CheckBox("fMeanNumberIslands", "MeanNumIslands");
|
---|
499 | CheckBox("fPSF", "PSF");
|
---|
500 | CheckBox("fRatio", "Ratio");
|
---|
501 |
|
---|
502 | printf(" </tr><tr>\n");
|
---|
503 |
|
---|
504 | CheckBox("fMuonRate", "MuonRate");
|
---|
505 | CheckBox("fMuonNumber", "MuonNumber");
|
---|
506 | CheckBox("fEffOnTime", "EffOnTime");
|
---|
507 |
|
---|
508 | printf(" </tr><tr>\n");
|
---|
509 |
|
---|
510 | CheckBox("fMaxHumidity", "MaxHumidity");
|
---|
511 | CheckBox("fDataRate", "CleanedEvtRate");
|
---|
512 | CheckBox("fInhomogeneity", "Inhomogeneity");
|
---|
513 |
|
---|
514 | printf(" </tr>\n");
|
---|
515 | printf(" </table>\n");
|
---|
516 | printf(" <p>\n");
|
---|
517 |
|
---|
518 | // pull down boxes
|
---|
519 |
|
---|
520 | printf(" <table>\n");
|
---|
521 | printf(" <tr><td>\n");
|
---|
522 | PrintPullDown($db, "Source", "fSourceName", "fSourceKEY", "Source Name");
|
---|
523 | printf(" </td><td>\n");
|
---|
524 | PrintPullDown($db, "L1TriggerTable", "fL1TriggerTableName", "fL1TriggerTableKEY", "L1Trigger Table");
|
---|
525 | printf(" </td><td>\n");
|
---|
526 | PrintPullDown($db, "L2TriggerTable", "fL2TriggerTableName", "fL2TriggerTableKEY", "L2Trigger Table");
|
---|
527 | printf(" </td><td>\n");
|
---|
528 | PrintPullDown($db, "TriggerDelayTable", "fTriggerDelayTableName", "fTriggerDelayTableKEY", "Trigger Delay Table");
|
---|
529 | printf(" </td></tr><tr><td>\n");
|
---|
530 | PrintPullDown($db, "LightConditions", "fLightConditionsName", "fLightConditionsKEY", "Light Conditions");
|
---|
531 | printf(" </td><td>\n");
|
---|
532 | PrintPullDown($db, "Project", "fProjectName", "fProjectKEY", "Project Name");
|
---|
533 | printf(" </td><td>\n");
|
---|
534 | PrintPullDown($db, "HvSettings", "fHvSettingsName", "fHvSettingsKEY", "HV Settings");
|
---|
535 | printf(" </td><td>\n");
|
---|
536 | PrintPullDown($db, "DiscriminatorThresholdTable", "fDiscriminatorThresholdTableName", "fDiscriminatorThresholdTableKEY", "DT Table");
|
---|
537 | printf(" </td></tr><tr><td>\n");
|
---|
538 | PrintPullDown($db, "ManuallyChanged", "fManuallyChangedName", "fManuallyChangedKEY", "Manually changed");
|
---|
539 | printf(" </td><td>\n");
|
---|
540 | PrintPullDown($db, "TestFlag", "fTestFlagName", "fTestFlagKEY", "Test Flag");
|
---|
541 | printf(" </td></tr>\n");
|
---|
542 | printf(" </table>\n");
|
---|
543 | printf(" <p>\n");
|
---|
544 |
|
---|
545 | if (empty($_GET["fStartDate"]))
|
---|
546 | $timemin = GetMin("fRunStart", "Sequences", $db);
|
---|
547 | else
|
---|
548 | $timemin = $_GET["fStartDate"];
|
---|
549 |
|
---|
550 | if (empty($_GET["fStopDate"]))
|
---|
551 | $timemax = GetMax("fRunStart", "Sequences", $db);
|
---|
552 | else
|
---|
553 | $timemax = $_GET["fStopDate"];
|
---|
554 |
|
---|
555 | printf("Night (yyyy-mm-dd) from <input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
|
---|
556 | printf("to <input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\"> \n", $timemax);
|
---|
557 |
|
---|
558 | if (empty($_GET["fRunMin"]))
|
---|
559 | $min = GetMin("fSequenceFirst", "Sequences", $db);
|
---|
560 | else
|
---|
561 | $min = $_GET["fRunMin"];
|
---|
562 |
|
---|
563 | if (empty($_GET["fRunMax"]))
|
---|
564 | $max = GetMax("fSequenceFirst", "Sequences", $db);
|
---|
565 | else
|
---|
566 | $max = $_GET["fRunMax"];
|
---|
567 |
|
---|
568 | /*
|
---|
569 | printf("Date (yyyy-mm-dd) <input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
|
---|
570 | if (!empty($_GET["fDate"]))
|
---|
571 | printf("%s", $_GET["fDate"]);
|
---|
572 | printf("\"> \n");
|
---|
573 | */
|
---|
574 |
|
---|
575 | printf("Sequences from <input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
|
---|
576 | printf("to <input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\"> \n", $max);
|
---|
577 |
|
---|
578 | printf(" <P>\n");
|
---|
579 |
|
---|
580 | printf("Source (<A HREF=\"regexp.html\">regexp</A>) <input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
|
---|
581 | if (!empty($_GET["fSourceN"]))
|
---|
582 | printf("%s", $_GET["fSourceN"]);
|
---|
583 | printf("\"> \n");
|
---|
584 |
|
---|
585 | printf(" Results:\n");
|
---|
586 | printf(" <select name=\"fNumResults\">\n");
|
---|
587 |
|
---|
588 | $numres = array("10", "20", "50", "100", "200", "500");
|
---|
589 | foreach ($numres as $element)
|
---|
590 | {
|
---|
591 | if ($element==$_GET["fNumResults"])
|
---|
592 | printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
|
---|
593 | else
|
---|
594 | printf("<option value=\"%s\">%3s</option>\n", $element, $element);
|
---|
595 | }
|
---|
596 | printf(" </select>\n");
|
---|
597 | printf(" \n");
|
---|
598 |
|
---|
599 | ini_set("mysql.trace_mode", "Off");
|
---|
600 | ini_set("display_errors", "Off");
|
---|
601 |
|
---|
602 | printf("<input class='Width' type='submit' value='Query Table'> \n");
|
---|
603 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"sequinfo.php\"'> \n");
|
---|
604 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
---|
605 | printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
---|
606 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
---|
607 | printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
---|
608 | printf("</form>\n");
|
---|
609 | printf("</center>\n");
|
---|
610 | printf("</td>\n");
|
---|
611 | printf("</tr>\n");
|
---|
612 | printf("<tr class='Block'>\n");
|
---|
613 | printf("<td>\n");
|
---|
614 | }
|
---|
615 |
|
---|
616 | function PrintPage($html, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
|
---|
617 | {
|
---|
618 | $db_id = mysql_connect("hercules.astro.uni-wuerzburg.de", "MAGIC", "d99swMT!");
|
---|
619 | if ($db_id==FALSE)
|
---|
620 | {
|
---|
621 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
622 | die("");
|
---|
623 | }
|
---|
624 | mysql_select_db($db);
|
---|
625 |
|
---|
626 | $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
627 |
|
---|
628 | $result0 = mysql_query($query0, $db_id);
|
---|
629 |
|
---|
630 | if ($result0)
|
---|
631 | {
|
---|
632 | if ($html=="1" || $html=="2")
|
---|
633 | PrintMagicTable($result0, $alias, $rightalign, "", "", $_GET);
|
---|
634 | else
|
---|
635 | PrintText($result0);
|
---|
636 |
|
---|
637 | mysql_free_result($result0);
|
---|
638 | }
|
---|
639 | mysql_close($db_id);
|
---|
640 |
|
---|
641 | if ($html=="1")
|
---|
642 | printf("<U><B>submitted query:</B></U><BR>%s<BR>", htmlspecialchars($query0));
|
---|
643 | }
|
---|
644 |
|
---|
645 | include ("include.php");
|
---|
646 | include ("db.php");
|
---|
647 | include ("magicdefs.php");
|
---|
648 |
|
---|
649 | ini_set("display_errors", "On");
|
---|
650 | ini_set("mysql.trace_mode", "On");
|
---|
651 |
|
---|
652 | if (!empty($_GET["fSendTxt"]))
|
---|
653 | {
|
---|
654 | header("Content-type: application/octet");
|
---|
655 | header("Content-Disposition: attachment; filename=query-result.txt");
|
---|
656 |
|
---|
657 | PrintPage("0", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
658 | }
|
---|
659 | else
|
---|
660 | {
|
---|
661 | echo (file_get_contents("index-header.html"));
|
---|
662 |
|
---|
663 | $environment = sizeof($_GET);
|
---|
664 |
|
---|
665 | InitGet($_GET);
|
---|
666 | if (empty($_GET["fPrintTable"]))
|
---|
667 | PrintForm($_GET, $db);
|
---|
668 |
|
---|
669 | if ($environment==0)
|
---|
670 | printf("No query submitted yet.<BR>");
|
---|
671 | else
|
---|
672 | {
|
---|
673 | if (empty($_GET["fPrintTable"]))
|
---|
674 | PrintPage("1", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
675 | else
|
---|
676 | PrintPage("2", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
677 | }
|
---|
678 |
|
---|
679 | echo (file_get_contents("index-footer.html"));
|
---|
680 | }
|
---|
681 |
|
---|
682 | ini_set("display_errors", "Off");
|
---|
683 | ini_set("mysql.trace_mode", "Off");
|
---|
684 | }
|
---|
685 | ?>
|
---|