| 1 | <?php | 
|---|
| 2 | { | 
|---|
| 3 | function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup) | 
|---|
| 4 | { | 
|---|
| 5 | $fromtable="RunData"; | 
|---|
| 6 |  | 
|---|
| 7 | $groups = 0; | 
|---|
| 8 | foreach ($checkgroup as $element) | 
|---|
| 9 | if ($element==-1) | 
|---|
| 10 | $groups++; | 
|---|
| 11 |  | 
|---|
| 12 | $query0 = "SELECT "; | 
|---|
| 13 |  | 
|---|
| 14 | if ($groups>0) | 
|---|
| 15 | { | 
|---|
| 16 | foreach ($checkgroup as $key => $element) | 
|---|
| 17 | if ($element==-1) | 
|---|
| 18 | $query0 .=  $key . " as '" . $alias[$key] . "' " . ", "; | 
|---|
| 19 | //-------------------------------------------------- | 
|---|
| 20 | //$query0 .= " TIMEDIFF(fRunStop, fRunStart), "; | 
|---|
| 21 | // Only available in MySQL>4.1.1 | 
|---|
| 22 | $query0 .= "SUM(if(TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)<0, " . | 
|---|
| 23 | "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)+24*60*60, " . | 
|---|
| 24 | "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)))/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', "; | 
|---|
| 25 | //-------------------------------------------------- | 
|---|
| 26 | $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', "; | 
|---|
| 27 | $query0 .= " Min(fZenithDistance) as '" . $alias["Min(fZenithDistance)"] . "', "; | 
|---|
| 28 | $query0 .= " Max(fZenithDistance) as '" . $alias["Max(fZenithDistance)"] . "', "; | 
|---|
| 29 | $query0 .= " COUNT(*) as '# Runs' "; | 
|---|
| 30 | } | 
|---|
| 31 | else | 
|---|
| 32 | { | 
|---|
| 33 | $query0 .= " fRunNumber as 'Run#' "; | 
|---|
| 34 |  | 
|---|
| 35 | foreach ($_GET as $key => $element) | 
|---|
| 36 | if ($_GET[$key]=="On") | 
|---|
| 37 | if (empty($checkwhere[$key]) || $checkwhere[$key]==0) | 
|---|
| 38 | $query0 .= ", " . $key . " as '" . $alias[$key] . "' "; | 
|---|
| 39 | } | 
|---|
| 40 |  | 
|---|
| 41 | $query0 .= " FROM RunData "; | 
|---|
| 42 |  | 
|---|
| 43 | foreach ($_GET as $key => $element) | 
|---|
| 44 | if (($_GET[$key]=="On" || $groups>0))// && !empty($joins[$key])) | 
|---|
| 45 | $query0 .= GetJoin($fromtable, $key); | 
|---|
| 46 |  | 
|---|
| 47 | foreach ($checkwhere as $key => $element) | 
|---|
| 48 | { | 
|---|
| 49 | if (empty($element) || $element<=0) | 
|---|
| 50 | continue; | 
|---|
| 51 |  | 
|---|
| 52 | if (strpos($query0, " WHERE ")==FALSE) | 
|---|
| 53 | $query0 .= " WHERE "; | 
|---|
| 54 | else | 
|---|
| 55 | if ($element!=-1) | 
|---|
| 56 | if (strrpos($query0, " AND ")!=strlen($query0)-5)// this if clause doesn't work | 
|---|
| 57 | $query0 .= " AND "; | 
|---|
| 58 |  | 
|---|
| 59 | if ($element!=-1) | 
|---|
| 60 | $query0 .= GetCheck($fromtable, $key) . "=" . $element; | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | if (strpos($query0, " WHERE ")==FALSE) | 
|---|
| 64 | $query0 .= " WHERE "; | 
|---|
| 65 | else | 
|---|
| 66 | $query0 .= " AND "; | 
|---|
| 67 |  | 
|---|
| 68 | if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"])) | 
|---|
| 69 | $query0 .= "fRunNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " "; | 
|---|
| 70 |  | 
|---|
| 71 | /* | 
|---|
| 72 | if (!empty($_GET["fDate"])) | 
|---|
| 73 | $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" "; | 
|---|
| 74 | */ | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|
| 77 | if (!empty($_GET["fStartDate"])) | 
|---|
| 78 | { | 
|---|
| 79 | if (strpos(strrev($query0), " DNA ")!=0) | 
|---|
| 80 | $query0 .= " AND "; | 
|---|
| 81 |  | 
|---|
| 82 | $startdate=substr($_GET["fStartDate"], 0, 10); | 
|---|
| 83 | if ($startdate=="0000-00-00") | 
|---|
| 84 | $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' "; | 
|---|
| 85 | else | 
|---|
| 86 | $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) "; | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|
| 89 | if (!empty($_GET["fStopDate"])) | 
|---|
| 90 | { | 
|---|
| 91 | if (strpos(strrev($query0), " DNA ")!=0) | 
|---|
| 92 | $query0 .= " AND "; | 
|---|
| 93 |  | 
|---|
| 94 | $stopdate=substr($_GET["fStopDate"], 0, 10); | 
|---|
| 95 | $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' "; | 
|---|
| 96 | } | 
|---|
| 97 |  | 
|---|
| 98 | if (!empty($_GET["fSequenceNo"])) | 
|---|
| 99 | { | 
|---|
| 100 | if (strpos(strrev($query0), " DNA ")!=0) | 
|---|
| 101 | $query0 .= " AND "; | 
|---|
| 102 |  | 
|---|
| 103 | $query0 .= " fSequenceFirst = '" . $_GET["fSequenceNo"] . "' "; | 
|---|
| 104 | } | 
|---|
| 105 |  | 
|---|
| 106 |  | 
|---|
| 107 | if ($groups>0) | 
|---|
| 108 | { | 
|---|
| 109 | $query0 .= " GROUP BY "; | 
|---|
| 110 | $num = $groups; | 
|---|
| 111 | foreach ($checkgroup as $key => $element) | 
|---|
| 112 | if ($element==-1) | 
|---|
| 113 | { | 
|---|
| 114 | $query0 .= GetCheck($fromtable, $key); | 
|---|
| 115 | if ($num-->1) | 
|---|
| 116 | $query0 .= ", "; | 
|---|
| 117 | } | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | if (!empty($_GET["fSortBy"])) | 
|---|
| 121 | { | 
|---|
| 122 | $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " "; | 
|---|
| 123 | if (substr($_GET["fSortBy"], -1)=="-") | 
|---|
| 124 | $query0 .= "DESC"; | 
|---|
| 125 | } | 
|---|
| 126 |  | 
|---|
| 127 | if (empty($_GET["fNumStart"])) | 
|---|
| 128 | $_GET["fNumStart"]=0; | 
|---|
| 129 |  | 
|---|
| 130 | if (empty($_GET["fSendTxt"])) | 
|---|
| 131 | $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"]; | 
|---|
| 132 |  | 
|---|
| 133 | return $query0; | 
|---|
| 134 | } | 
|---|
| 135 |  | 
|---|
| 136 | function InitGet($_GET) | 
|---|
| 137 | { | 
|---|
| 138 | /* | 
|---|
| 139 | if (empty($_GET["fRawFileKEY"])) | 
|---|
| 140 | $_GET["fRawFileKEY"]="Off"; | 
|---|
| 141 | */ | 
|---|
| 142 |  | 
|---|
| 143 | // Find out whether it is the first call to the php script | 
|---|
| 144 | $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]); | 
|---|
| 145 |  | 
|---|
| 146 | if (empty($_GET["fNumResults"])) | 
|---|
| 147 | $_GET["fNumResults"]="20"; | 
|---|
| 148 |  | 
|---|
| 149 | if (empty($_GET["fLastUpdate"])) | 
|---|
| 150 | $_GET["fLastUpdate"]="Off"; | 
|---|
| 151 |  | 
|---|
| 152 | if (empty($_GET["fFormatVersion"])) | 
|---|
| 153 | $_GET["fFormatVersion"]="Off"; | 
|---|
| 154 |  | 
|---|
| 155 | if (empty($_GET["fNumEvents"])) | 
|---|
| 156 | $_GET["fNumEvents"]=$first?"On":""; | 
|---|
| 157 |  | 
|---|
| 158 | if (empty($_GET["fRunStart"])) | 
|---|
| 159 | $_GET["fRunStart"]=$first?"On":""; | 
|---|
| 160 |  | 
|---|
| 161 | if (empty($_GET["fRunStop"])) | 
|---|
| 162 | $_GET["fRunStop"]="Off"; | 
|---|
| 163 |  | 
|---|
| 164 | if (empty($_GET["fAzimuth"])) | 
|---|
| 165 | $_GET["fAzimuth"]="Off"; | 
|---|
| 166 |  | 
|---|
| 167 | if (empty($_GET["fZenithDistance"])) | 
|---|
| 168 | $_GET["fZenithDistance"]=$first?"On":""; | 
|---|
| 169 |  | 
|---|
| 170 | if (empty($_GET["fRunTypeName"])) | 
|---|
| 171 | $_GET["fRunTypeName"]=$first?"On":""; | 
|---|
| 172 |  | 
|---|
| 173 | if (empty($_GET["fMagicNumberName"])) | 
|---|
| 174 | $_GET["fMagicNumberName"]="Off"; | 
|---|
| 175 |  | 
|---|
| 176 | if (empty($_GET["fSourceName"])) | 
|---|
| 177 | $_GET["fSourceName"]=$first?"On":""; | 
|---|
| 178 |  | 
|---|
| 179 | if (empty($_GET["fProjectName"])) | 
|---|
| 180 | $_GET["fProjectName"]="Off"; | 
|---|
| 181 |  | 
|---|
| 182 | if (empty($_GET["fL1TriggerTableName"])) | 
|---|
| 183 | $_GET["fL1TriggerTableName"]="Off"; | 
|---|
| 184 |  | 
|---|
| 185 | if (empty($_GET["fL2TriggerTableName"])) | 
|---|
| 186 | $_GET["fL2TriggerTableName"]="Off"; | 
|---|
| 187 |  | 
|---|
| 188 | if (empty($_GET["fMeanTriggerRate"])) | 
|---|
| 189 | $_GET["fMeanTriggerRate"]=$first?"On":""; | 
|---|
| 190 |  | 
|---|
| 191 | if (empty($_GET["fHvSettingsName"])) | 
|---|
| 192 | $_GET["fHvSettingsName"]="Off"; | 
|---|
| 193 |  | 
|---|
| 194 | if (empty($_GET["fCalibrationScriptName"])) | 
|---|
| 195 | $_GET["fCalibrationScriptName"]="Off"; | 
|---|
| 196 |  | 
|---|
| 197 | if (empty($_GET["fDiscriminatorThresholdTableName"])) | 
|---|
| 198 | $_GET["fDiscriminatorThresholdTableName"]="Off"; | 
|---|
| 199 |  | 
|---|
| 200 | if (empty($_GET["fTriggerDelayTableName"])) | 
|---|
| 201 | $_GET["fTriggerDelayTableName"]="Off"; | 
|---|
| 202 |  | 
|---|
| 203 | if (empty($_GET["fLightConditionsName"])) | 
|---|
| 204 | $_GET["fLightConditionsName"]="Off"; | 
|---|
| 205 |  | 
|---|
| 206 | if (empty($_GET["fTestFlagName"])) | 
|---|
| 207 | $_GET["fTestFlagName"]="Off"; | 
|---|
| 208 |  | 
|---|
| 209 | if (empty($_GET["fDaqStoreRate"])) | 
|---|
| 210 | $_GET["fDaqStoreRate"]="Off"; | 
|---|
| 211 |  | 
|---|
| 212 | if (empty($_GET["fDaqTriggerRate"])) | 
|---|
| 213 | $_GET["fDaqTriggerRate"]="Off"; | 
|---|
| 214 |  | 
|---|
| 215 | if (empty($_GET["fL2RatePresc"])) | 
|---|
| 216 | $_GET["fL2RatePresc"]="Off"; | 
|---|
| 217 |  | 
|---|
| 218 | if (empty($_GET["fL2RateUnpresc"])) | 
|---|
| 219 | $_GET["fL2RateUnpresc"]="Off"; | 
|---|
| 220 |  | 
|---|
| 221 | if (empty($_GET["fExcludedFDAName"])) | 
|---|
| 222 | $_GET["fExcludedFDAName"]=$first?"On":""; | 
|---|
| 223 |  | 
|---|
| 224 | if (empty($_GET["fSequenceFirst"])) | 
|---|
| 225 | $_GET["fSequenceFirst"]="Off"; | 
|---|
| 226 | } | 
|---|
| 227 |  | 
|---|
| 228 | function PrintForm($_GET, $host, $user, $pw, $db) | 
|---|
| 229 | { | 
|---|
| 230 | printf("<center>\n"); | 
|---|
| 231 | printf("<form action=\"index.php\" METHOD=\"GET\">\n"); | 
|---|
| 232 | printf(" <table>\n"); | 
|---|
| 233 | printf("  <tr>\n"); | 
|---|
| 234 |  | 
|---|
| 235 | CheckBox("fRunStart",         "Run start time"); | 
|---|
| 236 | CheckBox("fL2RatePresc",      "L2 presc Rate"); | 
|---|
| 237 | CheckBox("fDaqStoreRate",     "DAQ Storage Rate"); | 
|---|
| 238 | CheckBox("fAzimuth",          "Azimuth"); | 
|---|
| 239 |  | 
|---|
| 240 | printf("  </tr><tr>\n"); | 
|---|
| 241 |  | 
|---|
| 242 | CheckBox("fRunStop",          "Run stop time"); | 
|---|
| 243 | CheckBox("fL2RateUnpresc",    "L2 unpresc Rate"); | 
|---|
| 244 | CheckBox("fDaqTriggerRate",   "DAQ Trigger Rate"); | 
|---|
| 245 | CheckBox("fZenithDistance",   "Zenith distance"); | 
|---|
| 246 |  | 
|---|
| 247 | printf("  </tr><tr>\n"); | 
|---|
| 248 |  | 
|---|
| 249 | CheckBox("fFormatVersion",    "File format"); | 
|---|
| 250 | CheckBox("fNumEvents",        "Num of events"); | 
|---|
| 251 | CheckBox("fMeanTriggerRate",  "Mean Trigger rate"); | 
|---|
| 252 | CheckBox("fSequenceFirst",    "Sequence Number"); | 
|---|
| 253 |  | 
|---|
| 254 | printf("  </tr>\n"); | 
|---|
| 255 | printf(" </table>\n"); | 
|---|
| 256 | printf(" <p>\n"); | 
|---|
| 257 |  | 
|---|
| 258 | // pull down boxes | 
|---|
| 259 |  | 
|---|
| 260 | printf(" <table>\n"); | 
|---|
| 261 | printf("  <tr><td>\n"); | 
|---|
| 262 | PrintPullDown($host, $user, $pw, $db, "RunType",     "fRunTypeName",     "fRunTypeKEY", "Run type"); | 
|---|
| 263 | printf("  </td><td>\n"); | 
|---|
| 264 | PrintPullDown($host, $user, $pw, $db, "Source",      "fSourceName",      "fSourceKEY", "Source Name"); | 
|---|
| 265 | printf("  </td><td>\n"); | 
|---|
| 266 | PrintPullDown($host, $user, $pw, $db, "HvSettings",  "fHvSettingsName",  "fHvSettingsKEY", "HV Settings"); | 
|---|
| 267 | printf("  </td><td>\n"); | 
|---|
| 268 | PrintPullDown($host, $user, $pw, $db, "L1TriggerTable", "fL1TriggerTableName", "fL1TriggerTableKEY", "L1 Trigger Table"); | 
|---|
| 269 | printf("  </td></tr><tr><td>\n"); | 
|---|
| 270 | PrintPullDown($host, $user, $pw, $db, "TestFlag",  "fTestFlagName",  "fTestFlagKEY", "Test Flag"); | 
|---|
| 271 | printf("  </td><td>\n"); | 
|---|
| 272 | PrintPullDown($host, $user, $pw, $db, "Project",     "fProjectName",     "fProjectKEY", "Project Name"); | 
|---|
| 273 | printf("  </td><td>\n"); | 
|---|
| 274 | PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable",  "fDiscriminatorThresholdTableName",  "fDiscriminatorThresholdTableKEY", "DT Table"); | 
|---|
| 275 | printf("  </td><td>\n"); | 
|---|
| 276 | PrintPullDown($host, $user, $pw, $db, "L2TriggerTable", "fL2TriggerTableName", "fL2TriggerTableKEY", "L2 Trigger Table"); | 
|---|
| 277 | printf("  </td></tr><tr><td>\n"); | 
|---|
| 278 | PrintPullDown($host, $user, $pw, $db, "ExcludedFDA", "fExcludedFDAName", "fExcludedFDAKEY", "Exclusions"); | 
|---|
| 279 | printf("  </td><td>\n"); | 
|---|
| 280 | PrintPullDown($host, $user, $pw, $db, "LightConditions",  "fLightConditionsName",  "fLightConditionsKEY", "Light Conditions"); | 
|---|
| 281 | printf("  </td><td>\n"); | 
|---|
| 282 | PrintPullDown($host, $user, $pw, $db, "CalibrationScript",  "fCalibrationScriptName",  "fCalibrationScriptKEY", "Cal Script"); | 
|---|
| 283 | printf("  </td><td>\n"); | 
|---|
| 284 | PrintPullDown($host, $user, $pw, $db, "TriggerDelayTable",  "fTriggerDelayTableName",  "fTriggerDelayTableKEY", "Trigger Delay Table"); | 
|---|
| 285 | printf("  </td></tr><tr><td>\n"); | 
|---|
| 286 | PrintPullDown($host, $user, $pw, $db, "MagicNumber", "fMagicNumberName", "fMagicNumberKEY", "Magic Number"); | 
|---|
| 287 | printf(" </td></tr></table>\n"); | 
|---|
| 288 | printf(" <p>\n"); | 
|---|
| 289 |  | 
|---|
| 290 | if (empty($_GET["fStartDate"])) | 
|---|
| 291 | $timemin = GetMin("fRunStart", "RunData", $host, $user, $pw, $db); | 
|---|
| 292 | else | 
|---|
| 293 | $timemin = $_GET["fStartDate"]; | 
|---|
| 294 |  | 
|---|
| 295 | if (empty($_GET["fStopDate"])) | 
|---|
| 296 | $timemax = GetMax("fRunStart", "RunData", $host, $user, $pw, $db); | 
|---|
| 297 | else | 
|---|
| 298 | $timemax = $_GET["fStopDate"]; | 
|---|
| 299 |  | 
|---|
| 300 | printf("Night (yyyy-mm-dd) from <input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin); | 
|---|
| 301 | printf("to <input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">    \n", $timemax); | 
|---|
| 302 |  | 
|---|
| 303 | /* | 
|---|
| 304 | printf("Date (yyyy-mm-dd) <input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\""); | 
|---|
| 305 | if (!empty($_GET["fDate"])) | 
|---|
| 306 | printf("%s", $_GET["fDate"]); | 
|---|
| 307 | printf("\">   \n"); | 
|---|
| 308 | */ | 
|---|
| 309 |  | 
|---|
| 310 | if (empty($_GET["fRunMin"])) | 
|---|
| 311 | $min = GetMin("fRunNumber", "RunData", $host, $user, $pw, $db); | 
|---|
| 312 | else | 
|---|
| 313 | $min = $_GET["fRunMin"]; | 
|---|
| 314 |  | 
|---|
| 315 | if (empty($_GET["fRunMax"])) | 
|---|
| 316 | $max = GetMax("fRunNumber", "RunData", $host, $user, $pw, $db); | 
|---|
| 317 | else | 
|---|
| 318 | $max = $_GET["fRunMax"]; | 
|---|
| 319 |  | 
|---|
| 320 | printf("Runs from <input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min); | 
|---|
| 321 | printf("to <input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">   \n", $max); | 
|---|
| 322 |  | 
|---|
| 323 | printf(" <P>\n"); | 
|---|
| 324 |  | 
|---|
| 325 | printf("Sequ# <input name=\"fSequenceNo\" type=\"text\" size=\"6\" maxlength=\"6\" value=\""); | 
|---|
| 326 | if (!empty($_GET["fSequenceNo"])) | 
|---|
| 327 | printf("%s", $_GET["fSequenceNo"]); | 
|---|
| 328 | printf("\">   \n"); | 
|---|
| 329 |  | 
|---|
| 330 | printf(" Results:\n"); | 
|---|
| 331 | printf(" <select name=\"fNumResults\">\n"); | 
|---|
| 332 |  | 
|---|
| 333 | $numres = array("10", "20", "50", "100", "200", "500", "1000", "2000"); | 
|---|
| 334 | foreach ($numres as $element) | 
|---|
| 335 | { | 
|---|
| 336 | if ($element==$_GET["fNumResults"]) | 
|---|
| 337 | printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element); | 
|---|
| 338 | else | 
|---|
| 339 | printf("<option value=\"%s\">%3s</option>\n", $element, $element); | 
|---|
| 340 | } | 
|---|
| 341 | printf(" </select>\n"); | 
|---|
| 342 | printf("    \n"); | 
|---|
| 343 |  | 
|---|
| 344 | ini_set("mysql.trace_mode", "Off"); | 
|---|
| 345 | ini_set("display_errors", "Off"); | 
|---|
| 346 |  | 
|---|
| 347 | printf("<input class='Width' type='submit' value='Query Table'>   \n"); | 
|---|
| 348 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"index.php\"'>   \n"); | 
|---|
| 349 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE) | 
|---|
| 350 | printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>   \n", $_SERVER["REQUEST_URI"]); | 
|---|
| 351 | printf("</form>\n"); | 
|---|
| 352 | printf("</center>\n"); | 
|---|
| 353 | printf("</td>\n"); | 
|---|
| 354 | printf("</tr>\n"); | 
|---|
| 355 | printf("<tr class='Block'>\n"); | 
|---|
| 356 | printf("<td>\n"); | 
|---|
| 357 | } | 
|---|
| 358 |  | 
|---|
| 359 | function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup) | 
|---|
| 360 | { | 
|---|
| 361 | $db_id = mysql_connect($host, $user, $pw); | 
|---|
| 362 | if ($db_id==FALSE) | 
|---|
| 363 | { | 
|---|
| 364 | printf("mysql_connect returned the following error: %s\n", mysql_error()); | 
|---|
| 365 | die(""); | 
|---|
| 366 | } | 
|---|
| 367 | mysql_select_db($db); | 
|---|
| 368 | mysql_query("SET BIG_TABLES=1"); // necessary for mySQL <= 4 | 
|---|
| 369 |  | 
|---|
| 370 |  | 
|---|
| 371 | $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup); | 
|---|
| 372 |  | 
|---|
| 373 | $result0 = mysql_query($query0, $db_id); | 
|---|
| 374 |  | 
|---|
| 375 | if ($result0) | 
|---|
| 376 | { | 
|---|
| 377 | if ($html=="1") | 
|---|
| 378 | PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET); | 
|---|
| 379 | else | 
|---|
| 380 | PrintText($result0); | 
|---|
| 381 |  | 
|---|
| 382 | mysql_free_result($result0); | 
|---|
| 383 | } | 
|---|
| 384 | mysql_close($db_id); | 
|---|
| 385 |  | 
|---|
| 386 | PrintSubmittedQuery($query0, $html, $db, "old"); | 
|---|
| 387 | } | 
|---|
| 388 |  | 
|---|
| 389 | include ("include.php"); | 
|---|
| 390 | include ("db.php"); | 
|---|
| 391 | include ("magicdefs.php"); | 
|---|
| 392 |  | 
|---|
| 393 | ini_set("display_errors",   "On"); | 
|---|
| 394 | ini_set("mysql.trace_mode", "On"); | 
|---|
| 395 |  | 
|---|
| 396 | if (!empty($_GET["fSendTxt"])) | 
|---|
| 397 | { | 
|---|
| 398 | header("Content-type: application/octet"); | 
|---|
| 399 | header("Content-Disposition: attachment; filename=query-result.txt"); | 
|---|
| 400 |  | 
|---|
| 401 | PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup); | 
|---|
| 402 | } | 
|---|
| 403 | else | 
|---|
| 404 | { | 
|---|
| 405 | echo (file_get_contents("index-header.html")); | 
|---|
| 406 |  | 
|---|
| 407 | $environment = sizeof($_GET); | 
|---|
| 408 |  | 
|---|
| 409 | InitGet($_GET); | 
|---|
| 410 | PrintForm($_GET, $host, $user, $pw, $db); | 
|---|
| 411 |  | 
|---|
| 412 | if ($environment==0) | 
|---|
| 413 | printf("No query submitted yet.<BR>"); | 
|---|
| 414 | else | 
|---|
| 415 | PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup); | 
|---|
| 416 |  | 
|---|
| 417 | echo (file_get_contents("index-footer.html")); | 
|---|
| 418 | } | 
|---|
| 419 |  | 
|---|
| 420 | ini_set("display_errors",   "Off"); | 
|---|
| 421 | ini_set("mysql.trace_mode", "Off"); | 
|---|
| 422 | } | 
|---|
| 423 | ?> | 
|---|