source: trunk/Mars/datacenter/db/builddatasets.php@ 20033

Last change on this file since 20033 was 17386, checked in by tbretz, 11 years ago
Removed svn:executable property, these are no executables.
File size: 50.0 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 //$obskey >1 makes sure that fObservationMode is not N/A (old data)
692 if ($obskey!=$_SESSION["obsmode"] && $obskey>1)
693 {
694 printf("<li style='color:%s'>%s: You have a mistake in your observation mode. </li>\n",
695 $color["ERROR"], "ERROR");
696 $numerr=$numerr+1;
697 }
698 if ($doubleseq>0)
699 {
700 printf("<li style='color:%s'>%s: You have selected sequences (%s) as On AND Off. </li>\n",
701 $color["ERROR"], "ERROR", $doubleseq);
702 $numerr=$numerr+1;
703 }
704 if ($numrealkeys>1)
705 {
706 printf("<li style='color:%s'>%s: You have selected more than one (%s) on source. </li>\n",
707 $color["ERROR"], "ERROR", $numrealkeys);
708 $numerr=$numerr+1;
709 }
710 if ($numobskeys>1)
711 {
712 printf("<li style='color:%s'>%s: You have selected more than one (%s) different observation modes in your on sequences. </li>\n",
713 $color["ERROR"], "WARN", $numobskeys);
714 //$numerr=$numerr+1;
715 }
716 if ($numdtkeys>1)
717 {
718 printf("<li style='color:%s'>%s: Your selected on sequences have more than one (%s) different discriminator threshold tables. </li>\n",
719 $color["ERROR"], "WARN", $numdtkeys);
720 }
721 if (empty($_SESSION["realsourcekey"]))
722 {
723 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",
724 $color["ERROR"], "ERROR", $sourceson);
725 $numerr=$numerr+1;
726 }
727 if (empty($_SESSION["name"]))
728 {
729 printf("<li style='color:%s'>%s: You have to choose a name. </li>\n",
730 $color["ERROR"], "ERROR");
731 $numerr=$numerr+1;
732 }
733 if (empty($_SESSION["comment"]))
734 {
735 printf("<li style='color:%s'>%s: You have to comment your data set. </li>\n",
736 $color["ERROR"], "ERROR");
737 $numerr=$numerr+1;
738 }
739 printf("</ul></font>\n");
740 printf("</div>");
741
742 //set runtime in session (has to be after calling GetSequenceValues())
743 $_SESSION["runtime"] = $values["Sum(fRunTime)/60"]["on"];
744 $_SESSION["zdmin"] = $values["Min(fZenithDistanceMin)"]["on"];
745 $_SESSION["zdmax"] = $values["Max(fZenithDistanceMax)"]["on"];
746 $_SESSION["meanrate"] = $values["Avg(fDataRate)"]["on"];
747 $_SESSION["psfmean"] = $values["Avg(fPSF)"]["on"];
748 $_SESSION["psfmin"] = $values["Min(fPSF)"]["on"];
749 $_SESSION["psfmax"] = $values["Max(fPSF)"]["on"];
750
751 printf("SequencesOn: %s<br>\n", $_SESSION["sequon"]);
752 if ($_SESSION["sequoff"]!="")
753 printf("SequencesOff: %s<br>\n", $_SESSION["sequoff"]);
754
755 printf("Observation mode: %s <br>\n", $obsmode);
756 printf("RunTime: %s min <br>\n", $_SESSION["runtime"]);
757 printf("Mean Rate after cleaning: %s Hz <br>\n", $_SESSION["meanrate"]);
758 printf("Zd: %s - %s deg <br>\n", $_SESSION["zdmin"], $_SESSION["zdmax"]);
759 printf("PSF: %s (%s - %s) mm <br>\n", $_SESSION["psfmean"], $_SESSION["psfmin"], $_SESSION["psfmax"]);
760
761 //user name
762 printf("User name: %s <br><br>\n", $_SERVER['PHP_AUTH_USER']);
763
764 // data set name and comment: to be inserted by the user
765 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"]);
766 printf("Data set name: &nbsp;<input name='name' type='text' size='20' maxlength='20' value='%s'><br>\n", $_SESSION["name"]);
767 printf("Comment: &nbsp;<input name='comment' type='text' size='50' maxlength='255' value='%s'><br><br>\n", $_SESSION["comment"]);
768
769
770 //PrintUpdateDataSetButton() has to be called before InsertUpdateDataSet()
771 // to ensure that there are no problem with insert and $_SESSION["insert"]
772
773 //allow 'insert/get dataset' in case no error is found
774 if ($numerr!=0)
775 {
776 printf("Remark: Only data sets without errors can be inserted.<br>");
777 printf("<font color='red'>Your data set has %s error(s).</font><br><br>", $numerr);
778 PrintUpdateDataSetButton();
779 }
780 else
781 {
782 PrintUpdateDataSetButton();
783
784 if ($_SERVER['PHP_AUTH_USER']=="MAGIC")
785 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");
786 else
787 InsertUpdateDataSet($values, $dataset);
788
789 printf("<input type='button' value='Get Data Set File' onClick='self.location.href=\"%s&fSendTxt=2\"'>&nbsp;&nbsp;&nbsp;\n", GetClearedURL());
790 }
791
792
793 //print table with more information on dataset
794 printf("<br><br><br>\n");
795 printf("<table><tr><td colspan='2'><b>More Information on Your Data Set:<b></td></tr>");
796 printf("<tr><td>Next DataSet# in DB: </td><td>%s</td></tr>", $dataset);
797 printf("<tr><td>DataSet# for data set file: </td><td>%s</td></tr>", empty($_SESSION["AnalysisNumber"])?"1":$_SESSION["AnalysisNumber"]);
798 printf("<tr><td valign='top'>SequencesOn:</td><td> %s</td></tr>", $_SESSION["sequon"]);
799 if ($_SESSION["sequoff"]!="")
800 {
801 printf("<tr><td valign='top'>SequencesOff:</td><td> %s</td></tr>", $_SESSION["sequoff"]);
802 printf("<tr><td>Scale factor (On/Off): </td><td>%0.2f</td></tr>", $scale);
803 }
804 printf("<tr><td>SourcenamesOn [%s]: </td><td>%s</td></tr>", str_word_count($sourceson, 0, "1234567890+"), $sourceson);
805 if ($_SESSION["sequoff"]!="")
806 printf("<tr><td>SourcenamesOff [%s]: </td><td>%s</td></tr>", str_word_count($sourcesoff, 0, "1234567890+"), $sourcesoff);
807 printf("</table>\n");
808
809 printf("<table border='1'>\n");
810 printf("<tr><td>Value</td><td>On</td>");
811 if (!empty($off))
812 printf("<td>Off</td></tr>\n");
813 foreach($values as $name => $varname)
814 {
815 printf("<tr><td>%s</td>\n", $name);
816 foreach($vals as $num => $val)
817 if (!empty(${$val}))
818 printf("<td>%s</td>\n", $varname[$val]);
819 printf("</tr>\n");
820 }
821 printf("</table>\n");
822 }
823 }
824 else
825 {
826 if ($_SESSION["user"]!=$_SESSION["olduser"] && !empty($_SESSION["olduser"]))
827 printf("Remark: You (userkey %s) are not allowed to change data set # %d (created by userkey %s).<br> \n",
828 $_SESSION["user"], $_SESSION["SelectedDataSet"], $_SESSION["olduser"]);
829 else
830 {
831 printf("<input type='submit' value='Store Selection'><br><br>\n");
832 printf("Remark: To store your selection for the data set, you have to press 'Store Selection'<br> \n");
833 }
834
835 }
836
837 printf("</div>\n");
838 printf("</td>\n");
839 printf("</tr>\n");
840
841 printf("</form>\n");
842 }
843 else
844 PrintText($result0);
845
846 mysql_free_result($result0);
847 mysql_free_result($result1);
848 }
849 mysql_close($db_id);
850
851 if ($html=="1")
852 PrintSubmittedQuery($query0, $db, "");
853 }
854
855 include ("include.php");
856 include ("menu.php");
857 include ("db.php");
858 include ("magicdefs.php");
859
860// $debug="yes";
861 session_start();
862 if ($debug)
863 {
864 echo "GET: ";
865 print_r($_GET);
866 echo " <br>";
867
868 echo "POST: ";
869 print_r($_POST);
870 echo " <br>";
871 }
872
873 // set values given by $_GET
874 foreach ($_GET as $element => $value)
875 $_SESSION[$element]=$value;
876
877 // unset values in case of 'Reset'
878 if (empty($_GET))
879 foreach($_SESSION as $element => $value)
880 unset($_SESSION[$element]);
881
882 // set values given by $_POST
883 if (!empty($_POST))
884 foreach ($_POST as $element => $value)
885 $_SESSION[$element]=$value;
886 else
887 unset($_SESSION["SelectAllSequForDS"]);
888
889 if ($debug)
890 print_r($_SESSION);
891 /*
892 if ($_SESSION["DisplaySelected"]=="yes")
893 {
894 unset($_SESSION["fNumStart"]);
895 $_GET["fNumStart"]=0;
896 }
897 */
898 $_SESSION["sequon"]="";
899 $_SESSION["sequoff"]="";
900 foreach($_SESSION as $key => $val)
901 {
902 if ($val=="ON" && ereg("^DSSeq[0-9]*$", $key))
903 $_SESSION["sequon"].=str_replace("DSSeq", " ", $key);
904
905 if ($val=="Off" && ereg("^DSSeq[0-9]*$", $key))
906 $_SESSION["sequoff"].=str_replace("DSSeq", " ", $key);
907
908 if ($val=="Not" && ereg("^DSSeq[0-9]*$", $key))
909 unset($_SESSION[$key]);
910 }
911 if (empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"]))
912 unset($_SESSION["DisplaySelected"]);
913
914 ini_set("display_errors", "On");
915 ini_set("mysql.trace_mode", "On");
916
917 if (!isset($_SERVER['PHP_AUTH_USER']))
918 {
919 header('WWW-Authenticate: Basic realm="Build Datasets"');
920 header('HTTP/1.0 401 Unauthorized');
921 return;
922 }
923 else
924 {
925 $db_id = mysql_connect($host, $user, $pw);
926 if ($db_id==FALSE)
927 {
928 printf("mysql_connect returned the following error:<br>");
929 printf("%s<br>", mysql_error());
930 die("");
931 }
932
933 $userquery = "SELECT fUserName, fPassword, fUserKEY FROM " . $db . ".User ORDER BY fUserKEY";
934 $userresult = mysql_query($userquery);
935 if (!$userresult)
936 echo "query failed";
937 $validuser="no";
938 while ($userrow = mysql_fetch_assoc($userresult))
939 {
940// echo crypt($_SERVER['PHP_AUTH_PW']). "<br>";
941// echo "with crypt: " . crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"]) . " for user " . $userrow["fUserName"]. "<br>";
942 if (crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"])==$userrow["fPassword"]
943 && $_SERVER['PHP_AUTH_USER']==$userrow["fUserName"])
944 {
945 $validuser="yes";
946 $_SESSION["user"]=$userrow["fUserKEY"];
947 }
948 }
949 mysql_free_result($userresult);
950 if ($validuser=="no")
951 {
952 printf("<br>Password or username incorrect<br>");
953 return;
954 }
955 }
956
957 if (!empty($_GET["fSendTxt"]))
958 {
959 header("Content-Type: application/octet");
960 switch($_GET["fSendTxt"])
961 {
962 case 1:
963 header("Content-Disposition: attachment; filename=query-result.txt");
964 PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
965 break;
966 case 2:
967 header("Content-Disposition: attachment; filename=dataset_".str_replace(" ", "_", $_SESSION["name"]).".txt");
968 PrintDataSetFile();
969 }
970 unset($_SESSION["fSendTxt"]);
971 }
972 else
973 {
974 echo (file_get_contents("index-header.html"));
975
976 $environment = sizeof($_GET);
977
978 // Find out whether it is the first call to the php script
979 $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
980 InitBuildDataSets($first);
981 if (empty($_GET["fPrintTable"]))
982 PrintForm($host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias);
983
984 if ($environment==0)
985 {
986 printf("No query submitted yet.<br><br>\n");
987 printf("Either query above, or you have also the option to start with an already existing data set: <br>\n");
988 printf("Dataset: &nbsp;<input name='SelectedDataSet' type='text' size='8' maxlength='8' value='%s'><br><br>\n", $_SESSION["SelectedDataSet"]);
989 printf("How do you want to process this data set? <br>\n");
990 printf("<input type='radio' name='DataSetSelection' value='SelectSequences' %s>Use data set as starting point.<br>\n",
991 $_SESSION["DataSetSelection"]=="SelectSequences"?"checked":"");
992 printf("<input type='radio' name='DataSetSelection' value='UpdateDataSet' %s>Update data set in database.<br><br>\n",
993 $_SESSION["DataSetSelection"]=="UpdateDataSet"?"checked":"");
994 printf("<input type='submit' value='Query'><br>\n");
995 printf("</form>\n");
996 }
997 else
998 {
999 printf("</form>\n");
1000 if (empty($_SESSION["DataSetSelection"]) && !empty($_SESSION["SelectedDataSet"]))
1001 {
1002 printf("Remark: You have inserted a data set number (%s), but not selected what you want to do with it. <br>\n",
1003 $_SESSION["SelectedDataSet"]);
1004 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");
1005 }
1006 else
1007 {
1008
1009 if (empty($_GET["fPrintTable"]))
1010 PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
1011 else
1012 PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
1013 }
1014 }
1015
1016 echo (file_get_contents("index-footer.html"));
1017 }
1018
1019 if (!empty($_SESSION["DataSetSelection"]))
1020 $_SESSION["DataSetAcknowledged"]="yes";
1021
1022 ini_set("display_errors", "Off");
1023 ini_set("mysql.trace_mode", "Off");
1024
1025?>
Note: See TracBrowser for help on using the repository browser.