Changeset 9498 for trunk/MagicSoft/Mars/datacenter/db
- Timestamp:
- 08/20/09 14:43:59 (15 years ago)
- Location:
- trunk/MagicSoft/Mars/datacenter/db
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/db/builddatasets.php
r9486 r9498 1 1 <?php 2 { 3 function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs) 2 3 function PrintDataSetFile() 4 { 5 printf("AnalysisNumber: 1\n\n"); 6 printf("SeqencesOn: %s \n", $_SESSION["sequon"]); 7 if ($_SESSION["sequoff"]!=" ") 8 printf("SeqencesOff: %s \n\n", $_SESSION["sequoff"]); 9 else 10 printf("\n"); 11 12 printf("SourceName: %s \n", $_SESSION["realsourcename"]); 13 printf("Catalog: /magic/datacenter/setup/magic_favorites_dc.edb \n"); 14 if ($_SESSION["sequoff"]==" ") 15 printf("WobbleMode: On \n\n"); 16 printf("RunTime: %s \n", $_SESSION["runtime"]); 17 printf("Name: %s \n", $_SESSION["name"]); 18 printf("Comment: %s \n", $_SESSION["comment"]); 19 } 20 21 function CreateQuery($alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs) 4 22 { 5 23 $fromtable="Sequences"; … … 15 33 $statusgroups++; 16 34 17 $query0 = "SELECT ";35 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 36 19 37 if ($groups>0) … … 37 55 if ($element==-1) 38 56 $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 57 41 58 $query0 .= " COUNT(*) as '# Sequ'"; … … 45 62 { 46 63 $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' "; 47 if (!empty($_ GET["fLinks"]))64 if (!empty($_SESSION["fLinks"])) 48 65 { 49 66 $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 // 67 //$query0 .= " as " . $alias["fSequenceFirst"]; 51 68 $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 69 $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>'"; … … 58 75 } 59 76 60 foreach ($_ GETas $key => $element)61 if ($_ GET[$key]=="On")77 foreach ($_SESSION as $key => $element) 78 if ($_SESSION[$key]=="On") 62 79 if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff") 63 if (empty($checkwhere[$key]) || $checkwhere[$key]==0) 64 $query0 .= ", " . $key . " as '" . $alias[$key] . "' "; 80 if (!(ereg("^[0-9]*ON$", $key) || ereg("^[0-9]*Off$", $key))) 81 if (empty($checkwhere[$key]) || $checkwhere[$key]==0) 82 $query0 .= ", " . $key . " as '" . $alias[$key] . "' "; 65 83 } 66 84 } … … 72 90 $query0 .= " LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) "; 73 91 74 foreach ($_ GETas $key => $element)75 if (($_ GET[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key)))92 foreach ($_SESSION as $key => $element) 93 if (($_SESSION[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key))) 76 94 $query0 .= GetJoin($fromtable,$key); 77 95 78 if ($_GET["fTest"]!="On") 79 { 80 if ($_GET["fSourceName"]!="On") 81 $query0 .= " LEFT JOIN Source USING(fSourceKEY) "; 82 $query0 .= " WHERE fTest='no'"; 83 } 84 85 if ($_GET["fOff"]=="Off") 86 { 96 if ($_SESSION["DisplaySelected"]!="yes" || ($_SESSION["sequon"]==" " && $_SESSION["sequoff"]==" ")) 97 { 98 if ($_SESSION["fTest"]!="On") 99 { 100 if ($_SESSION["fSourceName"]!="On") 101 $query0 .= " LEFT JOIN Source USING(fSourceKEY) "; 102 $query0 .= " WHERE fTest='no'"; 103 } 104 105 if ($_SESSION["fOff"]=="Off") 106 { 107 if (strpos($query0, " WHERE ")==FALSE) 108 $query0 .= " WHERE "; 109 else 110 $query0 .= " AND "; 111 112 $query0 .= " NOT (fSourceName like '%Off%')"; 113 } 114 115 if ($_SESSION["fOnlyOff"]=="On") 116 { 117 if (strpos($query0, " WHERE ")==FALSE) 118 $query0 .= " WHERE "; 119 else 120 $query0 .= " AND "; 121 122 $query0 .= " fSourceName like '%Off%'"; 123 } 124 125 foreach ($checkwhere as $key => $element) 126 { 127 if (empty($element) || $element<=0) 128 continue; 129 130 if (strpos($query0, " WHERE ")==FALSE) 131 $query0 .= " WHERE "; 132 else 133 if ($element!=-1) 134 if (strrpos($query0, " AND ")!=strlen($query0)-5) 135 $query0 .= " AND "; 136 137 if ($element!=-1) 138 $query0 .= GetCheck($fromtable, $key) . "=" . $element; 139 } 140 87 141 if (strpos($query0, " WHERE ")==FALSE) 88 142 $query0 .= " WHERE "; … … 90 144 $query0 .= " AND "; 91 145 92 $query0 .= " NOT (fSourceName like '%Off%')"; 93 } 94 95 if ($_GET["fOnlyOff"]=="On") 96 { 97 if (strpos($query0, " WHERE ")==FALSE) 98 $query0 .= " WHERE "; 146 $query0 .= StatusQuery("fSequenceFileWritten", $needs, $timelimits); 147 $query0 .= StatusQuery("fAllFilesAvail", $needs, $timelimits); 148 $query0 .= StatusQuery("fCallisto", $needs, $timelimits); 149 $query0 .= StatusQuery("fFillCallisto", $needs, $timelimits); 150 $query0 .= StatusQuery("fStar", $needs, $timelimits); 151 $query0 .= StatusQuery("fFillStar", $needs, $timelimits); 152 153 if (!empty($_SESSION["fRunMin"]) && !empty($_SESSION["fRunMax"])) 154 $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_SESSION["fRunMin"] . " AND " . $_SESSION["fRunMax"] . " "; 99 155 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 "; 156 $query0 = substr($query0, 0, -4); 157 158 if ((!empty($_SESSION["fZDMin"]) || $_SESSION["fZDMin"]==0) && !empty($_SESSION["fZDMax"])) 159 $query0 .= "AND (fZenithDistanceMin >= " . $_SESSION["fZDMin"] . " AND fZenithDistanceMax <= " . $_SESSION["fZDMax"] . ") "; 160 161 if (!empty($_SESSION["fSourceN"])) 162 $query0 .= " AND fSourceName REGEXP \"^" . $_SESSION["fSourceN"] . "\" "; 163 164 if (!empty($_SESSION["fStartDate"])) 165 { 166 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) 167 $query0 .= " AND "; 168 169 $startdate=substr($_SESSION["fStartDate"], 0, 10); 170 if ($startdate=="0000-00-00") 171 $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' "; 172 else 173 $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) "; 174 } 175 176 if (!empty($_SESSION["fStopDate"])) 177 { 178 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) 179 $query0 .= " AND "; 180 181 $stopdate=substr($_SESSION["fStopDate"], 0, 10); 182 $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' "; 183 } 184 185 if (!empty($_SESSION["fStarStart"])) 186 { 187 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) 188 $query0 .= " AND "; 189 190 $starstart=substr($_SESSION["fStarStart"], 0, 10); 191 $query0 .=" fStar >= '" . $starstart . " 00:00:00' "; 192 } 193 194 if (!empty($_SESSION["fStarStop"])) 195 { 196 if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA ")) 197 $query0 .= " AND "; 198 199 $starstop=substr($_SESSION["fStarStop"], 0, 10); 200 $query0 .= " fStar < '" . $starstop . " 23:59:59' "; 201 } 202 203 if ($groups>0) 204 { 205 $query0 .= " GROUP BY "; 206 $num = $groups; 207 foreach ($checkgroup as $key => $element) 208 if ($element==-1) 209 { 210 $query0 .= GetCheck($fromtable,$key); 211 if ($num-->1) 212 $query0 .= ", "; 213 } 214 } 215 216 if ($statusgroups>0) 217 { 218 $query0 .= " GROUP BY "; 219 $num = $statusgroups; 220 foreach ($checkstatusgroup as $key => $element) 221 if ($element==-1) 222 { 223 $query0 .= $alias[$key]; 224 if ($num-->1) 225 $query0 .= ", "; 226 } 227 } 228 229 } 123 230 else 124 $query0 .= " AND "; 125 126 $query0 .= StatusQuery("fSequenceFileWritten", $needs, $timelimits); 127 $query0 .= StatusQuery("fAllFilesAvail", $needs, $timelimits); 128 $query0 .= StatusQuery("fCallisto", $needs, $timelimits); 129 $query0 .= StatusQuery("fFillCallisto", $needs, $timelimits); 130 $query0 .= StatusQuery("fStar", $needs, $timelimits); 131 $query0 .= StatusQuery("fFillStar", $needs, $timelimits); 132 133 if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"])) 134 $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " "; 231 { 232 $displsequ=str_replace(" ", " ", $_SESSION["sequon"].$_SESSION["sequoff"]); 233 $displsequ=ereg_replace("^ ", "(", $displsequ); 234 $displsequ=ereg_replace(" $", ")", $displsequ); 235 $displsequ=str_replace(" ", ",", $displsequ); 236 237 $query0 .= "WHERE fSequenceFirst IN " . $displsequ; 238 } 239 240 if (!empty($_SESSION["fSortBy"])) 241 { 242 $val=substr($_SESSION["fSortBy"], 0, -1); 243 $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " "; 244 if (substr($_SESSION["fSortBy"], -1)=="-") 245 $query0 .= "DESC"; 246 } 247 248 if (empty($_SESSION["fSortBy"]) && $groups==0 && $statusgroups==0) 249 $query0 .= " ORDER BY Sequences.fSequenceFirst DESC "; 250 251 if (empty($_SESSION["fNumStart"])) 252 $start=0; 135 253 else 136 $query0 = substr($query0, 0, -4); 137 138 if ((!empty($_GET["fZDMin"]) || $_GET["fZDMin"]==0) && !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"]="100"; 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["fUnreliableInner"])) 259 $_GET["fUnreliableInner"]=$first?"On":""; 260 261 if (empty($_GET["fIsolatedInner"])) 262 $_GET["fIsolatedInner"]=$first?"On":""; 263 264 if (empty($_GET["fIsolatedMaxCluster"])) 265 $_GET["fIsolatedMaxCluster"]=$first?"On":""; 266 267 // if (empty($_GET["fArrTimeMeanInner"])) 268 // $_GET["fArrTimeMeanInner"]=$first?"On":""; 269 270 if (empty($_GET["fArrTimeRmsInner"])) 271 $_GET["fArrTimeRmsInner"]=$first?"On":""; 272 273 if (empty($_GET["fMeanPedRmsInner"])) 274 $_GET["fMeanPedRmsInner"]=$first?"On":""; 275 276 if (empty($_GET["fPulsePosMean"])) 277 $_GET["fPulsePosMean"]=$first?"On":""; 278 279 if (empty($_GET["fConvFactorInner"])) 280 $_GET["fConvFactorInner"]=$first?"On":""; 281 282 if (empty($_GET["fInhomogeneity"])) 283 $_GET["fInhomogeneity"]=$first?"On":""; 284 285 if (empty($_GET["fPSF"])) 286 $_GET["fPSF"]=$first?"On":""; 287 288 if (empty($_GET["fMuonNumber"])) 289 $_GET["fMuonNumber"]=$first?"On":""; 290 291 if (empty($_GET["fEffOnTime/fRunTime"])) 292 $_GET["fEffOnTime/fRunTime"]=$first?"On":""; 293 294 if (empty($_GET["fMuonRate"])) 295 $_GET["fMuonRate"]=$first?"On":""; 296 297 if (empty($_GET["fDataRate"])) 298 $_GET["fDataRate"]=$first?"On":""; 299 300 // if (empty($_GET["fMaxHumidity"])) 301 // $_GET["fMaxHumidity"]=$first?"On":""; 302 303 if (empty($_GET["fBrightnessMed"])) 304 $_GET["fBrightnessMed"]=$first?"On":""; 305 306 if (empty($_GET["fNumStarsMed"])) 307 $_GET["fNumStarsMed"]=$first?"On":""; 308 309 if (empty($_GET["fNumStarsCorMed"])) 310 $_GET["fNumStarsCorMed"]=$first?"On":""; 311 312 if (empty($_GET["fOff"])) 313 $_GET["fOff"]=$first?"On":""; 314 315 if (empty($_GET["fLinks"])) 316 $_GET["fLinks"]=$first?"On":""; 317 318 if (empty($_GET["fOnlyOff"])) 319 $_GET["fOnlyOff"]=$first?"Off":""; 320 321 InitFindOffData($_GET, $first); 322 } 323 324 function PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias) 254 $start=$_SESSION["fNumStart"]; 255 256 if (empty($_SESSION["fSendTxt"])) 257 $query0 .= " LIMIT " . $start . ", " . $_SESSION["fNumResults"]; 258 259 return $query0; 260 } 261 262 function PrintForm($host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias) 325 263 { 326 264 printf("<center>\n"); 327 265 printf("<form action='builddatasets.php' METHOD='GET'>\n"); 328 266 printf("<input id='sh' type='hidden' name='fShowHide' value='"); 329 if (!empty($_ GET["fShowHide"]))330 printf("%s", $_ GET["fShowHide"]);267 if (!empty($_SESSION["fShowHide"])) 268 printf("%s", $_SESSION["fShowHide"]); 331 269 else 332 printf("10000000 00");270 printf("1000000010");//display Ranges 333 271 printf("'>\n"); 334 272 printf("<img id='allbutton' src='minus.png' alt='-' onclick='showhide(\"all\")'> <b>Menu</b> \n"); … … 370 308 PrintButtons("builddatasets.php"); 371 309 372 $sequon=" ";373 $sequoff=" ";374 foreach($_POST as $key => $val)375 if ($val=="On")376 {377 if (ereg("ON$", $key))378 $sequon.=str_replace("ON", " ", $key);379 if (ereg("Off$", $key))380 $sequoff.=str_replace("Off", " ", $key);381 }382 printf("<input name='Set' type='hidden' value='%s'>\n", $sequon);383 printf("<input name='Set2' type='hidden' value='%s'>\n", $sequoff);384 printf("<input name='name' type='hidden' value='%s'>\n", $_POST["name"]);385 printf("<input name='comment' type='hidden' value='%s'>\n", $_POST["comment"]);386 printf("<input name='obsmode' type='hidden' value='%s'>\n", $_POST["fObservationModeKEY"]);387 printf("<input name='username' type='hidden' value='%s'>\n", $_POST["fUserKEY"]);388 310 printf("</form>\n"); 389 311 printf("</center>\n"); … … 394 316 } 395 317 318 function InsertDataSet($values, $dataset) 319 { 320 $insquery[0]="INSERT DataSets SET fDataSetNumber=" . $dataset . ", fUserKEY=" . $_SESSION["user"]; 321 $insquery[0].=", fComment='" . $_SESSION["comment"] . "', fObservationModeKEY=" . $_SESSION["obsmode"]; 322 $insquery[0].=", fDataSetName='" . $_SESSION["name"] . "', fSourceKEY= " . $_SESSION["realsourcekey"]; 323 $insquery[0].=", fRunStart='" . $values["Min(fRunStart)"]["on"]; 324 $insquery[0].="', fRunStop='" . $values["Max(fRunStop)"]["on"]; 325 $insquery[0].="', fZenithDistanceMin=" . $values["Min(fZenithDistanceMin)"]["on"]; 326 $insquery[0].=", fZenithDistanceMax=" . $values["Max(fZenithDistanceMax)"]["on"]; 327 $insquery[0].=", fRunTime=" . $_SESSION["runtime"]; 328 $insquery[1]="INSERT DataSetProcessStatus SET fDataSetNumber=" . $dataset . ", fDataSetInserted=Now()"; 329 $i=2; 330 foreach(explode(" ", trim($_SESSION["sequon"])) as $key => $sequ) 331 { 332 $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset; 333 $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=1"; 334 $i=$i+1; 335 } 336 if (!empty($off)) 337 { 338 foreach(explode(" ", trim($_SESSION["sequoff"])) as $key => $sequ) 339 { 340 $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset; 341 $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=2"; 342 $i=$i+1; 343 } 344 } 345 // insert 346 if (!empty($_SESSION["insert"]) && $numerr==0) 347 { 348 printf("<br><br>\n"); 349 foreach($insquery as $num => $q) 350 { 351 printf("Inserted Query #%s: %s<br>\n", $num, $q); 352 $insresult=mysql_query($q); 353 if (mysql_errno()>0) 354 printf(" Errorno: %s <br>\n", mysql_errno()); 355 if (mysql_error()!="") 356 printf(" Errormsg: %s <br>\n", mysql_error()); 357 if (mysql_info()!="") 358 printf(" Info: %s <br>\n", mysql_info()); 359 printf(" Affected Rows: %s <br><br>\n", mysql_affected_rows()); 360 mysql_free_result($insresult); 361 if (mysql_errno()>0) 362 { 363 printf("ERROR => stop inserting. <br><br>\n"); 364 break; 365 } 366 } 367 // reset after insert 368 unset($_SESSION["insert"]); 369 unset($_SESSION["name"]); 370 unset($_SESSION["comment"]); 371 } 372 else 373 printf("<input type='button' value='Insert Data Set' onClick='self.location.href=\"%s&insert=yes\"'> \n", GetClearedURL()); 374 } 375 396 376 function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs) 397 377 { … … 404 384 mysql_select_db($db); 405 385 406 $query0 = CreateQuery($ _GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);386 $query0 = CreateQuery($alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs); 407 387 408 388 $result0 = mysql_query($query0, $db_id); 389 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 409 390 410 391 if ($result0) … … 412 393 if ($html=="1" || $html=="2") 413 394 { 414 PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, "yes", $_GET); 415 foreach($_POST as $key => $val) 416 if ($val=="On") 395 PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, "yes"); 396 397 if ($_SESSION["sequon"]!=" " || $_SESSION["sequoff"]!=" ") 398 { 399 printf("<div align='left'>\n"); 400 printf("Remark: To store your selection you have to press 'Update Data Set'<br> \n"); 401 if ($_SESSION["DisplaySelected"]!="yes" && ($_SESSION["sequon"]!=" " || $_SESSION["sequoff"]!=" ")) 417 402 { 418 if (ereg("ON$", $key))419 $sequon.=str_replace("ON", " ", $key);420 if (ereg("Off$", $key)) 421 $sequoff.=str_replace("Off", " ", $key);403 printf("Remark: To be able to remove sequence(s) from your selection you have to \n"); 404 printf("'Display Selected Sequences'"); 405 // printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'>\n", GetClearedURL("yes")); 406 printf(" only.<br>\n"); 422 407 } 423 424 printf("<input type='submit' value='Get Dataset'><br><br>\n"); 425 printf("<input name='submit' type='hidden' value='post'>\n"); 426 427 $on=str_replace(" ", ",", trim($sequon)); 428 $off=str_replace(" ", ",", trim($sequoff)); 429 430 $values=array("Sum(fRunTime)/60" => $runtime, 431 "Min(fRunTime)/60" => $runtimemin, 432 "Max(fUnsuitableInner)" => $unsuitablemax, 433 "Max(fUnreliableInner)" => $unreliablemax, 434 "Max(fIsolatedInner)" => $isolatedmax, 435 "Max(fIsolatedMaxCluster)" => $imcmax, 436 "Max(fArrTimeMeanInner)" => $arrtimemax, 437 "Min(fArrTimeMeanInner)" => $arrtimemin, 438 "Max(fArrTimeRmsInner)" => $arrtimermsmax, 439 "Avg(fMeanPedRmsInner)" => $pedrmsmean, 440 "Std(fMeanPedRmsInner)" => $pedrmsrms, 441 "Min(fMeanPedRmsInner)" => $pedrmsmin, 442 "Max(fMeanPedRmsInner)" => $pedrmsmax, 443 "Min(fPulsePosMean)" => $pulseposmin, 444 "Max(fPulsePosMean)" => $pulseposmax, 445 "Max(fPulsePosRms)" => $pulseposrmsmax, 446 "Max(fMaxHumidity)" => $hummax, 447 "Max(fInhomogeneity)" => $inhommax, 448 "Avg(fInhomogeneity)" => $inhommean, 449 "Std(fInhomogeneity)" => $inhomrms, 450 "Min(fMeanNumberIslands)" => $numislmin, 451 "Max(fMeanNumberIslands)" => $numislmax, 452 "Min(fDataRate)" => $clratemin, 453 "Max(fDataRate)" => $clratemax, 454 "Min(fMuonRate)" => $muonratemin, 455 "Max(fMuonRate)" => $muonratemax, 456 "Min(fMuonNumber)" => $muonnumbermin, 457 "Avg(fPSF)" => $psfmean, 458 "Std(fPSF)" => $psfrms, 459 "Min(fPSF)" => $psfmin, 460 "Max(fPSF)" => $psfmax, 461 "Min(fEffOnTime/fRunTime)" => $relontimemin, 462 "Max(fEffOnTime/fRunTime)" => $relontimemax, 463 "Min(fBrightnessMed)" => $brightmin, 464 "Max(fBrightnessMed)" => $brightmax, 465 "Min(fNumStarsMed)" => $idstarsmin, 466 "Max(fNumStarsMed)" => $idstarsmax, 467 "Min(fNumStarsCorMed)" => $corstarsmin, 468 "Max(fNumStarsCorMed)" => $corstarsmax, 469 "Min(fZenithDistanceMin)" => $zdmin, 470 "Max(fZenithDistanceMax)" => $zdmax, 471 "Min(fRunStart)" => $starttime, 472 "Max(fRunStop)" => $stoptime, 473 ); 474 //get runtimes of dataset 475 function GetSequenceValues($db_id, $sequences, $txt, &$values) 476 { 477 $query="SELECT COUNT(*) "; 478 foreach($values as $name => $varname) 479 $query.=", " . $name; 480 $query.=" FROM Sequences "; 481 $query.=" LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) "; 482 $query.=" LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) "; 483 $query.=" WHERE Sequences.fSequenceFirst IN (" . $sequences . ")"; 408 printf("<br>\n"); 409 410 printf("<u>Your Data Set:</u> <br>\n"); 411 412 $on=str_replace(" ", ",", trim($_SESSION["sequon"])); 413 $off=str_replace(" ", ",", trim($_SESSION["sequoff"])); 414 415 $values=array("Sum(fRunTime)/60" => $runtime, 416 "Min(fRunTime)/60" => $runtimemin, 417 "Max(fUnsuitableInner)" => $unsuitablemax, 418 "Max(fUnreliableInner)" => $unreliablemax, 419 "Max(fIsolatedInner)" => $isolatedmax, 420 "Max(fIsolatedMaxCluster)" => $imcmax, 421 "Max(fArrTimeMeanInner)" => $arrtimemax, 422 "Min(fArrTimeMeanInner)" => $arrtimemin, 423 "Max(fArrTimeRmsInner)" => $arrtimermsmax, 424 "Avg(fMeanPedRmsInner)" => $pedrmsmean, 425 "Std(fMeanPedRmsInner)" => $pedrmsrms, 426 "Min(fMeanPedRmsInner)" => $pedrmsmin, 427 "Max(fMeanPedRmsInner)" => $pedrmsmax, 428 "Min(fPulsePosMean)" => $pulseposmin, 429 "Max(fPulsePosMean)" => $pulseposmax, 430 "Max(fPulsePosRms)" => $pulseposrmsmax, 431 "Max(fMaxHumidity)" => $hummax, 432 "Max(fInhomogeneity)" => $inhommax, 433 "Avg(fInhomogeneity)" => $inhommean, 434 "Std(fInhomogeneity)" => $inhomrms, 435 "Min(fMeanNumberIslands)" => $numislmin, 436 "Max(fMeanNumberIslands)" => $numislmax, 437 "Avg(fDataRate)" => $clratemean, 438 "Min(fDataRate)" => $clratemin, 439 "Max(fDataRate)" => $clratemax, 440 "Min(fMuonRate)" => $muonratemin, 441 "Max(fMuonRate)" => $muonratemax, 442 "Min(fMuonNumber)" => $muonnumbermin, 443 "Avg(fPSF)" => $psfmean, 444 "Std(fPSF)" => $psfrms, 445 "Min(fPSF)" => $psfmin, 446 "Max(fPSF)" => $psfmax, 447 "Min(fEffOnTime/fRunTime)" => $relontimemin, 448 "Max(fEffOnTime/fRunTime)" => $relontimemax, 449 "Min(fBrightnessMed)" => $brightmin, 450 "Max(fBrightnessMed)" => $brightmax, 451 "Min(fNumStarsMed)" => $idstarsmin, 452 "Max(fNumStarsMed)" => $idstarsmax, 453 "Min(fNumStarsCorMed)" => $corstarsmin, 454 "Max(fNumStarsCorMed)" => $corstarsmax, 455 "Min(fZenithDistanceMin)" => $zdmin, 456 "Max(fZenithDistanceMax)" => $zdmax, 457 "Min(fRunStart)" => $starttime, 458 "Max(fRunStop)" => $stoptime, 459 ); 460 //get runtimes of dataset 461 function GetSequenceValues($db_id, $sequences, $txt, &$values) 462 { 463 $query="SELECT COUNT(*) "; 464 foreach($values as $name => $varname) 465 $query.=", " . $name; 466 $query.=" FROM Sequences "; 467 $query.=" LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) "; 468 $query.=" LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) "; 469 $query.=" WHERE Sequences.fSequenceFirst IN (" . $sequences . ")"; 470 $result = mysql_query($query, $db_id); 471 $row = mysql_fetch_assoc($result); 472 foreach($values as $name => $varname) 473 $values[$name][$txt]=$row[$name]; 474 mysql_free_result($result); 475 } 476 477 //get next dataset# 478 $query="SELECT fDataSetNumber+1 FROM DataSets ORDER BY fDataSetNumber DESC LIMIT 0,1"; 484 479 $result = mysql_query($query, $db_id); 485 480 $row = mysql_fetch_assoc($result); 486 foreach($values as $name => $varname) 487 $values[$name][$txt]=$row[$name]; 481 $dataset=$row["fDataSetNumber+1"]; 482 if (empty($dataset)) 483 $dataset=1; 488 484 mysql_free_result($result); 485 486 //get sourcenames 487 function GetSources($db_id, $sequences) 488 { 489 $query="SELECT fSourceName FROM Source LEFT JOIN Sequences USING(fSourceKEY) "; 490 $query.="WHERE fSequenceFirst IN (" . $sequences . ") GROUP BY fSourceName"; 491 $result = mysql_query($query, $db_id); 492 while ($row = mysql_fetch_assoc($result)) 493 $sources.=" " . $row["fSourceName"]; 494 mysql_free_result($result); 495 return $sources; 496 } 497 $sourceson=GetSources($db_id, $on); 498 $sourcesoff=GetSources($db_id, $off); 499 500 //get sourcename for dataset 501 $son=str_replace(" ", "','", trim($sourceson)); 502 $query="SELECT fRealSourceKEY, Count(*), fSourceName FROM Source where fSourceName IN ('" . $son . "') GROUP BY fRealSourceKEY"; 503 $result = mysql_query($query, $db_id); 504 $row = mysql_fetch_assoc($result); 505 $numsources=$row["Count(*)"]; 506 $numrealkeys=mysql_num_rows($result); 507 $_SESSION["realsourcekey"]=$row["fRealSourceKEY"]; 508 $_SESSION["realsourcename"]=$row["fSourceName"]; 509 mysql_free_result($result); 510 //printf("found %s sources with real sourcekey %s", $numsources, $realsourcekey); 511 //printf("found %s keys", $numrealkeys); 512 513 //check observationmode for on-sequences 514 $query="SELECT fObservationModeKEY FROM Sequences where fSequenceFirst IN (" . $on . ") GROUP BY fObservationModeKEY"; 515 $result = mysql_query($query, $db_id); 516 $row = mysql_fetch_assoc($result); 517 $obskey=$row["fObservationModeKEY"]; 518 $numobskeys=mysql_num_rows($result); 519 mysql_free_result($result); 520 521 //check dt for on-sequences 522 $query="SELECT fDiscriminatorThresholdTableKEY FROM Sequences where fSequenceFirst IN (" . $on . ") GROUP BY fDiscriminatorThresholdTableKEY"; 523 $result = mysql_query($query, $db_id); 524 $numdtkeys=mysql_num_rows($result); 525 mysql_free_result($result); 526 527 528 //set limit 529 $runtimelimit=5; 530 $unsuitablemaxlimit=15; 531 $isolatedlimit=0; 532 $imclimit=0; 533 $pedrmsrms=0.09; 534 $scalelimit=1.3; 535 $inhomlimit=13; 536 $numstarslimit=20; 537 $numstarscorlimit=10; 538 539 540 //check values for infos, warnings and errors 541 $numerr=0; 542 if (!empty($on)) 543 { 544 $color=array("INFO" => "#000000", 545 "WARN" => "#FF9900", 546 "ERROR" => "#FF0000"); 547 printf("<div align='left'><font><ul>\n"); 548 $vals=array("on", "off"); 549 foreach($vals as $num => $val) 550 { 551 if (empty(${$val})) 552 continue; 553 //get information from the database 554 GetSequenceValues($db_id, ${$val}, $val, $values); 555 556 if ($values["Min(fNumStarsCorMed)"][$val]<$numstarscorlimit) 557 printf("<li style='color:%s'>%s: One of your %s-sequences has less than %s correlated stars (%s). </li>\n", 558 $color["WARN"], "WARN", $val, $numstarscorlimit, $values["Min(fNumStarsCorMed)"][$val]); 559 if ($values["Min(fNumStarsMed)"][$val]<$numstarslimit) 560 printf("<li style='color:%s'>%s: One of your %s-sequences has less than %s identified stars (%s). </li>\n", 561 $color["WARN"], "WARN", $val, $numstarslimit, $values["Min(fNumStarsMed)"][$val]); 562 if ($values["Min(fRunTime)/60"][$val]<$runtimelimit) 563 printf("<li style='color:%s'>%s: One of your %s-sequences is shorter than %s min (%s min). </li>\n", 564 $color["INFO"], "INFO", $val, $runtimelimit, $values["Min(fRunTime)/60"][$val]); 565 if ($values["Max(fInhomogeneity)"][$val]>$inhomlimit) 566 printf("<li style='color:%s'>%s: One of your %s-sequences has an inhomogeneity larger than %s (%s). </li>\n", 567 $color["WARN"], "WARN", $val, $inhomlimit, $values["Max(fInhomogeneity)"][$val]); 568 if ($values["Max(fUnsuitableInner)"][$val]>$unsuitablemaxlimit) 569 printf("<li style='color:%s'>%s: One of your %s-sequences has more than %s unsuitable inner pixel (%s). </li>\n", 570 $color["WARN"], "WARN", $val, $unsuitablemaxlimit, $values["Max(fUnsuitableInner)"][$val]); 571 if ($values["Max(fIsolatedInner)"][$val]>$isolatedlimit) 572 printf("<li style='color:%s'>%s: One of your %s-sequences has more than %s isolated inner pixel (%s). </li>\n", 573 $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]); 574 if ($values["Max(fIsolatedMaxCluster)"][$val]>$imclimit) 575 printf("<li style='color:%s'>%s: One of your %s-sequences has more than %s isolated max cluster (%s). </li>\n", 576 $color["WARN"], "WARN", $val, $imclimit, $values["Max(fIsolatedMaxCluster)"][$val]); 577 } 578 //check selected dataset for errors 579 if (!empty($on) && $values["Max(fMeanPedRmsInner)"]["on"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms) 580 printf("<li style='color:%s'>%s: One of your on-sequences has a PedRms larger than %s (%s).</li>\n", 581 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["on"]); 582 if (!empty($off) && $values["Max(fMeanPedRmsInner)"]["off"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms) 583 printf("<li style='color:%s'>%s: One of your off-sequences has a PedRms larger than %s (%s). </li>\n", 584 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["off"]); 585 if (!empty($off) && $values["Min(fMeanPedRmsInner)"]["off"]<$values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms) 586 printf("<li style='color:%s'>%s: One of your off-sequences has a PedRms smaller than %s (%s). </li>\n", 587 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms, $values["Min(fMeanPedRmsInner)"]["off"]); 588 $scale=$values["Sum(fRunTime)/60"]["on"]/$values["Sum(fRunTime)/60"]["off"]; 589 if ($scale > $scalelimit) 590 printf("<li style='color:%s'>%s: Your scale factor is larger than %s (%0.2f). Try to find more offdata! </li>\n", 591 $color["WARN"], "WARN", $scalelimit, $scale); 592 $doubleseq=0; 593 foreach(explode(" ", $_SESSION["sequon"]) as $n => $s) 594 { 595 if (ereg($s, $_SESSION["sequoff"])) 596 $doubleseq++; 597 } 598 if ($obskey!=$_SESSION["obsmode"]) 599 { 600 printf("<li style='color:%s'>%s: You have not selected any Off sequences. </li>\n", 601 $color["ERROR"], "ERROR", $doubleseq); 602 $numerr=$numerr+1; 603 } 604 if ($doubleseq>0) 605 { 606 printf("<li style='color:%s'>%s: You have selected sequences (%s) as On AND Off. </li>\n", 607 $color["ERROR"], "ERROR", $doubleseq); 608 $numerr=$numerr+1; 609 } 610 if ($numrealkeys>1) 611 { 612 printf("<li style='color:%s'>%s: You have selected more than one (%s) on source. </li>\n", 613 $color["ERROR"], "ERROR", $numrealkeys); 614 $numerr=$numerr+1; 615 } 616 if ($numobskeys>1) 617 { 618 printf("<li style='color:%s'>%s: You have selected more than one (%s) different observation modes in your on sequences. </li>\n", 619 $color["ERROR"], "WARN", $numobskeys); 620 //$numerr=$numerr+1; 621 } 622 if ($numdtkeys>1) 623 { 624 printf("<li style='color:%s'>%s: Your selected on sequences have more than one (%s) different discriminator threshold tables. </li>\n", 625 $color["ERROR"], "WARN", $numdtkeys); 626 } 627 if (empty($_SESSION["realsourcekey"])) 628 { 629 printf("<li style='color:%s'>%s: The source you selected does not have a real sourcekey, yet. Please insert fRealSourceKEY in the DB for %s (contact: datacenter@astro.uni-wuerzburg.de). </li>\n", 630 $color["ERROR"], "ERROR", $sourceson); 631 $numerr=$numerr+1; 632 } 633 if (empty($_SESSION["name"])) 634 { 635 printf("<li style='color:%s'>%s: You have to choose a name. </li>\n", 636 $color["ERROR"], "ERROR"); 637 $numerr=$numerr+1; 638 } 639 if (empty($_SESSION["comment"])) 640 { 641 printf("<li style='color:%s'>%s: You have to comment your data set. </li>\n", 642 $color["ERROR"], "ERROR"); 643 $numerr=$numerr+1; 644 } 645 printf("</ul></font>\n"); 646 printf("</div>"); 647 648 //set runtime in session (has to be after calling GetSequenceValues()) 649 $_SESSION["runtime"] = $values["Sum(fRunTime)/60"]["on"]; 650 $_SESSION["zdmin"] = $values["Min(fZenithDistanceMin)"]["on"]; 651 $_SESSION["zdmax"] = $values["Max(fZenithDistanceMax)"]["on"]; 652 $_SESSION["meanrate"] = $values["Avg(fDataRate)"]["on"]; 653 $_SESSION["psfmean"] = $values["Avg(fPSF)"]["on"]; 654 $_SESSION["psfmin"] = $values["Min(fPSF)"]["on"]; 655 $_SESSION["psfmax"] = $values["Max(fPSF)"]["on"]; 656 657 printf("SequencesOn: %s<br>\n", $_SESSION["sequon"]); 658 if ($_SESSION["sequoff"]!=" ") 659 printf("SequencesOff: %s<br>\n", $_SESSION["sequoff"]); 660 661 //set observation mode 662 if ($_SESSION["sequoff"]==" ") 663 $obsmode="Wobble"; 664 else 665 $obsmode="On"; 666 //get key from db for insert query 667 $query = "SELECT fObservationModeKEY FROM ObservationMode WHERE fObservationModeName='".$obsmode."'"; 668 $result = mysql_query($query); 669 $row = mysql_fetch_assoc($result); 670 $_SESSION["obsmode"] = $row["fObservationModeKEY"]; 671 mysql_free_result($result); 672 printf("Observation mode: %s <br>\n", $obsmode); 673 printf("RunTime: %s min <br>\n", $_SESSION["runtime"]); 674 printf("Mean Rate after cleaning: %s Hz <br>\n", $_SESSION["meanrate"]); 675 printf("Zd: %s - %s deg <br>\n", $_SESSION["zdmin"], $_SESSION["zdmax"]); 676 printf("PSF: %s (%s - %s) mm <br>\n", $_SESSION["psfmean"], $_SESSION["psfmin"], $_SESSION["psfmax"]); 677 678 //user name 679 printf("User name: %s <br><br>\n", $_SERVER['PHP_AUTH_USER']); 680 681 // data set name and comment: to be inserted by the user 682 printf("Data set name: <input name='name' type='text' size='20' maxlength='20' value='%s'><br>\n", $_SESSION["name"]); 683 printf("Comment: <input name='comment' type='text' size='50' maxlength='255' value='%s'><br><br>\n", $_SESSION["comment"]); 684 685 686 //PrintUpdateDataSetButton() has to be called before InsertDataSet() 687 // to ensure that there are no problem with insert and $_SESSION["insert"] 688 689 //allow 'insert/get dataset' in case no error is found 690 if ($numerr!=0) 691 { 692 printf("Remark: Only data sets without errors can be inserted.<br>"); 693 printf("<font color='red'>Your data set has %s error(s).</font><br><br>", $numerr); 694 PrintUpdateDataSetButton(); 695 } 696 else 697 { 698 PrintUpdateDataSetButton(); 699 700 if ($_SERVER['PHP_AUTH_USER']=="MAGIC") 701 printf("<br><br>\n Remark: As user MAGIC you are not allowed to insert data sets into the database. For an own account, please contact datacenter@astro.uni-wuerzburg.de <br><br>\n"); 702 else 703 InsertDataSet($values, $dataset); 704 705 printf("<input type='button' value='Get Data Set File' onClick='self.location.href=\"%s&fSendTxt=2\"'> \n", GetClearedURL()); 706 } 707 708 709 //print table with more information on dataset 710 printf("<br><br><br>\n"); 711 printf("<table><tr><td colspan='2'><b>More Information on Your Data Set:<b></td></tr>"); 712 printf("<tr><td>Next DataSet# in DB: </td><td>%s</td></tr>", $dataset); 713 printf("<tr><td valign='top'>SequencesOn:</td><td> %s</td></tr>", $_SESSION["sequon"]); 714 if ($_SESSION["sequoff"]!=" ") 715 { 716 printf("<tr><td valign='top'>SequencesOff:</td><td> %s</td></tr>", $_SESSION["sequoff"]); 717 printf("<tr><td>Scale factor (On/Off): </td><td>%0.2f</td></tr>", $scale); 718 } 719 printf("<tr><td>SourcenamesOn [%s]: </td><td>%s</td></tr>", str_word_count($sourceson, 0, "1234567890+"), $sourceson); 720 if ($_SESSION["sequoff"]!=" ") 721 printf("<tr><td>SourcenamesOff [%s]: </td><td>%s</td></tr>", str_word_count($sourcesoff, 0, "1234567890+"), $sourcesoff); 722 printf("</table>\n"); 723 724 printf("<table border='1'>\n"); 725 printf("<tr><td>Value</td><td>On</td>"); 726 if (!empty($off)) 727 printf("<td>Off</td></tr>\n"); 728 foreach($values as $name => $varname) 729 { 730 printf("<tr><td>%s</td>\n", $name); 731 foreach($vals as $num => $val) 732 if (!empty(${$val})) 733 printf("<td>%s</td>\n", $varname[$val]); 734 printf("</tr>\n"); 735 } 736 printf("</table>\n"); 737 } 489 738 } 490 491 //get next dataset# 492 $query="SELECT fDataSetNumber+1 FROM DataSets ORDER BY fDataSetNumber DESC LIMIT 0,1"; 493 $result = mysql_query($query, $db_id); 494 $row = mysql_fetch_assoc($result); 495 $dataset=$row["fDataSetNumber+1"]; 496 if (empty($dataset)) 497 $dataset=1; 498 mysql_free_result($result); 499 500 //get sourcenames 501 function GetSources($db_id, $sequences) 502 { 503 $query="SELECT fSourceName FROM Source LEFT JOIN Sequences USING(fSourceKEY) "; 504 $query.="WHERE fSequenceFirst IN (" . $sequences . ") GROUP BY fSourceName"; 505 $result = mysql_query($query, $db_id); 506 while ($row = mysql_fetch_assoc($result)) 507 $sources.=" " . $row["fSourceName"]; 508 mysql_free_result($result); 509 return $sources; 510 } 511 $sourceson=GetSources($db_id, $on); 512 $sourcesoff=GetSources($db_id, $off); 513 514 //get sourcename for dataset 515 $son=str_replace(" ", "','", trim($sourceson)); 516 $query="SELECT fRealSourceKEY, Count(*) FROM Source where fSourcename IN ('" . $son . "') GROUP BY fRealSourceKEY"; 517 // printf("q: %s <br>", $query); 518 $result = mysql_query($query, $db_id); 519 $row = mysql_fetch_assoc($result); 520 $numsources=$row["Count(*)"]; 521 $numrealkeys=mysql_num_rows($result); 522 $realsourcekey=$row["fRealSourceKEY"]; 523 mysql_free_result($result); 524 // printf("found %s sources with real sourcekey %s", $numsources, $realsourcekey); 525 // printf("found %s keys", $numrealkeys); 526 527 //check observationmode for on-sequences 528 $query="SELECT fObservationModeKEY FROM Sequences where fSequenceFirst IN (" . $on . ") GROUP BY fObservationModeKEY"; 529 $result = mysql_query($query, $db_id); 530 $numobskeys=mysql_num_rows($result); 531 mysql_free_result($result); 532 533 //check dt for on-sequences 534 $query="SELECT fDiscriminatorThresholdTableKEY FROM Sequences where fSequenceFirst IN (" . $on . ") GROUP BY fDiscriminatorThresholdTableKEY"; 535 $result = mysql_query($query, $db_id); 536 $numdtkeys=mysql_num_rows($result); 537 mysql_free_result($result); 538 539 540 //set limit 541 $runtimelimit=5; 542 $unsuitablemaxlimit=15; 543 $isolatedlimit=0; 544 $imclimit=0; 545 $pedrmsrms=0.09; 546 $scalelimit=1.3; 547 $inhomlimit=13; 548 $numstarslimit=20; 549 $numstarscorlimit=10; 550 551 552 //check values for infos, warnings and errors 553 $numerr=0; 554 if (!empty($on)) 555 { 556 $color=array("INFO" => "#000000", 557 "WARN" => "#FF9900", 558 "ERROR" => "#FF0000"); 559 printf("<div align='left'><font><ul>\n"); 560 $vals=array("on", "off"); 561 foreach($vals as $num => $val) 562 { 563 if (empty(${$val})) 564 continue; 565 GetSequenceValues($db_id, ${$val}, $val, $values); 566 567 if ($values["Min(fNumStarsCorMed)"][$val]<$numstarscorlimit) 568 printf("<li style='color:%s'>%s: one of your %s-sequences has less than %s correlated stars (%s)</li>", 569 $color["WARN"], "WARN", $val, $numstarscorlimit, $values["Min(fNumStarsCorMed)"][$val]); 570 if ($values["Min(fNumStarsMed)"][$val]<$numstarslimit) 571 printf("<li style='color:%s'>%s: one of your %s-sequences has less than %s identified stars (%s)</li>", 572 $color["WARN"], "WARN", $val, $numstarslimit, $values["Min(fNumStarsMed)"][$val]); 573 if ($values["Min(fRunTime)/60"][$val]<$runtimelimit) 574 printf("<li style='color:%s'>%s: one of your %s-sequences is shorter than %s min (%s min)</li>", 575 $color["INFO"], "INFO", $val, $runtimelimit, $values["Min(fRunTime)/60"][$val]); 576 if ($values["Max(fInhomogeneity)"][$val]>$inhomlimit) 577 printf("<li style='color:%s'>%s: one of your %s-sequences has an inhomogeneity larger than %s (%s)</li>", 578 $color["WARN"], "WARN", $val, $inhomlimit, $values["Max(fInhomogeneity)"][$val]); 579 if ($values["Max(fUnsuitableInner)"][$val]>$unsuitablemaxlimit) 580 printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s unsuitable inner pixel (%s)</li>", 581 $color["WARN"], "WARN", $val, $unsuitablemaxlimit, $values["Max(fUnsuitableInner)"][$val]); 582 if ($values["Max(fIsolatedInner)"][$val]>$isolatedlimit) 583 printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s isolated inner pixel (%s)</li>", 584 $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]); 585 if ($values["Max(fIsolatedMaxCluster)"][$val]>$imclimit) 586 printf("<li style='color:%s'>%s: one of your %s-sequences has more than %s isolated max cluster (%s)</li>", 587 $color["WARN"], "WARN", $val, $imclimit, $values["Max(fIsolatedMaxCluster)"][$val]); 588 } 589 if (!empty($on) && $values["Max(fMeanPedRmsInner)"]["on"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms) 590 printf("<li style='color:%s'>%s: one of your on-sequences has a PedRms larger than %s (%s)</li>", 591 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["on"]); 592 if (!empty($off) && $values["Max(fMeanPedRmsInner)"]["off"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms) 593 printf("<li style='color:%s'>%s: one of your off-sequences has a PedRms larger than %s (%s)</li>", 594 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["off"]); 595 if (!empty($off) && $values["Min(fMeanPedRmsInner)"]["off"]<$values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms) 596 printf("<li style='color:%s'>%s: one of your off-sequences has a PedRms smaller than %s (%s)</li>", 597 $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms, $values["Min(fMeanPedRmsInner)"]["off"]); 598 $scale=$values["Sum(fRunTime)/60"]["on"]/$values["Sum(fRunTime)/60"]["off"]; 599 if ($scale > $scalelimit) 600 printf("<li style='color:%s'>%s: Your scale factor is larger than %s (%0.2f). Try to find more offdata!", 601 $color["WARN"], "WARN", $scalelimit, $scale); 602 /* 603 if (str_word_count($sourceson) > 1) 604 printf("<li style='color:%s'>%s: You have selected more than one (%s) on source", 605 $color["WARN"], "WARN", str_word_count($sourceson)); 606 */ 607 $doubleseq=0; 608 // printf("finding: %s<br>", $sequon); 609 foreach(explode(" ", $sequon) as $n => $s) 610 { 611 // printf("finding %s in %s <br>", $s, $sequoff); 612 if (ereg($s, $sequoff)) 613 $doubleseq++; 614 } 615 if ($doubleseq>0) 616 { 617 printf("<li style='color:%s'>%s: You have selected sequences (%s) as On AND Off", 618 $color["ERROR"], "ERROR", $doubleseq); 619 $numerr=$numerr+1; 620 } 621 if ($numrealkeys>1) 622 { 623 printf("<li style='color:%s'>%s: You have selected more than one (%s) on source", 624 $color["ERROR"], "ERROR", $numrealkeys); 625 $numerr=$numerr+1; 626 } 627 if ($numobskeys>1) 628 { 629 printf("<li style='color:%s'>%s: You have selected more than one (%s) different observation modes for your on sequences", 630 $color["ERROR"], "WARN", $numobskeys); 631 // $numerr=$numerr+1; 632 } 633 if ($numdtkeys>1) 634 { 635 printf("<li style='color:%s'>%s: Your selected on sequences have more than one (%s) different discriminator threshold tables ", 636 $color["ERROR"], "WARN", $numdtkeys); 637 } 638 if (empty($_POST["fObservationModeKEY"]) && !empty($_GET["obsmode"])) 639 $_POST["fObservationModeKEY"]=$_GET["obsmode"]; 640 if ($_POST["fObservationModeKEY"]==3 && empty($off)) 641 { 642 printf("<li style='color:%s'>%s: You have selected on/off mode, but you haven't chosen any off sequences.", 643 $color["ERROR"], "WARN"); 644 // $numerr=$numerr+1; 645 } 646 if (empty($realsourcekey)) 647 { 648 printf("<li style='color:%s'>%s: The source you selected doesn't have a real sourcekey yet. Please insert fRealSourceKEY in the DB for %s", 649 $color["ERROR"], "ERROR", $sourceson); 650 $numerr=$numerr+1; 651 } 652 if (empty($_POST["fObservationModeKEY"])) 653 { 654 printf("<li style='color:%s'>%s: You have to choose an observation mode.", 655 $color["ERROR"], "ERROR"); 656 $numerr=$numerr+1; 657 } 658 if (empty($_POST["fUserKEY"])) 659 { 660 printf("<li style='color:%s'>%s: You have to choose your username.", 661 $color["ERROR"], "ERROR"); 662 $numerr=$numerr+1; 663 } 664 if (empty($_POST["name"])) 665 { 666 printf("<li style='color:%s'>%s: You have to choose a name.", 667 $color["ERROR"], "ERROR"); 668 $numerr=$numerr+1; 669 } 670 if (empty($_POST["comment"])) 671 { 672 printf("<li style='color:%s'>%s: You have to comment your dataset.", 673 $color["ERROR"], "ERROR"); 674 $numerr=$numerr+1; 675 } 676 // printf("<li></li>"); 677 printf("</ul></font>\n"); 678 679 printf("<div align='left'>"); 680 printf("SequencesOn: %s<br>", $sequon); 681 printf("SequencesOff: %s<br>", $sequoff); 682 $insquery[0]="INSERT DataSets SET fDataSetNumber=" . $dataset . ", fUserKEY=" . $_POST["fUserKEY"]; 683 $insquery[0].=", fComment='" . $_POST["comment"] . "', fObservationModeKEY=" . $_POST["fObservationModeKEY"]; 684 $insquery[0].=", fDataSetName='" . $_POST["name"] . "', fSourceKEY= " . $realsourcekey; 685 $insquery[0].=", fRunStart='" . $values["Min(fRunStart)"]["on"]; 686 $insquery[0].="', fRunStop='" . $values["Max(fRunStop)"]["on"]; 687 $insquery[0].="', fZenithDistanceMin=" . $values["Min(fZenithDistanceMin)"]["on"]; 688 $insquery[0].=", fZenithDistanceMax=" . $values["Max(fZenithDistanceMax)"]["on"]; 689 $insquery[0].=", fRunTime=" . $values["Sum(fRunTime)/60"]["on"]; 690 $insquery[1]="INSERT DataSetProcessStatus SET fDataSetNumber=" . $dataset . ", fDataSetInserted=Now()"; 691 $i=2; 692 foreach(explode(" ", trim($sequon)) as $key => $sequ) 693 { 694 $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset; 695 $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=1"; 696 $i=$i+1; 697 } 698 if (!empty($off)) 699 { 700 foreach(explode(" ", trim($sequoff)) as $key => $sequ) 701 { 702 $insquery[$i]="INSERT DataSetSequenceMapping SET fDataSetNumber=" . $dataset; 703 $insquery[$i].=", fSequenceFirst=" . $sequ . ", fOnOff=2"; 704 $i=$i+1; 705 } 706 } 707 foreach($insquery as $num => $q) 708 { 709 if (!empty($_POST["insert"]) && $numerr==0) 710 { 711 printf("Inserted Query #%s: %s<br>", $num, $q); 712 $insresult=mysql_query($q); 713 if (mysql_errno()>0) 714 printf(" Errorno: %s <br>", mysql_errno()); 715 if (mysql_error()!="") 716 printf(" Errormsg: %s <br>", mysql_error()); 717 if (mysql_info()!="") 718 printf(" Info: %s <br>", mysql_info()); 719 printf(" Affected Rows: %s <br>", mysql_affected_rows()); 720 mysql_free_result($insresult); 721 if (mysql_errno()>0) 722 { 723 printf("ERROR => stop inserting"); 724 break; 725 } 726 } 727 } 728 printf("</div>"); 729 if (empty($_POST["name"]) && !empty($_GET["name"])) 730 $_POST["name"]=$_GET["name"]; 731 if (empty($_POST["comment"]) && !empty($_GET["comment"])) 732 $_POST["comment"]=$_GET["comment"]; 733 if (empty($_POST["fUserKEY"]) && !empty($_GET["username"])) 734 $_POST["fUserKEY"]=$_GET["username"]; 735 printf("Name: <input name='name' type='text' size='20' maxlength='20' value='%s'><br>\n", $_POST["name"]); 736 printf("Comment: <input name='comment' type='text' size='50' maxlength='255' value='%s'><br>\n", $_POST["comment"]); 737 738 $query = "SELECT fObservationModeKEY, fObservationModeName FROM ObservationMode ORDER BY fObservationModeName"; 739 $result = mysql_query($query); 740 if (!$result) 741 printf("-N/A-"); 742 743 $numrows = mysql_num_rows($result); 744 745 printf("ObservationMode <select name='fObservationModeKEY' size='1' class='Width'>\n"); 746 while ($row = mysql_fetch_row($result)) 747 { 748 if (!empty($_POST["fObservationModeKEY"]) && $_POST["fObservationModeKEY"]==$row[0]) 749 printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]); 750 else 751 printf("<option value='%s'>%s</option>\n", $row[0], $row[1]); 752 } 753 printf("</select><br>\n"); 754 mysql_free_result($result); 755 756 $query = "SELECT fUserKEY, fUserName FROM User ORDER BY fUserKEY"; 757 $result = mysql_query($query); 758 if (!$result) 759 printf("-N/A-"); 760 761 $numrows = mysql_num_rows($result); 762 763 printf("UserName <select name='fUserKEY' size='1' class='Width'>\n"); 764 while ($row = mysql_fetch_row($result)) 765 { 766 if (!empty($_POST["fUserKEY"]) && $_POST["fUserKEY"]==$row[0]) 767 printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]); 768 else 769 printf("<option value='%s'>%s</option>\n", $row[0], $row[1]); 770 } 771 printf("</select><br>\n"); 772 mysql_free_result($result); 773 774 if ($numerr!=0) 775 { 776 printf("Remark: only datasets without errors can be inserted.<br>"); 777 printf("Your dataset has %s error(s).<br>", $numerr); 778 } 779 printf("<input type='checkbox' name='insert' value='On'>insert\n"); 780 781 printf("<table><tr><td colspan='2' align='center'>Dataset</td></tr>"); 782 printf("<tr><td>proposed DataSet#: </td><td>%s</td></tr>", $dataset); 783 printf("<tr><td valign='top'>SequencesOn:</td><td> %s</td></tr>", $sequon); 784 if (!empty($sequoff)) 785 printf("<tr><td valign='top'>SequencesOff:</td><td> %s</td></tr>", $sequoff); 786 printf("<tr><td>Scale: </td><td>%0.2f</td></tr>", $scale); 787 printf("<tr><td>SourcenamesOn[%s]: </td><td>%s</td></tr>", str_word_count($sourceson), $sourceson); 788 printf("<tr><td>SourcenamesOff[%s]: </td><td>%s</td></tr>", str_word_count($sourcesoff), $sourcesoff); 789 printf("</table>\n"); 790 791 printf("<table border='1'>\n"); 792 printf("<tr><td>Value</td><td>On</td>"); 793 if (!empty($off)) 794 printf("<td>Off</td></tr>\n"); 795 foreach($values as $name => $varname) 796 { 797 printf("<tr><td>%s</td>\n", $name); 798 foreach($vals as $num => $val) 799 if (!empty(${$val})) 800 printf("<td>%s</td>\n", $varname[$val]); 801 printf("</tr>\n"); 802 } 803 printf("</table>\n"); 804 } 739 else 740 printf("<input type='submit' value='Get Data Set'><br><br>\n"); 805 741 806 742 printf("</div>\n"); 807 /*808 printf("<table border='1'><tr>\n");809 printf("<td>--</td>\n");810 foreach($values as $name => $varname)811 printf("<td>%s</td>\n", $name);812 $vals=array("on", "off");813 foreach($vals as $num => $val)814 {815 GetSequenceValues($db_id, ${$val}, $val, $values);816 printf("</tr><tr>\n");817 printf("<td>On</td>\n");818 foreach($values as $name => $varname)819 printf("<td>%s</td>\n", $varname[$val]);820 }821 printf("</tr></table>\n");822 */823 824 printf("</center>\n");825 743 printf("</td>\n"); 826 744 printf("</tr>\n"); … … 832 750 833 751 mysql_free_result($result0); 752 mysql_free_result($result1); 834 753 } 835 754 mysql_close($db_id); … … 843 762 include ("magicdefs.php"); 844 763 764 // $debug="yes"; 765 session_start(); 766 if ($debug) 767 { 768 echo "GET: "; 769 print_r($_GET); 770 echo " <br>"; 771 772 echo "POST: "; 773 print_r($_POST); 774 echo " <br>"; 775 } 776 777 // set values given by $_GET 778 foreach ($_GET as $element => $value) 779 $_SESSION[$element]=$value; 780 781 // unset values in case of 'Reset' 782 if (empty($_GET)) 783 foreach($_SESSION as $element => $value) 784 unset($_SESSION[$element]); 785 786 // set values given by $_POST 787 if (!empty($_POST)) 788 foreach ($_POST as $element => $value) 789 $_SESSION[$element]=$value; 790 791 792 793 if ($debug) 794 print_r($_SESSION); 795 796 // remove sequence from selection 797 if (!empty($_POST) && $_SESSION["DisplaySelected"]=="yes" && $_SESSION["DisplaySelectedOld"]=="yes") 798 foreach ($_SESSION as $key => $element) 799 if (($_SESSION[$key]=="On") //value is set 800 && (ereg("^[0-9]*ON$", $key) || ereg("^[0-9]*Off$", $key)) // it is a sequence number 801 && (!$_POST[$key]==On)) // the sequence is not given in $_POST any more 802 unset($_SESSION[$key]); 803 804 //store old value of $_SESSION["DisplaySelected"] 805 if ($_SESSION["DisplaySelected"]=="yes") 806 { 807 unset($_SESSION["fNumStart"]); 808 $_GET["fNumStart"]=0; 809 $_SESSION["DisplaySelectedOld"]="yes"; 810 } 811 else 812 $_SESSION["DisplaySelectedOld"]="no"; 813 814 $_SESSION["sequon"]=" "; 815 $_SESSION["sequoff"]=" "; 816 foreach($_SESSION as $key => $val) 817 if ($val=="On") 818 { 819 if (ereg("^[0-9]*ON$", $key)) 820 $_SESSION["sequon"].=str_replace("ON", " ", $key); 821 if (ereg("^[0-9]*Off$", $key)) 822 $_SESSION["sequoff"].=str_replace("Off", " ", $key); 823 } 824 if ($_SESSION["sequon"]==" " && $_SESSION["sequoff"]==" ") 825 { 826 $_SESSION["DisplaySelected"]="no"; 827 $_SESSION["DisplaySelectedOld"]="no"; 828 } 829 845 830 ini_set("display_errors", "On"); 846 831 ini_set("mysql.trace_mode", "On"); 847 832 848 $sitepw="\$1\$ml/Gld67\$zOvhC4vFrLCkbAzQs2swo1"; 849 $siteuser="dcdb"; 850 851 852 if (!isset($_SERVER['PHP_AUTH_USER']) || crypt($_SERVER['PHP_AUTH_PW'], $sitepw)!=$sitepw || $_SERVER['PHP_AUTH_USER']!=$siteuser) 833 if (!isset($_SERVER['PHP_AUTH_USER'])) 853 834 { 854 835 header('WWW-Authenticate: Basic realm="Build Datasets"'); 855 836 header('HTTP/1.0 401 Unauthorized'); 856 echo 'Cancelled.';857 837 return; 858 838 } 859 839 else 860 840 { 861 // echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>"; 862 // echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>"; 863 // printf("pw: %s", crypt($_SERVER['PHP_AUTH_PW'])); 864 865 if (crypt($_SERVER['PHP_AUTH_PW'], $sitepw)!=$sitepw || $_SERVER['PHP_AUTH_USER']!=$siteuser) 866 { 867 printf("<br>pw or user incorrect<br>"); 841 $db_id = mysql_connect($host, $user, $pw); 842 if ($db_id==FALSE) 843 { 844 printf("mysql_connect returned the following error:<br>"); 845 printf("%s<br>", mysql_error()); 846 die(""); 847 } 848 849 $userquery = "SELECT fUserName, fPassword, fUserKEY FROM " . $db . ".User ORDER BY fUserKEY"; 850 $userresult = mysql_query($userquery); 851 if (!$userresult) 852 echo "query failed"; 853 $validuser="no"; 854 while ($userrow = mysql_fetch_assoc($userresult)) 855 { 856 // echo crypt($_SERVER['PHP_AUTH_PW']). "<br>"; 857 if (crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"])==$userrow["fPassword"] 858 && $_SERVER['PHP_AUTH_USER']==$userrow["fUserName"]) 859 { 860 $validuser="yes"; 861 $_SESSION["user"]=$userrow["fUserKEY"]; 862 } 863 } 864 mysql_free_result($userresult); 865 if ($validuser=="no") 866 { 867 printf("<br>Password or username incorrect<br>"); 868 868 return; 869 869 } 870 870 } 871 871 872 if (!empty($_GET["fSendTxt"])) 873 { 874 header("Content-type: application/octet"); 875 header("Content-Disposition: attachment; filename=query-result.txt"); 876 877 PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs); 872 if (!empty($_SESSION["fSendTxt"])) 873 { 874 header("Content-Type: application/octet"); 875 switch($_SESSION["fSendTxt"]) 876 { 877 case 1: 878 header("Content-Disposition: attachment; filename=query-result.txt"); 879 PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs); 880 break; 881 case 2: 882 header("Content-Disposition: attachment; filename=dataset_".str_replace(" ", "_", $_SESSION["name"]).".txt"); 883 PrintDataSetFile(); 884 echo "hallo\n"; 885 } 886 unset($_SESSION["fSendTxt"]); 878 887 } 879 888 else … … 883 892 $environment = sizeof($_GET); 884 893 885 InitGet($_GET); 886 if (empty($_GET["fPrintTable"])) 887 PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias); 894 // Find out whether it is the first call to the php script 895 $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]); 896 InitBuildDataSets($first); 897 if (empty($_SESSION["fPrintTable"])) 898 PrintForm($host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias); 888 899 889 900 if ($environment==0) … … 891 902 else 892 903 { 893 if (empty($_ GET["fPrintTable"]))904 if (empty($_SESSION["fPrintTable"])) 894 905 PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs); 895 906 else … … 902 913 ini_set("display_errors", "Off"); 903 914 ini_set("mysql.trace_mode", "Off"); 904 } 915 905 916 ?> -
trunk/MagicSoft/Mars/datacenter/db/ctadefs.php
r9486 r9498 25 25 $checkwhere = array 26 26 ( 27 "fParticleTypeName" => CheckWhere("fParticleTypeKEY", $_GET),27 "fParticleTypeName" => CheckWhere("fParticleTypeKEY"), 28 28 ); 29 29 30 30 $checkgroup = array 31 31 ( 32 "fParticleTypeName" => CheckGroup("fParticleTypeKEY", $_GET),32 "fParticleTypeName" => CheckGroup("fParticleTypeKEY"), 33 33 ); 34 34 … … 36 36 $checkstatusgroup = array 37 37 ( 38 "fCorsikaSimTelarray" => CheckStatusGroup("fCorsikaSimTelarrayStatus" , $_GET),39 "fChimp" => CheckStatusGroup("fChimpStatus" , $_GET),40 "fCTAStar" => CheckStatusGroup("fCTAStarStatus" , $_GET),41 "fStereoB" => CheckStatusGroup("fStereoBStatus" , $_GET),42 "fStereoC" => CheckStatusGroup("fStereoCStatus" , $_GET),43 "fStereoG" => CheckStatusGroup("fStereoGStatus" , $_GET),38 "fCorsikaSimTelarray" => CheckStatusGroup("fCorsikaSimTelarrayStatus"), 39 "fChimp" => CheckStatusGroup("fChimpStatus"), 40 "fCTAStar" => CheckStatusGroup("fCTAStarStatus"), 41 "fStereoB" => CheckStatusGroup("fStereoBStatus"), 42 "fStereoC" => CheckStatusGroup("fStereoCStatus"), 43 "fStereoG" => CheckStatusGroup("fStereoGStatus"), 44 44 ); 45 45 -
trunk/MagicSoft/Mars/datacenter/db/ctamcinfo.php
r9486 r9498 1 1 <?php 2 2 { 3 function CreateQuery($ _GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits)3 function CreateQuery($alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits) 4 4 { 5 5 $fromtable="MCRunData"; … … 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0 || $statusgroups>0) … … 204 204 205 205 if (empty($_GET["fNumStart"])) 206 $_GET["fNumStart"]=0; 206 $start=0; 207 else 208 $start=$_GET["fNumStart"]; 207 209 208 210 if (empty($_GET["fSendTxt"])) 209 $query0 .= " LIMIT " . $ _GET["fNumStart"]. ", " . $_GET["fNumResults"];211 $query0 .= " LIMIT " . $start . ", " . $_GET["fNumResults"]; 210 212 211 213 return $query0; 212 214 } 213 215 214 function InitGet( $_GET)216 function InitGet() 215 217 { 216 218 // Find out whether it is the first call to the php script … … 220 222 } 221 223 222 function PrintForm($ _GET, $host, $user, $pw, $db)224 function PrintForm($host, $user, $pw, $db) 223 225 { 224 226 printf("<center>\n"); … … 279 281 mysql_query("SET BIG_TABLES=1"); // necessary for mySQL <= 4 280 282 281 $query0 = CreateQuery($ _GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits);283 $query0 = CreateQuery($alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits); 282 284 283 285 $result0 = mysql_query($query0, $db_id); 286 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 284 287 285 288 if ($result0) 286 289 { 287 290 if ($html=="1" || $html=="2") 288 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);291 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 289 292 else 290 293 PrintText($result0); 291 294 292 295 mysql_free_result($result0); 296 mysql_free_result($result1); 293 297 } 294 298 mysql_close($db_id); … … 298 302 299 303 include ("include.php"); 300 include ("db .php");304 include ("db2.php"); 301 305 include ("menu.php"); 302 306 include ("ctadefs.php"); … … 319 323 $environment = sizeof($_GET); 320 324 321 InitGet( $_GET);325 InitGet(); 322 326 if (empty($_GET["fPrintTable"])) 323 PrintForm($ _GET, $host, $user, $pw, $db);327 PrintForm($host, $user, $pw, $db); 324 328 325 329 if ($environment==0) -
trunk/MagicSoft/Mars/datacenter/db/culminating.php
r8792 r9498 10 10 $groups++; 11 11 12 $query0 = "SELECT";12 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 13 13 14 14 if ($groups>0) … … 223 223 224 224 $result0 = mysql_query($query0, $db_id); 225 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 225 226 226 227 if ($result0) 227 228 { 228 229 if ($html=="1") 229 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);230 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 230 231 else 231 232 PrintText($result0); 232 233 233 234 mysql_free_result($result0); 235 mysql_free_result($result1); 234 236 } 235 237 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/datacheck.php
r9486 r9498 20 20 $enumgroups++; 21 21 22 $query0 = "SELECT ";22 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 23 23 24 24 if ($groups>0) … … 416 416 417 417 $result0 = mysql_query($query0, $db_id); 418 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 418 419 419 420 if ($result0) 420 421 { 421 422 if ($html=="1" || $html=="2") 422 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);423 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 423 424 else 424 425 PrintText($result0); 425 426 426 427 mysql_free_result($result0); 428 mysql_free_result($result1); 427 429 } 428 430 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/datasetinfo-aio.php
r9486 r9498 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0 || $statusgroups>0) … … 232 232 233 233 $result0 = mysql_query($query0, $db_id); 234 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 234 235 235 236 if ($result0) 236 237 { 237 238 if ($html=="1" || $html=="2") 238 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);239 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 239 240 else 240 241 PrintText($result0); 241 242 242 243 mysql_free_result($result0); 244 mysql_free_result($result1); 243 245 } 244 246 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/datasetinfo.php
r9486 r9498 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0) … … 372 372 373 373 $result0 = mysql_query($query0, $db_id); 374 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 374 375 375 376 if ($result0) 376 377 { 377 378 if ($html=="1" || $html=="2") 378 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);379 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 379 380 else 380 381 PrintText($result0); 381 382 382 383 mysql_free_result($result0); 384 mysql_free_result($result1); 383 385 } 384 386 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/dbstatus.php
r9486 r9498 51 51 $statusgroups++; 52 52 53 $query0 = "SELECT ";53 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 54 54 55 55 if ($groups>0) … … 355 355 356 356 $result0 = mysql_query($query0, $db_id); 357 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 357 358 358 359 if ($result0) 359 360 { 360 361 if ($html=="1" || $html=="2") 361 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);362 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 362 363 else 363 364 PrintText($result0); 364 365 365 366 mysql_free_result($result0); 367 mysql_free_result($result1); 366 368 } 367 369 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/findoffdata.php
r9486 r9498 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0) … … 409 409 410 410 $result0 = mysql_query($query0, $db_id); 411 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 411 412 412 413 if ($result0) 413 414 { 414 415 if ($html=="1" || $html=="2") 415 PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, "", $_GET);416 PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1); 416 417 else 417 418 PrintText($result0); 418 419 419 420 mysql_free_result($result0); 421 mysql_free_result($result1); 420 422 } 421 423 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/include.php
r9486 r9498 255 255 } 256 256 257 //for download of output 257 258 function PrintText($result0) 258 259 { 259 // header("Content-type: application/octet");260 // header("Content-Disposition: attachment; filename=query-result.txt");261 262 260 while ($row0 = mysql_fetch_assoc($result0)) 263 261 { … … 293 291 } 294 292 295 function Checkbox2($val, $set, $text) 296 { 297 $value=$val.$set; 298 switch ($set) 299 { 300 case "ON": 301 if (!isset($_POST["submit"]) && ereg(" ".$val." ", $_GET["Set"])) 302 $_POST[$value]="On"; 303 break; 304 case "Off": 305 if (!isset($_POST["submit"]) && ereg(" ".$val." ", $_GET["Set2"])) 306 $_POST[$value]="On"; 307 break; 308 } 309 310 if ($_POST[$value]=="On") 293 function Checkbox2($value, $text) 294 { 295 if ($_SESSION[$value]=="On") 311 296 $checked = "checked"; 312 297 else … … 316 301 } 317 302 318 function CheckWhere($column , $_GET)303 function CheckWhere($column) 319 304 { 320 305 foreach ($_GET as $key => $element) … … 330 315 } 331 316 332 function CheckGroup($column , $_GET)317 function CheckGroup($column) 333 318 { 334 319 foreach ($_GET as $key => $element) … … 344 329 } 345 330 346 function CheckStatusGroup($column , $_GET)331 function CheckStatusGroup($column) 347 332 { 348 333 foreach ($_GET as $key => $element) … … 353 338 } 354 339 355 function CheckEnumGroup($column , $_GET)340 function CheckEnumGroup($column) 356 341 { 357 342 foreach ($_GET as $key => $element) … … 360 345 return -1; 361 346 return 0; 362 }363 364 function CreateMenu($rows)365 {366 $menu = "";367 368 if (empty($_GET["fNumResults"]))369 return;370 371 if ($_GET["fNumStart"]!=0)372 {373 $uri = htmlspecialchars($_SERVER["REQUEST_URI"]);374 $pos = strpos($uri, "fNumStart");375 $amp3=FALSE;376 if ($pos!=FALSE)377 {378 $amp1 = substr($uri, 0, $pos-1);379 $amp2 = substr($uri, $pos);380 $amp3 = strchr($amp2, "&");381 382 $uri = $amp1;383 }384 $pos = $_GET["fNumStart"]-$rows;385 if ($pos<0)386 $pos=0;387 $uri .= "&fNumStart=" . $pos;388 if ($amp3!=FALSE)389 $uri .= $amp3;390 391 $menu .= "<A HREF='" . $uri . "'><<< Prev</A>\n";392 }393 394 $menu .= " --- <B>";395 $menu .= $_GET["fNumStart"];396 $menu .= "</B> --- \n";397 398 if ($rows==$_GET["fNumResults"])399 {400 $uri = $_SERVER["REQUEST_URI"];401 $pos = strpos($uri, "fNumStart");402 $amp3=FALSE;403 if ($pos!=FALSE)404 {405 $amp1 = substr($uri, 0, $pos-1);406 $amp2 = substr($uri, $pos);407 $amp3 = strchr($amp2, "&");408 409 $uri = $amp1;410 }411 $uri .= "&fNumStart=" . ($_GET["fNumStart"]+$rows);412 if ($amp3!=FALSE)413 $uri .= $amp3;414 415 $menu .= "<A HREF='" . htmlspecialchars($uri) . "'>Next >>></A>\n";416 }417 return $menu;418 347 } 419 348 … … 455 384 } 456 385 457 function PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $form, $_GET) 386 //function for button in builddatasets.php 387 function GetClearedURL($all) 388 { 389 // $url=htmlspecialchars($_SERVER["REQUEST_URI"]); 390 $url=$_SERVER["REQUEST_URI"]; 391 // echo "before:".$url."<br>"; 392 if ($all=="yes") 393 { 394 // echo "replace <br>"; 395 // $url=str_replace("&DisplaySelected", "halo", $url); 396 $url=str_replace("&DisplaySelected=yes", "", $url); 397 $url=str_replace("&DisplaySelected=no", "", $url); 398 } 399 $url=str_replace("&insert=yes", "", $url); 400 $url=str_replace("&fSendTxt=2", "", $url); 401 $url=str_replace("&fSendTxt=1", "", $url); 402 // echo "after:".$url."<br>"; 403 $url=htmlspecialchars($url); 404 return $url; 405 } 406 407 function PrintUpdateDataSetButton() 408 { 409 if (empty($_SESSION["insert"])) 410 printf("<input type='submit' value='Update Data Set'> \n"); 411 else 412 printf("<input type='button' value='Continue' onClick='self.location.href=\"%s\"'> \n", GetClearedURL()); 413 414 } 415 416 //function for button in builddatasets.php 417 function PrintDisplaySequencesButtons() 418 { 419 if ($_SESSION["DisplaySelected"]!="yes" && ($_SESSION["sequon"]!=" " || $_SESSION["sequoff"]!=" ")) 420 { 421 PrintUpdateDataSetButton(); 422 printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'><br><br>\n", GetClearedURL("yes")); 423 } 424 425 if ($_SESSION["DisplaySelected"]=="yes") 426 { 427 PrintUpdateDataSetButton(); 428 printf("<input type='button' value='Display All Sequences' onClick='self.location.href=\"%s&DisplaySelected=no\"'>\n", GetClearedURL("yes")); 429 printf(" <i>Currently only selected sequences are displayed.</i><br><br>\n"); 430 } 431 } 432 433 434 function ReplaceInUri($name, $rows, $direction, $result1=0) 435 { 436 $uri = htmlspecialchars($_SERVER["REQUEST_URI"]); 437 $pos = strpos($uri, "fNumStart"); 438 $amp3=FALSE; 439 if ($pos!=FALSE) 440 { 441 $amp1 = substr($uri, 0, $pos-1); 442 $amp2 = substr($uri, $pos); 443 $amp3 = strchr($amp2, "&"); 444 445 $uri = $amp1; 446 } 447 448 switch($direction) 449 { 450 case 0: 451 $pos = $_GET["fNumStart"]-$rows; 452 if ($pos<0) 453 $pos=0; 454 break; 455 case 1: 456 $pos = $_GET["fNumStart"]+$rows; 457 break; 458 case 2: 459 $pos = 0; 460 break; 461 case 3: 462 $row1 = mysql_fetch_assoc($result1); 463 $pos = $row1["FOUND_ROWS()"]-$rows+1; 464 break; 465 } 466 467 $uri .= "&fNumStart=" . $pos; 468 if ($amp3!=FALSE) 469 $uri .= $amp3; 470 471 switch($direction) 472 { 473 case 0: 474 $link .= " <A HREF='" . $uri . "'>< Prev</A> \n"; 475 break; 476 case 1: 477 $link .= " <A HREF='" . $uri . "'>Next ></A> \n"; 478 break; 479 case 2: 480 $link .= " <A HREF='" . $uri . "'><< First</A> \n"; 481 break; 482 case 3: 483 $link .= " <A HREF='" . $uri . "'>Last >></A> \n"; 484 break; 485 } 486 return $link; 487 } 488 489 function CreateMenu($rows, $result1) 490 { 491 $menu = ""; 492 493 if (empty($_GET["fNumResults"])) 494 return; 495 496 if ($_GET["fNumStart"]!=0) 497 { 498 $menu .= ReplaceInUri("fNumStart", $rows, 2); 499 $menu .= ReplaceInUri("fNumStart", $rows, 0); 500 } 501 502 $menu .= " --- <B>"; 503 if (empty($_GET["fNumStart"])) 504 $menu .= "0"; 505 else 506 $menu .= $_GET["fNumStart"]; 507 $menu .= "</B> --- \n"; 508 509 if ($rows==$_GET["fNumResults"]) 510 { 511 $menu .= ReplaceInUri("fNumStart", $rows, 1); 512 $menu .= ReplaceInUri("fNumStart", $rows, 3, $result1); 513 } 514 return $menu; 515 } 516 517 function PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, $form="") 458 518 { 459 519 $col = FALSE; … … 470 530 471 531 472 $menu = CreateMenu(mysql_num_rows($result0)); 473 532 $menu = CreateMenu(mysql_num_rows($result0), $result1); 533 534 if ($form) 535 { 536 printf("<form method='POST'>"); 537 PrintDisplaySequencesButtons(); 538 } 474 539 printf("\n<center>\n"); 475 if ($form)476 printf("<form method='POST'>");477 540 if (empty($_GET["fPrintTable"])) 478 541 printf("%s\n", $menu); 542 479 543 printf("<table BORDER='0' style='margin-top:1ex'>\n"); 480 544 $counter=0; … … 518 582 if ($form) 519 583 { 520 CheckBox2($row0["Sequ"] ,"ON","");521 CheckBox2($row0["Sequ"] ,"Off","");584 CheckBox2($row0["Sequ"]."ON",""); 585 CheckBox2($row0["Sequ"]."Off",""); 522 586 } 523 587 foreach ($row0 as $key => $element) … … 607 671 */ 608 672 609 printf("<P><B>Number of displayed results: %d</B><P><P>\n", mysql_num_rows($result0)); 673 $row1 = mysql_fetch_assoc($result1); 674 printf("<P><B>Number of displayed results: %d of %s in total</B><P><P>\n", mysql_num_rows($result0), $row1["FOUND_ROWS()"]); 610 675 if (empty($_GET["fPrintTable"])) 611 676 printf("%s\n", $menu); 612 677 printf("<P>\n"); 678 printf("</center>\n"); 613 679 614 680 if (!$form) 615 681 { 616 printf("</center>\n");617 682 printf("</td>\n"); 618 683 printf("</tr>\n"); 619 684 } 685 else 686 PrintDisplaySequencesButtons(); 620 687 } 621 688 -
trunk/MagicSoft/Mars/datacenter/db/index.php
r8180 r9498 10 10 $groups++; 11 11 12 $query0 = "SELECT ";12 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 13 13 14 14 if ($groups>0) … … 372 372 373 373 $result0 = mysql_query($query0, $db_id); 374 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 374 375 375 376 if ($result0) 376 377 { 377 378 if ($html=="1") 378 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);379 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 379 380 else 380 381 PrintText($result0); 381 382 382 383 mysql_free_result($result0); 384 mysql_free_result($result1); 383 385 } 384 386 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/magicdefs.php
r9486 r9498 66 66 $checkwhere = array 67 67 ( 68 "fRunTypeName" => CheckWhere("fRunTypeKEY" , $_GET),69 "fProjectName" => CheckWhere("fProjectKEY" , $_GET),70 "fSourceName" => CheckWhere("fSourceKEY" , $_GET),71 "fMagicNumberName" => CheckWhere("fMagicNumberKEY" , $_GET),72 "fL1TriggerTableName" => CheckWhere("fL1TriggerTableKEY" , $_GET),73 "fL2TriggerTableName" => CheckWhere("fL2TriggerTableKEY" , $_GET),74 "fL3TriggerTableName" => CheckWhere("fL3TriggerTableKEY" , $_GET),75 "fHvSettingsName" => CheckWhere("fHvSettingsKEY" , $_GET),76 "fCalibrationScriptName" => CheckWhere("fCalibrationScriptKEY" , $_GET),77 "fExcludedFDAName" => CheckWhere("fExcludedFDAKEY" , $_GET),78 "fManuallyChangedName" => CheckWhere("fManuallyChangedKEY" , $_GET),79 "fObservationModeName" => CheckWhere("fObservationModeKEY" , $_GET),80 "fSumTriggerFlagName" => CheckWhere("fSumTriggerFlagKEY" , $_GET),81 "fDiscriminatorThresholdTableName" => CheckWhere("fDiscriminatorThresholdTableKEY" , $_GET),82 "fTriggerDelayTableName" => CheckWhere("fTriggerDelayTableKEY" , $_GET),83 "fTestFlagName" => CheckWhere("fTestFlagKEY" , $_GET),84 "fLightConditionsName" => CheckWhere("fLightConditionsKEY" , $_GET),85 "fParticleTypeName" => CheckWhere("fParticleTypeKEY" , $_GET),86 "fFitsFileName" => CheckWhere("fFitsFileKEY" , $_GET),87 "fObjectName" => CheckWhere("fObjectKEY" , $_GET),88 "fStatusName" => CheckWhere("fStatusKEY" , $_GET),89 "fTelescopeName" => CheckWhere("fTelescopeKEY" , $_GET),90 "fBandName" => CheckWhere("fBandKEY" , $_GET),91 "fUserName" => CheckWhere("fUserKEY" , $_GET),92 "fCycleName" => CheckWhere("fCycleKEY" , $_GET),93 "fPIName" => CheckWhere("fPIKEY" , $_GET),94 "fWorkingGroupName" => CheckWhere("fWorkingGroupKEY" , $_GET),95 "fProposalName" => CheckWhere("fProposalKEY" , $_GET),68 "fRunTypeName" => CheckWhere("fRunTypeKEY"), 69 "fProjectName" => CheckWhere("fProjectKEY"), 70 "fSourceName" => CheckWhere("fSourceKEY"), 71 "fMagicNumberName" => CheckWhere("fMagicNumberKEY"), 72 "fL1TriggerTableName" => CheckWhere("fL1TriggerTableKEY"), 73 "fL2TriggerTableName" => CheckWhere("fL2TriggerTableKEY"), 74 "fL3TriggerTableName" => CheckWhere("fL3TriggerTableKEY"), 75 "fHvSettingsName" => CheckWhere("fHvSettingsKEY"), 76 "fCalibrationScriptName" => CheckWhere("fCalibrationScriptKEY"), 77 "fExcludedFDAName" => CheckWhere("fExcludedFDAKEY"), 78 "fManuallyChangedName" => CheckWhere("fManuallyChangedKEY"), 79 "fObservationModeName" => CheckWhere("fObservationModeKEY"), 80 "fSumTriggerFlagName" => CheckWhere("fSumTriggerFlagKEY"), 81 "fDiscriminatorThresholdTableName" => CheckWhere("fDiscriminatorThresholdTableKEY"), 82 "fTriggerDelayTableName" => CheckWhere("fTriggerDelayTableKEY"), 83 "fTestFlagName" => CheckWhere("fTestFlagKEY"), 84 "fLightConditionsName" => CheckWhere("fLightConditionsKEY"), 85 "fParticleTypeName" => CheckWhere("fParticleTypeKEY"), 86 "fFitsFileName" => CheckWhere("fFitsFileKEY"), 87 "fObjectName" => CheckWhere("fObjectKEY"), 88 "fStatusName" => CheckWhere("fStatusKEY"), 89 "fTelescopeName" => CheckWhere("fTelescopeKEY"), 90 "fBandName" => CheckWhere("fBandKEY"), 91 "fUserName" => CheckWhere("fUserKEY"), 92 "fCycleName" => CheckWhere("fCycleKEY"), 93 "fPIName" => CheckWhere("fPIKEY"), 94 "fWorkingGroupName" => CheckWhere("fWorkingGroupKEY"), 95 "fProposalName" => CheckWhere("fProposalKEY"), 96 96 ); 97 97 98 98 $checkgroup = array 99 99 ( 100 "fRunTypeName" => CheckGroup("fRunTypeKEY" , $_GET),101 "fProjectName" => CheckGroup("fProjectKEY" , $_GET),102 "fSourceName" => CheckGroup("fSourceKEY" , $_GET),103 "fMagicNumberName" => CheckGroup("fMagicNumberKEY" , $_GET),104 "fL1TriggerTableName" => CheckGroup("fL1TriggerTableKEY" , $_GET),105 "fL2TriggerTableName" => CheckGroup("fL2TriggerTableKEY" , $_GET),106 "fL3TriggerTableName" => CheckGroup("fL3TriggerTableKEY" , $_GET),107 "fHvSettingsName" => CheckGroup("fHvSettingsKEY" , $_GET),108 "fCalibrationScriptName" => CheckGroup("fCalibrationScriptKEY" , $_GET),109 "fExcludedFDAName" => CheckGroup("fExcludedFDAKEY" , $_GET),110 "fManuallyChangedName" => CheckGroup("fManuallyChangedKEY" , $_GET),111 "fObservationModeName" => CheckGroup("fObservationModeKEY" , $_GET),112 "fSumTriggerFlagName" => CheckGroup("fSumTriggerFlagKEY" , $_GET),113 "fDiscriminatorThresholdTableName" => CheckGroup("fDiscriminatorThresholdTableKEY" , $_GET),114 "fTriggerDelayTableName" => CheckGroup("fTriggerDelayTableKEY" , $_GET),115 "fTestFlagName" => CheckGroup("fTestFlagKEY" , $_GET),116 "fLightConditionsName" => CheckGroup("fLightConditionsKEY" , $_GET),117 "fParticleTypeName" => CheckGroup("fParticleTypeKEY" , $_GET),118 "fFitsFileName" => CheckGroup("fFitsFileKEY" , $_GET),119 "fObjectName" => CheckGroup("fObjectKEY" , $_GET),120 "fStatusName" => CheckGroup("fStatusKEY" , $_GET),121 "fBandName" => CheckGroup("fBandKEY" , $_GET),122 "fUserName" => CheckGroup("fUserKEY" , $_GET),123 "fTelescopeName" => CheckGroup("fTelescopeKEY" , $_GET),124 "fCycleName" => CheckWhere("fCycleKEY" , $_GET),125 "fPIName" => CheckWhere("fPIKEY" , $_GET),126 "fWorkingGroupName" => CheckWhere("fWorkingGroupKEY" , $_GET),127 "fProposalName" => CheckWhere("fProposalKEY" , $_GET),100 "fRunTypeName" => CheckGroup("fRunTypeKEY"), 101 "fProjectName" => CheckGroup("fProjectKEY"), 102 "fSourceName" => CheckGroup("fSourceKEY"), 103 "fMagicNumberName" => CheckGroup("fMagicNumberKEY"), 104 "fL1TriggerTableName" => CheckGroup("fL1TriggerTableKEY"), 105 "fL2TriggerTableName" => CheckGroup("fL2TriggerTableKEY"), 106 "fL3TriggerTableName" => CheckGroup("fL3TriggerTableKEY"), 107 "fHvSettingsName" => CheckGroup("fHvSettingsKEY"), 108 "fCalibrationScriptName" => CheckGroup("fCalibrationScriptKEY"), 109 "fExcludedFDAName" => CheckGroup("fExcludedFDAKEY"), 110 "fManuallyChangedName" => CheckGroup("fManuallyChangedKEY"), 111 "fObservationModeName" => CheckGroup("fObservationModeKEY"), 112 "fSumTriggerFlagName" => CheckGroup("fSumTriggerFlagKEY"), 113 "fDiscriminatorThresholdTableName" => CheckGroup("fDiscriminatorThresholdTableKEY"), 114 "fTriggerDelayTableName" => CheckGroup("fTriggerDelayTableKEY"), 115 "fTestFlagName" => CheckGroup("fTestFlagKEY"), 116 "fLightConditionsName" => CheckGroup("fLightConditionsKEY"), 117 "fParticleTypeName" => CheckGroup("fParticleTypeKEY"), 118 "fFitsFileName" => CheckGroup("fFitsFileKEY"), 119 "fObjectName" => CheckGroup("fObjectKEY"), 120 "fStatusName" => CheckGroup("fStatusKEY"), 121 "fBandName" => CheckGroup("fBandKEY"), 122 "fUserName" => CheckGroup("fUserKEY"), 123 "fTelescopeName" => CheckGroup("fTelescopeKEY"), 124 "fCycleName" => CheckWhere("fCycleKEY"), 125 "fPIName" => CheckWhere("fPIKEY"), 126 "fWorkingGroupName" => CheckWhere("fWorkingGroupKEY"), 127 "fProposalName" => CheckWhere("fProposalKEY"), 128 128 ); 129 129 … … 131 131 $checkstatusgroup = array 132 132 ( 133 "fCCFilled" => CheckStatusGroup("fCCFilledStatus" , $_GET),134 "fExclusionsDone" => CheckStatusGroup("fExclusionsDoneStatus" , $_GET),135 "fSequenceEntriesBuilt" => CheckStatusGroup("fSequenceEntriesBuiltStatus" ,$_GET),136 "fCCFileAvail" => CheckStatusGroup("fCCFileAvailStatus" , $_GET),137 "fCaCoFileAvail" => CheckStatusGroup("fCaCoFileAvailStatus" , $_GET),138 "fCaCoFileFound" => CheckStatusGroup("fCaCoFileFoundStatus" , $_GET),139 "fRawFileAvail" => CheckStatusGroup("fRawFileAvailStatus" , $_GET),140 "fTimingCorrection" => CheckStatusGroup("fTimingCorrectionStatus" , $_GET),141 "fDataCheckDone" => CheckStatusGroup("fDataCheckDoneStatus" , $_GET),142 // "fFillDotRaw" => CheckStatusGroup("fFillDotRawStatus" , $_GET),143 "fSequenceFileWritten" => CheckStatusGroup("fSequenceFileWrittenStatus" , $_GET),144 "fAllFilesAvail" => CheckStatusGroup("fAllFilesAvailStatus" , $_GET),145 "fCallisto" => CheckStatusGroup("fCallistoStatus" , $_GET),146 "fFillCallisto" => CheckStatusGroup("fFillCallistoStatus" , $_GET),147 "fStar" => CheckStatusGroup("fStarStatus" , $_GET),148 "fFillStar" => CheckStatusGroup("fFillStarStatus" , $_GET),149 "fDataSetInserted" => CheckStatusGroup("fDataSetInsertedStatus" , $_GET),150 "fDataSetFileWritten" => CheckStatusGroup("fDataSetFileWrittenStatus" , $_GET),151 "fStarFilesAvail" => CheckStatusGroup("fStarFilesAvailStatus" , $_GET),152 "fGanymed" => CheckStatusGroup("fGanymedStatus" , $_GET),153 "fFillGanymed" => CheckStatusGroup("fFillGanymedStatus" , $_GET),133 "fCCFilled" => CheckStatusGroup("fCCFilledStatus"), 134 "fExclusionsDone" => CheckStatusGroup("fExclusionsDoneStatus"), 135 "fSequenceEntriesBuilt" => CheckStatusGroup("fSequenceEntriesBuiltStatus"), 136 "fCCFileAvail" => CheckStatusGroup("fCCFileAvailStatus"), 137 "fCaCoFileAvail" => CheckStatusGroup("fCaCoFileAvailStatus"), 138 "fCaCoFileFound" => CheckStatusGroup("fCaCoFileFoundStatus"), 139 "fRawFileAvail" => CheckStatusGroup("fRawFileAvailStatus"), 140 "fTimingCorrection" => CheckStatusGroup("fTimingCorrectionStatus"), 141 "fDataCheckDone" => CheckStatusGroup("fDataCheckDoneStatus"), 142 // "fFillDotRaw" => CheckStatusGroup("fFillDotRawStatus"), 143 "fSequenceFileWritten" => CheckStatusGroup("fSequenceFileWrittenStatus"), 144 "fAllFilesAvail" => CheckStatusGroup("fAllFilesAvailStatus"), 145 "fCallisto" => CheckStatusGroup("fCallistoStatus"), 146 "fFillCallisto" => CheckStatusGroup("fFillCallistoStatus"), 147 "fStar" => CheckStatusGroup("fStarStatus"), 148 "fFillStar" => CheckStatusGroup("fFillStarStatus"), 149 "fDataSetInserted" => CheckStatusGroup("fDataSetInsertedStatus"), 150 "fDataSetFileWritten" => CheckStatusGroup("fDataSetFileWrittenStatus"), 151 "fStarFilesAvail" => CheckStatusGroup("fStarFilesAvailStatus"), 152 "fGanymed" => CheckStatusGroup("fGanymedStatus"), 153 "fFillGanymed" => CheckStatusGroup("fFillGanymedStatus"), 154 154 ); 155 155 … … 157 157 $checkenumgroup = array 158 158 ( 159 "fHasSignal" => CheckEnumGroup("fHasSignalEnum" , $_GET),160 "fHasPedestal" => CheckEnumGroup("fHasPedestalEnum" , $_GET),161 "fHasSignalInterlaced" => CheckEnumGroup("fHasSignalInterlacedEnum" , $_GET),162 "fHasPedestalInterlaced" => CheckEnumGroup("fHasPedestalInterlacedEnum" , $_GET),159 "fHasSignal" => CheckEnumGroup("fHasSignalEnum"), 160 "fHasPedestal" => CheckEnumGroup("fHasPedestalEnum"), 161 "fHasSignalInterlaced" => CheckEnumGroup("fHasSignalInterlacedEnum"), 162 "fHasPedestalInterlaced" => CheckEnumGroup("fHasPedestalInterlacedEnum"), 163 163 ); 164 164 -
trunk/MagicSoft/Mars/datacenter/db/mcdefs.php
r9486 r9498 17 17 $checkwhere = array 18 18 ( 19 "fParticleTypeName" => CheckWhere("fParticleTypeKEY" , $_GET),20 "fAtmosphericModelName" => CheckWhere("fAtmosphericModelKEY" , $_GET),19 "fParticleTypeName" => CheckWhere("fParticleTypeKEY"), 20 "fAtmosphericModelName" => CheckWhere("fAtmosphericModelKEY"), 21 21 ); 22 22 23 23 $checkgroup = array 24 24 ( 25 "fParticleTypeName" => CheckGroup("fParticleTypeKEY" , $_GET),26 "fAtmosphericModelName" => CheckGroup("fAtmosphericModelKEY" , $_GET),25 "fParticleTypeName" => CheckGroup("fParticleTypeKEY"), 26 "fAtmosphericModelName" => CheckGroup("fAtmosphericModelKEY"), 27 27 ); 28 28 … … 30 30 $checkstatusgroup = array 31 31 ( 32 "fCorsikaInputCreated" => CheckStatusGroup("fCorsikaInputCreatedStatus" , $_GET),33 "fCorsikaFileAvail" => CheckStatusGroup("fCorsikaFileAvailStatus" , $_GET),32 "fCorsikaInputCreated" => CheckStatusGroup("fCorsikaInputCreatedStatus"), 33 "fCorsikaFileAvail" => CheckStatusGroup("fCorsikaFileAvailStatus"), 34 34 ); 35 35 -
trunk/MagicSoft/Mars/datacenter/db/mcinfo.php
r9486 r9498 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0 || $statusgroups>0) … … 279 279 280 280 $result0 = mysql_query($query0, $db_id); 281 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 281 282 282 283 if ($result0) 283 284 { 284 285 if ($html=="1" || $html=="2") 285 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);286 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 286 287 else 287 288 PrintText($result0); 288 289 289 290 mysql_free_result($result0); 291 mysql_free_result($result1); 290 292 } 291 293 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/menu.php
r9486 r9498 698 698 $starmax = $_GET["fStarStop"]; 699 699 700 printf("<p>StarDone (yyyy-mm-dd ) from <input name=\"fStarStart\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $starmin);701 printf("to <input name=\"fStarStop\" type=\"text\" size=\"1 0\" maxlength=\"10\" value=\"%s\"> \n", $starmax);700 printf("<p>StarDone (yyyy-mm-dd hh:mm:ss) from <input name=\"fStarStart\" type=\"text\" size=\"19\" maxlength=\"19\" value=\"%s\">\n", $starmin); 701 printf("to <input name=\"fStarStop\" type=\"text\" size=\"19\" maxlength=\"19\" value=\"%s\"> \n", $starmax); 702 702 } 703 703 … … 766 766 } 767 767 768 function InitFailInfo($ _GET, $first)768 function InitFailInfo($first) 769 769 { 770 770 if (empty($_GET["fStartTime"])) … … 781 781 } 782 782 783 function InitInfo($ _GET, $first)783 function InitInfo($first) 784 784 { 785 785 if (empty($_GET["fNumResults"])) … … 838 838 839 839 if (empty($_GET["fProposalName"])) 840 $_GET["fProp salName"]="Off";841 } 842 843 function InitRunStatus($ _GET, $first)840 $_GET["fProposalName"]="Off"; 841 } 842 843 function InitRunStatus($first) 844 844 { 845 845 if (empty($_GET["fDataCheckDone"])) … … 880 880 } 881 881 882 function InitRunInfo($ _GET, $first)883 { 884 InitRunStatus($ _GET, $first);885 InitInfo($ _GET, $first);886 InitFailInfo($ _GET, $first);882 function InitRunInfo($first) 883 { 884 InitRunStatus($first); 885 InitInfo($first); 886 InitFailInfo($first); 887 887 888 888 if (empty($_GET["fLinks"])) … … 950 950 } 951 951 952 function InitSequStatus($ _GET, $first)952 function InitSequStatus($first) 953 953 { 954 954 if (empty($_GET["fSequenceFileWritten"])) … … 989 989 } 990 990 991 function InitStarInfo($ _GET, $first)991 function InitStarInfo($first) 992 992 { 993 993 if (empty($_GET["fMeanNumberIslands"])) … … 1061 1061 } 1062 1062 1063 function InitCalInfo($ _GET, $first)1063 function InitCalInfo($first) 1064 1064 { 1065 1065 if (empty($_GET["fUnreliableInner"])) … … 1157 1157 } 1158 1158 1159 function InitSequInfo($ _GET, $first)1160 { 1161 InitInfo($ _GET, $first);1162 InitSequStatus($ _GET, $first);1163 InitFailInfo($ _GET, $first);1164 InitCalInfo($ _GET, $first);1165 InitStarInfo($ _GET, $first);1159 function InitSequInfo($first) 1160 { 1161 InitInfo($first); 1162 InitSequStatus($first); 1163 InitFailInfo($first); 1164 InitCalInfo($first); 1165 InitStarInfo($first); 1166 1166 1167 1167 if (empty($_GET["fRunTime/60"])) … … 1189 1189 $_GET["fSumTriggerFlagName"]="Off"; 1190 1190 1191 if (empty($_GET["fOnlySum"])) 1192 $_GET["fOnlySum"]="Off"; 1193 1191 1194 // if (empty($_GET["fManuallyChangedName"])) 1192 1195 // $_GET["fManuallyChangedName"]="Off"; 1193 1196 } 1194 1197 1195 function InitDataSetStatus($ _GET, $first)1198 function InitDataSetStatus($first) 1196 1199 { 1197 1200 if (empty($_GET["fDataSetInserted"])) … … 1226 1229 } 1227 1230 1228 function InitDataSetInfo($ _GET, $first)1229 { 1230 InitDataSetStatus($ _GET, $first);1231 InitFailInfo($ _GET, $first);1231 function InitDataSetInfo($first) 1232 { 1233 InitDataSetStatus($first); 1234 InitFailInfo($first); 1232 1235 1233 1236 if (empty($_GET["fNumResults"])) … … 1299 1302 } 1300 1303 1301 function InitFindOffData($ _GET, $first)1302 { 1303 InitSequInfo($ _GET, $first);1304 function InitFindOffData($first) 1305 { 1306 InitSequInfo($first); 1304 1307 1305 1308 //init for limits … … 1441 1444 } 1442 1445 1443 function InitCTAMCRunStatus($_GET, $first) 1446 function InitBuildDataSets($first) 1447 { 1448 if (empty($_GET["fNumResults"])) 1449 // $_GET["fNumResults"]="50"; 1450 $_GET["fNumResults"]="10"; 1451 1452 if (empty($_GET["fRunStart"])) 1453 $_GET["fRunStart"]=$first?"On":""; 1454 1455 if (empty($_GET["fRunTime/60"])) 1456 $_GET["fRunTime/60"]=$first?"On":""; 1457 1458 if (empty($_GET["fZenithDistanceMin"])) 1459 $_GET["fZenithDistanceMin"]=$first?"On":""; 1460 1461 if (empty($_GET["fZenithDistanceMax"])) 1462 $_GET["fZenithDistanceMax"]=$first?"On":""; 1463 1464 if (empty($_GET["fSourceName"])) 1465 $_GET["fSourceName"]=$first?"On":""; 1466 1467 if (empty($_GET["fObservationModeName"])) 1468 $_GET["fObservationModeName"]=$first?"On":""; 1469 1470 if (empty($_GET["fUnsuitableInner"])) 1471 $_GET["fUnsuitableInner"]=$first?"On":""; 1472 1473 if (empty($_GET["fUnreliableInner"])) 1474 $_GET["fUnreliableInner"]=$first?"On":""; 1475 1476 if (empty($_GET["fIsolatedInner"])) 1477 $_GET["fIsolatedInner"]=$first?"On":""; 1478 1479 if (empty($_GET["fIsolatedMaxCluster"])) 1480 $_GET["fIsolatedMaxCluster"]=$first?"On":""; 1481 1482 if (empty($_GET["fArrTimeRmsInner"])) 1483 $_GET["fArrTimeRmsInner"]=$first?"On":""; 1484 1485 if (empty($_GET["fMeanPedRmsInner"])) 1486 $_GET["fMeanPedRmsInner"]=$first?"On":""; 1487 1488 if (empty($_GET["fPulsePosMean"])) 1489 $_GET["fPulsePosMean"]=$first?"On":""; 1490 1491 if (empty($_GET["fConvFactorInner"])) 1492 $_GET["fConvFactorInner"]=$first?"On":""; 1493 1494 if (empty($_GET["fInhomogeneity"])) 1495 $_GET["fInhomogeneity"]=$first?"On":""; 1496 1497 if (empty($_GET["fPSF"])) 1498 $_GET["fPSF"]=$first?"On":""; 1499 1500 if (empty($_GET["fMuonNumber"])) 1501 $_GET["fMuonNumber"]=$first?"On":""; 1502 1503 if (empty($_GET["fEffOnTime/fRunTime"])) 1504 $_GET["fEffOnTime/fRunTime"]=$first?"On":""; 1505 1506 if (empty($_GET["fMuonRate"])) 1507 $_GET["fMuonRate"]=$first?"On":""; 1508 1509 if (empty($_GET["fDataRate"])) 1510 $_GET["fDataRate"]=$first?"On":""; 1511 1512 if (empty($_GET["fAvgCloudiness"])) 1513 $_GET["fAvgCloudiness"]=$first?"On":""; 1514 1515 if (empty($_GET["fNumStarsMed"])) 1516 $_GET["fNumStarsMed"]=$first?"On":""; 1517 1518 if (empty($_GET["fNumStarsCorMed"])) 1519 $_GET["fNumStarsCorMed"]=$first?"On":""; 1520 1521 if (empty($_GET["fOff"])) 1522 $_GET["fOff"]=$first?"On":""; 1523 1524 if (empty($_GET["fLinks"])) 1525 $_GET["fLinks"]=$first?"On":""; 1526 1527 if (empty($_GET["fOnlyOff"])) 1528 $_GET["fOnlyOff"]=$first?"Off":""; 1529 1530 InitFindOffData($first); 1531 } 1532 1533 function InitCTAMCRunStatus($first) 1444 1534 { 1445 1535 if (empty($_GET["fCorsikaSimTelarray"])) … … 1481 1571 } 1482 1572 1483 function InitCTAMCRunInfo($ _GET, $first)1573 function InitCTAMCRunInfo($first) 1484 1574 { 1485 1575 if (empty($_GET["fNumResults"])) 1486 1576 $_GET["fNumResults"]="50"; 1487 1577 1488 InitCTAMCRunStatus($ _GET, $first);1489 InitInfo($ _GET, $first);1490 InitFailInfo($ _GET, $first);1578 InitCTAMCRunStatus($first); 1579 InitInfo($first); 1580 InitFailInfo($first); 1491 1581 1492 1582 if (empty($_GET["fNumEvents"])) -
trunk/MagicSoft/Mars/datacenter/db/opticaldata.php
r8235 r9498 10 10 $groups++; 11 11 12 $query0 = "SELECT ";12 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 13 13 14 14 if ($groups>0) … … 247 247 248 248 $result0 = mysql_query($query0, $db_id); 249 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 249 250 250 251 if ($result0) 251 252 { 252 253 if ($html=="1") 253 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);254 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 254 255 else 255 256 PrintText($result0); 256 257 257 258 mysql_free_result($result0); 259 mysql_free_result($result1); 258 260 } 259 261 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/printtable.php
r8249 r9498 28 28 29 29 $fromtable=$_GET["fTable"]; 30 $query0 = "SELECT * FROM " . $fromtable;30 $query0 = "SELECT SQL_CALC_FOUND_ROWS * FROM " . $fromtable; 31 31 if (!empty($_GET["fSortBy"])) 32 32 { … … 39 39 40 40 $result0 = mysql_query($query0, $db_id); 41 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 41 42 42 43 if ($result0) … … 50 51 ( 51 52 ); 52 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);53 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 53 54 } 54 55 else … … 56 57 57 58 mysql_free_result($result0); 59 mysql_free_result($result1); 58 60 } 59 61 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/querycal.php
r8512 r9498 3 3 function CreateQuery($_GET, $alias, $checkwhere) 4 4 { 5 $query0 = "SELECT fSequenceFirst as 'Sequence#' ";5 $query0 = "SELECT SQL_CALC_FOUND_ROWS fSequenceFirst as 'Sequence#' "; 6 6 7 7 foreach ($_GET as $key => $element) … … 217 217 218 218 $result0 = mysql_query($query0, $db_id); 219 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 219 220 220 221 if ($result0) 221 222 { 222 223 if ($html=="1") 223 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $ _GET);224 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $result1); 224 225 else 225 226 PrintText($result0); 226 227 227 228 mysql_free_result($result0); 229 mysql_free_result($result1); 228 230 } 229 231 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/querymc.php
r8180 r9498 10 10 $groups++; 11 11 12 $query0 = "SELECT ";12 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 13 13 14 14 if ($groups>0) … … 239 239 240 240 $result0 = mysql_query($query0, $db_id); 241 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 241 242 242 243 if ($result0) 243 244 { 244 245 if ($html=="1") 245 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);246 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 246 247 else 247 248 PrintText($result0); 248 249 249 250 mysql_free_result($result0); 251 mysql_free_result($result1); 250 252 } 251 253 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/queryrbk.php
r9184 r9498 50 50 mysql_select_db($db); 51 51 52 $query0 = "SELECT fRunBookDate AS Date, fRunBookText AS Entry ";52 $query0 = "SELECT SQL_CALC_FOUND_ROWS fRunBookDate AS Date, fRunBookText AS Entry "; 53 53 $query0 .= "FROM " . $db . ".RunBook "; 54 54 $query0 .= "WHERE fRunBookDate REGEXP '^" . $_GET["fDate"] . "' "; … … 63 63 64 64 $result0 = mysql_query($query0, $db_id); 65 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 65 66 66 67 if ($result0) … … 76 77 ( 77 78 ); 78 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);79 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 79 80 } 80 81 else … … 82 83 83 84 mysql_free_result($result0); 85 mysql_free_result($result1); 84 86 } 85 87 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/queryseq.php
r8180 r9498 10 10 $groups++; 11 11 12 $query0 = "SELECT ";12 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 13 13 14 14 if ($groups>0) … … 314 314 315 315 $result0 = mysql_query($query0, $db_id); 316 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 316 317 317 318 if ($result0) 318 319 { 319 320 if ($html=="1") 320 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);321 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 321 322 else 322 323 PrintText($result0); 323 324 324 325 mysql_free_result($result0); 326 mysql_free_result($result1); 325 327 } 326 328 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/querystar.php
r8180 r9498 3 3 function CreateQuery($_GET, $alias, $checkwhere) 4 4 { 5 $query0 = "SELECT fSequenceFirst as 'Sequence#' ";5 $query0 = "SELECT SQL_CALC_FOUND_ROWS fSequenceFirst as 'Sequence#' "; 6 6 7 7 foreach ($_GET as $key => $element) … … 160 160 161 161 $result0 = mysql_query($query0, $db_id); 162 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 162 163 163 164 if ($result0) 164 165 { 165 166 if ($html=="1") 166 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $ _GET);167 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $result1); 167 168 else 168 169 PrintText($result0); 169 170 170 171 mysql_free_result($result0); 172 mysql_free_result($result1); 171 173 } 172 174 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/runinfo-aio.php
r9486 r9498 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0 || ((!empty($_GET["fGroupByDate"])) && !$_GET["fGroupByDate"]==0) || $statusgroups>0) … … 324 324 325 325 $result0 = mysql_query($query0, $db_id); 326 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 326 327 327 328 if ($result0) 328 329 { 329 330 if ($html=="1" || $html=="2") 330 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);331 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 331 332 else 332 333 PrintText($result0); 333 334 334 335 mysql_free_result($result0); 336 mysql_free_result($result1); 335 337 } 336 338 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/runinfo.php
r9486 r9498 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0) … … 515 515 516 516 $result0 = mysql_query($query0, $db_id); 517 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 517 518 518 519 if ($result0) 519 520 { 520 521 if ($html=="1" || $html=="2") 521 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);522 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 522 523 else 523 524 PrintText($result0); 524 525 525 526 mysql_free_result($result0); 527 mysql_free_result($result1); 526 528 } 527 529 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/sequinfo-aio.php
r9486 r9498 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0 || ((!empty($_GET["fGroupByDate"])) && !$_GET["fGroupByDate"]==0) || $statusgroups>0) … … 397 397 398 398 $result0 = mysql_query($query0, $db_id); 399 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 399 400 400 401 if ($result0) 401 402 { 402 403 if ($html=="1" || $html=="2") 403 PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, "", $_GET);404 PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, ""); 404 405 else 405 406 PrintText($result0); 406 407 407 408 mysql_free_result($result0); 409 mysql_free_result($result1); 408 410 } 409 411 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/sequinfo.php
r9486 r9498 15 15 $statusgroups++; 16 16 17 $query0 = "SELECT ";17 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 18 18 19 19 if ($groups>0) … … 628 628 629 629 $result0 = mysql_query($query0, $db_id); 630 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 630 631 631 632 if ($result0) 632 633 { 633 634 if ($html=="1" || $html=="2") 634 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);635 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 635 636 else 636 637 PrintText($result0); 637 638 638 639 mysql_free_result($result0); 640 mysql_free_result($result1); 639 641 } 640 642 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/sources.php
r8621 r9498 4 4 { 5 5 6 $query0 = "SELECT ";6 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 7 7 if ($_GET["fLinks"]=="Off" || !empty($_GET["fSendTxt"])) 8 8 $query0 .= " fSourceName as 'Source' "; … … 112 112 113 113 $result0 = mysql_query($query0, $db_id); 114 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 114 115 115 116 if ($result0) 116 117 { 117 118 if ($html=="1") 118 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);119 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 119 120 else 120 121 PrintText($result0); 121 122 122 123 mysql_free_result($result0); 124 mysql_free_result($result1); 123 125 } 124 126 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/statusrps.php
r9486 r9498 3 3 function CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs) 4 4 { 5 $query0 = "SELECT ";5 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 6 6 7 7 $statusgroups = 0; … … 203 203 204 204 $result0 = mysql_query($query0, $db_id); 205 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 205 206 206 207 if ($result0) 207 208 { 208 209 if ($html=="1") 209 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);210 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 210 211 else 211 212 PrintText($result0); 212 213 213 214 mysql_free_result($result0); 215 mysql_free_result($result1); 214 216 } 215 217 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/statussbs.php
r9486 r9498 8 8 $statusgroups++; 9 9 10 $query0 = "SELECT ";10 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 11 11 12 12 if ($statusgroups>0) … … 179 179 180 180 $result0 = mysql_query($query0, $db_id); 181 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 181 182 182 183 if ($result0) 183 184 { 184 185 if ($html=="1") 185 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);186 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 186 187 else 187 188 PrintText($result0); 188 189 189 190 mysql_free_result($result0); 191 mysql_free_result($result1); 190 192 } 191 193 mysql_close($db_id); -
trunk/MagicSoft/Mars/datacenter/db/statussps.php
r9486 r9498 8 8 $statusgroups++; 9 9 10 $query0 = "SELECT ";10 $query0 = "SELECT SQL_CALC_FOUND_ROWS "; 11 11 12 12 if ($statusgroups>0) … … 192 192 193 193 $result0 = mysql_query($query0, $db_id); 194 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id); 194 195 195 196 if ($result0) 196 197 { 197 198 if ($html=="1") 198 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);199 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1); 199 200 else 200 201 PrintText($result0); 201 202 202 203 mysql_free_result($result0); 204 mysql_free_result($result1); 203 205 } 204 206 mysql_close($db_id);
Note:
See TracChangeset
for help on using the changeset viewer.