1 | <?php
|
---|
2 | {
|
---|
3 | function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
|
---|
4 | {
|
---|
5 | $fromtable="Sequences";
|
---|
6 |
|
---|
7 | $groups = 0;
|
---|
8 | foreach ($checkgroup as $element)
|
---|
9 | if ($element==-1)
|
---|
10 | $groups++;
|
---|
11 |
|
---|
12 | $statusgroups = 0;
|
---|
13 | foreach ($checkstatusgroup as $element)
|
---|
14 | if ($element==-1)
|
---|
15 | $statusgroups++;
|
---|
16 |
|
---|
17 | $query0 = "SELECT ";
|
---|
18 |
|
---|
19 | if ($groups>0)
|
---|
20 | {
|
---|
21 | foreach ($checkgroup as $key => $element)
|
---|
22 | if ($element==-1)
|
---|
23 | $query0 .= $key . " as '" . $alias[$key] . "' " . ", ";
|
---|
24 | //--------------------------------------------------
|
---|
25 | $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
|
---|
26 | //--------------------------------------------------
|
---|
27 | $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
|
---|
28 | $query0 .= " Min(fZenithDistanceMin) as '" . $alias["Min(fZenithDistanceMin)"] . "', ";
|
---|
29 | $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', ";
|
---|
30 | $query0 .= " COUNT(*) as '# Sequ' ";
|
---|
31 | }
|
---|
32 | else
|
---|
33 | {
|
---|
34 | if ($statusgroups>0)
|
---|
35 | {
|
---|
36 | foreach ($checkstatusgroup as $key => $element)
|
---|
37 | if ($element==-1)
|
---|
38 | $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
|
---|
39 | // $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
|
---|
40 |
|
---|
41 | $query0 .= " COUNT(*) as '# Sequ'";
|
---|
42 |
|
---|
43 | }
|
---|
44 | else
|
---|
45 | {
|
---|
46 | $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
|
---|
47 | if (!empty($_GET["fLinks"]))
|
---|
48 | {
|
---|
49 | $query0 .= ", CONCAT('<A&ws;HREF=\"runinfo-aio.php?', 'fRunStart=On', '&fZenithDistance=On', '&fRunMin=', Sequences.fSequenceFirst, '&fMeanTriggerRate=On', '&fTest=On', '&fRunTypeName=On', '&fRunMax=', fSequenceLast, '&fNumEvents=On', '&fSourceName=On&', 'fExcludedFDAKEY=1', '&fSequenceFirst=On', '&fRawFileAvail=On', '&fCCFileAvail=On', '&fCaCoFileAvail=On', '&fNumResults=500\">r</A>' ";
|
---|
50 | // $query0 .= " as " . $alias["fSequenceFirst"];
|
---|
51 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'callisto', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">cl</A>'";
|
---|
52 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">c</A>'";
|
---|
53 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'star', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">sl</A>'";
|
---|
54 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">s</A>'";
|
---|
55 | $query0 .= ", ' <A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/sequences/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/sequence', LPAD(CONCAT(Sequences.fSequenceFirst , '.txt'), 12,'0') , '\">', 'f </A>' ";
|
---|
56 | $query0 .= ", ' <A&ws;HREF=\"sequence.php?fSequenceNo=', Sequences.fSequenceFirst , '&fAll=On\">i</A>') ";
|
---|
57 | $query0 .= " as 'Links'";
|
---|
58 | }
|
---|
59 |
|
---|
60 | foreach ($_GET as $key => $element)
|
---|
61 | if ($_GET[$key]=="On")
|
---|
62 | if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff")
|
---|
63 | if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
|
---|
64 | $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | $query0 .= " FROM " . $fromtable;
|
---|
69 |
|
---|
70 | $query0 .= " LEFT JOIN SequenceProcessStatus ON Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst ";
|
---|
71 | $query0 .= " LEFT JOIN Calibration ON Sequences.fSequenceFirst=Calibration.fSequenceFirst ";
|
---|
72 | $query0 .= " LEFT JOIN Star ON Sequences.fSequenceFirst=Star.fSequenceFirst ";
|
---|
73 |
|
---|
74 | foreach ($_GET as $key => $element)
|
---|
75 | if (($_GET[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key)))
|
---|
76 | $query0 .= GetJoin($fromtable,$key);
|
---|
77 |
|
---|
78 | if ($_GET["fTest"]!="On")
|
---|
79 | {
|
---|
80 | if ($_GET["fSourceName"]!="On")
|
---|
81 | $query0 .= " LEFT JOIN Source ON Sequences.fSourceKEY=Source.fSourceKEY ";
|
---|
82 | $query0 .= " WHERE fTest='no'";
|
---|
83 | }
|
---|
84 |
|
---|
85 | if ($_GET["fOff"]=="Off")
|
---|
86 | {
|
---|
87 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
88 | $query0 .= " WHERE ";
|
---|
89 | else
|
---|
90 | $query0 .= " AND ";
|
---|
91 |
|
---|
92 | $query0 .= " NOT (fSourceName like '%Off%')";
|
---|
93 | }
|
---|
94 |
|
---|
95 | if ($_GET["fOnlyOff"]=="On")
|
---|
96 | {
|
---|
97 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
98 | $query0 .= " WHERE ";
|
---|
99 | else
|
---|
100 | $query0 .= " AND ";
|
---|
101 |
|
---|
102 | $query0 .= " fSourceName like '%Off%'";
|
---|
103 | }
|
---|
104 |
|
---|
105 | foreach ($checkwhere as $key => $element)
|
---|
106 | {
|
---|
107 | if (empty($element) || $element<=0)
|
---|
108 | continue;
|
---|
109 |
|
---|
110 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
111 | $query0 .= " WHERE ";
|
---|
112 | else
|
---|
113 | if ($element!=-1)
|
---|
114 | if (strrpos($query0, " AND ")!=strlen($query0)-5)
|
---|
115 | $query0 .= " AND ";
|
---|
116 |
|
---|
117 | if ($element!=-1)
|
---|
118 | $query0 .= GetCheck($fromtable, $key) . "=" . $element;
|
---|
119 | }
|
---|
120 |
|
---|
121 | if (strpos($query0, " WHERE ")==FALSE)
|
---|
122 | $query0 .= " WHERE ";
|
---|
123 | else
|
---|
124 | $query0 .= " AND ";
|
---|
125 |
|
---|
126 | $query0 .= StatusQuery("fSequenceFileWritten", $needs);
|
---|
127 | $query0 .= StatusQuery("fAllFilesAvail", $needs);
|
---|
128 | $query0 .= StatusQuery("fCallisto", $needs);
|
---|
129 | $query0 .= StatusQuery("fFillCallisto", $needs);
|
---|
130 | $query0 .= StatusQuery("fStar", $needs);
|
---|
131 | $query0 .= StatusQuery("fFillStar", $needs);
|
---|
132 |
|
---|
133 | if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
|
---|
134 | $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
|
---|
135 | else
|
---|
136 | $query0 = substr($query0, 0, -4);
|
---|
137 |
|
---|
138 | if (!empty($_GET["fZDMin"]) && !empty($_GET["fZDMax"]))
|
---|
139 | $query0 .= "AND (fZenithDistanceMin > " . $_GET["fZDMin"] . " AND fZenithDistanceMax < " . $_GET["fZDMax"] . ") ";
|
---|
140 |
|
---|
141 | if (!empty($_GET["fSourceN"]))
|
---|
142 | $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
|
---|
143 |
|
---|
144 | if (!empty($_GET["fStartDate"]))
|
---|
145 | {
|
---|
146 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
---|
147 | $query0 .= " AND ";
|
---|
148 |
|
---|
149 | $startdate=substr($_GET["fStartDate"], 0, 10);
|
---|
150 | if ($startdate=="0000-00-00")
|
---|
151 | $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
|
---|
152 | else
|
---|
153 | $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
|
---|
154 | }
|
---|
155 |
|
---|
156 | if (!empty($_GET["fStopDate"]))
|
---|
157 | {
|
---|
158 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
---|
159 | $query0 .= " AND ";
|
---|
160 |
|
---|
161 | $stopdate=substr($_GET["fStopDate"], 0, 10);
|
---|
162 | $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
|
---|
163 | }
|
---|
164 |
|
---|
165 | if (!empty($_GET["fStarStart"]))
|
---|
166 | {
|
---|
167 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
---|
168 | $query0 .= " AND ";
|
---|
169 |
|
---|
170 | $starstart=substr($_GET["fStarStart"], 0, 10);
|
---|
171 | $query0 .=" fStar >= '" . $starstart . " 00:00:00' ";
|
---|
172 | }
|
---|
173 |
|
---|
174 | if (!empty($_GET["fStarStop"]))
|
---|
175 | {
|
---|
176 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
---|
177 | $query0 .= " AND ";
|
---|
178 |
|
---|
179 | $starstop=substr($_GET["fStarStop"], 0, 10);
|
---|
180 | $query0 .= " fStar < '" . $starstop . " 23:59:59' ";
|
---|
181 | }
|
---|
182 |
|
---|
183 | if ($groups>0)
|
---|
184 | {
|
---|
185 | $query0 .= " GROUP BY ";
|
---|
186 | $num = $groups;
|
---|
187 | foreach ($checkgroup as $key => $element)
|
---|
188 | if ($element==-1)
|
---|
189 | {
|
---|
190 | $query0 .= GetCheck($fromtable,$key);
|
---|
191 | if ($num-->1)
|
---|
192 | $query0 .= ", ";
|
---|
193 | }
|
---|
194 | }
|
---|
195 |
|
---|
196 | if ($statusgroups>0)
|
---|
197 | {
|
---|
198 | $query0 .= " GROUP BY ";
|
---|
199 | $num = $statusgroups;
|
---|
200 | foreach ($checkstatusgroup as $key => $element)
|
---|
201 | if ($element==-1)
|
---|
202 | {
|
---|
203 | $query0 .= $alias[$key];
|
---|
204 | if ($num-->1)
|
---|
205 | $query0 .= ", ";
|
---|
206 | }
|
---|
207 | }
|
---|
208 |
|
---|
209 | if (!empty($_GET["fSortBy"]))
|
---|
210 | {
|
---|
211 | $val=substr($_GET["fSortBy"], 0, -1);
|
---|
212 | $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
|
---|
213 | if (substr($_GET["fSortBy"], -1)=="-")
|
---|
214 | $query0 .= "DESC";
|
---|
215 | }
|
---|
216 |
|
---|
217 | if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
|
---|
218 | $query0 .= "ORDER BY Sequences.fSequenceFirst DESC ";
|
---|
219 |
|
---|
220 | if (empty($_GET["fNumStart"]))
|
---|
221 | $_GET["fNumStart"]=0;
|
---|
222 |
|
---|
223 | if (empty($_GET["fSendTxt"]))
|
---|
224 | $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
|
---|
225 |
|
---|
226 | return $query0;
|
---|
227 | }
|
---|
228 |
|
---|
229 | function InitGet($_GET)
|
---|
230 | {
|
---|
231 | // Find out whether it is the first call to the php script
|
---|
232 | $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
|
---|
233 |
|
---|
234 | if (empty($_GET["fNumResults"]))
|
---|
235 | $_GET["fNumResults"]="10";
|
---|
236 |
|
---|
237 | if (empty($_GET["fRunStart"]))
|
---|
238 | $_GET["fRunStart"]=$first?"On":"";
|
---|
239 |
|
---|
240 | if (empty($_GET["fRunTime/60"]))
|
---|
241 | $_GET["fRunTime/60"]=$first?"On":"";
|
---|
242 |
|
---|
243 | if (empty($_GET["fZenithDistanceMin"]))
|
---|
244 | $_GET["fZenithDistanceMin"]=$first?"On":"";
|
---|
245 |
|
---|
246 | if (empty($_GET["fZenithDistanceMax"]))
|
---|
247 | $_GET["fZenithDistanceMax"]=$first?"On":"";
|
---|
248 |
|
---|
249 | if (empty($_GET["fSourceName"]))
|
---|
250 | $_GET["fSourceName"]=$first?"On":"";
|
---|
251 |
|
---|
252 | if (empty($_GET["fObservationModeName"]))
|
---|
253 | $_GET["fObservationModeName"]=$first?"On":"";
|
---|
254 |
|
---|
255 | if (empty($_GET["fUnsuitableInner"]))
|
---|
256 | $_GET["fUnsuitableInner"]=$first?"On":"";
|
---|
257 |
|
---|
258 | if (empty($_GET["fUnsInLimit1"]))
|
---|
259 | $_GET["fUnsInLimit1"]=$first?"12":"";
|
---|
260 |
|
---|
261 | if (empty($_GET["fUnsInLimit2"]))
|
---|
262 | $_GET["fUnsInLimit2"]=$first?"20":"";
|
---|
263 |
|
---|
264 | if (empty($_GET["fRunTimeLimit1"]))
|
---|
265 | $_GET["fRunTimeLimit1"]=$first?"2":"";
|
---|
266 |
|
---|
267 | if (empty($_GET["fRunTimeLimit2"]))
|
---|
268 | $_GET["fRunTimeLimit2"]=$first?"5":"";
|
---|
269 |
|
---|
270 | if (empty($_GET["fUnreliableInner"]))
|
---|
271 | $_GET["fUnreliableInner"]=$first?"On":"";
|
---|
272 |
|
---|
273 | if (empty($_GET["fIsolatedInner"]))
|
---|
274 | $_GET["fIsolatedInner"]=$first?"On":"";
|
---|
275 |
|
---|
276 | if (empty($_GET["fIsolatedMaxCluster"]))
|
---|
277 | $_GET["fIsolatedMaxCluster"]=$first?"On":"";
|
---|
278 |
|
---|
279 | if (empty($_GET["fArrTimeMeanInner"]))
|
---|
280 | $_GET["fArrTimeMeanInner"]=$first?"On":"";
|
---|
281 |
|
---|
282 | if (empty($_GET["fArrTimeRmsInner"]))
|
---|
283 | $_GET["fArrTimeRmsInner"]=$first?"On":"";
|
---|
284 |
|
---|
285 | if (empty($_GET["fMeanPedRmsInner"]))
|
---|
286 | $_GET["fMeanPedRmsInner"]=$first?"On":"";
|
---|
287 |
|
---|
288 | if (empty($_GET["fPulsePosMean"]))
|
---|
289 | $_GET["fPulsePosMean"]=$first?"On":"";
|
---|
290 |
|
---|
291 | if (empty($_GET["fConvFactorInner"]))
|
---|
292 | $_GET["fConvFactorInner"]=$first?"On":"";
|
---|
293 |
|
---|
294 | if (empty($_GET["fInhomogeneity"]))
|
---|
295 | $_GET["fInhomogeneity"]=$first?"On":"";
|
---|
296 |
|
---|
297 | if (empty($_GET["fPSF"]))
|
---|
298 | $_GET["fPSF"]=$first?"On":"";
|
---|
299 |
|
---|
300 | if (empty($_GET["fMuonNumber"]))
|
---|
301 | $_GET["fMuonNumber"]=$first?"On":"";
|
---|
302 |
|
---|
303 | if (empty($_GET["fEffOnTime/fRunTime"]))
|
---|
304 | $_GET["fEffOnTime/fRunTime"]=$first?"On":"";
|
---|
305 |
|
---|
306 | if (empty($_GET["fMuonRate"]))
|
---|
307 | $_GET["fMuonRate"]=$first?"On":"";
|
---|
308 |
|
---|
309 | if (empty($_GET["fDataRate"]))
|
---|
310 | $_GET["fDataRate"]=$first?"On":"";
|
---|
311 |
|
---|
312 | if (empty($_GET["fMaxHumidity"]))
|
---|
313 | $_GET["fMaxHumidity"]=$first?"On":"";
|
---|
314 |
|
---|
315 | if (empty($_GET["fBrightnessMed"]))
|
---|
316 | $_GET["fBrightnessMed"]=$first?"On":"";
|
---|
317 |
|
---|
318 | if (empty($_GET["fNumStarsMed"]))
|
---|
319 | $_GET["fNumStarsMed"]=$first?"On":"";
|
---|
320 |
|
---|
321 | if (empty($_GET["fNumStarsCorMed"]))
|
---|
322 | $_GET["fNumStarsCorMed"]=$first?"On":"";
|
---|
323 |
|
---|
324 | if (empty($_GET["fOff"]))
|
---|
325 | $_GET["fOff"]=$first?"On":"";
|
---|
326 |
|
---|
327 | if (empty($_GET["fLinks"]))
|
---|
328 | $_GET["fLinks"]=$first?"On":"";
|
---|
329 |
|
---|
330 | if (empty($_GET["fOnlyOff"]))
|
---|
331 | $_GET["fOnlyOff"]=$first?"Off":"";
|
---|
332 |
|
---|
333 | InitSequInfo($_GET);
|
---|
334 | }
|
---|
335 |
|
---|
336 | function PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias)
|
---|
337 | {
|
---|
338 | printf("<center>\n");
|
---|
339 | printf("<form action='builddatasets.php' METHOD='GET'>\n");
|
---|
340 | printf("<input id='sh' type='hidden' name='fShowHide' value='");
|
---|
341 | if (!empty($_GET["fShowHide"]))
|
---|
342 | printf("%s", $_GET["fShowHide"]);
|
---|
343 | else
|
---|
344 | printf("1000000000");
|
---|
345 | printf("'>\n");
|
---|
346 | printf("<img id='allbutton' src='../minus.png' alt='-' onclick='showhide(\"all\")'> Menu \n");
|
---|
347 | printf("<img id='infobutton' src='../plus.png' alt='+' onClick='showhide(\"info\");showhide(\"info2\")'>SequInfo \n");
|
---|
348 | printf("<img id='statbutton' src='../plus.png' alt='+' onClick='showhide(\"stat\");showhide(\"fail\")'> StatusInfo \n");
|
---|
349 | printf("<img id='calbutton' src='../plus.png' alt='+' onClick='showhide(\"cal\")'> CalInfo \n");
|
---|
350 | printf("<img id='starbutton' src='../plus.png' alt='+' onClick='showhide(\"star\")'> StarInfo \n");
|
---|
351 | printf("<img id='rangesbutton' src='../plus.png' alt='+' onClick='showhide(\"ranges\")'> Ranges \n");
|
---|
352 | printf("<img id='limitsbutton' src='../plus.png' alt='+' onClick='showhide(\"limits\")'> Limits \n");
|
---|
353 |
|
---|
354 | printf(" <div id='all' style='display:block'>");
|
---|
355 |
|
---|
356 | PrintSequInfo2Menu($host,$user,$pw,$db);
|
---|
357 | PrintSequInfoMenu();
|
---|
358 | PrintSequStatMenu();
|
---|
359 | PrintFailMenu();
|
---|
360 | PrintCalMenu();
|
---|
361 | PrintStarMenu();
|
---|
362 | PrintLimitsMenu($limitsmean, $limitsmin, $limitsmax, $alias, "");
|
---|
363 |
|
---|
364 | printf(" <div id='ranges' style='display:none'>");
|
---|
365 | PrintZdRangeMenu($host,$user,$pw,$db);
|
---|
366 | PrintSequRangeMenu($host,$user,$pw,$db);
|
---|
367 | printf("<p>");
|
---|
368 | PrintSourceMenu($host,$user,$pw,$db);
|
---|
369 | PrintNightRangeMenu($host,$user,$pw,$db);
|
---|
370 | PrintStarRangeMenu($host,$user,$pw,$db);
|
---|
371 | printf("<p>");
|
---|
372 | printf("</div>");
|
---|
373 |
|
---|
374 | printf("</div>");
|
---|
375 | printf(" <P>\n");
|
---|
376 |
|
---|
377 | PrintNumResPullDown();
|
---|
378 |
|
---|
379 | ini_set("mysql.trace_mode", "Off");
|
---|
380 | ini_set("display_errors", "Off");
|
---|
381 |
|
---|
382 | PrintButtons("builddatasets.php");
|
---|
383 |
|
---|
384 | $sequon=" ";
|
---|
385 | $sequoff=" ";
|
---|
386 | foreach($_POST as $key => $val)
|
---|
387 | if ($val=="On")
|
---|
388 | {
|
---|
389 | if (ereg("ON$", $key))
|
---|
390 | $sequon.=str_replace("ON", " ", $key);
|
---|
391 | if (ereg("Off$", $key))
|
---|
392 | $sequoff.=str_replace("Off", " ", $key);
|
---|
393 | }
|
---|
394 | printf("<input name='Set' type='hidden' value='%s'>\n", $sequon);
|
---|
395 | printf("<input name='Set2' type='hidden' value='%s'>\n", $sequoff);
|
---|
396 | printf("<input name='name' type='hidden' value='%s'>\n", $_POST["name"]);
|
---|
397 | printf("<input name='comment' type='hidden' value='%s'>\n", $_POST["comment"]);
|
---|
398 | printf("<input name='obsmode' type='hidden' value='%s'>\n", $_POST["fObservationModeKEY"]);
|
---|
399 | printf("</form>\n");
|
---|
400 | printf("</center>\n");
|
---|
401 | printf("</td>\n");
|
---|
402 | printf("</tr>\n");
|
---|
403 | printf("<tr class='Block'>\n");
|
---|
404 | printf("<td>\n");
|
---|
405 | }
|
---|
406 |
|
---|
407 | function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs)
|
---|
408 | {
|
---|
409 | $db_id = mysql_pconnect($host, $user, $pw);
|
---|
410 | if ($db_id==FALSE)
|
---|
411 | {
|
---|
412 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
413 | die("");
|
---|
414 | }
|
---|
415 | mysql_select_db($db);
|
---|
416 |
|
---|
417 | $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
---|
418 |
|
---|
419 | $result0 = mysql_query($query0, $db_id);
|
---|
420 |
|
---|
421 | if ($result0)
|
---|
422 | {
|
---|
423 | if ($html=="1" || $html=="2")
|
---|
424 | {
|
---|
425 | PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, "yes", $_GET);
|
---|
426 | foreach($_POST as $key => $val)
|
---|
427 | if ($val=="On")
|
---|
428 | {
|
---|
429 | if (ereg("ON$", $key))
|
---|
430 | $sequon.=str_replace("ON", " ", $key);
|
---|
431 | if (ereg("Off$", $key))
|
---|
432 | $sequoff.=str_replace("Off", " ", $key);
|
---|
433 | }
|
---|
434 | printf("<input type='submit' value='Get Dataset'><br><br>\n");
|
---|
435 | printf("pw: %s<br>", crypt("IutWDC+B"));
|
---|
436 | printf("<input name='submit' type='hidden' value='post'>\n");
|
---|
437 |
|
---|
438 | $on=str_replace(" ", ",", trim($sequon));
|
---|
439 | $off=str_replace(" ", ",", trim($sequoff));
|
---|
440 |
|
---|
441 | $values=array("Sum(fRunTime)/60" => $runtime,
|
---|
442 | "Min(fRunTime)/60" => $runtimemin,
|
---|
443 | "Max(fUnsuitableInner)" => $unsuitablemax,
|
---|
444 | "Max(fUnreliableInner)" => $unreliablemax,
|
---|
445 | "Max(fIsolatedInner)" => $isolatedmax,
|
---|
446 | "Max(fIsolatedMaxCluster)" => $imcmax,
|
---|
447 | "Max(fArrTimeMeanInner)" => $arrtimemax,
|
---|
448 | "Min(fArrTimeMeanInner)" => $arrtimemin,
|
---|
449 | "Max(fArrTimeRmsInner)" => $arrtimermsmax,
|
---|
450 | "Avg(fMeanPedRmsInner)" => $pedrmsmean,
|
---|
451 | "Std(fMeanPedRmsInner)" => $pedrmsrms,
|
---|
452 | "Min(fMeanPedRmsInner)" => $pedrmsmin,
|
---|
453 | "Max(fMeanPedRmsInner)" => $pedrmsmax,
|
---|
454 | "Min(fPulsePosMean)" => $pulseposmin,
|
---|
455 | "Max(fPulsePosMean)" => $pulseposmax,
|
---|
456 | "Max(fPulsePosRms)" => $pulseposrmsmax,
|
---|
457 | "Max(fMaxHumidity)" => $hummax,
|
---|
458 | "Max(fInhomogeneity)" => $inhommax,
|
---|
459 | "Avg(fInhomogeneity)" => $inhommean,
|
---|
460 | "Std(fInhomogeneity)" => $inhomrms,
|
---|
461 | "Min(fMeanNumberIslands)" => $numislmin,
|
---|
462 | "Max(fMeanNumberIslands)" => $numislmax,
|
---|
463 | "Min(fDataRate)" => $clratemin,
|
---|
464 | "Max(fDataRate)" => $clratemax,
|
---|
465 | "Min(fMuonRate)" => $muonratemin,
|
---|
466 | "Max(fMuonRate)" => $muonratemax,
|
---|
467 | "Min(fMuonNumber)" => $muonnumbermin,
|
---|
468 | "Avg(fPSF)" => $psfmean,
|
---|
469 | "Std(fPSF)" => $psfrms,
|
---|
470 | "Min(fPSF)" => $psfmin,
|
---|
471 | "Max(fPSF)" => $psfmax,
|
---|
472 | "Min(fEffOnTime/fRunTime)" => $relontimemin,
|
---|
473 | "Max(fEffOnTime/fRunTime)" => $relontimemax,
|
---|
474 | "Min(fBrightnessMed)" => $brightmin,
|
---|
475 | "Max(fBrightnessMed)" => $brightmax,
|
---|
476 | "Min(fNumStarsMed)" => $idstarsmin,
|
---|
477 | "Max(fNumStarsMed)" => $idstarsmax,
|
---|
478 | "Min(fNumStarsCorMed)" => $corstarsmin,
|
---|
479 | "Max(fNumStarsCorMed)" => $corstarsmax,
|
---|
480 | "Min(fZenithDistanceMin)" => $zdmin,
|
---|
481 | "Max(fZenithDistanceMax)" => $zdmax,
|
---|
482 | "Min(fRunStart)" => $starttime,
|
---|
483 | "Max(fRunStop)" => $stoptime,
|
---|
484 | );
|
---|
485 | //get runtimes of dataset
|
---|
486 | function GetSequenceValues($db_id, $sequences, $txt,&$values)
|
---|
487 | {
|
---|
488 | $query="SELECT COUNT(*) ";
|
---|
489 | foreach($values as $name => $varname)
|
---|
490 | $query.=", " . $name;
|
---|
491 | $query.=" FROM Sequences ";
|
---|
492 | $query.=" LEFT JOIN Calibration ON Calibration.fSequenceFirst=Sequences.fSequenceFirst ";
|
---|
493 | $query.=" LEFT JOIN Star ON Star.fSequenceFirst=Sequences.fSequenceFirst ";
|
---|
494 | $query.=" WHERE Sequences.fSequenceFirst IN (" . $sequences . ")";
|
---|
495 | $result = mysql_query($query, $db_id);
|
---|
496 | $row = mysql_fetch_assoc($result);
|
---|
497 | foreach($values as $name => $varname)
|
---|
498 | $values[$name][$txt]=$row[$name];
|
---|
499 | mysql_free_result($result);
|
---|
500 | }
|
---|
501 |
|
---|
502 | //get next dataset#
|
---|
503 | $query="SELECT fDataSetNumber+1 FROM DataSets ORDER BY fDataSetNumber LIMIT 0,1";
|
---|
504 | $result = mysql_query($query, $db_id);
|
---|
505 | $row = mysql_fetch_assoc($result);
|
---|
506 | $dataset=$row["fDataSetNumber+1"];
|
---|
507 | if (empty($dataset))
|
---|
508 | $dataset=1;
|
---|
509 | mysql_free_result($result);
|
---|
510 |
|
---|
511 | //get sourcenames
|
---|
512 | function GetSources($db_id, $sequences)
|
---|
513 | {
|
---|
514 | $query="SELECT fSourceName FROM Source LEFT JOIN Sequences ON Sequences.fSourceKEY=Source.fSourceKEY ";
|
---|
515 | $query.="WHERE fSequenceFirst IN (" . $sequences . ") GROUP BY fSourceName";
|
---|
516 | $result = mysql_query($query, $db_id);
|
---|
517 | while ($row = mysql_fetch_assoc($result))
|
---|
518 | $sources.=" " . $row["fSourceName"];
|
---|
519 | mysql_free_result($result);
|
---|
520 | return $sources;
|
---|
521 | }
|
---|
522 | $sourceson=GetSources($db_id, $on);
|
---|
523 | $sourcesoff=GetSources($db_id, $off);
|
---|
524 |
|
---|
525 | //get sourcename for dataset
|
---|
526 | $son=str_replace(" ", "','", trim($sourceson));
|
---|
527 | $query="SELECT fRealSourceKEY, Count(*) FROM Source where fSourcename IN ('" . $son . "') GROUP BY fRealSourceKEY";
|
---|
528 | // printf("q: %s <br>", $query);
|
---|
529 | $result = mysql_query($query, $db_id);
|
---|
530 | $row = mysql_fetch_assoc($result);
|
---|
531 | $numsources=$row["Count(*)"];
|
---|
532 | $numrealkeys=mysql_num_rows($result);
|
---|
533 | $realsourcekey=$row["fRealSourceKEY"];
|
---|
534 | mysql_free_result($result);
|
---|
535 | // printf("found %s sources with real sourcekey %s", $numsources, $realsourcekey);
|
---|
536 | // printf("found %s keys", $numrealkeys);
|
---|
537 |
|
---|
538 |
|
---|
539 | $runtimelimit=5;
|
---|
540 | $unsuitablemaxlimit=15;
|
---|
541 | $isolatedlimit=0;
|
---|
542 | $imclimit=0;
|
---|
543 | $pedrmsrms=0.09;
|
---|
544 | $scalelimit=1.3;
|
---|
545 |
|
---|
546 |
|
---|
547 | $numerr=0;
|
---|
548 | if (!empty($on))
|
---|
549 | {
|
---|
550 | $color=array("INFO" => "#000000",
|
---|
551 | "WARN" => "#FF9900",
|
---|
552 | "ERROR" => "#FF0000");
|
---|
553 | printf("<div align='left'><font><ul>\n");
|
---|
554 | $vals=array("on", "off");
|
---|
555 | foreach($vals as $num => $val)
|
---|
556 | {
|
---|
557 | if (empty(${$val}))
|
---|
558 | continue;
|
---|
559 | GetSequenceValues($db_id, ${$val}, $val, $values);
|
---|
560 |
|
---|
561 | if ($values["Min(fRunTime)/60"][$val]<$runtimelimit)
|
---|
562 | printf("<li style='color:%s'>%s: one of your %s-sequences is shorter than %s min (%s min)</li>",
|
---|
563 | $color["WARN"], "WARN", $val, $runtimelimit, $values["Min(fRunTime)/60"][$val]);
|
---|
564 | if ($values["Max(fUnsuitableInner)"][$val]>$unsuitablemaxlimit)
|
---|
565 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s unsuitable inner pixel (%s)</li>",
|
---|
566 | $color["WARN"], "WARN", $val, $unsuitablemaxlimit, $values["Max(fUnsuitableInner)"][$val]);
|
---|
567 | if ($values["Max(fIsolatedInner)"][$val]>$isolatedlimit)
|
---|
568 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s isolated inner pixel (%s)</li>",
|
---|
569 | $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]);
|
---|
570 | if ($values["Max(fIsolatedMaxCluster)"][$val]>$imclimit)
|
---|
571 | printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s isolated max cluster (%s)</li>",
|
---|
572 | $color["WARN"], "WARN", $val, $imclimit, $values["Max(fIsolatedMaxCluster)"][$val]);
|
---|
573 | }
|
---|
574 | if (!empty($on) && $values["Max(fMeanPedRmsInner)"]["on"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
|
---|
575 | printf("<li style='color:%s'>%s: one of your on-sequences has a PedRms larger than %s (%s)</li>",
|
---|
576 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["on"]);
|
---|
577 | if (!empty($off) && $values["Max(fMeanPedRmsInner)"]["off"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
|
---|
578 | printf("<li style='color:%s'>%s: one of your off-sequences has a PedRms larger than %s (%s)</li>",
|
---|
579 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["off"]);
|
---|
580 | if (!empty($off) && $values["Min(fMeanPedRmsInner)"]["off"]<$values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms)
|
---|
581 | printf("<li style='color:%s'>%s: one of your off-sequences has a PedRms smaller than %s (%s)</li>",
|
---|
582 | $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms, $values["Min(fMeanPedRmsInner)"]["off"]);
|
---|
583 | $scale=$values["Sum(fRunTime)/60"]["on"]/$values["Sum(fRunTime)/60"]["off"];
|
---|
584 | if ($scale > $scalelimit)
|
---|
585 | printf("<li style='color:%s'>%s: Your scale factor is larger than %s (%0.2f). Try to find more offdata!",
|
---|
586 | $color["WARN"], "WARN", $scalelimit, $scale);
|
---|
587 | /*
|
---|
588 | if (str_word_count($sourceson) > 1)
|
---|
589 | printf("<li style='color:%s'>%s: You have selected more than one (%s) on source",
|
---|
590 | $color["WARN"], "WARN", str_word_count($sourceson));
|
---|
591 | */
|
---|
592 | if ($numrealkeys>1)
|
---|
593 | {
|
---|
594 | printf("<li style='color:%s'>%s: You have selected more than one (%s) on source",
|
---|
595 | $color["ERROR"], "ERROR", $numrealkeays);
|
---|
596 | $numerr=$numerr+1;
|
---|
597 | }
|
---|
598 | if (empty($realsourcekey))
|
---|
599 | {
|
---|
600 | printf("<li style='color:%s'>%s: The source you selected doesn't have real sourceskeys yet.",
|
---|
601 | $color["ERROR"], "ERROR");
|
---|
602 | $numerr=$numerr+1;
|
---|
603 | }
|
---|
604 | if (empty($_POST["fObservationModeKEY"]))
|
---|
605 | {
|
---|
606 | printf("<li style='color:%s'>%s: You have to choose an observation mode.",
|
---|
607 | $color["ERROR"], "ERROR");
|
---|
608 | $numerr=$numerr+1;
|
---|
609 | }
|
---|
610 | if (empty($_POST["name"]))
|
---|
611 | {
|
---|
612 | printf("<li style='color:%s'>%s: You have to choose a name.",
|
---|
613 | $color["ERROR"], "ERROR");
|
---|
614 | $numerr=$numerr+1;
|
---|
615 | }
|
---|
616 | if (empty($_POST["comment"]))
|
---|
617 | {
|
---|
618 | printf("<li style='color:%s'>%s: You have to comment your dataset.",
|
---|
619 | $color["ERROR"], "ERROR");
|
---|
620 | $numerr=$numerr+1;
|
---|
621 | }
|
---|
622 | // printf("<li></li>");
|
---|
623 | printf("</ul></font>\n");
|
---|
624 |
|
---|
625 | printf("<div align='left'>");
|
---|
626 | printf("SequencesOn: %s<br>", $sequon);
|
---|
627 | printf("SequencesOff: %s<br>", $sequoff);
|
---|
628 | $insquery[0]="INSERT DataSets SET fDataSetNumber=" . $dataset;
|
---|
629 | $insquery[0].=", fComment='" . $_POST["comment"] . "', fObservationModeKEY=" . $_POST["fObservationModeKEY"];
|
---|
630 | $insquery[0].=", fDataSetName='" . $_POST["name"] . "', fSourceKEY= " . $realsourcekey;
|
---|
631 | $insquery[0].=", fRunStart='" . $values["Min(fRunStart)"]["on"];
|
---|
632 | $insquery[0].="', fRunStop='" . $values["Max(fRunStop)"]["on"];
|
---|
633 | $insquery[0].="', fZenithDistanceMin=" . $values["Min(fZenithDistanceMin)"]["on"];
|
---|
634 | $insquery[0].=", fZenithDistanceMax=" . $values["Max(fZenithDistanceMax)"]["on"];
|
---|
635 | $insquery[0].=", fRunTime=" . $values["Sum(fRunTime)/60"]["on"];
|
---|
636 | $insquery[1]="INSERT DataSetProcessStatus SET fDataSetNumber=" . $dataset . ", fDataSetInserted=Now()";
|
---|
637 | $i=2;
|
---|
638 | foreach(explode(" ", trim($sequon)) as $key => $sequ)
|
---|
639 | {
|
---|
640 | $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset;
|
---|
641 | $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=1";
|
---|
642 | $i=$i+1;
|
---|
643 | }
|
---|
644 | if (!empty($off))
|
---|
645 | {
|
---|
646 | foreach(explode(" ", trim($sequoff)) as $key => $sequ)
|
---|
647 | {
|
---|
648 | $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset;
|
---|
649 | $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=2";
|
---|
650 | $i=$i+1;
|
---|
651 | }
|
---|
652 | }
|
---|
653 | foreach($insquery as $num => $q)
|
---|
654 | {
|
---|
655 | if (!empty($_POST["insert"]) && $numerr==0)
|
---|
656 | {
|
---|
657 | $insresult=mysql_query($q);
|
---|
658 | printf("inserted query ");
|
---|
659 | printf("<br> result: <br>");
|
---|
660 | printf("errorno: %s <br>", mysql_errno());
|
---|
661 | printf("errormsg: %s <br>", mysql_error());
|
---|
662 | printf("info: %s <br>", mysql_info());
|
---|
663 | printf("affected rows: %s <br>", mysql_affected_rows());
|
---|
664 | mysql_free_result($insresult);
|
---|
665 | }
|
---|
666 | printf(" %s: %s<br>", $num, $q);
|
---|
667 | }
|
---|
668 | printf("</div>");
|
---|
669 | if (empty($_POST["name"]) && !empty($_GET["name"]))
|
---|
670 | $_POST["name"]=$_GET["name"];
|
---|
671 | if (empty($_POST["comment"]) && !empty($_GET["comment"]))
|
---|
672 | $_POST["comment"]=$_GET["comment"];
|
---|
673 | if (empty($_POST["fObservationModeKEY"]) && !empty($_GET["obsmode"]))
|
---|
674 | $_POST["fObservationModeKEY"]=$_GET["obsmode"];
|
---|
675 | printf("Name: <input name='name' type='text' size='10' maxlength='12' value='%s'><br>\n", $_POST["name"]);
|
---|
676 | printf("Comment: <input name='comment' type='text' size='20' maxlength='255' value='%s'><br>\n", $_POST["comment"]);
|
---|
677 |
|
---|
678 | $query = "SELECT fObservationModeKEY, fObservationModeName FROM ObservationMode ORDER BY fObservationModeName";
|
---|
679 | $result = mysql_query($query);
|
---|
680 | if (!$result)
|
---|
681 | printf("-N/A-");
|
---|
682 |
|
---|
683 | $numrows = mysql_num_rows($result);
|
---|
684 |
|
---|
685 | printf("ObservationMode <select name='fObservationModeKEY' size='1' class='Width'>\n");
|
---|
686 | while ($row = mysql_fetch_row($result))
|
---|
687 | {
|
---|
688 | if (!empty($_POST["fObservationModeKEY"]) && $_POST["fObservationModeKEY"]==$row[0])
|
---|
689 | printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]);
|
---|
690 | else
|
---|
691 | printf("<option value='%s'>%s</option>\n", $row[0], $row[1]);
|
---|
692 | }
|
---|
693 | printf("</select><br>\n");
|
---|
694 | mysql_free_result($result);
|
---|
695 |
|
---|
696 | printf("Remark: only datasets without errors can be inserted.<br>");
|
---|
697 | if ($numerr!=0)
|
---|
698 | printf("Your dataset has %s error(s).<br>", $numerr);
|
---|
699 | printf("<input type='checkbox' name='insert' value='On'>insert\n");
|
---|
700 |
|
---|
701 | printf("<table><tr><td colspan='2' align='center'>Dataset</td></tr>");
|
---|
702 | printf("<tr><td>proposed DataSet#: </td><td>%s</td></tr>", $dataset);
|
---|
703 | printf("<tr><td>SequencesOn:</td><td> %s</td></tr>", $sequon);
|
---|
704 | if (!empty($sequoff))
|
---|
705 | printf("<tr><td>SequencesOff:</td><td> %s</td></tr>", $sequoff);
|
---|
706 | printf("<tr><td>Scale: </td><td>%0.2f</td></tr>", $scale);
|
---|
707 | printf("<tr><td>SourcenamesOn[%s]: </td><td>%s</td></tr>", str_word_count($sourceson), $sourceson);
|
---|
708 | printf("<tr><td>SourcenamesOff[%s]: </td><td>%s</td></tr>", str_word_count($sourcesoff), $sourcesoff);
|
---|
709 | printf("</table>\n");
|
---|
710 |
|
---|
711 | printf("<table border='1'>\n");
|
---|
712 | printf("<tr><td>Value</td><td>On</td>");
|
---|
713 | if (!empty($off))
|
---|
714 | printf("<td>Off</td></tr>\n");
|
---|
715 | foreach($values as $name => $varname)
|
---|
716 | {
|
---|
717 | printf("<tr><td>%s</td>\n", $name);
|
---|
718 | foreach($vals as $num => $val)
|
---|
719 | if (!empty(${$val}))
|
---|
720 | printf("<td>%s</td>\n", $varname[$val]);
|
---|
721 | printf("</tr>\n");
|
---|
722 | }
|
---|
723 | printf("</table>\n");
|
---|
724 | }
|
---|
725 |
|
---|
726 | printf("</div>\n");
|
---|
727 | /*
|
---|
728 | printf("<table border='1'><tr>\n");
|
---|
729 | printf("<td>--</td>\n");
|
---|
730 | foreach($values as $name => $varname)
|
---|
731 | printf("<td>%s</td>\n", $name);
|
---|
732 | $vals=array("on", "off");
|
---|
733 | foreach($vals as $num => $val)
|
---|
734 | {
|
---|
735 | GetSequenceValues($db_id, ${$val}, $val, $values);
|
---|
736 | printf("</tr><tr>\n");
|
---|
737 | printf("<td>On</td>\n");
|
---|
738 | foreach($values as $name => $varname)
|
---|
739 | printf("<td>%s</td>\n", $varname[$val]);
|
---|
740 | }
|
---|
741 | printf("</tr></table>\n");
|
---|
742 | */
|
---|
743 |
|
---|
744 | printf("</center>\n");
|
---|
745 | printf("</td>\n");
|
---|
746 | printf("</tr>\n");
|
---|
747 |
|
---|
748 | printf("</form>\n");
|
---|
749 | }
|
---|
750 | else
|
---|
751 | PrintText($result0);
|
---|
752 |
|
---|
753 | mysql_free_result($result0);
|
---|
754 | }
|
---|
755 | mysql_close($db_id);
|
---|
756 |
|
---|
757 | PrintSubmittedQuery($query0, $html, $db, "");
|
---|
758 | }
|
---|
759 |
|
---|
760 | include ("include.php");
|
---|
761 | include ("menu.php");
|
---|
762 | include ("db.php");
|
---|
763 | include ("magicdefs.php");
|
---|
764 |
|
---|
765 | ini_set("display_errors", "On");
|
---|
766 | ini_set("mysql.trace_mode", "On");
|
---|
767 |
|
---|
768 | $sitepw="\$1\$ml/Gld67\$zOvhC4vFrLCkbAzQs2swo1";
|
---|
769 | $siteuser="dcdb";
|
---|
770 |
|
---|
771 | if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER']!=$siteuser)
|
---|
772 | {
|
---|
773 | header('WWW-Authenticate: Basic realm="My Realm"');
|
---|
774 | header('HTTP/1.0 401 Unauthorized');
|
---|
775 | echo 'Text to send if user hits Cancel button';
|
---|
776 | return;
|
---|
777 | }
|
---|
778 | else
|
---|
779 | {
|
---|
780 | // echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
|
---|
781 | // echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
|
---|
782 | // printf("pw: %s", crypt($_SERVER['PHP_AUTH_PW']));
|
---|
783 | if (crypt($_SERVER['PHP_AUTH_PW'], $sitepw)!=$sitepw || $_SERVER['PHP_AUTH_USER']!=$siteuser)
|
---|
784 | {
|
---|
785 | printf("<br>pw or user incorrect<br>");
|
---|
786 | return;
|
---|
787 | }
|
---|
788 | }
|
---|
789 |
|
---|
790 | if (!empty($_GET["fSendTxt"]))
|
---|
791 | {
|
---|
792 | header("Content-type: application/octet");
|
---|
793 | header("Content-Disposition: attachment; filename=query-result.txt");
|
---|
794 |
|
---|
795 | PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
---|
796 | }
|
---|
797 | else
|
---|
798 | {
|
---|
799 | echo (file_get_contents("index-header.html"));
|
---|
800 |
|
---|
801 | $environment = sizeof($_GET);
|
---|
802 |
|
---|
803 | InitGet($_GET);
|
---|
804 | if (empty($_GET["fPrintTable"]))
|
---|
805 | PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias);
|
---|
806 |
|
---|
807 | if ($environment==0)
|
---|
808 | printf("No query submitted yet.<BR>");
|
---|
809 | else
|
---|
810 | {
|
---|
811 | if (empty($_GET["fPrintTable"]))
|
---|
812 | PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
---|
813 | else
|
---|
814 | PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
---|
815 | }
|
---|
816 |
|
---|
817 | echo (file_get_contents("index-footer.html"));
|
---|
818 | }
|
---|
819 |
|
---|
820 | ini_set("display_errors", "Off");
|
---|
821 | ini_set("mysql.trace_mode", "Off");
|
---|
822 | }
|
---|
823 | ?>
|
---|