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

Last change on this file was 7547, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 25.0 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["fDataRate"]))
390 $_GET["fDataRate"]=$first?"On":"";
391
392 if (empty($_GET["fMaxHumidity"]))
393 $_GET["fMaxHumidity"]="Off";
394
395 }
396
397 function PrintForm($_GET, $host, $user, $pw, $db, $limits, $rms, $alias)
398 {
399 printf("<center>\n");
400 printf("<form action=\"findoffdata.php\" METHOD=\"GET\">\n");
401
402 printf(" <table>\n");
403 printf(" <tr><td align='center'>\n");
404
405
406 printf(" <table>\n");
407 printf(" <tr>\n");
408
409 CheckBox("fRunStart", "Start time");
410 CheckBox("fSequenceLast", "Last run");
411 CheckBox("fZenithDistanceMin", "Zd min");
412 CheckBox("fZenithDistanceMax", "Zd max");
413
414 printf(" </tr><tr>\n");
415
416 CheckBox("fNumEvents", "Num of events");
417 CheckBox("fRunTime/60", "Duration");
418 CheckBox("fAzimuthMin", "Azimuth min");
419 CheckBox("fAzimuthMax", "Azimuth max");
420// CheckBox("fLinks", "Links");
421/*
422 printf(" </tr></table>\n");
423 printf(" <p>\n");
424 printf(" <table>\n");
425 printf(" <tr>\n");
426*/
427
428 printf(" </tr><tr>\n");
429
430 CheckBox("fUnsuitableInner", "Unsuitable inner");
431 CheckBox("fUnsuitableOuter", "Unsuitable outer");
432 CheckBox("fUnreliableInner", "Unreliable inner");
433 CheckBox("fUnreliableOuter", "Unreliable outer");
434
435 printf(" </tr><tr>\n");
436
437 CheckBox("fIsolatedInner", "Isolated inner");
438 CheckBox("fIsolatedOuter", "Isolated outer");
439 CheckBox("fIsolatedMaxCluster", "IsolatedMaxCl.");
440 CheckBox("fMaxHumidity", "MaxHumidity");
441
442 printf(" </tr><tr>\n");
443
444 CheckBox("fArrTimeMeanInner", "ArrTimeMean in");
445 CheckBox("fArrTimeMeanOuter", "ArrTimeMean out");
446 CheckBox("fArrTimeRmsInner", "ArrTimeRms in");
447 CheckBox("fArrTimeRmsOuter", "ArrTimeRms out");
448
449 printf(" </tr><tr>\n");
450
451 CheckBox("fConvFactorInner", "Conv inner ");
452 CheckBox("fConvFactorOuter", "Conv outer ");
453 CheckBox("fMeanPedRmsInner", "MeanPedRms in");
454 CheckBox("fMeanPedRmsOuter", "MeanPedRms out");
455
456/*
457 printf(" </tr></table>\n");
458 printf(" <p>\n");
459
460 printf(" <table>\n");
461 printf(" <tr>\n");
462*/
463
464 printf(" </tr><tr>\n");
465
466 CheckBox("fMeanNumberIslands", "MeanNumIslands");
467 CheckBox("fPSF", "PSF");
468 CheckBox("fRatio", "Ratio");
469 CheckBox("fMuonRate", "MuonRate");
470
471 printf(" </tr><tr>\n");
472
473 CheckBox("fMuonNumber", "MuonNumber");
474 CheckBox("fEffOnTime", "EffOnTime");
475 CheckBox("fEffOnTime/fRunTime", "RelOnTime");
476 CheckBox("fDataRate", "CleanedEvtRate");
477
478 printf(" </tr>\n");
479 printf(" </table>\n");
480 printf(" <p>\n");
481
482 printf(" <table><tr><td>\n");
483
484 PrintPullDown($host, $user, $pw, $db, "Source", "fSourceName", "fSourceKEY", "Source Name");
485 printf(" </td><td>\n");
486 PrintPullDown($host, $user, $pw, $db, "LightConditions", "fLightConditionsName", "fLightConditionsKEY", "Light Conditions");
487 printf(" </td><td>\n");
488 PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable", "fDiscriminatorThresholdTableName", "fDiscriminatorThresholdTableKEY", "DT Table");
489 printf(" </td></tr><tr><td>\n");
490 PrintPullDown($host, $user, $pw, $db, "ManuallyChanged", "fManuallyChangedName", "fManuallyChangedKEY", "Manually changed");
491 printf(" </td><td>\n");
492 PrintStatusMenu("fStar", "Star");
493
494 printf("</td></tr> </table>\n");
495 printf(" <p>\n");
496
497 printf(" </td><td valign='top'>\n");
498
499 printf(" <table>\n");
500 printf(" <tr><th colspan='3'>Limits</th><tr>\n");
501 printf(" <tr><td>Name </td><td> Mean </td><td> Rms </td></tr>\n");
502 PrintLimitsMenu($limits, $rms, $alias);
503 printf(" </td></tr></table>\n");
504
505 printf(" </td></tr><tr><td colspan='2' align='center'>\n");
506
507 printf(" <p>\n");
508
509 printf(" <table>\n");
510 printf(" <tr><td>\n");
511
512 if (empty($_GET["fStarStart"]))
513 $starmin = GetMin("fStar", "SequenceProcessStatus", $host, $user, $pw, $db);
514 else
515 $starmin = $_GET["fStarStart"];
516
517 if (empty($_GET["fStarStop"]))
518 $starmax = GetMax("fStar", "SequenceProcessStatus", $host, $user, $pw, $db);
519 else
520 $starmax = $_GET["fStarStop"];
521
522 printf("StarDone&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStarStart\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $starmin);
523 printf("to&nbsp;<input name=\"fStarStop\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">&nbsp;&nbsp;&nbsp;&nbsp;\n", $starmax);
524 printf(" </td>\n");
525 CheckBox("fLinks", "Links");
526 CheckBox("fOff", "incl. offsources");
527 CheckBox("fOnlyOff", "only offsources");
528
529 printf(" </tr>\n");
530 printf(" </table>\n");
531 printf(" <p>\n");
532
533 if (empty($_GET["fStartDate"]))
534 $timemin = GetMin("fRunStart", "Sequences", $host, $user, $pw, $db);
535 else
536 $timemin = $_GET["fStartDate"];
537
538 if (empty($_GET["fStopDate"]))
539 $timemax = GetMax("fRunStart", "Sequences", $host, $user, $pw, $db);
540 else
541 $timemax = $_GET["fStopDate"];
542
543 printf("Night&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
544 printf("to&nbsp;<input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">&nbsp;&nbsp;&nbsp;&nbsp;\n", $timemax);
545
546 if (empty($_GET["fRunMin"]))
547 $min = GetMin("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
548 else
549 $min = $_GET["fRunMin"];
550
551 if (empty($_GET["fRunMax"]))
552 $max = GetMax("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
553 else
554 $max = $_GET["fRunMax"];
555
556/*
557 printf("Date&nbsp;(yyyy-mm-dd)&nbsp;<input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
558 if (!empty($_GET["fDate"]))
559 printf("%s", $_GET["fDate"]);
560 printf("\">&nbsp;&nbsp;&nbsp;\n");
561*/
562
563 printf("Sequences&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
564 printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
565
566 printf(" <P>\n");
567
568 printf("Source&nbsp;(<A HREF=\"regexp.html\">regexp</A>)&nbsp;<input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
569 if (!empty($_GET["fSourceN"]))
570 printf("%s", $_GET["fSourceN"]);
571 printf("\">&nbsp;&nbsp;&nbsp;\n");
572
573 printf(" Results:\n");
574 printf(" <select name=\"fNumResults\">\n");
575
576 $numres = array("10", "20", "50", "100", "200", "500");
577 foreach ($numres as $element)
578 {
579 if ($element==$_GET["fNumResults"])
580 printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
581 else
582 printf("<option value=\"%s\">%3s</option>\n", $element, $element);
583 }
584 printf(" </select>\n");
585 printf(" &nbsp;&nbsp;&nbsp;\n");
586
587 ini_set("mysql.trace_mode", "Off");
588 ini_set("display_errors", "Off");
589
590 printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
591 printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"findoffdata.php\"'>&nbsp;&nbsp;&nbsp;\n");
592 if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
593 printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
594 if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
595 printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
596 printf("</form>\n");
597 printf("</center>\n");
598
599
600 printf(" </td></tr> </table>\n");
601
602 printf("</td>\n");
603 printf("</tr>\n");
604
605
606 printf("<tr class='Block'>\n");
607 printf("<td>\n");
608 }
609
610 function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms, $needs)
611 {
612 $db_id = mysql_connect($host, $user, $pw);
613 if ($db_id==FALSE)
614 {
615 printf("mysql_connect returned the following error: %s\n", mysql_error());
616 die("");
617 }
618 mysql_select_db($db);
619
620 $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
621
622 $result0 = mysql_query($query0, $db_id);
623
624 if ($result0)
625 {
626 if ($html=="1" || $html=="2")
627 PrintMagicTable($result0, $alias, $rightalign, $limits, $rms, $_GET);
628 else
629 PrintText($result0);
630
631 mysql_free_result($result0);
632 }
633 mysql_close($db_id);
634
635 if ($html=="1")
636 printf("<U><B>submitted query:</B></U><BR>%s<BR>", htmlspecialchars($query0));
637 }
638
639 include ("include.php");
640 include ("db.php");
641 include ("magicdefs.php");
642
643 ini_set("display_errors", "On");
644 ini_set("mysql.trace_mode", "On");
645
646 if (!empty($_GET["fSendTxt"]))
647 {
648 header("Content-type: application/octet");
649 header("Content-Disposition: attachment; filename=query-result.txt");
650
651 PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms, $needs);
652 }
653 else
654 {
655 echo (file_get_contents("index-header.html"));
656
657 $environment = sizeof($_GET);
658
659 InitGet($_GET);
660 if (empty($_GET["fPrintTable"]))
661 PrintForm($_GET, $host, $user, $pw, $db, $limits, $rms, $alias);
662
663 if ($environment==0)
664 printf("No query submitted yet.<BR>");
665 else
666 {
667 if (empty($_GET["fPrintTable"]))
668 PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms, $needs);
669 else
670 PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms, $needs);
671 }
672
673 echo (file_get_contents("index-footer.html"));
674 }
675
676 ini_set("display_errors", "Off");
677 ini_set("mysql.trace_mode", "Off");
678}
679?>
Note: See TracBrowser for help on using the repository browser.