| 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 | }
|
|---|
| 43 |
|
|---|
| 44 | function PrintForm($_GET, $host, $user, $pw, $db)
|
|---|
| 45 | {
|
|---|
| 46 | printf("<center>\n");
|
|---|
| 47 | printf("<form action=\"ganymed.php\" METHOD=\"GET\">\n");
|
|---|
| 48 |
|
|---|
| 49 | printf("DataSet# <input name=\"fDataSetNo\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"");
|
|---|
| 50 | if (!empty($_GET["fDataSetNo"]))
|
|---|
| 51 | printf("%s", $_GET["fDataSetNo"]);
|
|---|
| 52 | printf("\"> \n");
|
|---|
| 53 |
|
|---|
| 54 | if (empty($_GET["fRunMin"]))
|
|---|
| 55 | $min = "100";
|
|---|
| 56 | // $min = GetMin("fDataSetNumber", "DataSets", $host, $user, $pw, $db);
|
|---|
| 57 | else
|
|---|
| 58 | $min = $_GET["fRunMin"];
|
|---|
| 59 |
|
|---|
| 60 | if (empty($_GET["fRunMax"]))
|
|---|
| 61 | $max = GetMax("fDataSetNumber", "DataSets", $host, $user, $pw, $db);
|
|---|
| 62 | else
|
|---|
| 63 | $max = $_GET["fRunMax"];
|
|---|
| 64 |
|
|---|
| 65 | printf("DataSets from <input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
|
|---|
| 66 | printf("to <input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\"> \n", $max);
|
|---|
| 67 |
|
|---|
| 68 | if ($_GET["fAll"]=="On")
|
|---|
| 69 | $checked = "checked";
|
|---|
| 70 | else
|
|---|
| 71 | $checked = "";
|
|---|
| 72 | printf("<input type=\"checkbox\" name=\"fAll\" value=\"On\" %s>plots\n", $checked);
|
|---|
| 73 |
|
|---|
| 74 | printf(" <P>\n");
|
|---|
| 75 |
|
|---|
| 76 | printf("Source (<A HREF=\"regexp.html\">regexp</A>) <input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
|
|---|
| 77 | if (!empty($_GET["fSourceN"]))
|
|---|
| 78 | printf("%s", $_GET["fSourceN"]);
|
|---|
| 79 | printf("\"> \n");
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 83 | ini_set("display_errors", "Off");
|
|---|
| 84 |
|
|---|
| 85 | printf("<input class='Width' type='submit' value='Query Table'> \n");
|
|---|
| 86 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"ganymed.php\"'> \n");
|
|---|
| 87 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
|---|
| 88 | printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
|---|
| 89 | printf("</form>\n");
|
|---|
| 90 | printf("</center>\n");
|
|---|
| 91 | printf("</td>\n");
|
|---|
| 92 | printf("</tr>\n");
|
|---|
| 93 | printf("<tr class='Block'>\n");
|
|---|
| 94 | printf("<td>\n");
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | function GetStatus($step)
|
|---|
| 98 | {
|
|---|
| 99 | if (is_null($step))
|
|---|
| 100 | return "<font color='#FF0000'>not done</font>";
|
|---|
| 101 | else
|
|---|
| 102 | {
|
|---|
| 103 | if (strpos($step, "1970-01-01 00:00:00")==FALSE)
|
|---|
| 104 | return "done";
|
|---|
| 105 | else
|
|---|
| 106 | return "not to be done";
|
|---|
| 107 | }
|
|---|
| 108 | return "there is an error -> tell Dani";
|
|---|
| 109 | }
|
|---|
| 110 | /*
|
|---|
| 111 | function GetSequences($datasetfile)
|
|---|
| 112 | // function QueryRuns($type, $sequ, $db_id, $db)
|
|---|
| 113 | {
|
|---|
| 114 | printf(" <td align='left'>");
|
|---|
| 115 | printf(" to be done");
|
|---|
| 116 | printf(" </td>\n");
|
|---|
| 117 | printf(" <td> to be done ");
|
|---|
| 118 | printf(" </td>\n");
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | function QueryMissingFiles($sequ, $db_id, $db)
|
|---|
| 122 | {
|
|---|
| 123 | $query2 = "SELECT fSequenceFirst FROM SequencesSequenceProcessStatus ";
|
|---|
| 124 | $query2 .= " WHERE fSequenceFirst=" . $sequ . " AND IsNull(fStar)";
|
|---|
| 125 |
|
|---|
| 126 | mysql_select_db($db);
|
|---|
| 127 | $files = mysql_query($query2, $db_id);
|
|---|
| 128 | $numfiles = mysql_num_rows($files);
|
|---|
| 129 | printf(" <td align='left'>");
|
|---|
| 130 | for ($i=0 ; $i<$numfiles ; $i++)
|
|---|
| 131 | {
|
|---|
| 132 | $file=mysql_result($files, $i, 0);
|
|---|
| 133 | if ($i!=0)
|
|---|
| 134 | printf(", ");
|
|---|
| 135 | printf(" %s ", $file);
|
|---|
| 136 | }
|
|---|
| 137 | printf(" </td>\n");
|
|---|
| 138 | }
|
|---|
| 139 | */
|
|---|
| 140 |
|
|---|
| 141 | function PrintDataSetInfo($result0)
|
|---|
| 142 | {
|
|---|
| 143 | $numres = mysql_num_rows($result0);
|
|---|
| 144 |
|
|---|
| 145 | printf("<center>");
|
|---|
| 146 | printf("<table BORDER=\"0\">\n");
|
|---|
| 147 | printf("<tr><td>");
|
|---|
| 148 | printf("# of DataSets: %d ", $numres);
|
|---|
| 149 | printf("</td></tr>");
|
|---|
| 150 |
|
|---|
| 151 | for ($i=0 ; $i<$numres ; $i++)
|
|---|
| 152 | {
|
|---|
| 153 | $datasetno=mysql_result($result0, $i, 0);
|
|---|
| 154 | $wobble=mysql_result($result0, $i, 1);
|
|---|
| 155 | $comment=mysql_result($result0, $i, 2);
|
|---|
| 156 | $source=mysql_result($result0, $i, 3);
|
|---|
| 157 | $inserted=mysql_result($result0, $i, 4);
|
|---|
| 158 | $filesavail=mysql_result($result0, $i, 5);
|
|---|
| 159 | $ganymed=mysql_result($result0, $i, 6);
|
|---|
| 160 | $fillganymed=mysql_result($result0, $i, 7);
|
|---|
| 161 | $excess=mysql_result($result0, $i, 8);
|
|---|
| 162 | $bg=mysql_result($result0, $i, 9);
|
|---|
| 163 | $signal=mysql_result($result0, $i, 10);
|
|---|
| 164 | $signif=mysql_result($result0, $i, 11);
|
|---|
| 165 | $scale=mysql_result($result0, $i, 12);
|
|---|
| 166 | $effontime=mysql_result($result0, $i, 13);
|
|---|
| 167 |
|
|---|
| 168 | printf("<tr><td>");
|
|---|
| 169 |
|
|---|
| 170 | printf(" <table BORDER=\"1\">");
|
|---|
| 171 | printf(" <tr BGCOLOR='#C0C0C0'>\n");
|
|---|
| 172 | printf(" <th colspan=\"6\"><u>DataSet#:</u> %s - %s </th>", $datasetno, $source);
|
|---|
| 173 | printf(" </tr><tr BGCOLOR='#E0E0E0' ALIGN='left'>\n");
|
|---|
| 174 | printf(" <th colspan=\"6\"> %s ", $comment);
|
|---|
| 175 | printf(" </th></tr><tr>\n");
|
|---|
| 176 |
|
|---|
| 177 | printf(" <td colspan=\"6\"> Wobble: %s", $wobble);
|
|---|
| 178 | if (!is_null($ganymed))
|
|---|
| 179 | printf(", <font color='green'> ganymed done</font> ");
|
|---|
| 180 |
|
|---|
| 181 | printf(" <tr>");
|
|---|
| 182 |
|
|---|
| 183 | if (!is_null($fillganymed))
|
|---|
| 184 | {
|
|---|
| 185 | printf("<td colspan=\"6\"></td></tr>\n");
|
|---|
| 186 | printf(" <tr BGCOLOR='#C0C0C0'><th colspan=\"6\">results - ");
|
|---|
| 187 | $num=sprintf("%08d",$datasetno);
|
|---|
| 188 | printf(" <a href=\"http://www.astro.uni-wuerzburg.de/datacenter/ganymed/%s/%s/\">plots</a>",
|
|---|
| 189 | substr($num,0,5), $num);
|
|---|
| 190 | printf(" </th></tr><tr BGCOLOR='#E0E0E0'>\n");
|
|---|
| 191 | printf(" <td>excess events</td>\n");
|
|---|
| 192 | printf(" <td>background events</td>\n");
|
|---|
| 193 | printf(" <td>signal events</td>\n");
|
|---|
| 194 | printf(" <td>significance</td>\n");
|
|---|
| 195 | printf(" <td>scale factor</td>\n");
|
|---|
| 196 | printf(" <td>effective ontime</td>\n");
|
|---|
| 197 | printf(" </tr><tr BGCOLOR='#D0D0D0' align='right'>");
|
|---|
| 198 | printf(" <td>%s</td>\n", $excess);
|
|---|
| 199 | printf(" <td>%s</td>\n", $bg);
|
|---|
| 200 | printf(" <td>%s</td>\n", $signal);
|
|---|
| 201 | printf(" <td>%s</td>\n", $signif);
|
|---|
| 202 | printf(" <td>%s</td>\n", $scale);
|
|---|
| 203 | printf(" <td>%s h</td>\n", $effontime);
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | if ($_GET["fAll"]=="On" && !is_null($ganymed))
|
|---|
| 207 | {
|
|---|
| 208 | printf("<tr><td colspan=\"6\" align='center'>\n");
|
|---|
| 209 | printf(" <img src=\"http://www.astro.uni-wuerzburg.de/datacenter/ganymed/%s/%s/ganymed%s-tab11.png\">",
|
|---|
| 210 | substr($num,0,5), $num, $num);
|
|---|
| 211 | printf(" <img src=\"http://www.astro.uni-wuerzburg.de/datacenter/ganymed/%s/%s/ganymed%s-tab10.png\">",
|
|---|
| 212 | substr($num,0,5), $num, $num);
|
|---|
| 213 | printf(" </td></tr>");
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | printf(" </table>");
|
|---|
| 217 | printf("</td></tr><tr><td><br></td></tr>");
|
|---|
| 218 | }
|
|---|
| 219 | printf("</table>\n");
|
|---|
| 220 |
|
|---|
| 221 | printf("</center>\n");
|
|---|
| 222 | printf("</tr><tr class='Block'><td>\n");
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | function PrintPage($html, $host, $user, $pw, $db)
|
|---|
| 226 | {
|
|---|
| 227 | $db_id = mysql_connect($host, $user, $pw);
|
|---|
| 228 | if ($db_id==FALSE)
|
|---|
| 229 | {
|
|---|
| 230 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
|---|
| 231 | die("");
|
|---|
| 232 | }
|
|---|
| 233 | mysql_select_db($db);
|
|---|
| 234 |
|
|---|
| 235 | $query0 = CreateQuery($_GET);
|
|---|
| 236 |
|
|---|
| 237 | $result0 = mysql_query($query0, $db_id);
|
|---|
| 238 |
|
|---|
| 239 | if ($result0)
|
|---|
| 240 | {
|
|---|
| 241 | if ($html=="1" || $html=="2")
|
|---|
| 242 | PrintDataSetInfo($result0);
|
|---|
| 243 | else
|
|---|
| 244 | PrintText($result0);
|
|---|
| 245 |
|
|---|
| 246 | mysql_free_result($result0);
|
|---|
| 247 | }
|
|---|
| 248 | mysql_close($db_id);
|
|---|
| 249 |
|
|---|
| 250 | if ($html=="1")
|
|---|
| 251 | printf("<U><B>submitted query:</B></U><BR>%s<BR>", htmlspecialchars($query0));
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | include ("include.php");
|
|---|
| 255 | include ("db.php");
|
|---|
| 256 |
|
|---|
| 257 | ini_set("display_errors", "On");
|
|---|
| 258 | ini_set("mysql.trace_mode", "On");
|
|---|
| 259 |
|
|---|
| 260 | if (!empty($_GET["fSendTxt"]))
|
|---|
| 261 | {
|
|---|
| 262 | header("Content-type: application/octet");
|
|---|
| 263 | header("Content-Disposition: attachment; filename=query-result.txt");
|
|---|
| 264 |
|
|---|
| 265 | PrintPage("0", $host, $user, $pw, $db);
|
|---|
| 266 | }
|
|---|
| 267 | else
|
|---|
| 268 | {
|
|---|
| 269 | echo (file_get_contents("index-header.html"));
|
|---|
| 270 |
|
|---|
| 271 | $environment = sizeof($_GET);
|
|---|
| 272 |
|
|---|
| 273 | InitGet($_GET);
|
|---|
| 274 | if (empty($_GET["fPrintTable"]))
|
|---|
| 275 | PrintForm($_GET, $host, $user, $pw, $db);
|
|---|
| 276 |
|
|---|
| 277 | if ($environment==0)
|
|---|
| 278 | printf("No query submitted yet.<BR>");
|
|---|
| 279 | else
|
|---|
| 280 | {
|
|---|
| 281 | if (empty($_GET["fPrintTable"]))
|
|---|
| 282 | PrintPage("1", $host, $user, $pw, $db);
|
|---|
| 283 | else
|
|---|
| 284 | PrintPage("2", $host, $user, $pw, $db);
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | echo (file_get_contents("index-footer.html"));
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | ini_set("display_errors", "Off");
|
|---|
| 291 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 292 | }
|
|---|
| 293 | ?>
|
|---|