source: trunk/MagicSoft/Mars/datacenter/db/sequinfo.php@ 9442

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