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

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