source: trunk/MagicSoft/Mars/datacenter/db/findoffdata.php@ 7546

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