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 'Run#'";
|
---|
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["fFailedCode"]))
|
---|
329 | $_GET["fFailedCode"]="Off";
|
---|
330 |
|
---|
331 | if (empty($_GET["fFailedCodeAdd"]))
|
---|
332 | $_GET["fFailedCodeAdd"]="Off";
|
---|
333 | }
|
---|
334 |
|
---|
335 | function PrintForm($_GET, $host, $user, $pw, $db)
|
---|
336 | {
|
---|
337 | printf("<center>\n");
|
---|
338 | printf("<form action=\"runinfo.php\" METHOD=\"GET\">\n");
|
---|
339 | printf(" <table>\n");
|
---|
340 | printf(" <tr>\n");
|
---|
341 |
|
---|
342 | CheckBox("fRunStart", "Run start time");
|
---|
343 | CheckBox("fL2RatePresc", "L2 presc Rate");
|
---|
344 | CheckBox("fDaqStoreRate", "DAQ Storage Rate");
|
---|
345 | CheckBox("fAzimuth", "Azimuth");
|
---|
346 |
|
---|
347 | printf(" </tr><tr>\n");
|
---|
348 |
|
---|
349 | CheckBox("fRunStop", "Run stop time");
|
---|
350 | CheckBox("fL2RateUnpresc", "L2 unpresc Rate");
|
---|
351 | CheckBox("fDaqTriggerRate", "DAQ Trigger Rate");
|
---|
352 | CheckBox("fZenithDistance", "Zenith distance");
|
---|
353 |
|
---|
354 | printf(" </tr><tr>\n");
|
---|
355 |
|
---|
356 | // CheckBox("fFormatVersion", "File format");
|
---|
357 | CheckBox("fNumEvents", "Num of events");
|
---|
358 | CheckBox("fMeanTriggerRate", "Mean Trigger rate");
|
---|
359 | CheckBox("fSequenceFirst", "Sequence Number");
|
---|
360 | CheckBox("fTest", "incl. TestSources");
|
---|
361 |
|
---|
362 | printf(" </tr>\n");
|
---|
363 | printf(" </table>\n");
|
---|
364 | printf(" <table>\n");
|
---|
365 | printf(" <tr><td>\n");
|
---|
366 |
|
---|
367 | PrintStatusMenu("fCCFileAvail", "CC File available");
|
---|
368 | printf(" </td><td>\n");
|
---|
369 | PrintStatusMenu("fCaCoFileAvail", "Caco File available");
|
---|
370 | printf(" </td><td>\n");
|
---|
371 | PrintStatusMenu("fRawFileAvail", "Rawfile available");
|
---|
372 |
|
---|
373 | printf(" </td></tr><tr><td>\n");
|
---|
374 |
|
---|
375 | PrintStatusMenu("fTimingCorrection", "Timing Correction");
|
---|
376 | printf(" </td><td>\n");
|
---|
377 | PrintStatusMenu("fCaCoFileFound", "Caco File");
|
---|
378 | printf(" </td><td>\n");
|
---|
379 | PrintStatusMenu("fDataCheckDone", "DataCheck");
|
---|
380 |
|
---|
381 | printf(" </td></tr></table>\n");
|
---|
382 | printf(" <p>\n");
|
---|
383 |
|
---|
384 | printf(" <table>\n");
|
---|
385 | printf(" <tr>\n");
|
---|
386 |
|
---|
387 | CheckBox("fStartTime", "StartTime");
|
---|
388 | CheckBox("fFailedTime", "FailedTime");
|
---|
389 | CheckBox("fReturnCode", "ErrCode");
|
---|
390 | CheckBox("fFailedCode", "RetCode");
|
---|
391 | CheckBox("fFailedCodeAdd", "CodeAdd");
|
---|
392 |
|
---|
393 | printf(" </tr>\n");
|
---|
394 | printf(" </table>\n");
|
---|
395 | printf(" <p>\n");
|
---|
396 |
|
---|
397 | // pull down boxes
|
---|
398 |
|
---|
399 | printf(" <table>\n");
|
---|
400 | printf(" <tr><td>\n");
|
---|
401 | PrintPullDown($host, $user, $pw, $db, "RunType", "fRunTypeName", "fRunTypeKEY", "Run type");
|
---|
402 | printf(" </td><td>\n");
|
---|
403 | PrintPullDown($host, $user, $pw, $db, "Source", "fSourceName", "fSourceKEY", "Source Name");
|
---|
404 | printf(" </td><td>\n");
|
---|
405 | PrintPullDown($host, $user, $pw, $db, "HvSettings", "fHvSettingsName", "fHvSettingsKEY", "HV Settings");
|
---|
406 | printf(" </td><td>\n");
|
---|
407 | PrintPullDown($host, $user, $pw, $db, "L1TriggerTable", "fL1TriggerTableName", "fL1TriggerTableKEY", "L1 Trigger Table");
|
---|
408 | printf(" </td></tr><tr><td>\n");
|
---|
409 | PrintPullDown($host, $user, $pw, $db, "TestFlag", "fTestFlagName", "fTestFlagKEY", "Test Flag");
|
---|
410 | printf(" </td><td>\n");
|
---|
411 | PrintPullDown($host, $user, $pw, $db, "Project", "fProjectName", "fProjectKEY", "Project Name");
|
---|
412 | printf(" </td><td>\n");
|
---|
413 | PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable", "fDiscriminatorThresholdTableName", "fDiscriminatorThresholdTableKEY", "DT Table");
|
---|
414 | printf(" </td><td>\n");
|
---|
415 | PrintPullDown($host, $user, $pw, $db, "L2TriggerTable", "fL2TriggerTableName", "fL2TriggerTableKEY", "L2 Trigger Table");
|
---|
416 | printf(" </td></tr><tr><td>\n");
|
---|
417 | PrintPullDown($host, $user, $pw, $db, "ExcludedFDA", "fExcludedFDAName", "fExcludedFDAKEY", "Exclusions");
|
---|
418 | printf(" </td><td>\n");
|
---|
419 | PrintPullDown($host, $user, $pw, $db, "LightConditions", "fLightConditionsName", "fLightConditionsKEY", "Light Conditions");
|
---|
420 | printf(" </td><td>\n");
|
---|
421 | PrintPullDown($host, $user, $pw, $db, "CalibrationScript", "fCalibrationScriptName", "fCalibrationScriptKEY", "Cal Script");
|
---|
422 | printf(" </td><td>\n");
|
---|
423 | PrintPullDown($host, $user, $pw, $db, "TriggerDelayTable", "fTriggerDelayTableName", "fTriggerDelayTableKEY", "Trigger Delay Table");
|
---|
424 | printf(" </td></tr><tr><td>\n");
|
---|
425 | PrintPullDown($host, $user, $pw, $db, "MagicNumber", "fMagicNumberName", "fMagicNumberKEY", "Magic Number");
|
---|
426 | printf(" </td></tr></table>\n");
|
---|
427 |
|
---|
428 | printf(" <p>\n");
|
---|
429 |
|
---|
430 | if (empty($_GET["fStartDate"]))
|
---|
431 | $timemin = GetMin("fRunStart", "RunData", $host, $user, $pw, $db);
|
---|
432 | else
|
---|
433 | $timemin = $_GET["fStartDate"];
|
---|
434 |
|
---|
435 | if (empty($_GET["fStopDate"]))
|
---|
436 | $timemax = GetMax("fRunStart", "RunData", $host, $user, $pw, $db);
|
---|
437 | else
|
---|
438 | $timemax = $_GET["fStopDate"];
|
---|
439 |
|
---|
440 | printf("Sequ# <input name=\"fSequenceNo\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"");
|
---|
441 | if (!empty($_GET["fSequenceNo"]))
|
---|
442 | printf("%s", $_GET["fSequenceNo"]);
|
---|
443 | printf("\"> \n");
|
---|
444 |
|
---|
445 | printf("Night (yyyy-mm-dd) from <input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
|
---|
446 | printf("to <input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\"> \n", $timemax);
|
---|
447 |
|
---|
448 | /*
|
---|
449 | printf("Date (yyyy-mm-dd) <input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
|
---|
450 | if (!empty($_GET["fDate"]))
|
---|
451 | printf("%s", $_GET["fDate"]);
|
---|
452 | printf("\"> \n");
|
---|
453 | */
|
---|
454 |
|
---|
455 | if (empty($_GET["fRunMin"]))
|
---|
456 | $min = GetMin("fRunNumber", "RunData", $host, $user, $pw, $db);
|
---|
457 | else
|
---|
458 | $min = $_GET["fRunMin"];
|
---|
459 |
|
---|
460 | if (empty($_GET["fRunMax"]))
|
---|
461 | $max = GetMax("fRunNumber", "RunData", $host, $user, $pw, $db);
|
---|
462 | else
|
---|
463 | $max = $_GET["fRunMax"];
|
---|
464 |
|
---|
465 | printf("Runs from <input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
|
---|
466 | printf("to <input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\"> \n", $max);
|
---|
467 |
|
---|
468 | printf(" <P>\n");
|
---|
469 |
|
---|
470 | printf("Source (<A HREF=\"regexp.html\">regexp</A>) <input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
|
---|
471 | if (!empty($_GET["fSourceN"]))
|
---|
472 | printf("%s", $_GET["fSourceN"]);
|
---|
473 | printf("\"> \n");
|
---|
474 |
|
---|
475 | printf(" Results:\n");
|
---|
476 | printf(" <select name=\"fNumResults\">\n");
|
---|
477 |
|
---|
478 | $numres = array("10", "20", "50", "100", "200", "500", "1000", "2000");
|
---|
479 | foreach ($numres as $element)
|
---|
480 | {
|
---|
481 | if ($element==$_GET["fNumResults"])
|
---|
482 | printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
|
---|
483 | else
|
---|
484 | printf("<option value=\"%s\">%3s</option>\n", $element, $element);
|
---|
485 | }
|
---|
486 | printf(" </select>\n");
|
---|
487 | printf(" \n");
|
---|
488 |
|
---|
489 | ini_set("mysql.trace_mode", "Off");
|
---|
490 | ini_set("display_errors", "Off");
|
---|
491 |
|
---|
492 | printf("<input class='Width' type='submit' value='Query Table'> \n");
|
---|
493 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"runinfo.php\"'> \n");
|
---|
494 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
---|
495 | printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
---|
496 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
---|
497 | printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
---|
498 | printf("</form>\n");
|
---|
499 | printf("</center>\n");
|
---|
500 | printf("</td>\n");
|
---|
501 | printf("</tr>\n");
|
---|
502 | printf("<tr class='Block'>\n");
|
---|
503 | printf("<td>\n");
|
---|
504 | }
|
---|
505 |
|
---|
506 | function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
|
---|
507 | {
|
---|
508 | $db_id = mysql_connect($host, $user, $pw);
|
---|
509 | if ($db_id==FALSE)
|
---|
510 | {
|
---|
511 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
512 | die("");
|
---|
513 | }
|
---|
514 | mysql_select_db($db);
|
---|
515 | mysql_query("SET BIG_TABLES=1"); // necessary for mySQL <= 4
|
---|
516 |
|
---|
517 | $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
518 |
|
---|
519 | $result0 = mysql_query($query0, $db_id);
|
---|
520 |
|
---|
521 | if ($result0)
|
---|
522 | {
|
---|
523 | if ($html=="1" || $html=="2")
|
---|
524 | PrintMagicTable($result0, $alias, $rightalign, "", "", $_GET);
|
---|
525 | else
|
---|
526 | PrintText($result0);
|
---|
527 |
|
---|
528 | mysql_free_result($result0);
|
---|
529 | }
|
---|
530 | mysql_close($db_id);
|
---|
531 |
|
---|
532 | PrintSubmittedQuery($query0, $html, $db, "old");
|
---|
533 | }
|
---|
534 |
|
---|
535 | include ("include.php");
|
---|
536 | include ("db.php");
|
---|
537 | include ("magicdefs.php");
|
---|
538 |
|
---|
539 | ini_set("display_errors", "On");
|
---|
540 | ini_set("mysql.trace_mode", "On");
|
---|
541 |
|
---|
542 | if (!empty($_GET["fSendTxt"]))
|
---|
543 | {
|
---|
544 | header("Content-type: application/octet");
|
---|
545 | header("Content-Disposition: attachment; filename=query-result.txt");
|
---|
546 |
|
---|
547 | PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
548 | }
|
---|
549 | else
|
---|
550 | {
|
---|
551 | echo (file_get_contents("index-header.html"));
|
---|
552 |
|
---|
553 | $environment = sizeof($_GET);
|
---|
554 |
|
---|
555 | InitGet($_GET);
|
---|
556 | if (empty($_GET["fPrintTable"]))
|
---|
557 | PrintForm($_GET, $host, $user, $pw, $db);
|
---|
558 |
|
---|
559 | if ($environment==0)
|
---|
560 | printf("No query submitted yet.<BR>");
|
---|
561 | else
|
---|
562 | {
|
---|
563 | if (empty($_GET["fPrintTable"]))
|
---|
564 | PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
565 | else
|
---|
566 | PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
567 | }
|
---|
568 |
|
---|
569 | echo (file_get_contents("index-footer.html"));
|
---|
570 | }
|
---|
571 |
|
---|
572 | ini_set("display_errors", "Off");
|
---|
573 | ini_set("mysql.trace_mode", "Off");
|
---|
574 | }
|
---|
575 | ?>
|
---|