source: tags/Mars-V0.9.6/datacenter/db/findoffdata.php

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