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