| 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 | if (!empty($_GET["fSendTxt"]))
|
|---|
| 47 | $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
|
|---|
| 48 | else
|
|---|
| 49 | {
|
|---|
| 50 | //old version using fRunMin, fRunMax
|
|---|
| 51 | //$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\">', Sequences.fSequenceFirst, '</A>') ";
|
|---|
| 52 | //new version using fSequenceNo
|
|---|
| 53 | $query0 .= " CONCAT('<A&ws;HREF=\"runinfo-aio.php?', 'fRunStart=On', '&fZenithDistance=On', '&fSequenceNo=', Sequences.fSequenceFirst, '&fMeanTriggerRate=On', '&fTest=On', '&fRunTypeName=On', '&fNumEvents=On', '&fSourceName=On&', 'fExcludedFDAKEY=1', '&fSequenceFirst=On', '&fRawFileAvail=On', '&fCCFileAvail=On', '&fCaCoFileAvail=On', '&fNumResults=500\">', Sequences.fSequenceFirst, '</A>') ";
|
|---|
| 54 | $query0 .= " as " . $alias["fSequenceFirst"];
|
|---|
| 55 | if (!empty($_GET["fLinks"]))
|
|---|
| 56 | {
|
|---|
| 57 | $query0 .= ", CONCAT('<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>'";
|
|---|
| 58 | $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>'";
|
|---|
| 59 | $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>'";
|
|---|
| 60 | $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>'";
|
|---|
| 61 | $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>' ";
|
|---|
| 62 | $query0 .= ", ' <A&ws;HREF=\"sequence.php?fSequenceNo=', Sequences.fSequenceFirst , '&fAll=On\">i</A>'";
|
|---|
| 63 | $query0 .= ", ' <A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&fDate=2\">rbk</A>') ";
|
|---|
| 64 | $query0 .= " as 'Links'";
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | foreach ($_GET as $key => $element)
|
|---|
| 69 | if ($_GET[$key]=="On")
|
|---|
| 70 | if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff")
|
|---|
| 71 | if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
|
|---|
| 72 | $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
|
|---|
| 73 | }
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | $query0 .= " FROM " . $fromtable;
|
|---|
| 77 |
|
|---|
| 78 | $query0 .= " LEFT JOIN SequenceProcessStatus ON Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst ";
|
|---|
| 79 | $query0 .= " LEFT JOIN Calibration ON Sequences.fSequenceFirst=Calibration.fSequenceFirst ";
|
|---|
| 80 | $query0 .= " LEFT JOIN Star ON Sequences.fSequenceFirst=Star.fSequenceFirst ";
|
|---|
| 81 |
|
|---|
| 82 | foreach ($_GET as $key => $element)
|
|---|
| 83 | if (($_GET[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key)))
|
|---|
| 84 | $query0 .= GetJoin($fromtable,$key);
|
|---|
| 85 |
|
|---|
| 86 | if ($_GET["fTest"]!="On")
|
|---|
| 87 | {
|
|---|
| 88 | if ($_GET["fSourceName"]!="On")
|
|---|
| 89 | $query0 .= " LEFT JOIN Source ON Sequences.fSourceKEY=Source.fSourceKEY ";
|
|---|
| 90 | $query0 .= " WHERE fTest='no'";
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | if ($_GET["fOff"]=="Off")
|
|---|
| 94 | {
|
|---|
| 95 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 96 | $query0 .= " WHERE ";
|
|---|
| 97 | else
|
|---|
| 98 | $query0 .= " AND ";
|
|---|
| 99 |
|
|---|
| 100 | $query0 .= " NOT (fSourceName like '%Off%')";
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | if ($_GET["fOnlyOff"]=="On")
|
|---|
| 104 | {
|
|---|
| 105 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 106 | $query0 .= " WHERE ";
|
|---|
| 107 | else
|
|---|
| 108 | $query0 .= " AND ";
|
|---|
| 109 |
|
|---|
| 110 | $query0 .= " fSourceName like '%Off%'";
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | foreach ($checkwhere as $key => $element)
|
|---|
| 114 | {
|
|---|
| 115 | if (empty($element) || $element<=0)
|
|---|
| 116 | continue;
|
|---|
| 117 |
|
|---|
| 118 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 119 | $query0 .= " WHERE ";
|
|---|
| 120 | else
|
|---|
| 121 | if ($element!=-1)
|
|---|
| 122 | if (strrpos($query0, " AND ")!=strlen($query0)-5)
|
|---|
| 123 | $query0 .= " AND ";
|
|---|
| 124 |
|
|---|
| 125 | if ($element!=-1)
|
|---|
| 126 | $query0 .= GetCheck($fromtable, $key) . "=" . $element;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 130 | $query0 .= " WHERE ";
|
|---|
| 131 | else
|
|---|
| 132 | $query0 .= " AND ";
|
|---|
| 133 |
|
|---|
| 134 | $query0 .= StatusQuery("fSequenceFileWritten", $needs);
|
|---|
| 135 | $query0 .= StatusQuery("fAllFilesAvail", $needs);
|
|---|
| 136 | $query0 .= StatusQuery("fCallisto", $needs);
|
|---|
| 137 | $query0 .= StatusQuery("fFillCallisto", $needs);
|
|---|
| 138 | $query0 .= StatusQuery("fStar", $needs);
|
|---|
| 139 | $query0 .= StatusQuery("fFillStar", $needs);
|
|---|
| 140 |
|
|---|
| 141 | if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
|
|---|
| 142 | $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
|
|---|
| 143 | else
|
|---|
| 144 | $query0 = substr($query0, 0, -4);
|
|---|
| 145 |
|
|---|
| 146 | if ((!empty($_GET["fZDMin"]) || $_GET["fZDMin"]==0) && !empty($_GET["fZDMax"]))
|
|---|
| 147 | $query0 .= "AND (fZenithDistanceMin >= " . $_GET["fZDMin"] . " AND fZenithDistanceMax <= " . $_GET["fZDMax"] . ") ";
|
|---|
| 148 |
|
|---|
| 149 | if (!empty($_GET["fSourceN"]))
|
|---|
| 150 | $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
|
|---|
| 151 |
|
|---|
| 152 | if (!empty($_GET["fStartDate"]))
|
|---|
| 153 | {
|
|---|
| 154 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
|---|
| 155 | $query0 .= " AND ";
|
|---|
| 156 |
|
|---|
| 157 | $startdate=substr($_GET["fStartDate"], 0, 10);
|
|---|
| 158 | if ($startdate=="0000-00-00")
|
|---|
| 159 | $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
|
|---|
| 160 | else
|
|---|
| 161 | $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | if (!empty($_GET["fStopDate"]))
|
|---|
| 165 | {
|
|---|
| 166 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
|---|
| 167 | $query0 .= " AND ";
|
|---|
| 168 |
|
|---|
| 169 | $stopdate=substr($_GET["fStopDate"], 0, 10);
|
|---|
| 170 | $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | if (!empty($_GET["fStarStart"]))
|
|---|
| 174 | {
|
|---|
| 175 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
|---|
| 176 | $query0 .= " AND ";
|
|---|
| 177 |
|
|---|
| 178 | $starstart=substr($_GET["fStarStart"], 0, 10);
|
|---|
| 179 | $query0 .=" fStar >= '" . $starstart . " 00:00:00' ";
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | if (!empty($_GET["fStarStop"]))
|
|---|
| 183 | {
|
|---|
| 184 | if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
|
|---|
| 185 | $query0 .= " AND ";
|
|---|
| 186 |
|
|---|
| 187 | $starstop=substr($_GET["fStarStop"], 0, 10);
|
|---|
| 188 | $query0 .= " fStar < '" . $starstop . " 23:59:59' ";
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | if ($groups>0)
|
|---|
| 192 | {
|
|---|
| 193 | $query0 .= " GROUP BY ";
|
|---|
| 194 | $num = $groups;
|
|---|
| 195 | foreach ($checkgroup as $key => $element)
|
|---|
| 196 | if ($element==-1)
|
|---|
| 197 | {
|
|---|
| 198 | $query0 .= GetCheck($fromtable,$key);
|
|---|
| 199 | if ($num-->1)
|
|---|
| 200 | $query0 .= ", ";
|
|---|
| 201 | }
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | if ($statusgroups>0)
|
|---|
| 205 | {
|
|---|
| 206 | $query0 .= " GROUP BY ";
|
|---|
| 207 | $num = $statusgroups;
|
|---|
| 208 | foreach ($checkstatusgroup as $key => $element)
|
|---|
| 209 | if ($element==-1)
|
|---|
| 210 | {
|
|---|
| 211 | $query0 .= $alias[$key];
|
|---|
| 212 | if ($num-->1)
|
|---|
| 213 | $query0 .= ", ";
|
|---|
| 214 | }
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | if (!empty($_GET["fSortBy"]))
|
|---|
| 218 | {
|
|---|
| 219 | $val=substr($_GET["fSortBy"], 0, -1);
|
|---|
| 220 | $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
|
|---|
| 221 | if (substr($_GET["fSortBy"], -1)=="-")
|
|---|
| 222 | $query0 .= "DESC";
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
|
|---|
| 226 | $query0 .= "ORDER BY Sequences.fSequenceFirst ASC ";
|
|---|
| 227 |
|
|---|
| 228 | if (empty($_GET["fNumStart"]))
|
|---|
| 229 | $_GET["fNumStart"]=0;
|
|---|
| 230 |
|
|---|
| 231 | if (empty($_GET["fSendTxt"]))
|
|---|
| 232 | $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
|
|---|
| 233 |
|
|---|
| 234 | return $query0;
|
|---|
| 235 | }
|
|---|
| 236 |
|
|---|
| 237 | function InitGet($_GET)
|
|---|
| 238 | {
|
|---|
| 239 | // Find out whether it is the first call to the php script
|
|---|
| 240 | $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
|
|---|
| 241 |
|
|---|
| 242 | if (empty($_GET["fNumResults"]))
|
|---|
| 243 | $_GET["fNumResults"]="50";
|
|---|
| 244 |
|
|---|
| 245 | if (empty($_GET["fRunStart"]))
|
|---|
| 246 | $_GET["fRunStart"]=$first?"On":"";
|
|---|
| 247 |
|
|---|
| 248 | if (empty($_GET["fRunTime/60"]))
|
|---|
| 249 | $_GET["fRunTime/60"]=$first?"On":"";
|
|---|
| 250 |
|
|---|
| 251 | if (empty($_GET["fZenithDistanceMin"]))
|
|---|
| 252 | $_GET["fZenithDistanceMin"]=$first?"On":"";
|
|---|
| 253 |
|
|---|
| 254 | if (empty($_GET["fSourceName"]))
|
|---|
| 255 | $_GET["fSourceName"]=$first?"On":"";
|
|---|
| 256 |
|
|---|
| 257 | if (empty($_GET["fStar"]))
|
|---|
| 258 | $_GET["fStar"]=$first?"On":"";
|
|---|
| 259 |
|
|---|
| 260 | if (empty($_GET["fInhomogeneity"]))
|
|---|
| 261 | $_GET["fInhomogeneity"]=$first?"On":"";
|
|---|
| 262 |
|
|---|
| 263 | if (empty($_GET["fPSF"]))
|
|---|
| 264 | $_GET["fPSF"]=$first?"On":"";
|
|---|
| 265 |
|
|---|
| 266 | if (empty($_GET["fMeanPedRmsInner"]))
|
|---|
| 267 | $_GET["fMeanPedRmsInner"]=$first?"On":"";
|
|---|
| 268 |
|
|---|
| 269 | if (empty($_GET["fOff"]))
|
|---|
| 270 | $_GET["fOff"]=$first?"On":"";
|
|---|
| 271 |
|
|---|
| 272 | if (empty($_GET["fLinks"]))
|
|---|
| 273 | $_GET["fLinks"]=$first?"On":"";
|
|---|
| 274 |
|
|---|
| 275 | if (empty($_GET["fOnlyOff"]))
|
|---|
| 276 | $_GET["fOnlyOff"]=$first?"Off":"";
|
|---|
| 277 |
|
|---|
| 278 | InitFindOffData($_GET, $first);
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | function PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias)
|
|---|
| 282 | {
|
|---|
| 283 | printf("<center>\n");
|
|---|
| 284 | printf("<form action='sequinfo-aio.php' METHOD='GET'>\n");
|
|---|
| 285 | printf("<input id='sh' type='hidden' name='fShowHide' value='");
|
|---|
| 286 | if (!empty($_GET["fShowHide"]))
|
|---|
| 287 | printf("%s", $_GET["fShowHide"]);
|
|---|
| 288 | else
|
|---|
| 289 | printf("1000000010");
|
|---|
| 290 | printf("'>\n");
|
|---|
| 291 | printf("<img id='allbutton' src='minus.png' alt='-' onclick='showhide(\"all\")'> <b>Menu</b> \n");
|
|---|
| 292 | printf(" <img id='infobutton' src='plus.png' alt='+' onClick='showhide(\"info\");showhide(\"info2\")'> SequInfo \n");
|
|---|
| 293 | printf(" <img id='statbutton' src='plus.png' alt='+' onClick='showhide(\"stat\");showhide(\"fail\")'> StatusInfo \n");
|
|---|
| 294 | printf(" <img id='calbutton' src='plus.png' alt='+' onClick='showhide(\"cal\")'> CalInfo \n");
|
|---|
| 295 | printf(" <img id='starbutton' src='plus.png' alt='+' onClick='showhide(\"star\")'> StarInfo \n");
|
|---|
| 296 | printf(" <img id='limitsbutton' src='plus.png' alt='+' onClick='showhide(\"limits\")'> Limits \n");
|
|---|
| 297 | printf(" <img id='rangesbutton' src='minus.png' alt='-' onClick='showhide(\"ranges\")'> Ranges \n");
|
|---|
| 298 |
|
|---|
| 299 | printf(" <div id='all' style='display:block'>");
|
|---|
| 300 |
|
|---|
| 301 | PrintSequInfoMenu();
|
|---|
| 302 | PrintSequInfo2Menu($host,$user,$pw,$db);
|
|---|
| 303 | PrintSequStatMenu();
|
|---|
| 304 | PrintFailMenu();
|
|---|
| 305 | PrintCalMenu();
|
|---|
| 306 | PrintStarMenu();
|
|---|
| 307 | PrintLimitsMenu($limitsmean, $limitsmin, $limitsmax, $alias, "");
|
|---|
| 308 |
|
|---|
| 309 | printf(" <div id='ranges' style='display:block'>");
|
|---|
| 310 | PrintZdRangeMenu($host,$user,$pw,$db);
|
|---|
| 311 | PrintSequRangeMenu($host,$user,$pw,$db);
|
|---|
| 312 | printf("<p>");
|
|---|
| 313 | PrintSourceMenu($host,$user,$pw,$db);
|
|---|
| 314 | PrintNightRangeMenu($host,$user,$pw,$db, "Sequences");
|
|---|
| 315 | printf("<p>");
|
|---|
| 316 | printf("</div>");
|
|---|
| 317 |
|
|---|
| 318 | printf("</div>");
|
|---|
| 319 | printf(" <P>\n");
|
|---|
| 320 |
|
|---|
| 321 | PrintNumResPullDown();
|
|---|
| 322 |
|
|---|
| 323 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 324 | ini_set("display_errors", "Off");
|
|---|
| 325 |
|
|---|
| 326 | PrintButtons("sequinfo-aio.php");
|
|---|
| 327 |
|
|---|
| 328 | printf("</form>\n");
|
|---|
| 329 | printf("</center>\n");
|
|---|
| 330 | printf("</td>\n");
|
|---|
| 331 | printf("</tr>\n");
|
|---|
| 332 | printf("<tr class='Block'>\n");
|
|---|
| 333 | printf("<td>\n");
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs)
|
|---|
| 337 | {
|
|---|
| 338 | $db_id = mysql_pconnect($host, $user, $pw);
|
|---|
| 339 | if ($db_id==FALSE)
|
|---|
| 340 | {
|
|---|
| 341 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
|---|
| 342 | die("");
|
|---|
| 343 | }
|
|---|
| 344 | mysql_select_db($db);
|
|---|
| 345 |
|
|---|
| 346 | $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
|
|---|
| 347 |
|
|---|
| 348 | $result0 = mysql_query($query0, $db_id);
|
|---|
| 349 |
|
|---|
| 350 | if ($result0)
|
|---|
| 351 | {
|
|---|
| 352 | if ($html=="1" || $html=="2")
|
|---|
| 353 | PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, "", $_GET);
|
|---|
| 354 | else
|
|---|
| 355 | PrintText($result0);
|
|---|
| 356 |
|
|---|
| 357 | mysql_free_result($result0);
|
|---|
| 358 | }
|
|---|
| 359 | mysql_close($db_id);
|
|---|
| 360 |
|
|---|
| 361 | PrintSubmittedQuery($query0, $html, $db, "");
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | include ("include.php");
|
|---|
| 365 | include ("menu.php");
|
|---|
| 366 | include ("db.php");
|
|---|
| 367 | include ("magicdefs.php");
|
|---|
| 368 |
|
|---|
| 369 | ini_set("display_errors", "On");
|
|---|
| 370 | ini_set("mysql.trace_mode", "On");
|
|---|
| 371 |
|
|---|
| 372 | if (!empty($_GET["fSendTxt"]))
|
|---|
| 373 | {
|
|---|
| 374 | header("Content-type: application/octet");
|
|---|
| 375 | header("Content-Disposition: attachment; filename=query-result.txt");
|
|---|
| 376 |
|
|---|
| 377 | PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
|---|
| 378 | }
|
|---|
| 379 | else
|
|---|
| 380 | {
|
|---|
| 381 | if (empty($_GET["fPrintTable"]))
|
|---|
| 382 | echo (file_get_contents("index-header.html"));
|
|---|
| 383 |
|
|---|
| 384 | $environment = sizeof($_GET);
|
|---|
| 385 |
|
|---|
| 386 | InitGet($_GET);
|
|---|
| 387 | if (empty($_GET["fPrintTable"]))
|
|---|
| 388 | PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias);
|
|---|
| 389 |
|
|---|
| 390 | if ($environment==0)
|
|---|
| 391 | printf("No query submitted yet.<BR>");
|
|---|
| 392 | else
|
|---|
| 393 | {
|
|---|
| 394 | if (empty($_GET["fPrintTable"]))
|
|---|
| 395 | PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
|---|
| 396 | else
|
|---|
| 397 | PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | if (empty($_GET["fPrintTable"]))
|
|---|
| 401 | echo (file_get_contents("index-footer.html"));
|
|---|
| 402 | }
|
|---|
| 403 |
|
|---|
| 404 | ini_set("display_errors", "Off");
|
|---|
| 405 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 406 | }
|
|---|
| 407 | ?>
|
|---|