1 | <?php
|
---|
2 | {
|
---|
3 | function CreateQuery($_GET)
|
---|
4 | {
|
---|
5 | $query0 = "SELECT ";
|
---|
6 | //datasets (0-3)
|
---|
7 | $query0 .= " DataSets.fDataSetNumber, fDataSetName, fComment, ";//0,1,2
|
---|
8 | $query0 .= " fSourceName, fObservationModeName, ";//3, 4
|
---|
9 | //steps (5-8)
|
---|
10 | $query0 .= " fDataSetInserted, fStarFilesAvail, ";//5,6
|
---|
11 | $query0 .= " fGanymed, fFillGanymed, ";//7,8
|
---|
12 | //ganymed (9-14)
|
---|
13 | $query0 .= " fExcessEvents, fBackgroundEvents, fSignalEvents, ";//9,10,11
|
---|
14 | $query0 .= " fSignificance, fScaleFactor, fEffOnTime/3600 ";//12,13, 14
|
---|
15 |
|
---|
16 | $query0 .= " FROM DataSets ";
|
---|
17 |
|
---|
18 | $query0 .= " LEFT JOIN Source ON DataSets.fSourceKEY=Source.fSourceKEY ";
|
---|
19 | $query0 .= " LEFT JOIN ObservationMode ON DataSets.fObservationModeKEY=ObservationMode.fObservationModeKEY ";
|
---|
20 | $query0 .= " LEFT JOIN DataSetProcessStatus ON DataSets.fDataSetNumber=DataSetProcessStatus.fDataSetNumber ";
|
---|
21 | $query0 .= " LEFT JOIN Ganymed ON DataSets.fDataSetNumber=Ganymed.fDataSetNumber ";
|
---|
22 |
|
---|
23 | if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
|
---|
24 | $query0 .= " WHERE DataSets.fDataSetNumber between " . $_GET["fRunMin"] . " and " . $_GET["fRunMax"] ;
|
---|
25 | if (!empty($_GET["fDataSetNo"]))
|
---|
26 | {
|
---|
27 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
28 | $query0 .= " WHERE ";
|
---|
29 | else
|
---|
30 | $query0 .= " AND ";
|
---|
31 | $query0 .= " DataSets.fDataSetNumber='" . $_GET["fDataSetNo"] . "'";
|
---|
32 | }
|
---|
33 | if (!empty($_GET["fSourceN"]))
|
---|
34 | {
|
---|
35 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
36 | $query0 .= " WHERE ";
|
---|
37 | else
|
---|
38 | $query0 .= " AND ";
|
---|
39 | $query0 .= " fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
|
---|
40 | }
|
---|
41 | $query0 .= " ORDER BY DataSets.fDataSetNumber ";
|
---|
42 |
|
---|
43 | return $query0;
|
---|
44 | }
|
---|
45 |
|
---|
46 | function InitGet($_GET)
|
---|
47 | {
|
---|
48 | // Find out whether it is the first call to the php script
|
---|
49 | $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
|
---|
50 |
|
---|
51 | if (empty($_GET["fNumResults"]))
|
---|
52 | $_GET["fNumResults"]="20";
|
---|
53 |
|
---|
54 | if (empty($_GET["fAll"]))
|
---|
55 | $_GET["fAll"]="Off";
|
---|
56 |
|
---|
57 | if (empty($_GET["fSequ"]))
|
---|
58 | $_GET["fSequ"]="Off";
|
---|
59 |
|
---|
60 | }
|
---|
61 |
|
---|
62 | function PrintForm($_GET, $host, $user, $pw, $db)
|
---|
63 | {
|
---|
64 | printf("<center>\n");
|
---|
65 | printf("<form action=\"ganymed.php\" METHOD=\"GET\">\n");
|
---|
66 |
|
---|
67 | printf("DataSet# <input name=\"fDataSetNo\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"");
|
---|
68 | if (!empty($_GET["fDataSetNo"]))
|
---|
69 | printf("%s", $_GET["fDataSetNo"]);
|
---|
70 | printf("\"> \n");
|
---|
71 |
|
---|
72 | if (empty($_GET["fRunMin"]))
|
---|
73 | // $min = "100";
|
---|
74 | $min = GetMin("fDataSetNumber", "DataSets", $host, $user, $pw, $db);
|
---|
75 | else
|
---|
76 | $min = $_GET["fRunMin"];
|
---|
77 |
|
---|
78 | if (empty($_GET["fRunMax"]))
|
---|
79 | $max = GetMax("fDataSetNumber", "DataSets", $host, $user, $pw, $db);
|
---|
80 | else
|
---|
81 | $max = $_GET["fRunMax"];
|
---|
82 |
|
---|
83 | printf("DataSets from <input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
|
---|
84 | printf("to <input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\"> \n", $max);
|
---|
85 |
|
---|
86 | if ($_GET["fAll"]=="On")
|
---|
87 | $checked = "checked";
|
---|
88 | else
|
---|
89 | $checked = "";
|
---|
90 | printf("<input type=\"checkbox\" name=\"fAll\" value=\"On\" %s>plots\n", $checked);
|
---|
91 |
|
---|
92 | if ($_GET["fSequ"]=="On")
|
---|
93 | $checked = "checked";
|
---|
94 | else
|
---|
95 | $checked = "";
|
---|
96 | printf("<input type=\"checkbox\" name=\"fSequ\" value=\"On\" %s>sequences\n", $checked);
|
---|
97 |
|
---|
98 | printf(" <P>\n");
|
---|
99 |
|
---|
100 | printf("Source (<A HREF=\"regexp.html\">regexp</A>) <input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
|
---|
101 | if (!empty($_GET["fSourceN"]))
|
---|
102 | printf("%s", $_GET["fSourceN"]);
|
---|
103 | printf("\"> \n");
|
---|
104 |
|
---|
105 |
|
---|
106 | ini_set("mysql.trace_mode", "Off");
|
---|
107 | ini_set("display_errors", "Off");
|
---|
108 |
|
---|
109 | printf("<input class='Width' type='submit' value='Query Table'> \n");
|
---|
110 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"ganymed.php\"'> \n");
|
---|
111 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
---|
112 | printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
---|
113 | printf("</form>\n");
|
---|
114 | printf("</center>\n");
|
---|
115 | printf("</td>\n");
|
---|
116 | printf("</tr>\n");
|
---|
117 | printf("<tr class='Block'>\n");
|
---|
118 | printf("<td>\n");
|
---|
119 | }
|
---|
120 |
|
---|
121 | function GetStatus($step)
|
---|
122 | {
|
---|
123 | if (is_null($step))
|
---|
124 | return "<font color='#FF0000'>not done</font>";
|
---|
125 | else
|
---|
126 | {
|
---|
127 | if (strpos($step, "1970-01-01 00:00:00")==FALSE)
|
---|
128 | return "done";
|
---|
129 | else
|
---|
130 | return "not to be done";
|
---|
131 | }
|
---|
132 | return "there is an error -> tell Dani";
|
---|
133 | }
|
---|
134 |
|
---|
135 | function GetRanges($db_id, $sequences)
|
---|
136 | {
|
---|
137 | $query="SELECT Min(fZenithDistanceMin), Max(fZenithDistanceMax), Min(fRunStart), Max(fRunStart) FROM Sequences WHERE fSequenceFirst IN (";
|
---|
138 | $sequlist=str_replace(" ", ",", trim($sequences));
|
---|
139 | // printf("sequ-after: %s", $sequlist);
|
---|
140 | $query .= $sequlist . ")";
|
---|
141 | $result = mysql_query($query, $db_id);
|
---|
142 | // printf("query: %s", $query);
|
---|
143 | $zdmin=mysql_result($result, $i, 0);
|
---|
144 | $zdmax=mysql_result($result, $i, 1);
|
---|
145 | $starttime=str_replace("-", "/",substr(mysql_result($result, $i, 2),0,10));
|
---|
146 | $stoptime=str_replace("-", "/",substr(mysql_result($result, $i, 3),0,10));
|
---|
147 | printf("<br> Zd: %s - %s degree <br> Observationperiod: %s - %s ", $zdmin, $zdmax, $starttime, $stoptime);
|
---|
148 | }
|
---|
149 |
|
---|
150 | function PrintDataSetInfo($db_id, $result0, $ganymedtabsw, $ganymedtabs)
|
---|
151 | {
|
---|
152 | $numres = mysql_num_rows($result0);
|
---|
153 |
|
---|
154 | printf("<center>");
|
---|
155 | printf("<table BORDER=\"0\">\n");
|
---|
156 | printf("<tr><td>");
|
---|
157 | printf("# of DataSets: %d ", $numres);
|
---|
158 | printf("</td></tr>");
|
---|
159 |
|
---|
160 | for ($i=0 ; $i<$numres ; $i++)
|
---|
161 | {
|
---|
162 | $datasetno=mysql_result($result0, $i, 0);
|
---|
163 | $datasetname=mysql_result($result0, $i, 1);
|
---|
164 | $comment=mysql_result($result0, $i, 2);
|
---|
165 | $source=mysql_result($result0, $i, 3);
|
---|
166 | $wobble=mysql_result($result0, $i, 4);
|
---|
167 | $inserted=mysql_result($result0, $i, 5);
|
---|
168 | $filesavail=mysql_result($result0, $i, 6);
|
---|
169 | $ganymed=mysql_result($result0, $i, 7);
|
---|
170 | $fillganymed=mysql_result($result0, $i, 8);
|
---|
171 | $excess=mysql_result($result0, $i, 9);
|
---|
172 | $bg=mysql_result($result0, $i, 10);
|
---|
173 | $signal=mysql_result($result0, $i, 11);
|
---|
174 | $signif=mysql_result($result0, $i, 12);
|
---|
175 | $scale=mysql_result($result0, $i, 13);
|
---|
176 | $effontime=mysql_result($result0, $i, 14);
|
---|
177 | $num=sprintf("%08d",$datasetno);
|
---|
178 | $num2=substr($num,0,5);
|
---|
179 | $datasetfile="http://www.astro.uni-wuerzburg.de/datacenter/datasets/" . $num2 . "/dataset" . $num . ".txt";
|
---|
180 |
|
---|
181 | printf("<tr><td>");
|
---|
182 |
|
---|
183 | printf(" <table BORDER=\"1\">");
|
---|
184 | printf(" <tr BGCOLOR='#C0C0C0'>\n");
|
---|
185 | printf(" <th colspan=\"6\"><big>Source: <big>%s </big></big>(DataSet#:", $source, $datasetno);
|
---|
186 | printf(" <a href=\"%s\">%s</a>) </th>", $datasetfile, $datasetno);
|
---|
187 | printf(" </tr><tr BGCOLOR='#E0E0E0' ALIGN='left'>\n");
|
---|
188 | printf(" <th colspan=\"6\"> <b>%s Mode</b>, %s ", $wobble, $comment);
|
---|
189 | printf(" </th></tr><tr>\n");
|
---|
190 |
|
---|
191 | printf(" <td colspan=\"6\"> DatasetName: %s", $datasetname);
|
---|
192 | if (!is_null($ganymed))
|
---|
193 | printf(", <font color='green'> ganymed done</font> ");
|
---|
194 |
|
---|
195 | printf(" <tr>");
|
---|
196 |
|
---|
197 | if (!is_null($fillganymed))
|
---|
198 | {
|
---|
199 | printf("<td colspan=\"6\"></td></tr>\n");
|
---|
200 | printf(" <tr BGCOLOR='#C0C0C0'><th colspan=\"6\">results ");
|
---|
201 | printf(" (<a href=\"http://www.astro.uni-wuerzburg.de/datacenter/ganymed/%s/%s/\">plots</a>)",
|
---|
202 | $num2, $num);
|
---|
203 | printf(" </th></tr><tr BGCOLOR='#E0E0E0'>\n");
|
---|
204 | printf(" <td>excess events</td>\n");
|
---|
205 | printf(" <td>background events</td>\n");
|
---|
206 | printf(" <td>signal events</td>\n");
|
---|
207 | printf(" <td>significance</td>\n");
|
---|
208 | printf(" <td>scale factor</td>\n");
|
---|
209 | printf(" <td>effective ontime</td>\n");
|
---|
210 | printf(" </tr><tr BGCOLOR='#D0D0D0' align='right'>");
|
---|
211 | printf(" <td>%s</td>\n", $excess);
|
---|
212 | printf(" <td>%s</td>\n", $bg);
|
---|
213 | printf(" <td>%s</td>\n", $signal);
|
---|
214 | printf(" <td>%s</td>\n", $signif);
|
---|
215 | printf(" <td>%s</td>\n", $scale);
|
---|
216 | printf(" <td>%s h</td>\n", $effontime);
|
---|
217 | }
|
---|
218 |
|
---|
219 | if ($_GET["fSequ"]=="On")
|
---|
220 | {
|
---|
221 | $dataset=file_get_contents($datasetfile);
|
---|
222 | $onpos=strpos($dataset, "SequencesOn:");
|
---|
223 | $offpos=strpos($dataset, "SequencesOff:");
|
---|
224 | $possource=strpos($dataset, "SourceName:");
|
---|
225 | $sequoff="";
|
---|
226 | if (!empty($offpos))
|
---|
227 | $sequoff=substr($dataset, $offpos+13, $possource-($offpos+13));
|
---|
228 | if (empty($offpos))
|
---|
229 | $offpos=$possource;
|
---|
230 | $sequon=substr($dataset, $onpos+12, $offpos-($onpos+12));
|
---|
231 |
|
---|
232 | if (!empty($sequon))
|
---|
233 | {
|
---|
234 | printf("<tr><td colspan=\"6\">\n SequencesOn: ");
|
---|
235 | $sequences=split(" ", trim($sequon));
|
---|
236 | foreach($sequences as $key => $sequ)
|
---|
237 | printf("<a href=\"sequence.php?fSequenceNo=%s&fAll=On\">%s</a> ", $sequ, $sequ);
|
---|
238 | GetRanges($db_id, $sequon);
|
---|
239 | printf("</td></tr>");
|
---|
240 |
|
---|
241 | if (!empty($sequoff))
|
---|
242 | {
|
---|
243 | printf("<tr><td colspan=\"6\">\n SequencesOff: ");
|
---|
244 | $sequences=split(" ", trim($sequoff));
|
---|
245 | foreach($sequences as $key => $sequ)
|
---|
246 | printf("<a href=\"sequence.php?fSequenceNo=%s&fAll=On\">%s</a> ", $sequ, $sequ);
|
---|
247 | GetRanges($db_id, $sequoff);
|
---|
248 | printf("</td></tr>");
|
---|
249 | }
|
---|
250 | }
|
---|
251 | }
|
---|
252 | printf("<tr><td colspan=\"6\">\n Plots: ");
|
---|
253 |
|
---|
254 | if ($wobble=='Wobble')
|
---|
255 | $tabs=$ganymedtabsw;
|
---|
256 | else
|
---|
257 | $tabs=$ganymedtabs;
|
---|
258 | foreach($tabs as $key => $element)
|
---|
259 | if (!$key==0)
|
---|
260 | printf("<a href=\"http://www.astro.uni-wuerzburg.de/datacenter/ganymed/%s/%s/ganymed%s-tab%s.png\">%s</a> ", $num2, $num, $num, $key, $element);
|
---|
261 |
|
---|
262 | printf("</td></tr>");
|
---|
263 |
|
---|
264 | if ($_GET["fAll"]=="On" && !is_null($ganymed))
|
---|
265 | {
|
---|
266 | //plotting Hist and FS
|
---|
267 | printf("<tr><td colspan=\"6\" align='center'>\n");
|
---|
268 | printf(" <img src=\"http://www.astro.uni-wuerzburg.de/datacenter/ganymed/%s/%s/ganymed%s-tab14.png\">",
|
---|
269 | $num2, $num, $num);
|
---|
270 | printf(" <img src=\"http://www.astro.uni-wuerzburg.de/datacenter/ganymed/%s/%s/ganymed%s-tab13.png\">",
|
---|
271 | $num2, $num, $num);
|
---|
272 | printf(" </td></tr>");
|
---|
273 | }
|
---|
274 |
|
---|
275 | printf(" </table>");
|
---|
276 | printf("</td></tr><tr><td><br></td></tr>");
|
---|
277 | }
|
---|
278 | printf("</table>\n");
|
---|
279 |
|
---|
280 | printf("</center>\n");
|
---|
281 | printf("</tr><tr class='Block'><td>\n");
|
---|
282 | }
|
---|
283 |
|
---|
284 | function PrintPage($html, $host, $user, $pw, $db, $ganymedtabsw, $ganymedtabs)
|
---|
285 | {
|
---|
286 | $db_id = mysql_connect($host, $user, $pw);
|
---|
287 | if ($db_id==FALSE)
|
---|
288 | {
|
---|
289 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
290 | die("");
|
---|
291 | }
|
---|
292 | mysql_select_db($db);
|
---|
293 |
|
---|
294 | $query0 = CreateQuery($_GET);
|
---|
295 |
|
---|
296 | $result0 = mysql_query($query0, $db_id);
|
---|
297 |
|
---|
298 | if ($result0)
|
---|
299 | {
|
---|
300 | if ($html=="1" || $html=="2")
|
---|
301 | PrintDataSetInfo($db_id, $result0, $ganymedtabsw, $ganymedtabs);
|
---|
302 | else
|
---|
303 | PrintText($result0);
|
---|
304 |
|
---|
305 | mysql_free_result($result0);
|
---|
306 | }
|
---|
307 | mysql_close($db_id);
|
---|
308 |
|
---|
309 | PrintSubmittedQuery($query0, $html, $db, "old");
|
---|
310 | }
|
---|
311 |
|
---|
312 | include ("include.php");
|
---|
313 | include ("db.php");
|
---|
314 | include ("tabs.php");
|
---|
315 |
|
---|
316 | ini_set("display_errors", "On");
|
---|
317 | ini_set("mysql.trace_mode", "On");
|
---|
318 |
|
---|
319 | if (!empty($_GET["fSendTxt"]))
|
---|
320 | {
|
---|
321 | header("Content-type: application/octet");
|
---|
322 | header("Content-Disposition: attachment; filename=query-result.txt");
|
---|
323 |
|
---|
324 | PrintPage("0", $host, $user, $pw, $db, $ganymedtabsw, $ganymedtabs);
|
---|
325 | }
|
---|
326 | else
|
---|
327 | {
|
---|
328 | if (empty($_GET["fPrintTable"]))
|
---|
329 | echo (file_get_contents("index-header.html"));
|
---|
330 |
|
---|
331 | $environment = sizeof($_GET);
|
---|
332 |
|
---|
333 | InitGet($_GET);
|
---|
334 | if (empty($_GET["fPrintTable"]))
|
---|
335 | PrintForm($_GET, $host, $user, $pw, $db);
|
---|
336 |
|
---|
337 | if ($environment==0)
|
---|
338 | printf("No query submitted yet.<BR>");
|
---|
339 | else
|
---|
340 | {
|
---|
341 | if (empty($_GET["fPrintTable"]))
|
---|
342 | PrintPage("1", $host, $user, $pw, $db, $ganymedtabsw, $ganymedtabs);
|
---|
343 | else
|
---|
344 | PrintPage("2", $host, $user, $pw, $db, $ganymedtabsw, $ganymedtabs);
|
---|
345 | }
|
---|
346 |
|
---|
347 | if (empty($_GET["fPrintTable"]))
|
---|
348 | echo (file_get_contents("index-footer.html"));
|
---|
349 | }
|
---|
350 |
|
---|
351 | ini_set("display_errors", "Off");
|
---|
352 | ini_set("mysql.trace_mode", "Off");
|
---|
353 | }
|
---|
354 | ?>
|
---|