1 | <?php
|
---|
2 | {
|
---|
3 | function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
|
---|
4 | {
|
---|
5 | $fromtable="RunData";
|
---|
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 .= " TIMEDIFF(fRunStop, fRunStart), ";
|
---|
26 | // Only available in MySQL>4.1.1
|
---|
27 | $query0 .= "SUM(if(TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)<0, " .
|
---|
28 | "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)+24*60*60, " .
|
---|
29 | "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)))/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
|
---|
30 | //--------------------------------------------------
|
---|
31 | $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
|
---|
32 | $query0 .= " Min(fZenithDistance) as '" . $alias["Min(fZenithDistance)"] . "', ";
|
---|
33 | $query0 .= " Max(fZenithDistance) as '" . $alias["Max(fZenithDistance)"] . "', ";
|
---|
34 | $query0 .= " COUNT(*) as '# Runs' ";
|
---|
35 | }
|
---|
36 | else
|
---|
37 | {
|
---|
38 | if ($statusgroups>0)
|
---|
39 | {
|
---|
40 | foreach ($checkstatusgroup as $key => $element)
|
---|
41 | if ($element==-1)
|
---|
42 | $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] . "', ";
|
---|
43 | // $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
|
---|
44 |
|
---|
45 | $query0 .= " count(*) as '# Runs'";
|
---|
46 |
|
---|
47 | }
|
---|
48 | else
|
---|
49 | {
|
---|
50 | $query0 .= " RunData.fRunNumber as 'Run#' ";
|
---|
51 |
|
---|
52 | foreach ($_GET as $key => $element)
|
---|
53 | if ($_GET[$key]=="On" && $key!="fTest")
|
---|
54 | if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
|
---|
55 | $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | $query0 .= " FROM RunData ";
|
---|
60 |
|
---|
61 | $query0 .= " LEFT JOIN RunProcessStatus ON RunData.fRunNumber=RunProcessStatus.fRunNumber ";
|
---|
62 |
|
---|
63 | foreach ($_GET as $key => $element)
|
---|
64 | if (($_GET[$key]=="On" || $groups>0))// && !empty($joins[$key]))
|
---|
65 | $query0 .= GetJoin($fromtable,$key);
|
---|
66 |
|
---|
67 | if ($_GET["fTest"]!="On")
|
---|
68 | {
|
---|
69 | if ($_GET["fSourceName"]!="On")
|
---|
70 | $query0 .= " LEFT JOIN Source ON Sequences.fSourceKEY=Source.fSourceKEY ";
|
---|
71 | $query0 .= " WHERE fTest='no'";
|
---|
72 | }
|
---|
73 |
|
---|
74 | foreach ($checkwhere as $key => $element)
|
---|
75 | {
|
---|
76 | if (empty($element) || $element<=0)
|
---|
77 | continue;
|
---|
78 |
|
---|
79 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
80 | $query0 .= " WHERE ";
|
---|
81 | else
|
---|
82 | if ($element!=-1)
|
---|
83 | if (strrpos($query0, " AND ")!=strlen($query0)-5)// this if clause doesn't work
|
---|
84 | $query0 .= " AND ";
|
---|
85 |
|
---|
86 | if ($element!=-1)
|
---|
87 | $query0 .= GetCheck($fromtable, $key) . "=" . $element;
|
---|
88 | }
|
---|
89 |
|
---|
90 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
91 | $query0 .= " WHERE ";
|
---|
92 | else
|
---|
93 | $query0 .= " AND ";
|
---|
94 |
|
---|
95 | $query0 .= StatusQuery("fCCFileAvail", $needs);
|
---|
96 | $query0 .= StatusQuery("fCaCoFileAvail", $needs);
|
---|
97 | $query0 .= StatusQuery("fCaCoFileFound", $needs);
|
---|
98 | $query0 .= StatusQuery("fRawFileAvail", $needs);
|
---|
99 | $query0 .= StatusQuery("fDataCheckDone", $needs);
|
---|
100 | $query0 .= StatusQuery("fTimingCorrection", $needs);
|
---|
101 |
|
---|
102 | if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
|
---|
103 | $query0 .= "RunData.fRunNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
|
---|
104 |
|
---|
105 | /*
|
---|
106 | if (!empty($_GET["fDate"]))
|
---|
107 | $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
|
---|
108 | */
|
---|
109 |
|
---|
110 | if (!empty($_GET["fSourceN"]))
|
---|
111 | $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
|
---|
112 |
|
---|
113 | if (!empty($_GET["fStartDate"]))
|
---|
114 | {
|
---|
115 | if (strpos(strrev($query0), " DNA ")!=0)
|
---|
116 | $query0 .= " AND ";
|
---|
117 |
|
---|
118 | $startdate=substr($_GET["fStartDate"], 0, 10);
|
---|
119 | if ($startdate=="0000-00-00")
|
---|
120 | $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
|
---|
121 | else
|
---|
122 | $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
|
---|
123 | }
|
---|
124 |
|
---|
125 | if (!empty($_GET["fStopDate"]))
|
---|
126 | {
|
---|
127 | if (strpos(strrev($query0), " DNA ")!=0)
|
---|
128 | $query0 .= " AND ";
|
---|
129 |
|
---|
130 | $stopdate=substr($_GET["fStopDate"], 0, 10);
|
---|
131 | $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
|
---|
132 | }
|
---|
133 |
|
---|
134 | if (!empty($_GET["fSequenceNo"]) || $_GET["fSequenceNo"]=="0")
|
---|
135 | {
|
---|
136 | if (strpos(strrev($query0), " DNA ")!=0)
|
---|
137 | $query0 .= " AND ";
|
---|
138 |
|
---|
139 | $query0 .= " fSequenceFirst = '" . $_GET["fSequenceNo"] . "' ";
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | if ($groups>0)
|
---|
144 | {
|
---|
145 | $query0 .= " GROUP BY ";
|
---|
146 | $num = $groups;
|
---|
147 | foreach ($checkgroup as $key => $element)
|
---|
148 | if ($element==-1)
|
---|
149 | {
|
---|
150 | $query0 .= GetCheck($fromtable,$key);
|
---|
151 | if ($num-->1)
|
---|
152 | $query0 .= ", ";
|
---|
153 | }
|
---|
154 | }
|
---|
155 |
|
---|
156 | if ($statusgroups>0)
|
---|
157 | {
|
---|
158 | $query0 .= " GROUP BY ";
|
---|
159 | $num = $statusgroups;
|
---|
160 | foreach ($checkstatusgroup as $key => $element)
|
---|
161 | if ($element==-1)
|
---|
162 | {
|
---|
163 | $query0 .= $alias[$key];
|
---|
164 | if ($num-->1)
|
---|
165 | $query0 .= ", ";
|
---|
166 | }
|
---|
167 | }
|
---|
168 |
|
---|
169 | if (!empty($_GET["fSortBy"]))
|
---|
170 | {
|
---|
171 | $val=substr($_GET["fSortBy"], 0, -1);
|
---|
172 | $query0 .= " ORDER BY " . GetTable($fromtable, $val) . " ";
|
---|
173 | if (substr($_GET["fSortBy"], -1)=="-")
|
---|
174 | $query0 .= "DESC";
|
---|
175 | }
|
---|
176 |
|
---|
177 | if (empty($_GET["fNumStart"]))
|
---|
178 | $_GET["fNumStart"]=0;
|
---|
179 |
|
---|
180 | if (empty($_GET["fSendTxt"]))
|
---|
181 | $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
|
---|
182 |
|
---|
183 | return $query0;
|
---|
184 | }
|
---|
185 |
|
---|
186 | function InitGet($_GET)
|
---|
187 | {
|
---|
188 | /*
|
---|
189 | if (empty($_GET["fRawFileKEY"]))
|
---|
190 | $_GET["fRawFileKEY"]="Off";
|
---|
191 | */
|
---|
192 |
|
---|
193 | // Find out whether it is the first call to the php script
|
---|
194 | $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
|
---|
195 |
|
---|
196 | if (empty($_GET["fNumResults"]))
|
---|
197 | $_GET["fNumResults"]="20";
|
---|
198 |
|
---|
199 | if (empty($_GET["fLastUpdate"]))
|
---|
200 | $_GET["fLastUpdate"]="Off";
|
---|
201 |
|
---|
202 | if (empty($_GET["fTest"]))
|
---|
203 | $_GET["fTest"]=$first?"On":"";
|
---|
204 |
|
---|
205 | if (empty($_GET["fFormatVersion"]))
|
---|
206 | $_GET["fFormatVersion"]="Off";
|
---|
207 |
|
---|
208 | if (empty($_GET["fNumEvents"]))
|
---|
209 | $_GET["fNumEvents"]=$first?"On":"";
|
---|
210 |
|
---|
211 | if (empty($_GET["fRunStart"]))
|
---|
212 | $_GET["fRunStart"]=$first?"On":"";
|
---|
213 |
|
---|
214 | if (empty($_GET["fRunStop"]))
|
---|
215 | $_GET["fRunStop"]="Off";
|
---|
216 |
|
---|
217 | if (empty($_GET["fAzimuth"]))
|
---|
218 | $_GET["fAzimuth"]="Off";
|
---|
219 |
|
---|
220 | if (empty($_GET["fZenithDistance"]))
|
---|
221 | $_GET["fZenithDistance"]=$first?"On":"";
|
---|
222 |
|
---|
223 | if (empty($_GET["fRunTypeName"]))
|
---|
224 | $_GET["fRunTypeName"]=$first?"On":"";
|
---|
225 |
|
---|
226 | if (empty($_GET["fMagicNumberName"]))
|
---|
227 | $_GET["fMagicNumberName"]="Off";
|
---|
228 |
|
---|
229 | if (empty($_GET["fSourceName"]))
|
---|
230 | $_GET["fSourceName"]=$first?"On":"";
|
---|
231 |
|
---|
232 | if (empty($_GET["fProjectName"]))
|
---|
233 | $_GET["fProjectName"]="Off";
|
---|
234 |
|
---|
235 | if (empty($_GET["fL1TriggerTableName"]))
|
---|
236 | $_GET["fL1TriggerTableName"]="Off";
|
---|
237 |
|
---|
238 | if (empty($_GET["fL2TriggerTableName"]))
|
---|
239 | $_GET["fL2TriggerTableName"]="Off";
|
---|
240 |
|
---|
241 | if (empty($_GET["fMeanTriggerRate"]))
|
---|
242 | $_GET["fMeanTriggerRate"]=$first?"On":"";
|
---|
243 |
|
---|
244 | if (empty($_GET["fHvSettingsName"]))
|
---|
245 | $_GET["fHvSettingsName"]="Off";
|
---|
246 |
|
---|
247 | if (empty($_GET["fCalibrationScriptName"]))
|
---|
248 | $_GET["fCalibrationScriptName"]="Off";
|
---|
249 |
|
---|
250 | if (empty($_GET["fDiscriminatorThresholdTableName"]))
|
---|
251 | $_GET["fDiscriminatorThresholdTableName"]="Off";
|
---|
252 |
|
---|
253 | if (empty($_GET["fTriggerDelayTableName"]))
|
---|
254 | $_GET["fTriggerDelayTableName"]="Off";
|
---|
255 |
|
---|
256 | if (empty($_GET["fLightConditionsName"]))
|
---|
257 | $_GET["fLightConditionsName"]="Off";
|
---|
258 |
|
---|
259 | if (empty($_GET["fTestFlagName"]))
|
---|
260 | $_GET["fTestFlagName"]="Off";
|
---|
261 |
|
---|
262 | if (empty($_GET["fDaqStoreRate"]))
|
---|
263 | $_GET["fDaqStoreRate"]="Off";
|
---|
264 |
|
---|
265 | if (empty($_GET["fDaqTriggerRate"]))
|
---|
266 | $_GET["fDaqTriggerRate"]="Off";
|
---|
267 |
|
---|
268 | if (empty($_GET["fL2RatePresc"]))
|
---|
269 | $_GET["fL2RatePresc"]="Off";
|
---|
270 |
|
---|
271 | if (empty($_GET["fL2RateUnpresc"]))
|
---|
272 | $_GET["fL2RateUnpresc"]="Off";
|
---|
273 |
|
---|
274 | if (empty($_GET["fExcludedFDAName"]))
|
---|
275 | $_GET["fExcludedFDAName"]=$first?"On":"";
|
---|
276 |
|
---|
277 | if (empty($_GET["fSequenceFirst"]))
|
---|
278 | $_GET["fSequenceFirst"]="Off";
|
---|
279 |
|
---|
280 | if (empty($_GET["fSequenceNo"]))
|
---|
281 | $_GET["fSequenceNo"]="";
|
---|
282 |
|
---|
283 | if (empty($_GET["fDataCheckDone"]))
|
---|
284 | $_GET["fDataCheckDone"]="Off";
|
---|
285 |
|
---|
286 | if (empty($_GET["fDataCheckDoneStatus"]))
|
---|
287 | $_GET["fDataCheckDoneStatus"]="0";
|
---|
288 |
|
---|
289 | if (empty($_GET["fCCFileAvail"]))
|
---|
290 | $_GET["fCCFileAvail"]=$first?"On":"";
|
---|
291 |
|
---|
292 | if (empty($_GET["fCCFileAvailStatus"]))
|
---|
293 | $_GET["fCCFileAvailStatus"]="0";
|
---|
294 |
|
---|
295 | if (empty($_GET["fCaCoFileAvail"]))
|
---|
296 | $_GET["fCaCoFileAvail"]=$first?"On":"";
|
---|
297 |
|
---|
298 | if (empty($_GET["fCaCoFileAvailStatus"]))
|
---|
299 | $_GET["fCaCoFileAvailStatus"]="0";
|
---|
300 |
|
---|
301 | if (empty($_GET["fCaCoFileFound"]))
|
---|
302 | $_GET["fCaCoFileFound"]="Off";
|
---|
303 |
|
---|
304 | if (empty($_GET["fCaCoFileFoundStatus"]))
|
---|
305 | $_GET["fCaCoFileFoundStatus"]="0";
|
---|
306 |
|
---|
307 | if (empty($_GET["fRawFileAvail"]))
|
---|
308 | $_GET["fRawFileAvail"]=$first?"On":"";
|
---|
309 |
|
---|
310 | if (empty($_GET["fRawFileAvailStatus"]))
|
---|
311 | $_GET["fRawFileAvailStatus"]="0";
|
---|
312 |
|
---|
313 | if (empty($_GET["fTimingCorrection"]))
|
---|
314 | $_GET["fTimingCorrection"]=$first?"On":"";
|
---|
315 |
|
---|
316 | if (empty($_GET["fTimingCorrectionStatus"]))
|
---|
317 | $_GET["fTimingCorrectionStatus"]="0";
|
---|
318 |
|
---|
319 | if (empty($_GET["fStartTime"]))
|
---|
320 | $_GET["fStartTime"]="Off";
|
---|
321 |
|
---|
322 | if (empty($_GET["fFailedTime"]))
|
---|
323 | $_GET["fFailedTime"]="Off";
|
---|
324 |
|
---|
325 | if (empty($_GET["fReturnCode"]))
|
---|
326 | $_GET["fReturnCode"]="Off";
|
---|
327 |
|
---|
328 | if (empty($_GET["fProgramId"]))
|
---|
329 | $_GET["fProgramId"]="Off";
|
---|
330 |
|
---|
331 | }
|
---|
332 |
|
---|
333 | function PrintForm($_GET, $host, $user, $pw, $db)
|
---|
334 | {
|
---|
335 | printf("<center>\n");
|
---|
336 | printf("<form action=\"runinfo.php\" METHOD=\"GET\">\n");
|
---|
337 | printf(" <table>\n");
|
---|
338 | printf(" <tr>\n");
|
---|
339 |
|
---|
340 | CheckBox("fRunStart", "Run start time");
|
---|
341 | CheckBox("fL2RatePresc", "L2 presc Rate");
|
---|
342 | CheckBox("fDaqStoreRate", "DAQ Storage Rate");
|
---|
343 | CheckBox("fAzimuth", "Azimuth");
|
---|
344 |
|
---|
345 | printf(" </tr><tr>\n");
|
---|
346 |
|
---|
347 | CheckBox("fRunStop", "Run stop time");
|
---|
348 | CheckBox("fL2RateUnpresc", "L2 unpresc Rate");
|
---|
349 | CheckBox("fDaqTriggerRate", "DAQ Trigger Rate");
|
---|
350 | CheckBox("fZenithDistance", "Zenith distance");
|
---|
351 |
|
---|
352 | printf(" </tr><tr>\n");
|
---|
353 |
|
---|
354 | // CheckBox("fFormatVersion", "File format");
|
---|
355 | CheckBox("fNumEvents", "Num of events");
|
---|
356 | CheckBox("fMeanTriggerRate", "Mean Trigger rate");
|
---|
357 | CheckBox("fSequenceFirst", "Sequence Number");
|
---|
358 | CheckBox("fTest", "incl. TestSources");
|
---|
359 |
|
---|
360 | printf(" </tr>\n");
|
---|
361 | printf(" </table>\n");
|
---|
362 | printf(" <table>\n");
|
---|
363 | printf(" <tr><td>\n");
|
---|
364 |
|
---|
365 | PrintStatusMenu("fCCFileAvail", "CC File available");
|
---|
366 | printf(" </td><td>\n");
|
---|
367 | PrintStatusMenu("fCaCoFileAvail", "Caco File available");
|
---|
368 | printf(" </td><td>\n");
|
---|
369 | PrintStatusMenu("fRawFileAvail", "Rawfile available");
|
---|
370 |
|
---|
371 | printf(" </td></tr><tr><td>\n");
|
---|
372 |
|
---|
373 | PrintStatusMenu("fTimingCorrection", "Timing Correction");
|
---|
374 | printf(" </td><td>\n");
|
---|
375 | PrintStatusMenu("fCaCoFileFound", "Caco File");
|
---|
376 | printf(" </td><td>\n");
|
---|
377 | PrintStatusMenu("fDataCheckDone", "DataCheck");
|
---|
378 |
|
---|
379 | printf(" </td></tr></table>\n");
|
---|
380 | printf(" <p>\n");
|
---|
381 |
|
---|
382 | printf(" <table>\n");
|
---|
383 | printf(" <tr>\n");
|
---|
384 |
|
---|
385 | CheckBox("fStartTime", "StartTime");
|
---|
386 | CheckBox("fFailedTime", "FailedTime");
|
---|
387 | CheckBox("fReturnCode", "RetCode");
|
---|
388 | CheckBox("fProgramId", "ProgramId");
|
---|
389 |
|
---|
390 | printf(" </tr>\n");
|
---|
391 | printf(" </table>\n");
|
---|
392 | printf(" <p>\n");
|
---|
393 |
|
---|
394 | // pull down boxes
|
---|
395 |
|
---|
396 | printf(" <table>\n");
|
---|
397 | printf(" <tr><td>\n");
|
---|
398 | PrintPullDown($host, $user, $pw, $db, "RunType", "fRunTypeName", "fRunTypeKEY", "Run type");
|
---|
399 | printf(" </td><td>\n");
|
---|
400 | PrintPullDown($host, $user, $pw, $db, "Source", "fSourceName", "fSourceKEY", "Source Name");
|
---|
401 | printf(" </td><td>\n");
|
---|
402 | PrintPullDown($host, $user, $pw, $db, "HvSettings", "fHvSettingsName", "fHvSettingsKEY", "HV Settings");
|
---|
403 | printf(" </td><td>\n");
|
---|
404 | PrintPullDown($host, $user, $pw, $db, "L1TriggerTable", "fL1TriggerTableName", "fL1TriggerTableKEY", "L1 Trigger Table");
|
---|
405 | printf(" </td></tr><tr><td>\n");
|
---|
406 | PrintPullDown($host, $user, $pw, $db, "TestFlag", "fTestFlagName", "fTestFlagKEY", "Test Flag");
|
---|
407 | printf(" </td><td>\n");
|
---|
408 | PrintPullDown($host, $user, $pw, $db, "Project", "fProjectName", "fProjectKEY", "Project Name");
|
---|
409 | printf(" </td><td>\n");
|
---|
410 | PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable", "fDiscriminatorThresholdTableName", "fDiscriminatorThresholdTableKEY", "DT Table");
|
---|
411 | printf(" </td><td>\n");
|
---|
412 | PrintPullDown($host, $user, $pw, $db, "L2TriggerTable", "fL2TriggerTableName", "fL2TriggerTableKEY", "L2 Trigger Table");
|
---|
413 | printf(" </td></tr><tr><td>\n");
|
---|
414 | PrintPullDown($host, $user, $pw, $db, "ExcludedFDA", "fExcludedFDAName", "fExcludedFDAKEY", "Exclusions");
|
---|
415 | printf(" </td><td>\n");
|
---|
416 | PrintPullDown($host, $user, $pw, $db, "LightConditions", "fLightConditionsName", "fLightConditionsKEY", "Light Conditions");
|
---|
417 | printf(" </td><td>\n");
|
---|
418 | PrintPullDown($host, $user, $pw, $db, "CalibrationScript", "fCalibrationScriptName", "fCalibrationScriptKEY", "Cal Script");
|
---|
419 | printf(" </td><td>\n");
|
---|
420 | PrintPullDown($host, $user, $pw, $db, "TriggerDelayTable", "fTriggerDelayTableName", "fTriggerDelayTableKEY", "Trigger Delay Table");
|
---|
421 | printf(" </td></tr><tr><td>\n");
|
---|
422 | PrintPullDown($host, $user, $pw, $db, "MagicNumber", "fMagicNumberName", "fMagicNumberKEY", "Magic Number");
|
---|
423 | printf(" </td></tr></table>\n");
|
---|
424 |
|
---|
425 | printf(" <p>\n");
|
---|
426 |
|
---|
427 | if (empty($_GET["fStartDate"]))
|
---|
428 | $timemin = GetMin("fRunStart", "RunData", $host, $user, $pw, $db);
|
---|
429 | else
|
---|
430 | $timemin = $_GET["fStartDate"];
|
---|
431 |
|
---|
432 | if (empty($_GET["fStopDate"]))
|
---|
433 | $timemax = GetMax("fRunStart", "RunData", $host, $user, $pw, $db);
|
---|
434 | else
|
---|
435 | $timemax = $_GET["fStopDate"];
|
---|
436 |
|
---|
437 | printf("Sequ# <input name=\"fSequenceNo\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"");
|
---|
438 | if (!empty($_GET["fSequenceNo"]))
|
---|
439 | printf("%s", $_GET["fSequenceNo"]);
|
---|
440 | printf("\"> \n");
|
---|
441 |
|
---|
442 | printf("Night (yyyy-mm-dd) from <input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
|
---|
443 | printf("to <input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\"> \n", $timemax);
|
---|
444 |
|
---|
445 | /*
|
---|
446 | printf("Date (yyyy-mm-dd) <input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
|
---|
447 | if (!empty($_GET["fDate"]))
|
---|
448 | printf("%s", $_GET["fDate"]);
|
---|
449 | printf("\"> \n");
|
---|
450 | */
|
---|
451 |
|
---|
452 | if (empty($_GET["fRunMin"]))
|
---|
453 | $min = GetMin("fRunNumber", "RunData", $host, $user, $pw, $db);
|
---|
454 | else
|
---|
455 | $min = $_GET["fRunMin"];
|
---|
456 |
|
---|
457 | if (empty($_GET["fRunMax"]))
|
---|
458 | $max = GetMax("fRunNumber", "RunData", $host, $user, $pw, $db);
|
---|
459 | else
|
---|
460 | $max = $_GET["fRunMax"];
|
---|
461 |
|
---|
462 | printf("Runs from <input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
|
---|
463 | printf("to <input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\"> \n", $max);
|
---|
464 |
|
---|
465 | printf(" <P>\n");
|
---|
466 |
|
---|
467 | printf("Source (<A HREF=\"regexp.html\">regexp</A>) <input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
|
---|
468 | if (!empty($_GET["fSourceN"]))
|
---|
469 | printf("%s", $_GET["fSourceN"]);
|
---|
470 | printf("\"> \n");
|
---|
471 |
|
---|
472 | printf(" Results:\n");
|
---|
473 | printf(" <select name=\"fNumResults\">\n");
|
---|
474 |
|
---|
475 | $numres = array("10", "20", "50", "100", "200", "500", "1000", "2000");
|
---|
476 | foreach ($numres as $element)
|
---|
477 | {
|
---|
478 | if ($element==$_GET["fNumResults"])
|
---|
479 | printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
|
---|
480 | else
|
---|
481 | printf("<option value=\"%s\">%3s</option>\n", $element, $element);
|
---|
482 | }
|
---|
483 | printf(" </select>\n");
|
---|
484 | printf(" \n");
|
---|
485 |
|
---|
486 | ini_set("mysql.trace_mode", "Off");
|
---|
487 | ini_set("display_errors", "Off");
|
---|
488 |
|
---|
489 | printf("<input class='Width' type='submit' value='Query Table'> \n");
|
---|
490 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"runinfo.php\"'> \n");
|
---|
491 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
---|
492 | printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
---|
493 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
---|
494 | printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
---|
495 | printf("</form>\n");
|
---|
496 | printf("</center>\n");
|
---|
497 | printf("</td>\n");
|
---|
498 | printf("</tr>\n");
|
---|
499 | printf("<tr class='Block'>\n");
|
---|
500 | printf("<td>\n");
|
---|
501 | }
|
---|
502 |
|
---|
503 | function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
|
---|
504 | {
|
---|
505 | $db_id = mysql_connect($host, $user, $pw);
|
---|
506 | if ($db_id==FALSE)
|
---|
507 | {
|
---|
508 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
509 | die("");
|
---|
510 | }
|
---|
511 | mysql_select_db($db);
|
---|
512 | mysql_query("SET BIG_TABLES=1"); // necessary for mySQL <= 4
|
---|
513 |
|
---|
514 | $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
515 |
|
---|
516 | $result0 = mysql_query($query0, $db_id);
|
---|
517 |
|
---|
518 | if ($result0)
|
---|
519 | {
|
---|
520 | if ($html=="1" || $html=="2")
|
---|
521 | PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);
|
---|
522 | else
|
---|
523 | PrintText($result0);
|
---|
524 |
|
---|
525 | mysql_free_result($result0);
|
---|
526 | }
|
---|
527 | mysql_close($db_id);
|
---|
528 |
|
---|
529 | PrintSubmittedQuery($query0, $html, $db, "old");
|
---|
530 | }
|
---|
531 |
|
---|
532 | include ("include.php");
|
---|
533 | include ("db.php");
|
---|
534 | include ("magicdefs.php");
|
---|
535 |
|
---|
536 | ini_set("display_errors", "On");
|
---|
537 | ini_set("mysql.trace_mode", "On");
|
---|
538 |
|
---|
539 | if (!empty($_GET["fSendTxt"]))
|
---|
540 | {
|
---|
541 | header("Content-type: application/octet");
|
---|
542 | header("Content-Disposition: attachment; filename=query-result.txt");
|
---|
543 |
|
---|
544 | PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
545 | }
|
---|
546 | else
|
---|
547 | {
|
---|
548 | echo (file_get_contents("index-header.html"));
|
---|
549 |
|
---|
550 | $environment = sizeof($_GET);
|
---|
551 |
|
---|
552 | InitGet($_GET);
|
---|
553 | if (empty($_GET["fPrintTable"]))
|
---|
554 | PrintForm($_GET, $host, $user, $pw, $db);
|
---|
555 |
|
---|
556 | if ($environment==0)
|
---|
557 | printf("No query submitted yet.<BR>");
|
---|
558 | else
|
---|
559 | {
|
---|
560 | if (empty($_GET["fPrintTable"]))
|
---|
561 | PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
562 | else
|
---|
563 | PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
564 | }
|
---|
565 |
|
---|
566 | echo (file_get_contents("index-footer.html"));
|
---|
567 | }
|
---|
568 |
|
---|
569 | ini_set("display_errors", "Off");
|
---|
570 | ini_set("mysql.trace_mode", "Off");
|
---|
571 | }
|
---|
572 | ?>
|
---|