source: trunk/MagicSoft/Mars/datacenter/db/ganymed.php@ 7577

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