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

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