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

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