source: trunk/MagicSoft/Mars/datacenter/db/builddatasets.php@ 9548

Last change on this file since 9548 was 9548, checked in by Daniela Dorner, 15 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 49.9 KB
Line 
1<?php
2
3 function PrintDataSetFile()
4 {
5 if (empty($_SESSION["AnalysisNumber"]))
6 printf("AnalysisNumber: 1\n\n");
7 else
8 printf("AnalysisNumber: %s\n\n", $_SESSION["AnalysisNumber"]);
9 printf("SeqencesOn: %s \n", $_SESSION["sequon"]);
10 if ($_SESSION["sequoff"]!="")
11 printf("SeqencesOff: %s \n\n", $_SESSION["sequoff"]);
12 else
13 printf("\n");
14
15 printf("SourceName: %s \n", $_SESSION["realsourcename"]);
16 printf("Catalog: /magic/datacenter/setup/magic_favorites_dc.edb \n");
17 if ($_SESSION["sequoff"]==" ")
18 printf("WobbleMode: On \n\n");
19 printf("RunTime: %s \n", $_SESSION["runtime"]);
20 printf("Name: %s \n", $_SESSION["name"]);
21 printf("Comment: %s \n", $_SESSION["comment"]);
22 }
23
24 function CreateQuery($alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $db_id)
25 {
26 $fromtable="Sequences";
27
28 $groups = 0;
29 foreach ($checkgroup as $element)
30 if ($element==-1)
31 $groups++;
32
33 $statusgroups = 0;
34 foreach ($checkstatusgroup as $element)
35 if ($element==-1)
36 $statusgroups++;
37
38 $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
39
40 if ($groups>0)
41 {
42 foreach ($checkgroup as $key => $element)
43 if ($element==-1)
44 $query0 .= $key . " as '" . $alias[$key] . "' " . ", ";
45 //--------------------------------------------------
46 $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
47 //--------------------------------------------------
48 $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
49 $query0 .= " Min(fZenithDistanceMin) as '" . $alias["Min(fZenithDistanceMin)"] . "', ";
50 $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', ";
51 $query0 .= " COUNT(*) as '# Sequ' ";
52 }
53 else
54 {
55 if ($statusgroups>0)
56 {
57 foreach ($checkstatusgroup as $key => $element)
58 if ($element==-1)
59 $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] . "', ";
60
61 $query0 .= " COUNT(*) as '# Sequ'";
62
63 }
64 else
65 {
66 $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
67 if (!empty($_GET["fLinks"]))
68 {
69 $query0 .= ", CONCAT('<A&ws;HREF=\"tabs.php?t=calib&n=', fSequenceFirst, '\">cal</A>'";
70 $query0 .= ", '&nbsp;<A&ws;HREF=\"tabs.php?t=signal&n=', fSequenceFirst, '\">sig</A>'";
71 $query0 .= ", '&nbsp;<A&ws;HREF=\"tabs.php?t=star&n=', fSequenceFirst, '\">star</A>'";
72 $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>' ";
73 $query0 .= ", '&nbsp;<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&amp;fDate=2\">rbk</A>') ";
74 $query0 .= " as 'Links'";
75 }
76
77 foreach ($_GET as $key => $element)
78 if ($_GET[$key]=="On")
79 if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff" && $key!="fNumStart")
80 if (!(ereg("^DSSeq[0-9]*$", $key)))
81 if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
82 $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
83 }
84 }
85
86 $query0 .= " FROM " . $fromtable;
87
88 $query0 .= " LEFT JOIN SequenceProcessStatus USING(fSequenceFirst,fTelescopeNumber) ";
89 $query0 .= " LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) ";
90 $query0 .= " LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) ";
91
92 foreach ($_GET as $key => $element)
93 if (($_GET[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key)))
94 $query0 .= GetJoin($fromtable,$key);
95
96 if (($_SESSION["DisplaySelected"]!="yes"
97 || ($_SESSION["sequon"]=="" && $_SESSION["sequoff"]==""))
98 && (empty($_SESSION["DataSetSelection"]) || $_SESSION["DataSetAcknowledged"]=="yes"))
99 {
100 if ($_GET["fTest"]!="On")
101 {
102 if ($_GET["fSourceName"]!="On")
103 $query0 .= " LEFT JOIN Source USING(fSourceKEY) ";
104 $query0 .= " WHERE fTest='no'";
105 }
106
107 if ($_GET["fOff"]=="Off")
108 {
109 if (strpos($query0, " WHERE ")==FALSE)
110 $query0 .= " WHERE ";
111 else
112 $query0 .= " AND ";
113
114 $query0 .= " NOT (fSourceName like '%Off%')";
115 }
116
117 if ($_GET["fOnlyOff"]=="On")
118 {
119 if (strpos($query0, " WHERE ")==FALSE)
120 $query0 .= " WHERE ";
121 else
122 $query0 .= " AND ";
123
124 $query0 .= " fSourceName like '%Off%'";
125 }
126
127 foreach ($checkwhere as $key => $element)
128 {
129 if (empty($element) || $element<=0)
130 continue;
131
132 if (strpos($query0, " WHERE ")==FALSE)
133 $query0 .= " WHERE ";
134 else
135 if ($element!=-1)
136 if (strrpos($query0, " AND ")!=strlen($query0)-5)
137 $query0 .= " AND ";
138
139 if ($element!=-1)
140 $query0 .= GetCheck($fromtable, $key) . "=" . $element;
141 }
142
143 if (strpos($query0, " WHERE ")==FALSE)
144 $query0 .= " WHERE ";
145 else
146 $query0 .= " AND ";
147
148 $query0 .= StatusQuery("fSequenceFileWritten", $needs, $timelimits);
149 $query0 .= StatusQuery("fAllFilesAvail", $needs, $timelimits);
150 $query0 .= StatusQuery("fCallisto", $needs, $timelimits);
151 $query0 .= StatusQuery("fFillCallisto", $needs, $timelimits);
152 $query0 .= StatusQuery("fStar", $needs, $timelimits);
153 $query0 .= StatusQuery("fFillStar", $needs, $timelimits);
154
155 if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
156 $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
157 else
158 $query0 = substr($query0, 0, -4);
159
160 if ((!empty($_GET["fZDMin"]) || $_GET["fZDMin"]==0) && !empty($_GET["fZDMax"]))
161 $query0 .= "AND (fZenithDistanceMin >= " . $_GET["fZDMin"] . " AND fZenithDistanceMax <= " . $_GET["fZDMax"] . ") ";
162
163 if (!empty($_GET["fSourceN"]))
164 $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
165
166 if (!empty($_GET["fStartDate"]))
167 {
168 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
169 $query0 .= " AND ";
170
171 $startdate=substr($_GET["fStartDate"], 0, 10);
172 if ($startdate=="0000-00-00")
173 $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
174 else
175 $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
176 }
177
178 if (!empty($_GET["fStopDate"]))
179 {
180 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
181 $query0 .= " AND ";
182
183 $stopdate=substr($_GET["fStopDate"], 0, 10);
184 $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
185 }
186
187 if (!empty($_GET["fStarStart"]))
188 {
189 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
190 $query0 .= " AND ";
191
192 $starstart=substr($_GET["fStarStart"], 0, 10);
193 $query0 .=" fStar >= '" . $starstart . " 00:00:00' ";
194 }
195
196 if (!empty($_GET["fStarStop"]))
197 {
198 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
199 $query0 .= " AND ";
200
201 $starstop=substr($_GET["fStarStop"], 0, 10);
202 $query0 .= " fStar < '" . $starstop . " 23:59:59' ";
203 }
204
205 if ($_SESSION["DisplaySelected"]=="inverse")
206 {
207 $displsequ=str_replace(" ", " ", $_SESSION["sequon"].$_SESSION["sequoff"]);
208 $displsequ=ereg_replace("^ ", "(", $displsequ);
209 $displsequ=ereg_replace("$", ")", $displsequ);
210 $displsequ=str_replace(" ", ",", $displsequ);
211
212 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
213 $query0 .= " AND ";
214
215 $query0 .= " fSequenceFirst NOT IN " . $displsequ;
216 }
217
218 if ($groups>0)
219 {
220 $query0 .= " GROUP BY ";
221 $num = $groups;
222 foreach ($checkgroup as $key => $element)
223 if ($element==-1)
224 {
225 $query0 .= GetCheck($fromtable,$key);
226 if ($num-->1)
227 $query0 .= ", ";
228 }
229 }
230
231 if ($statusgroups>0)
232 {
233 $query0 .= " GROUP BY ";
234 $num = $statusgroups;
235 foreach ($checkstatusgroup as $key => $element)
236 if ($element==-1)
237 {
238 $query0 .= $alias[$key];
239 if ($num-->1)
240 $query0 .= ", ";
241 }
242 }
243
244 }
245 else
246 {
247 if (empty($_SESSION["DataSetSelection"]) || $_SESSION["DataSetAcknowledged"]=="yes")
248 {
249 $displsequ=str_replace(" ", " ", $_SESSION["sequon"].$_SESSION["sequoff"]);
250 $displsequ=ereg_replace("^ ", "(", $displsequ);
251 $displsequ=ereg_replace("$", ")", $displsequ);
252 $displsequ=str_replace(" ", ",", $displsequ);
253 }
254 else
255 {
256 //get on sequences
257 $query1 = "SELECT fSequenceFirst FROM DataSetSequenceMapping WHERE fOnOff=1 AND fDataSetNumber=".$_SESSION["SelectedDataSet"];
258 $result1 = mysql_query($query1, $db_id);
259 while ($row = mysql_fetch_assoc($result1))
260 {
261 $_SESSION["DSSeq".$row["fSequenceFirst"]]="ON";
262 $onseq.=" " . $row["fSequenceFirst"];
263 }
264 mysql_free_result($result1);
265 //get off sequences
266 $query1 = "SELECT fSequenceFirst FROM DataSetSequenceMapping WHERE fOnOff=2 AND fDataSetNumber=".$_SESSION["SelectedDataSet"];
267 $result1 = mysql_query($query1, $db_id);
268 while ($row = mysql_fetch_assoc($result1))
269 {
270 $_SESSION["DSSeq".$row["fSequenceFirst"]]="Off";
271 $offseq.=" " . $row["fSequenceFirst"];
272 }
273 mysql_free_result($result1);
274
275 $displsequ=str_replace(" ", " ", $onseq.$offseq);
276 $displsequ=ereg_replace("^ ", "(", $displsequ);
277 $displsequ=ereg_replace("$", ")", $displsequ);
278 $displsequ=str_replace(" ", ",", $displsequ);
279
280 if ($_SESSION["DataSetSelection"]=="UpdateDataSet")
281 {
282 //get values of old data set from db
283 $queryold = "SELECT fUserKEY, fComment, fDataSetName FROM DataSets WHERE fDataSetNumber=".$_SESSION["SelectedDataSet"];
284 $resultold = mysql_query($queryold);
285 $rowold = mysql_fetch_assoc($resultold);
286 $_SESSION["olduser"] = $rowold["fUserKEY"];
287 $_SESSION["comment"] = $rowold["fComment"];
288 $_SESSION["name"] = $rowold["fDataSetName"];
289 mysql_free_result($resultold);
290 }
291 $_SESSION["DisplaySelected"]="yes";
292 }
293
294 $query0 .= "WHERE fSequenceFirst IN " . $displsequ;
295 }
296
297 if (!empty($_GET["fSortBy"]))
298 {
299 $val=substr($_GET["fSortBy"], 0, -1);
300 $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
301 if (substr($_GET["fSortBy"], -1)=="-")
302 $query0 .= "DESC";
303 }
304
305 if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
306 $query0 .= " ORDER BY Sequences.fSequenceFirst DESC ";
307
308 if (empty($_GET["fNumStart"]))
309 $start=0;
310 else
311 $start=$_GET["fNumStart"];
312
313 if (empty($_GET["fSendTxt"]))
314 $query0 .= " LIMIT " . $start . ", " . $_GET["fNumResults"];
315
316 return $query0;
317 }
318
319 function PrintForm($host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias)
320 {
321 printf("<center>\n");
322 printf("<form action='builddatasets.php' METHOD='GET'>\n");
323 printf("<input id='sh' type='hidden' name='fShowHide' value='");
324 if (!empty($_GET["fShowHide"]))
325 printf("%s", $_GET["fShowHide"]);
326 else
327 printf("1000000010");//display Ranges
328 printf("'>\n");
329 printf("<img id='allbutton' src='minus.png' alt='-' onclick='showhide(\"all\")'> <b>Menu</b>&nbsp;&nbsp;&nbsp;&nbsp;\n");
330 printf("&nbsp;&nbsp;<img id='infobutton' src='plus.png' alt='+' onClick='showhide(\"info\");showhide(\"info2\")'> SequInfo \n");
331 printf("&nbsp;&nbsp;<img id='statbutton' src='plus.png' alt='+' onClick='showhide(\"stat\");showhide(\"fail\")'> StatusInfo \n");
332 printf("&nbsp;&nbsp;<img id='calbutton' src='plus.png' alt='+' onClick='showhide(\"cal\")'> CalInfo \n");
333 printf("&nbsp;&nbsp;<img id='starbutton' src='plus.png' alt='+' onClick='showhide(\"star\")'> StarInfo \n");
334 printf("&nbsp;&nbsp;<img id='limitsbutton' src='plus.png' alt='+' onClick='showhide(\"limits\")'> Limits \n");
335 printf("&nbsp;&nbsp;<img id='rangesbutton' src='plus.png' alt='+' onClick='showhide(\"ranges\")'> Ranges \n");
336
337 printf(" <div id='all' style='display:block'>");
338
339 PrintSequInfo2Menu($host,$user,$pw,$db);
340 PrintSequInfoMenu();
341 PrintSequStatMenu();
342 PrintFailMenu();
343 PrintCalMenu();
344 PrintStarMenu();
345 PrintLimitsMenu($limitsmean, $limitsmin, $limitsmax, $alias, "");
346
347 printf(" <div id='ranges' style='display:none'>");
348 PrintZdRangeMenu($host,$user,$pw,$db);
349 PrintSequRangeMenu($host,$user,$pw,$db);
350 printf("<p>");
351 PrintSourceMenu($host,$user,$pw,$db);
352 PrintNightRangeMenu($host,$user,$pw,$db, "Sequences");
353 PrintStarRangeMenu($host,$user,$pw,$db);
354 printf("<p>");
355 printf("</div>");
356
357 printf("</div>");
358 printf(" <P>\n");
359
360 PrintNumResPullDown();
361
362 ini_set("mysql.trace_mode", "Off");
363 ini_set("display_errors", "Off");
364
365 PrintButtons("builddatasets.php");
366
367// printf("</form>\n");
368 printf("</center>\n");
369 printf("</td>\n");
370 printf("</tr>\n");
371 printf("<tr class='Block'>\n");
372 printf("<td>\n");
373 }
374
375 function InsertUpdateDataSet($values, $dataset)
376 {
377 if ($_SESSION["DataSetSelection"]=="UpdateDataSet")
378 $insquery[0]="UPDATE DataSets SET ";
379 else
380 $insquery[0]="INSERT DataSets SET fDataSetNumber=" . $dataset . ", fUserKEY=" . $_SESSION["user"] . ", ";
381 $insquery[0].=" fComment='" . $_SESSION["comment"] . "', fObservationModeKEY=" . $_SESSION["obsmode"];
382 $insquery[0].=", fDataSetName='" . $_SESSION["name"] . "', fSourceKEY= " . $_SESSION["realsourcekey"];
383 $insquery[0].=", fRunStart='" . $values["Min(fRunStart)"]["on"];
384 $insquery[0].="', fRunStop='" . $values["Max(fRunStop)"]["on"];
385 $insquery[0].="', fZenithDistanceMin=" . $values["Min(fZenithDistanceMin)"]["on"];
386 $insquery[0].=", fZenithDistanceMax=" . $values["Max(fZenithDistanceMax)"]["on"];
387 $insquery[0].=", fRunTime=" . $_SESSION["runtime"];
388 if ($_SESSION["DataSetSelection"]=="UpdateDataSet")
389 {
390 $insquery[0].=" WHERE fDataSetNumber=" . $_SESSION["SelectedDataSet"];
391
392 $insquery[1]="UPDATE DataSetProcessStatus SET fDataSetInserted=Now(), fDataSetFileWritten=NULL, ";
393 $insquery[1].=" fStarFilesAvail=NULL, fGanymed=NULL, fFillGanymed=NULL, fWebGanymed=NULL, ";
394 $insquery[1].=" fWebPlotDBGanymed=NULL, fStartTime=NULL, fFailedTime=NULL, fProgramId=NULL, ";
395 $insquery[1].=" fReturnCode=NULL WHERE fDataSetNumber=" . $_SESSION["SelectedDataSet"];
396
397 $insquery[2]=" DELETE FROM DataSetSequenceMapping WHERE fDataSetNumber=" . $_SESSION["SelectedDataSet"];
398 $i=3;
399 }
400 else
401 {
402 $insquery[1]="INSERT DataSetProcessStatus SET fDataSetNumber=" . $dataset . ", fDataSetInserted=Now()";
403 $i=2;
404 }
405 foreach(explode(" ", trim($_SESSION["sequon"])) as $key => $sequ)
406 {
407 $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=";
408 if ($_SESSION["DataSetSelection"]=="UpdateDataSet")
409 $insquery[$i].=$_SESSION["SelectedDataSet"];
410 else
411 $insquery[$i].=$dataset;
412 $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=1";
413 $i=$i+1;
414 }
415 if (!empty($off))
416 {
417 foreach(explode(" ", trim($_SESSION["sequoff"])) as $key => $sequ)
418 {
419 $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=";
420 if ($_SESSION["DataSetSelection"]=="UpdateDataSet")
421 $insquery[$i].=$_SESSION["SelectedDataSet"];
422 else
423 $insquery[$i].=$dataset;
424 $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=2";
425 $i=$i+1;
426 }
427 }
428 // insert
429 if (!empty($_SESSION["insert"]) && $numerr==0)
430 {
431 printf("<br><br>\n");
432 foreach($insquery as $num => $q)
433 {
434 printf("Executed Query #%s: %s<br>\n", $num, $q);
435 $insresult=mysql_query($q);
436 if (mysql_errno()>0)
437 printf("&nbsp; Errorno: %s <br>\n", mysql_errno());
438 if (mysql_error()!="")
439 printf("&nbsp; Errormsg: %s <br>\n", mysql_error());
440 if (mysql_info()!="")
441 printf("&nbsp; Info: %s <br>\n", mysql_info());
442 printf("&nbsp; Affected Rows: %s <br><br>\n", mysql_affected_rows());
443 mysql_free_result($insresult);
444 if (mysql_errno()>0)
445 {
446 printf("ERROR => stop inserting. <br><br>\n");
447 break;
448 }
449 }
450 // reset after insert
451 unset($_SESSION["insert"]);
452// unset($_SESSION["name"]);
453// unset($_SESSION["comment"]);
454 }
455 else
456 if ($_SESSION["DataSetSelection"]=="UpdateDataSet")
457 printf("<input type='button' value='Update Data Set in DB' onClick='self.location.href=\"%s&insert=yes\"'>&nbsp;&nbsp;&nbsp;\n", GetClearedURL());
458 else
459 printf("<input type='button' value='Insert Data Set in DB' onClick='self.location.href=\"%s&insert=yes\"'>&nbsp;&nbsp;&nbsp;\n", GetClearedURL());
460 }
461
462 function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs)
463 {
464 $db_id = mysql_pconnect($host, $user, $pw);
465 if ($db_id==FALSE)
466 {
467 printf("mysql_connect returned the following error: %s\n", mysql_error());
468 die("");
469 }
470 mysql_select_db($db);
471
472 $query0 = CreateQuery($alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $db_id);
473
474 $result0 = mysql_query($query0, $db_id);
475 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
476
477 if ($result0)
478 {
479 if ($html=="1" || $html=="2")
480 {
481 PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, "yes");
482
483 if (!(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"]))
484 && (empty($_SESSION["olduser"]) || $_SESSION["olduser"]==$_SESSION["user"]))
485 {
486 printf("<div align='left'>\n");
487 printf("Remark: To store your selection, you have to press 'Update Selection'<br> \n");
488 printf("<br>\n");
489
490 printf("<u>Your Data Set:</u> <br>\n");
491
492 $on=str_replace(" ", ",", trim($_SESSION["sequon"]));
493 $off=str_replace(" ", ",", trim($_SESSION["sequoff"]));
494
495 //set observation mode
496 if ($_SESSION["sequoff"]=="")
497 $obsmode="Wobble";
498 else
499 $obsmode="On";
500
501 //get key from db for insert query
502 $query = "SELECT fObservationModeKEY FROM ObservationMode WHERE fObservationModeName='".$obsmode."'";
503 $result = mysql_query($query);
504 $row = mysql_fetch_assoc($result);
505 $_SESSION["obsmode"] = $row["fObservationModeKEY"];
506 mysql_free_result($result);
507
508 $values=array("Sum(fRunTime)/60" => $runtime,
509 "Min(fRunTime)/60" => $runtimemin,
510 "Max(fUnsuitableInner)" => $unsuitablemax,
511 "Max(fUnreliableInner)" => $unreliablemax,
512 "Max(fIsolatedInner)" => $isolatedmax,
513 "Max(fIsolatedMaxCluster)" => $imcmax,
514 "Max(fArrTimeMeanInner)" => $arrtimemax,
515 "Min(fArrTimeMeanInner)" => $arrtimemin,
516 "Max(fArrTimeRmsInner)" => $arrtimermsmax,
517 "Avg(fMeanPedRmsInner)" => $pedrmsmean,
518 "Std(fMeanPedRmsInner)" => $pedrmsrms,
519 "Min(fMeanPedRmsInner)" => $pedrmsmin,
520 "Max(fMeanPedRmsInner)" => $pedrmsmax,
521 "Min(fPulsePosMean)" => $pulseposmin,
522 "Max(fPulsePosMean)" => $pulseposmax,
523 "Max(fPulsePosRms)" => $pulseposrmsmax,
524 "Max(fMaxHumidity)" => $hummax,
525 "Max(fInhomogeneity)" => $inhommax,
526 "Avg(fInhomogeneity)" => $inhommean,
527 "Std(fInhomogeneity)" => $inhomrms,
528 "Min(fMeanNumberIslands)" => $numislmin,
529 "Max(fMeanNumberIslands)" => $numislmax,
530 "Avg(fDataRate)" => $clratemean,
531 "Min(fDataRate)" => $clratemin,
532 "Max(fDataRate)" => $clratemax,
533 "Min(fMuonRate)" => $muonratemin,
534 "Max(fMuonRate)" => $muonratemax,
535 "Min(fMuonNumber)" => $muonnumbermin,
536 "Avg(fPSF)" => $psfmean,
537 "Std(fPSF)" => $psfrms,
538 "Min(fPSF)" => $psfmin,
539 "Max(fPSF)" => $psfmax,
540 "Min(fEffOnTime/fRunTime)" => $relontimemin,
541 "Max(fEffOnTime/fRunTime)" => $relontimemax,
542 "Min(fBrightnessMed)" => $brightmin,
543 "Max(fBrightnessMed)" => $brightmax,
544 "Min(fNumStarsMed)" => $idstarsmin,
545 "Max(fNumStarsMed)" => $idstarsmax,
546 "Min(fNumStarsCorMed)" => $corstarsmin,
547 "Max(fNumStarsCorMed)" => $corstarsmax,
548 "Min(fZenithDistanceMin)" => $zdmin,
549 "Max(fZenithDistanceMax)" => $zdmax,
550 "Min(fRunStart)" => $starttime,
551 "Max(fRunStop)" => $stoptime,
552 );
553 //get runtimes of dataset
554 function GetSequenceValues($db_id, $sequences, $txt, &$values)
555 {
556 $query="SELECT COUNT(*) ";
557 foreach($values as $name => $varname)
558 $query.=", " . $name;
559 $query.=" FROM Sequences ";
560 $query.=" LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) ";
561 $query.=" LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) ";
562 $query.=" WHERE Sequences.fSequenceFirst IN (" . $sequences . ")";
563 $result = mysql_query($query, $db_id);
564 $row = mysql_fetch_assoc($result);
565 foreach($values as $name => $varname)
566 $values[$name][$txt]=$row[$name];
567 mysql_free_result($result);
568 }
569
570 //get next dataset#
571 $query="SELECT fDataSetNumber+1 FROM DataSets ORDER BY fDataSetNumber DESC LIMIT 0,1";
572 $result = mysql_query($query, $db_id);
573 $row = mysql_fetch_assoc($result);
574 $dataset=$row["fDataSetNumber+1"];
575 if (empty($dataset))
576 $dataset=1;
577 mysql_free_result($result);
578
579 //get sourcenames
580 function GetSources($db_id, $sequences)
581 {
582 $query="SELECT fSourceName FROM Source LEFT JOIN Sequences USING(fSourceKEY) ";
583 $query.="WHERE fSequenceFirst IN (" . $sequences . ") GROUP BY fSourceName";
584 $result = mysql_query($query, $db_id);
585 while ($row = mysql_fetch_assoc($result))
586 $sources.=" " . $row["fSourceName"];
587 mysql_free_result($result);
588 return $sources;
589 }
590 $sourceson=GetSources($db_id, $on);
591 $sourcesoff=GetSources($db_id, $off);
592
593 //get sourcename for dataset
594 $son=str_replace(" ", "','", trim($sourceson));
595 $query="SELECT fRealSourceKEY, Count(*), fSourceName FROM Source where fSourceName IN ('" . $son . "') GROUP BY fRealSourceKEY";
596 $result = mysql_query($query, $db_id);
597 $row = mysql_fetch_assoc($result);
598 $numsources=$row["Count(*)"];
599 $numrealkeys=mysql_num_rows($result);
600 $_SESSION["realsourcekey"]=$row["fRealSourceKEY"];
601 $_SESSION["realsourcename"]=$row["fSourceName"];
602 mysql_free_result($result);
603 //printf("found %s sources with real sourcekey %s", $numsources, $realsourcekey);
604 //printf("found %s keys", $numrealkeys);
605
606 //check observationmode for on-sequences
607 $query="SELECT fObservationModeKEY FROM Sequences where fSequenceFirst IN (" . $on . ") GROUP BY fObservationModeKEY";
608 $result = mysql_query($query, $db_id);
609 $row = mysql_fetch_assoc($result);
610 $obskey=$row["fObservationModeKEY"];
611 $numobskeys=mysql_num_rows($result);
612 mysql_free_result($result);
613
614 //check dt for on-sequences
615 $query="SELECT fDiscriminatorThresholdTableKEY FROM Sequences where fSequenceFirst IN (" . $on . ") GROUP BY fDiscriminatorThresholdTableKEY";
616 $result = mysql_query($query, $db_id);
617 $numdtkeys=mysql_num_rows($result);
618 mysql_free_result($result);
619
620
621 //set limit
622 $runtimelimit=5;
623 $unsuitablemaxlimit=15;
624 $isolatedlimit=0;
625 $imclimit=0;
626 $pedrmsrms=0.09;
627 $scalelimit=1.3;
628 $inhomlimit=13;
629 $numstarslimit=20;
630 $numstarscorlimit=10;
631
632
633 //check values for infos, warnings and errors
634 $numerr=0;
635 if (!empty($on))
636 {
637 $color=array("INFO" => "#000000",
638 "WARN" => "#FF9900",
639 "ERROR" => "#FF0000");
640 printf("<div align='left'><font><ul>\n");
641 $vals=array("on", "off");
642 foreach($vals as $num => $val)
643 {
644 if (empty(${$val}))
645 continue;
646 //get information from the database
647 GetSequenceValues($db_id, ${$val}, $val, $values);
648
649 if ($values["Min(fNumStarsCorMed)"][$val]<$numstarscorlimit)
650 printf("<li style='color:%s'>%s: At least one of your %s-sequences has less than %s correlated stars (%s). </li>\n",
651 $color["WARN"], "WARN", $val, $numstarscorlimit, $values["Min(fNumStarsCorMed)"][$val]);
652 if ($values["Min(fNumStarsMed)"][$val]<$numstarslimit)
653 printf("<li style='color:%s'>%s: At least one of your %s-sequences has less than %s identified stars (%s). </li>\n",
654 $color["WARN"], "WARN", $val, $numstarslimit, $values["Min(fNumStarsMed)"][$val]);
655 if ($values["Min(fRunTime)/60"][$val]<$runtimelimit)
656 printf("<li style='color:%s'>%s: At least one of your %s-sequences is shorter than %s min (%s min). </li>\n",
657 $color["INFO"], "INFO", $val, $runtimelimit, $values["Min(fRunTime)/60"][$val]);
658 if ($values["Max(fInhomogeneity)"][$val]>$inhomlimit)
659 printf("<li style='color:%s'>%s: At least one of your %s-sequences has an inhomogeneity larger than %s (%s). </li>\n",
660 $color["WARN"], "WARN", $val, $inhomlimit, $values["Max(fInhomogeneity)"][$val]);
661 if ($values["Max(fUnsuitableInner)"][$val]>$unsuitablemaxlimit)
662 printf("<li style='color:%s'>%s: At least one of your %s-sequences has more than %s unsuitable inner pixel (%s). </li>\n",
663 $color["WARN"], "WARN", $val, $unsuitablemaxlimit, $values["Max(fUnsuitableInner)"][$val]);
664 if ($values["Max(fIsolatedInner)"][$val]>$isolatedlimit)
665 printf("<li style='color:%s'>%s: At least one of your %s-sequences has more than %s isolated inner pixel (%s). </li>\n",
666 $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]);
667 if ($values["Max(fIsolatedMaxCluster)"][$val]>$imclimit)
668 printf("<li style='color:%s'>%s: At least one of your %s-sequences has more than %s isolated max cluster (%s). </li>\n",
669 $color["WARN"], "WARN", $val, $imclimit, $values["Max(fIsolatedMaxCluster)"][$val]);
670 }
671 //check selected dataset for errors
672 if (!empty($on) && $values["Max(fMeanPedRmsInner)"]["on"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
673 printf("<li style='color:%s'>%s: At least one of your on-sequences has a PedRms larger than %s (%s).</li>\n",
674 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["on"]);
675 if (!empty($off) && $values["Max(fMeanPedRmsInner)"]["off"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
676 printf("<li style='color:%s'>%s: At least one of your off-sequences has a PedRms larger than %s (%s). </li>\n",
677 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["off"]);
678 if (!empty($off) && $values["Min(fMeanPedRmsInner)"]["off"]<$values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms)
679 printf("<li style='color:%s'>%s: At least one of your off-sequences has a PedRms smaller than %s (%s). </li>\n",
680 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms, $values["Min(fMeanPedRmsInner)"]["off"]);
681 $scale=$values["Sum(fRunTime)/60"]["on"]/$values["Sum(fRunTime)/60"]["off"];
682 if ($scale > $scalelimit)
683 printf("<li style='color:%s'>%s: Your scale factor is larger than %s (%0.2f). Try to find more offdata! </li>\n",
684 $color["WARN"], "WARN", $scalelimit, $scale);
685 $doubleseq=0;
686 foreach(explode(" ", $_SESSION["sequon"]) as $n => $s)
687 {
688 if (ereg($s, $_SESSION["sequoff"]))
689 $doubleseq++;
690 }
691 if ($obskey!=$_SESSION["obsmode"])
692 {
693 printf("<li style='color:%s'>%s: You have a mistake in your observation mode. </li>\n",
694 $color["ERROR"], "ERROR");
695 $numerr=$numerr+1;
696 }
697 if ($doubleseq>0)
698 {
699 printf("<li style='color:%s'>%s: You have selected sequences (%s) as On AND Off. </li>\n",
700 $color["ERROR"], "ERROR", $doubleseq);
701 $numerr=$numerr+1;
702 }
703 if ($numrealkeys>1)
704 {
705 printf("<li style='color:%s'>%s: You have selected more than one (%s) on source. </li>\n",
706 $color["ERROR"], "ERROR", $numrealkeys);
707 $numerr=$numerr+1;
708 }
709 if ($numobskeys>1)
710 {
711 printf("<li style='color:%s'>%s: You have selected more than one (%s) different observation modes in your on sequences. </li>\n",
712 $color["ERROR"], "WARN", $numobskeys);
713 //$numerr=$numerr+1;
714 }
715 if ($numdtkeys>1)
716 {
717 printf("<li style='color:%s'>%s: Your selected on sequences have more than one (%s) different discriminator threshold tables. </li>\n",
718 $color["ERROR"], "WARN", $numdtkeys);
719 }
720 if (empty($_SESSION["realsourcekey"]))
721 {
722 printf("<li style='color:%s'>%s: The source you selected does not have a real sourcekey, yet. Please insert fRealSourceKEY in the DB for %s (contact: datacenter@astro.uni-wuerzburg.de). </li>\n",
723 $color["ERROR"], "ERROR", $sourceson);
724 $numerr=$numerr+1;
725 }
726 if (empty($_SESSION["name"]))
727 {
728 printf("<li style='color:%s'>%s: You have to choose a name. </li>\n",
729 $color["ERROR"], "ERROR");
730 $numerr=$numerr+1;
731 }
732 if (empty($_SESSION["comment"]))
733 {
734 printf("<li style='color:%s'>%s: You have to comment your data set. </li>\n",
735 $color["ERROR"], "ERROR");
736 $numerr=$numerr+1;
737 }
738 printf("</ul></font>\n");
739 printf("</div>");
740
741 //set runtime in session (has to be after calling GetSequenceValues())
742 $_SESSION["runtime"] = $values["Sum(fRunTime)/60"]["on"];
743 $_SESSION["zdmin"] = $values["Min(fZenithDistanceMin)"]["on"];
744 $_SESSION["zdmax"] = $values["Max(fZenithDistanceMax)"]["on"];
745 $_SESSION["meanrate"] = $values["Avg(fDataRate)"]["on"];
746 $_SESSION["psfmean"] = $values["Avg(fPSF)"]["on"];
747 $_SESSION["psfmin"] = $values["Min(fPSF)"]["on"];
748 $_SESSION["psfmax"] = $values["Max(fPSF)"]["on"];
749
750 printf("SequencesOn: %s<br>\n", $_SESSION["sequon"]);
751 if ($_SESSION["sequoff"]!="")
752 printf("SequencesOff: %s<br>\n", $_SESSION["sequoff"]);
753
754 printf("Observation mode: %s <br>\n", $obsmode);
755 printf("RunTime: %s min <br>\n", $_SESSION["runtime"]);
756 printf("Mean Rate after cleaning: %s Hz <br>\n", $_SESSION["meanrate"]);
757 printf("Zd: %s - %s deg <br>\n", $_SESSION["zdmin"], $_SESSION["zdmax"]);
758 printf("PSF: %s (%s - %s) mm <br>\n", $_SESSION["psfmean"], $_SESSION["psfmin"], $_SESSION["psfmax"]);
759
760 //user name
761 printf("User name: %s <br><br>\n", $_SERVER['PHP_AUTH_USER']);
762
763 // data set name and comment: to be inserted by the user
764 printf("Data set number: &nbsp;<input name='AnalysisNumber' type='text' size='8' maxlength='8' value='%s'> (only used for data set file) <br>\n", $_SESSION["AnalysisNumber"]);
765 printf("Data set name: &nbsp;<input name='name' type='text' size='20' maxlength='20' value='%s'><br>\n", $_SESSION["name"]);
766 printf("Comment: &nbsp;<input name='comment' type='text' size='50' maxlength='255' value='%s'><br><br>\n", $_SESSION["comment"]);
767
768
769 //PrintUpdateDataSetButton() has to be called before InsertUpdateDataSet()
770 // to ensure that there are no problem with insert and $_SESSION["insert"]
771
772 //allow 'insert/get dataset' in case no error is found
773 if ($numerr!=0)
774 {
775 printf("Remark: Only data sets without errors can be inserted.<br>");
776 printf("<font color='red'>Your data set has %s error(s).</font><br><br>", $numerr);
777 PrintUpdateDataSetButton();
778 }
779 else
780 {
781 PrintUpdateDataSetButton();
782
783 if ($_SERVER['PHP_AUTH_USER']=="MAGIC")
784 printf("<br><br>\n Remark: As user MAGIC you are not allowed to insert data sets into the database. For an own account, please contact datacenter@astro.uni-wuerzburg.de <br><br>\n");
785 else
786 InsertUpdateDataSet($values, $dataset);
787
788 printf("<input type='button' value='Get Data Set File' onClick='self.location.href=\"%s&fSendTxt=2\"'>&nbsp;&nbsp;&nbsp;\n", GetClearedURL());
789 }
790
791
792 //print table with more information on dataset
793 printf("<br><br><br>\n");
794 printf("<table><tr><td colspan='2'><b>More Information on Your Data Set:<b></td></tr>");
795 printf("<tr><td>Next DataSet# in DB: </td><td>%s</td></tr>", $dataset);
796 printf("<tr><td>DataSet# for data set file: </td><td>%s</td></tr>", empty($_SESSION["AnalysisNumber"])?"1":$_SESSION["AnalysisNumber"]);
797 printf("<tr><td valign='top'>SequencesOn:</td><td> %s</td></tr>", $_SESSION["sequon"]);
798 if ($_SESSION["sequoff"]!="")
799 {
800 printf("<tr><td valign='top'>SequencesOff:</td><td> %s</td></tr>", $_SESSION["sequoff"]);
801 printf("<tr><td>Scale factor (On/Off): </td><td>%0.2f</td></tr>", $scale);
802 }
803 printf("<tr><td>SourcenamesOn [%s]: </td><td>%s</td></tr>", str_word_count($sourceson, 0, "1234567890+"), $sourceson);
804 if ($_SESSION["sequoff"]!="")
805 printf("<tr><td>SourcenamesOff [%s]: </td><td>%s</td></tr>", str_word_count($sourcesoff, 0, "1234567890+"), $sourcesoff);
806 printf("</table>\n");
807
808 printf("<table border='1'>\n");
809 printf("<tr><td>Value</td><td>On</td>");
810 if (!empty($off))
811 printf("<td>Off</td></tr>\n");
812 foreach($values as $name => $varname)
813 {
814 printf("<tr><td>%s</td>\n", $name);
815 foreach($vals as $num => $val)
816 if (!empty(${$val}))
817 printf("<td>%s</td>\n", $varname[$val]);
818 printf("</tr>\n");
819 }
820 printf("</table>\n");
821 }
822 }
823 else
824 {
825 if ($_SESSION["user"]!=$_SESSION["olduser"] && !empty($_SESSION["olduser"]))
826 printf("Remark: You (userkey %s) are not allowed to change data set # %d (created by userkey %s).<br> \n",
827 $_SESSION["user"], $_SESSION["SelectedDataSet"], $_SESSION["olduser"]);
828 else
829 {
830 printf("<input type='submit' value='Store Selection'><br><br>\n");
831 printf("Remark: To store your selection for the data set, you have to press 'Store Selection'<br> \n");
832 }
833
834 }
835
836 printf("</div>\n");
837 printf("</td>\n");
838 printf("</tr>\n");
839
840 printf("</form>\n");
841 }
842 else
843 PrintText($result0);
844
845 mysql_free_result($result0);
846 mysql_free_result($result1);
847 }
848 mysql_close($db_id);
849
850 if ($html=="1")
851 PrintSubmittedQuery($query0, $db, "");
852 }
853
854 include ("include.php");
855 include ("menu.php");
856 include ("db.php");
857 include ("magicdefs.php");
858
859// $debug="yes";
860 session_start();
861 if ($debug)
862 {
863 echo "GET: ";
864 print_r($_GET);
865 echo " <br>";
866
867 echo "POST: ";
868 print_r($_POST);
869 echo " <br>";
870 }
871
872 // set values given by $_GET
873 foreach ($_GET as $element => $value)
874 $_SESSION[$element]=$value;
875
876 // unset values in case of 'Reset'
877 if (empty($_GET))
878 foreach($_SESSION as $element => $value)
879 unset($_SESSION[$element]);
880
881 // set values given by $_POST
882 if (!empty($_POST))
883 foreach ($_POST as $element => $value)
884 $_SESSION[$element]=$value;
885 else
886 unset($_SESSION["SelectAllSequForDS"]);
887
888 if ($debug)
889 print_r($_SESSION);
890 /*
891 if ($_SESSION["DisplaySelected"]=="yes")
892 {
893 unset($_SESSION["fNumStart"]);
894 $_GET["fNumStart"]=0;
895 }
896 */
897 $_SESSION["sequon"]="";
898 $_SESSION["sequoff"]="";
899 foreach($_SESSION as $key => $val)
900 {
901 if ($val=="ON" && ereg("^DSSeq[0-9]*$", $key))
902 $_SESSION["sequon"].=str_replace("DSSeq", " ", $key);
903
904 if ($val=="Off" && ereg("^DSSeq[0-9]*$", $key))
905 $_SESSION["sequoff"].=str_replace("DSSeq", " ", $key);
906
907 if ($val=="Not" && ereg("^DSSeq[0-9]*$", $key))
908 unset($_SESSION[$key]);
909 }
910 if (empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"]))
911 unset($_SESSION["DisplaySelected"]);
912
913 ini_set("display_errors", "On");
914 ini_set("mysql.trace_mode", "On");
915
916 if (!isset($_SERVER['PHP_AUTH_USER']))
917 {
918 header('WWW-Authenticate: Basic realm="Build Datasets"');
919 header('HTTP/1.0 401 Unauthorized');
920 return;
921 }
922 else
923 {
924 $db_id = mysql_connect($host, $user, $pw);
925 if ($db_id==FALSE)
926 {
927 printf("mysql_connect returned the following error:<br>");
928 printf("%s<br>", mysql_error());
929 die("");
930 }
931
932 $userquery = "SELECT fUserName, fPassword, fUserKEY FROM " . $db . ".User ORDER BY fUserKEY";
933 $userresult = mysql_query($userquery);
934 if (!$userresult)
935 echo "query failed";
936 $validuser="no";
937 while ($userrow = mysql_fetch_assoc($userresult))
938 {
939// echo crypt($_SERVER['PHP_AUTH_PW']). "<br>";
940// echo "with crypt: " . crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"]) . " for user " . $userrow["fUserName"]. "<br>";
941 if (crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"])==$userrow["fPassword"]
942 && $_SERVER['PHP_AUTH_USER']==$userrow["fUserName"])
943 {
944 $validuser="yes";
945 $_SESSION["user"]=$userrow["fUserKEY"];
946 }
947 }
948 mysql_free_result($userresult);
949 if ($validuser=="no")
950 {
951 printf("<br>Password or username incorrect<br>");
952 return;
953 }
954 }
955
956 if (!empty($_GET["fSendTxt"]))
957 {
958 header("Content-Type: application/octet");
959 switch($_GET["fSendTxt"])
960 {
961 case 1:
962 header("Content-Disposition: attachment; filename=query-result.txt");
963 PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
964 break;
965 case 2:
966 header("Content-Disposition: attachment; filename=dataset_".str_replace(" ", "_", $_SESSION["name"]).".txt");
967 PrintDataSetFile();
968 }
969 unset($_SESSION["fSendTxt"]);
970 }
971 else
972 {
973 echo (file_get_contents("index-header.html"));
974
975 $environment = sizeof($_GET);
976
977 // Find out whether it is the first call to the php script
978 $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
979 InitBuildDataSets($first);
980 if (empty($_GET["fPrintTable"]))
981 PrintForm($host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias);
982
983 if ($environment==0)
984 {
985 printf("No query submitted yet.<br><br>\n");
986 printf("Either query above, or you have also the option to start with an already existing data set: <br>\n");
987 printf("Dataset: &nbsp;<input name='SelectedDataSet' type='text' size='8' maxlength='8' value='%s'><br><br>\n", $_SESSION["SelectedDataSet"]);
988 printf("How do you want to process this data set? <br>\n");
989 printf("<input type='radio' name='DataSetSelection' value='SelectSequences' %s>Use data set as starting point.<br>\n",
990 $_SESSION["DataSetSelection"]=="SelectSequences"?"checked":"");
991 printf("<input type='radio' name='DataSetSelection' value='UpdateDataSet' %s>Update data set in database.<br><br>\n",
992 $_SESSION["DataSetSelection"]=="UpdateDataSet"?"checked":"");
993 printf("<input type='submit' value='Query'><br>\n");
994 printf("</form>\n");
995 }
996 else
997 {
998 printf("</form>\n");
999 if (empty($_SESSION["DataSetSelection"]) && !empty($_SESSION["SelectedDataSet"]))
1000 {
1001 printf("Remark: You have inserted a data set number (%s), but not selected what you want to do with it. <br>\n",
1002 $_SESSION["SelectedDataSet"]);
1003 printf("Please press 'Reset'. Then to choose a data set and what you want to do with it or simply 'Query Table' to start a new data set.<br>\n");
1004 }
1005 else
1006 {
1007
1008 if (empty($_GET["fPrintTable"]))
1009 PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
1010 else
1011 PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
1012 }
1013 }
1014
1015 echo (file_get_contents("index-footer.html"));
1016 }
1017
1018 if (!empty($_SESSION["DataSetSelection"]))
1019 $_SESSION["DataSetAcknowledged"]="yes";
1020
1021 ini_set("display_errors", "Off");
1022 ini_set("mysql.trace_mode", "Off");
1023
1024?>
Note: See TracBrowser for help on using the repository browser.