source: trunk/MagicSoft/Mars/datacenter/db/querycal.php@ 9463

Last change on this file since 9463 was 8512, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 8.8 KB
Line 
1<?php
2{
3 function CreateQuery($_GET, $alias, $checkwhere)
4 {
5 $query0 = "SELECT fSequenceFirst as 'Sequence#' ";
6
7 foreach ($_GET as $key => $element)
8 if ($_GET[$key]=="On")
9 if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
10 $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
11
12 $query0 .= " FROM Calibration ";
13
14 if (strpos($query0, " WHERE ")==FALSE)
15 $query0 .= " WHERE ";
16 else
17 $query0 .= " AND ";
18
19 $query0 .= "fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
20
21 if (!empty($_GET["fSortBy"]))
22 {
23 $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
24 if (substr($_GET["fSortBy"], -1)=="-")
25 $query0 .= "DESC";
26 }
27
28 if (empty($_GET["fNumStart"]))
29 $_GET["fNumStart"]=0;
30
31 if (empty($_GET["fSendTxt"]))
32 $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
33
34 return $query0;
35 }
36
37 function InitGet($_GET)
38 {
39 // Find out whether it is the first call to the php script
40 $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
41
42 if (empty($_GET["fNumResults"]))
43 $_GET["fNumResults"]="20";
44
45 if (empty($_GET["fLastUpdate"]))
46 $_GET["fLastUpdate"]="Off";
47
48 if (empty($_GET["fUnreliableInner"]))
49 $_GET["fUnreliableInner"]=$first?"On":"";
50
51 if (empty($_GET["fUnsuitableOuter"]))
52 $_GET["fUnsuitableOuter"]=$first?"On":"";
53
54 if (empty($_GET["fUnsuitable50"]))
55 $_GET["fUnsuitable50"]=$first?"On":"";
56
57 if (empty($_GET["fUnsuitable01"]))
58 $_GET["fUnsuitable01"]=$first?"On":"";
59
60 if (empty($_GET["fUnsuitableMax"]))
61 $_GET["fUnsuitableMax"]=$first?"On":"";
62
63 if (empty($_GET["fDeadMax"]))
64 $_GET["fDeadMax"]=$first?"On":"";
65
66 if (empty($_GET["fUnreliableOuter"]))
67 $_GET["fUnreliableOuter"]=$first?"On":"";
68
69 if (empty($_GET["fUnsuitableInner"]))
70 $_GET["fUnsuitableInner"]=$first?"On":"";
71
72 if (empty($_GET["fIsolatedInner"]))
73 $_GET["fIsolatedInner"]=$first?"On":"";
74
75 if (empty($_GET["fIsolatedOuter"]))
76 $_GET["fIsolatedOuter"]=$first?"On":"";
77
78 if (empty($_GET["fMeanPedRmsInner"]))
79 $_GET["fMeanPedRmsInner"]=$first?"On":"";
80
81 if (empty($_GET["fMeanPedRmsOuter"]))
82 $_GET["fMeanPedRmsOuter"]=$first?"On":"";
83
84 if (empty($_GET["fIsolatedMaxCluster"]))
85 $_GET["fIsolatedMaxCluster"]=$first?"On":"";
86
87 if (empty($_GET["fArrTimeMeanInner"]))
88 $_GET["fArrTimeMeanInner"]=$first?"On":"";
89
90 if (empty($_GET["fArrTimeMeanOuter"]))
91 $_GET["fArrTimeMeanOuter"]=$first?"On":"";
92
93 if (empty($_GET["fArrTimeRmsInner"]))
94 $_GET["fArrTimeRmsInner"]=$first?"On":"";
95
96 if (empty($_GET["fArrTimeRmsOuter"]))
97 $_GET["fArrTimeRmsOuter"]=$first?"On":"";
98
99 if (empty($_GET["fMeanSignalInner"]))
100 $_GET["fMeanSignalInner"]=$first?"Off":"";
101
102 if (empty($_GET["fMeanSignalOuter"]))
103 $_GET["fMeanSignalOuter"]=$first?"Off":"";
104
105 if (empty($_GET["fPulsePosMean"]))
106 $_GET["fPulsePosMean"]=$first?"Off":"";
107
108 if (empty($_GET["fConvFactorInner"]))
109 $_GET["fConvFactorInner"]=$first?"On":"";
110
111 if (empty($_GET["fConvFactorOuter"]))
112 $_GET["fConvFactorOuter"]=$first?"On":"";
113
114 }
115
116 function PrintForm($_GET, $host, $user, $pw, $db)
117 {
118 printf("<center>\n");
119 printf("<form action=\"querycal.php\" METHOD=\"GET\">\n");
120 printf(" <table>\n");
121 printf(" <tr>\n");
122
123 CheckBox("fUnsuitableInner", "Unsuitable inner");
124 CheckBox("fUnsuitableOuter", "Unsuitable outer");
125 CheckBox("fUnreliableInner", "Unreliable inner");
126 CheckBox("fUnreliableOuter", "Unreliable outer");
127
128 printf(" </tr><tr>\n");
129
130 CheckBox("fUnsuitable50", "Unsuitable (50%)");
131 CheckBox("fUnsuitable01", "Unsuitable (1%)");
132 CheckBox("fUnsuitableMax", "Unsuitable (99.9%)");
133 CheckBox("fDeadMax", "DeadMax");
134
135 printf(" </tr><tr>\n");
136
137 CheckBox("fIsolatedInner", "Isolated inner");
138 CheckBox("fIsolatedOuter", "Isolated outer");
139
140 printf(" </tr><tr>\n");
141
142 CheckBox("fIsolatedMaxCluster", "IsolatedMaxCluster");
143 CheckBox("fArrTimeMeanInner", "ArrTimeMean inner ");
144 CheckBox("fArrTimeMeanOuter", "ArrTimeMean outer ");
145 CheckBox("fArrTimeRmsInner", "ArrTimeRms inner ");
146 CheckBox("fArrTimeRmsOuter", "ArrTimeRms outer ");
147 CheckBox("fPulsePosMean", "Mean PulsePos");
148
149 printf(" </tr><tr>\n");
150
151 CheckBox("fConvFactorInner", "Conv inner ");
152 CheckBox("fConvFactorOuter", "Conv outer ");
153 CheckBox("fMeanPedRmsInner", "MeanPedRms inner");
154 CheckBox("fMeanPedRmsOuter", "MeanPedRms outer");
155 CheckBox("fMeanSignalInner", "MeanSignal inner");
156 CheckBox("fMeanSignalOuter", "MeanSignal outer");
157
158 printf(" </table>\n");
159 printf(" <p>\n");
160
161 if (empty($_GET["fRunMin"]))
162 $min = GetMin("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
163 else
164 $min = $_GET["fRunMin"];
165
166 if (empty($_GET["fRunMax"]))
167 $max = GetMax("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
168 else
169 $max = $_GET["fRunMax"];
170
171
172 printf("Sequences&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
173 printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
174
175 printf(" <P>\n");
176
177 printf(" Results:\n");
178 printf(" <select name=\"fNumResults\">\n");
179
180 $numres = array("10", "20", "50", "100", "200", "500");
181 foreach ($numres as $element)
182 {
183 if ($element==$_GET["fNumResults"])
184 printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
185 else
186 printf("<option value=\"%s\">%3s</option>\n", $element, $element);
187 }
188 printf(" </select>\n");
189 printf(" &nbsp;&nbsp;&nbsp;\n");
190
191 ini_set("mysql.trace_mode", "Off");
192 ini_set("display_errors", "Off");
193
194 printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
195 printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"querycal.php\"'>&nbsp;&nbsp;&nbsp;\n");
196 if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
197 printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
198 printf("</form>\n");
199 printf("</center>\n");
200 printf("</td>\n");
201 printf("</tr>\n");
202 printf("<tr class='Block'>\n");
203 printf("<td>\n");
204 }
205
206 function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere)
207 {
208 $db_id = mysql_connect($host, $user, $pw);
209 if ($db_id==FALSE)
210 {
211 printf("mysql_connect returned the following error: %s\n", mysql_error());
212 die("");
213 }
214 mysql_select_db($db);
215
216 $query0 = CreateQuery($_GET, $alias, $checkwhere);
217
218 $result0 = mysql_query($query0, $db_id);
219
220 if ($result0)
221 {
222 if ($html=="1")
223 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);
224 else
225 PrintText($result0);
226
227 mysql_free_result($result0);
228 }
229 mysql_close($db_id);
230
231 PrintSubmittedQuery($query0, $html, $db, "old");
232 }
233
234 include ("include.php");
235 include ("db.php");
236 include ("magicdefs.php");
237
238 ini_set("display_errors", "On");
239 ini_set("mysql.trace_mode", "On");
240
241 if (!empty($_GET["fSendTxt"]))
242 {
243 header("Content-type: application/octet");
244 header("Content-Disposition: attachment; filename=query-result.txt");
245
246 PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere);
247 }
248 else
249 {
250 echo (file_get_contents("index-header.html"));
251
252 $environment = sizeof($_GET);
253
254 InitGet($_GET);
255 PrintForm($_GET, $host, $user, $pw, $db);
256
257 if ($environment==0)
258 printf("No query submitted yet.<BR>");
259 else
260 PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere);
261
262 echo (file_get_contents("index-footer.html"));
263 }
264
265 ini_set("display_errors", "Off");
266 ini_set("mysql.trace_mode", "Off");
267}
268?>
Note: See TracBrowser for help on using the repository browser.