connect_error) { header("HTTP/1.0 500 Internal server error"); $error_con = $db->connect_error; //die("mysqli_connect: ".$db->connect_errno." ".$db->connect_error); } if (isset($_GET["short"]) && !$db->connect_error) { $query = "SELECT URL from ShortURL.ShortURL WHERE `Key`=(".base62_decode($_GET["short"]).")"; if ($result = $db->query($query)) { $uri = $_SERVER['REQUEST_URI']; $pos = strpos($uri, '?'); $uri = $pos===FALSE ? $uri : substr($uri, 0, $pos); $row = $result->fetch_assoc(); $result->free(); $url = $row['URL']; $tiny = $_SERVER['HTTP_HOST'].$uri.'?'.$url; if (isset($_GET["print"]) && strstr($url, "?print")==FALSE && strstr($url, "&print")==FALSE) $tiny .= "&print"; header('Location: //'.$tiny); die(""); } } $hidden = isset($_GET["print"]) ? "*{visibility:hidden;}.print{position:fixed;left:0;top:0;}.print *{visibility:visible;}" : ""; $begin = isset($_GET["b"]) ? $_GET["b"] : ""; $end = isset($_GET["e"]) ? $_GET["e"] : ""; $source = isset($_GET["s"]) ? intval($_GET["s"]) : 0; $group = isset($_GET["g"]) ? intval($_GET["g"]) : 1; $table = isset($_GET["t"]) ? $_GET["t"] : "LP"; $cut = isset($_GET["cut"]) ? trim($_GET["cut"]) : ""; $having = isset($_GET["hav"]) ? trim($_GET["hav"]) : ""; $vmin = isset($_GET["min"]) ? "minValue:".intval($_GET["min"])."," : ""; $vmax = isset($_GET["max"]) ? "maxValue:".intval($_GET["max"])."," : ""; $width = isset($_GET["w"]) ? floatval($_GET["w"]) : 1; $sql_x = isset($_GET["x"]) ? trim($_GET["x"]) : ""; $sql_y = isset($_GET["y"]) ? trim($_GET["y"]) : ""; $sql_err= isset($_GET["err"]) ? trim($_GET["err"]) : ""; $rate = isset($_GET["r"]) ? intval($_GET["r"]) : 6; $offset = isset($_GET["o"]) ? floatval($_GET["o"]) : 0; $nohist = isset($_GET["no-hist"]) ? 1 : 0; $noerr = isset($_GET["no-errors"]) ? 1 : 0; $ontime = isset($_GET["on"]) ? floatval($_GET["on"]) : -1; //$clean = isset($_GET["clean"]) ? "AND fEffectiveOn>0.015" : ""; if (!empty($sql_x)) $group = 42; if ($width<=0) $width = 1; if (empty($offset)) $offset = 0; switch($table) { case "LP": $zdfactor="(pow(cos(fZenithDistanceMean*PI()/180),3)+14.8/21.9*pow(sin(2*fZenithDistanceMean*PI()/180),5))"; $thfactor="(1-0.00124/1.21*(fThresholdMinSet-500)*(fThresholdMinSet>=500))"; // ETh: 715 GeV $crabflux="1.81"; break; case "ISDC": $zdfactor="pow(cos(fZenithDistanceMean*PI()/180)*exp(1-cos(fZenithDistanceMean*PI()/180)),4.2)"; $thfactor="(1.18-IF(ISNULL(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)*0.00062)"; // ETh: 764 GeV $crabflux="1.89"; break; case "CutsLC": $zdfactor="pow(cos(fZenithDistanceMean*PI()/180)*exp(1-cos(fZenithDistanceMean*PI()/180)),4.5)"; $thfactor="(1.37-IF(ISNULL(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)*0.00118)"; // ETh: 543 GeV $crabflux="3.14"; break; default: $zdfactor="0"; $thfactor="0"; $crabflux="0"; break; } /* $join = isset($_GET["join"]) ? "LEFT JOIN ".$_GET["join"]." USING(fNight,fRunID)" : ""; if (isset($_GET["x"])) $group = 42; if (isset($_GET["y"])) $rate = 44; // Backward compatibility if (isset($_GET["avg"])) { $y = $_GET["avg"]; $rate = 42; } if (isset($_GET["sum"])) { $y = $_GET["sum"]; $rate = 43; } if (isset($_GET["hist"])) { $x = $_GET["hist"]; $rate = 45; $group = 42; } */ $good = ""; if (isset($_GET["good"])) { $g = $_GET["good"]; if ($g&0x1) $good .= " AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "; if ($g&0x2) $good .= " AND fZenithDistance < 45 "; if ($g&0x4) $good .= " AND IF (ISNULL(fThresholdMinSet), fThresholdMedian, fThresholdMinSet) < 550 "; if ($g&0x8) $good .= " AND fTNGDust<10 "; } $sqlbegin = !empty($begin) ? "AND (DATE(fNight)>='".$begin."')" : ""; $sqlend = !empty($end) ? "AND (DATE(fNight)<='".$end."')" : ""; $sqlcut = !empty($cut) ? "AND (".$cut.") " : ""; $sqlhaving = !empty($having)? "AND (".$having.") " : ""; // -------------------------------------------------------------------- $query2 = <<connect_error ? FALSE : $db->query($query2); if ($result2) { while ($row = $result2->fetch_assoc()) $columns .= '"'.$row['COLUMN_NAME'].'",'."\n"; $result2->free(); } else { $error2 .= $db->error; } // -------------------------------------------------------------------- $query1 = <<connect_error ? FALSE : $db->query($query1); if ($result1) { while ($row = $result1->fetch_assoc()) { $sources[$row['k']] = $row; $sourceoptions .= "\n"; } $result1->free(); } else { $error1 .= $db->error; } $sourcename = $source==0 ? "All" : $sources[$source]['name']; $ra = $source==0 ? 0 : $sources[$source]['ra']; $sqlsource = $source==0 ? "" : "AND fSourceKey=".$source; // -------------------------------------------------------------------- $unitx = ""; switch ($group) { case 1: $selectx="fPeriod"; $titlex="Period"; $axistype="number"; $mintime=60; break; case 2: //$selectx="FROM_UNIXTIME(UNIX_TIMESTAMP(fRunStart)+(UNIX_TIMESTAMP(fRunStop)-UNIX_TIMESTAMP(fRunStart))/2)"; $selectx="STR_TO_DATE(fNight, '%Y%m%d')"; $titlex="Night"; $axistype="date"; $mintime=20; break; case 3: $selectx="YEAR(fNight)";//"SUBSTR(fNight,1,4)"; $titlex="Year"; $axistype="date"; $mintime=60; break; case 4: $selectx="ADDDATE(DATE(CONCAT(YEAR(ADDDATE(DATE(fNight), INTERVAL - (".$ra."/24.*365+80) DAY)), '-01-01')), INTERVAL + (".$ra."/24.*365+80+365/2) DAY)"; // FIXME shift back to get the center! //$selectx="ADDDATE(DATE(YEAR(ADDDATE(DATE(fNight), INTERVAL - (".$ra."/24.*365+80) DAY))), INTERVAL + (".$ra."/24.*365+80) DAY)"; $titlex="Season"; $axistype="date"; $mintime=60; break; case 5: $selectx="FROM_UNIXTIME((UNIX_TIMESTAMP(fRunStop)+UNIX_TIMESTAMP(fRunStart))/2)"; $titlex="Time"; $axistype="date"; $mintime=0.5; break; case 6: $bin = isset($width) ? $width : 5; $selectx="FLOOR(fZenithDistanceMean/".$bin.")*".$bin."+".$bin."/2"; $titlex="Zd [deg]"; $axistype="number"; $mintime=0.5; break; case 7: $bin = isset($width) ? $width : 50; $selectx="FLOOR(fThresholdMinSet/".$bin.")*".$bin."+".$bin."/2"; $titlex="Threshold"; $axistype="number"; $mintime=0.5; break; case 8: $bin = isset($width) ? $width : 5; $selectx="FLOOR(fCurrentsMedMean/".$bin.")*".$bin."+".$bin."/2"; $titlex="Current [\u00B5A/pix]"; // \u00B5 = µ $axistype="number"; $mintime=0.5; break; case 9: $selectx="MONTH(fNight)";//"SUBSTR(fNight,1,4)"; $titlex="Month"; $axistype="date"; $mintime=60; break; case 42: $bin = isset($width) ? $width : 1; $selectx="FLOOR(((".$sql_x.")-".$offset.")/".$bin.")*".$bin."+".$bin."/2+".$offset; $titlex=addslashes($sql_x)." / ".$bin; $axistype="number"; $mintime=0.5; break; default: $selectx="fPeriod"; $titlex="Period"; $axistype="number"; $mintime=60; break; } if ($ontime>=0) $mintime = $ontime; // -------------------------------------------------------------------- $isnull = ""; $unity = "[Hz]"; $selecterr="1"; $vminval = 0; $errors = 0; $histogram = 0; switch ($rate) { case 1: $selecty="AVG(fTriggerRateMedian)"; $isnull="AND NOT ISNULL(fTriggerRateMedian)"; $titley="Average TriggerRate"; break; case 21: $selecty="SUM(fNumPhysicsTrigger)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumPhysicsTrigger)"; $titley="PhysicsTriggerRate"; break; case 22: //$selecty="(SUM(fNumPhysicsTrigger)-SUM(fNum27Sec))/SUM(fOnTime)"; $selecty="SUM(fNumPhysicsTrigger*1.0-fNum27Sec*1.0)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumPhysicsTrigger) AND NOT ISNULL(fNum27Sec)"; $titley="PhysicsTrigger-27Sec"; break; case 2: $selecty="SUM(fNumEvtsAfterCleaning)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumEvtsAfterCleaning)"; $titley="Rate after Cleaning"; break; case 23: $selecty="SUM(fNumEvtsAfterCleaning*1.0-fNum27Sec*1.0)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumEvtsAfterCleaning) AND NOT ISNULL(fNum27Sec)"; $titley="Rate after Cleaning-27Sec"; break; case 20: //$selecty="SUM((fNumEvtsAfterCleaning*1.0-fNum27Sec*1.0)/(1-(22.3-6)/22.5/0.4*(LOG10(fThresholdMinSet)-2.5))/(cos(fZenithDistanceMean*PI()/180)+0.18*pow(sin(2*fZenithDistanceMean*PI()/180),3)))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $selecty="SUM((fNumEvtsAfterCleaning*1.0-fNum27Sec*1.0)/((-2381.1+2766.3*LOG10(fThresholdMinSet)-1049.9*POW(LOG10(fThresholdMinSet),2)+131.05*POW(LOG10(fThresholdMinSet),3))/21.15)/(COS(fZenithDistanceMean*PI()/180)+0.179*POW(SIN(1.89*fZenithDistanceMean*PI()/180),5)))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumEvtsAfterCleaning) AND LOG10(fThresholdMinSet)<2.8 AND NOT ISNULL(fZenithDistanceMean) AND fThresholdMinSet>0 "; $titley="Rate after cleaning (Zd/TH/27s corrected)"; break; case 3: $selecty="SUM(fNumEvtsAfterQualCuts)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumEvtsAfterQualCuts)"; $titley="Rate after Quality Cuts"; break; case 4: $selecty="SUM(fNumEvtsAfterBgCuts)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumEvtsAfterBgCuts)"; $titley="Rate after Background Cuts"; break; case 24: $selecty="SUM(fNumEvtsAfterBgCuts/(1.41*POW(fZenithDistanceMean*PI()/180,2)+0.975)/(-7.53e-12*POW(10, LOG10(fThresholdMinSet)*3.69)+1.035) )/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumEvtsAfterBgCuts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)"; $titley="BgRate (corrected)"; break; case 28: $selecty="SUM(fNumExcEvts/((1.41*POW(fZenithDistanceMean*PI()/180,2)+0.975)/(-7.53e-12*POW(10, LOG10(fThresholdMinSet)*3.69)+1.035) ))/SUM(fNumExcEvts)"; $isnull="AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)"; $titley="Ratio Corrected(fNumEvtsAfterBgCuts) Exc / Exc"; break; case 25: $selecty="SUM(fNumEvtsAfterQualCuts/(cos(fZenithDistanceMean*PI()/180)+0.179*pow(sin(1.89*fZenithDistanceMean*PI()/180),5))/((8598.9- 13181*log10(fThresholdMinSet)+7567.4*pow(log10(fThresholdMinSet),2)-1925.2*pow(log10(fThresholdMinSet),3)+183*pow(log10(fThresholdMinSet),4))/9.2 ))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumEvtsAfterQualCuts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)"; $titley="QualCutRate (corrected)"; break; case 29: $selecty="SUM(fNumExcEvts/(cos(fZenithDistanceMean*PI()/180)+0.179*pow(sin(1.89*fZenithDistanceMean*PI()/180),5))/((8598.9- 13181*log10(fThresholdMinSet)+7567.4*pow(log10(fThresholdMinSet),2)-1925.2*pow(log10(fThresholdMinSet),3)+183*pow(log10(fThresholdMinSet),4))/9.2 ))/SUM(fNumExcEvts)"; $isnull="AND NOT ISNULL(fNumEvtsAfterQualCuts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)"; $titley="Ratio Corrected(fNumEvtsAfterQualCuts) Exc / Exc"; break; case 30: $selecty="SUM(fNumExcEvts/(pow(cos(fZenithDistanceMean*PI()/180),3)+14.8/21.9*pow(sin(2*fZenithDistanceMean*PI()/180),5))/(1-0.00124/1.21*(fThresholdMinSet-500)*(fThresholdMinSet>=500)))/SUM(fNumExcEvts)"; $isnull="AND NOT ISNULL(fNumEvtsAfterQualCuts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)"; $titley="Ratio Corrected(fNumExcEvts) Exc / Exc"; break; case 17: $selecty="SUM(fNumSigEvts)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumSigEvts)"; $titley="Signal rate"; break; case 5: $selecty="SUM(fNumBgEvts)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumBgEvts)"; $titley="Background rate"; break; case 6: $selecty="SUM(fNumExcEvts)*3600/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $selecterr="EXCERR(SUM(fNumSigEvts), SUM(fNumBgEvts))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)*3600"; $isnull="AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fEffectiveOn)"; $titley="Excess rate"; $unity="[1/h]"; $errors = $noerr ? 0 : 1; break; case 31: $selecty="SUM(fNumExcEvts/".$zdfactor."/".$thfactor.")*3600/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $selecterr="EXCERR(SUM(fNumSigEvts), SUM(fNumBgEvts))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)*3600*SUM(fNumExcEvts/".$zdfactor."/".$thfactor.")/SUM(fNumExcEvts)"; $isnull="AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fEffectiveOn) AND NOT ISNULL(fZenithDistanceMean) AND NOT (ISNULL(fThresholdMinSet) AND ISNULL(fThresholdMedian)) "; $sqlhaving.=" AND abs(e) < 1000 "; $titley="Corrected excess rate"; $unity="[1/h]"; $errors = $noerr ? 0 : 1; break; case 32: $selecty="SUM(fNumExcEvts/".$zdfactor."/".$thfactor."/fCU)*3600/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $selecterr="EXCERR(SUM(fNumSigEvts), SUM(fNumBgEvts))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)*3600*SUM(fNumExcEvts/".$zdfactor."/".$thfactor."/fCU)/SUM(fNumExcEvts)"; $isnull="AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fEffectiveOn) AND NOT ISNULL(fZenithDistanceMean) AND NOT (ISNULL(fThresholdMinSet) AND ISNULL(fThresholdMedian)) "; $sqlhaving.=" AND abs(e) < 10 "; $titley="Flux"; $unity="[CU]"; $errors = $noerr ? 0 : 1; break; case 33: $selecty=$crabflux." * SUM(fNumExcEvts/".$zdfactor."/".$thfactor."/fCU)*3600/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $selecterr=$crabflux." * EXCERR(SUM(fNumSigEvts), SUM(fNumBgEvts))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)*3600*SUM(fNumExcEvts/".$zdfactor."/".$thfactor."/fCU)/SUM(fNumExcEvts)"; $isnull="AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fEffectiveOn) AND NOT ISNULL(fZenithDistanceMean) AND NOT (ISNULL(fThresholdMinSet) AND ISNULL(fThresholdMedian)) "; $sqlhaving.=" AND abs(e) < 1000 "; $titley="Flux"; $unity="[10^-11/cm2/s]"; $errors = $noerr ? 0 : 1; break; case 7: $selecty="SUM(fNum27Sec)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNum27Sec)"; $titley="27sec Rate"; break; case 8: $selecty="SUM(fNumThreshold500)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumThreshold500)"; $titley="Threshold 500 Rate"; break; case 9: $selecty="SUM(fNumThreshold750)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumThreshold750)"; $titley="Threshold 750 Rate"; break; case 10: $selecty="SUM(fNumThreshold1000)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumThreshold1000)"; $titley="Threshold 1000 Rate"; break; case 11: $selecty="SUM(fNumThreshold1250)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumThreshold1250)"; $titley="Threshold 1250 Rate"; break; case 12: $selecty="SUM(fNumThreshold2500)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumThreshold2500)"; $titley="Threshold 2500 Rate"; break; case 13: $selecty="SUM(fNumThreshold5000)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumThreshold5000)"; $titley="Threshold 5000 Rate"; break; case 14: $selecty="SUM(fNumThreshold10000)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fNumThreshold10000)"; $titley="Threshold 10000 Rate"; break; case 15: $selecty="AVG(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn-fOnTime)"; $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fRunStop) AND NOT ISNULL(fRunStart) AND NOT fRunStop='0000-00-00 00:00:00' AND NOT fRunStart='0000-00-00 00:00:00'"; $titley="Ontime difference"; $sqlhaving.="AND y>0"; $unity="[s]"; break; case 26: $selecty="AVG(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn-fOnTimeAfterCuts)"; $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fOnTimeAfterCuts) AND NOT ISNULL(fRunStop) AND NOT ISNULL(fRunStart) AND NOT fRunStop='0000-00-00 00:00:00' AND NOT fRunStart='0000-00-00 00:00:00'"; $titley="Calculated ontime minus ontime after cuts"; $unity="[s]"; break; case 27: $selecty="AVG(fOnTime-fOnTimeAfterCuts)"; $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fOnTimeAfterCuts) AND NOT ISNULL(fRunStop) AND NOT ISNULL(fRunStart) AND NOT fRunStop='0000-00-00 00:00:00' AND NOT fRunStart='0000-00-00 00:00:00'"; $titley="Average difference between ontime and ontime after cuts"; $unity="[s]"; break; case 18: $selecty="AVG(fEffectiveOn)"; $isnull="AND NOT ISNULL(fEffectiveOn)"; $titley="Average (On time / elapsed time)"; $unity=""; $vminval=0.8; break; case 19: $selecty="SUM(fOnTime)/SUM(fOnTime/fEffectiveOn)"; $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fEffectiveOn)"; $titley="SUM(On time) / SUM(Elapsed time)"; $unity=""; $vminval=0.8; break; case 16: $selecty="SUM(fNumThreshold750/(cos(fZenithDistanceMean*PI()/180)+0.179*pow(sin(1.89*fZenithDistanceMean*PI()/180),5)))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"; $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fRunStop) AND NOT ISNULL(fRunStart) AND NOT fRunStop='0000-00-00 00:00:00' AND NOT fRunStart='0000-00-00 00:00:00' AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fNumThreshold750)"; $titley="Threshold 750 Rate (Zd corrected)"; break; case 42: $selecty="AVG(".$sql_y.")"; $isnull="AND NOT ISNULL(".$sql_y.")"; $titley="Average ".$sql_y; $unity=""; //$vmin =""; $histogram = 1;//$nohist ? 0 : 1; break; case 43: $selecty="SUM(".$sql_y.")"; $isnull="AND NOT ISNULL(".$sql_y.")"; $titley="Sum of ".$sql_y; $unity=""; //$vmin =""; $histogram = 1;//$nohist ? 0 : 1; break; case 44: $selecty=$sql_y; $titley=$sql_y; $unity=""; //$vmin =""; $histogram = 1;//$nohist ? 0 : 1; break; case 45: $selecty="COUNT(".(empty($sql_y)?"*":$sql_y).")"; $titley="Counts"; $unity=""; //$vmin =""; $histogram = 1;//$nohist ? 0 : 1; break; case 46: $selecty="LOG10(COUNT(".(empty($sql_y)?"*":$sql_y)."))"; $titley="log10(Counts)"; $unity=""; //$vmin =""; $histogram = 1;//$nohist ? 0 : 1; break; default: $selecty="AVG(fTriggerRateMedian)"; $isnull="AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fNumBgEvts) AND NOT ISNULL(fNumSigEvts)"; $titley="TriggerRate"; break; } // -------------------------------------------------------------------- /* SELECT o.night, MIN(o.start), MAX(o.stop), SUM(o.sigevts), SUM(o.bgevts), ROUND(SUM(o.ot)/60.,1) FROM ( SELECT fNight, fRunID, fOnTimeAfterCuts AS ot, fRunStart AS start, fRunStop AS stop, fNumSigEvts AS sigevts, fNumBgEvts AS bgevts, if ( @night=fNight AND FLOOR((@os+fOnTimeAfterCuts)/20./60.)<1, @bl, @bl := @bl + 1 ) as block, if ( @night=fNight AND FLOOR((@os+fOnTimeAfterCuts)/20./60.)<1, @os := @os + fOnTimeAfterCuts, @os := fOnTimeAfterCuts ) as os, @os/20./60. AS a, FLOOR(@os/20./60.) AS b, @night := fNight AS night FROM RunInfo LEFT JOIN AnalysisResultsRunLP USING(fNight,fRunID) CROSS JOIN ( SELECT @night := 0, @os := 0, @bl := 0 ) PARAMS WHERE fNight BETWEEN 20130414 AND 20130415 AND fRunTypeKey=1 AND fSourceKey=1 ) o GROUP BY block */ // -------------------------------------------------------------------- $query0 = <<$mintime) $sqlhaving EOT; /* # SUM(fNumExcEvts)/SUM(fOnTimeAfterCuts)*3600 AS y, AND NOT ISNULL(fNumSigEvts) AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fNumBgEvts) */ $var0 = ""; $error0 = ""; $data = "\n \n"; $timeStart = microtime(true); $result0 = $db->connect_error ? FALSE : $db->query($query0); $timeMeasured = number_format((microtime(true)-$timeStart)*1000, 2, ".", ""); if ($result0) { while ($row = $result0->fetch_assoc()) { $data .= " \n"; switch ($group) { case 3: // Year $x = "new Date('".$row['x']."-07-01')"; $xtext = $titlex." ".$row['x']; break; case 9: // Month $x = "new Date('2000-".$row['x']."-15')"; $xtext = $titlex." ".$row['x']; break; case 2: // Night case 4: // Season case 5: // Run $x = "new Date('".$row['x']."')"; $xtext = $titlex." ".$row['x']; break; default: $x = $row['x']; $xtext = $titlex." ".$row['x']." ".$unitx; } $y = $row['y']; $ymin = $row['y']-$row['e']; $ymax = $row['y']+$row['e']; $s = round($row['s'], 2); $sr = round($row['s']/sqrt($row['ontime']/60), 1); $t = round($row['ontime'], 2); $time = $t>60 ? round($row['ontime']/60,2).' h' : round($row['ontime'],1).' min'; $start= $row['start']; $stop = $row['stop']; $zdmin= $row['zdmin']; $zdmax= $row['zdmax']; $azmin= $row['azmin']; $azmax= $row['azmax']; $thmin= $row['thmin']; $thmax= $row['thmax']; // $var0 .= "["; $var0 .= $x.","; $var0 .= $y.","; if ($histogram==1 && !$nohist) $var0 .= $y.",0,0,"; if ($errors==1) { $var0 .= $y.","; $var0 .= $ymin.","; $var0 .= $ymax.","; } // $var0 .= "'

".addslashes($xtext); if ($errors==1) { $var0 .= "

".round($y,1)." ± ".round($row['e'],1); $var0 .= "

".$s." σ"; $var0 .= "

".$sr." σ/√h"; } else $var0 .= "

".round($y,3); $var0 .= "

".$time; $var0 .= "

".$start." – ".$stop; $var0 .= "

Zd=[".$zdmin.";".$zdmax."] Az=[".$azmin.";".$azmax."]"; $var0 .= "

TH=[".$thmin.";".$thmax."]"; $var0 .= "'"; // $var0 .= "],\n"; // } $result0->free(); } else { $error0 .= $db->error; } // -------------------------------------------------------------------- if (!isset($_GET['list']) && !isset($_GET['list-only'])) $data=""; else $data.="

XYEOnTimeStartStopZdminZdmaxAzminAzmaxTHminTHmax
".$row['x']."".$row['y']."".$row['e']."".$row['ontime']."".$row['start']."".$row['stop']."".$row['zdmin']."".$row['zdmax']."".$row['azmin']."".$row['azmax']."".$row['thmin']."".$row['thmax']."
\n
\n"; $querycol0 = colorize($query0); $querycol1 = colorize($query1); $errorcol_con = !empty($error_con) ? colorize($error_con) : ""; $errorcol2 = !empty($error2) ? colorize($error2) ."\n\n".$querycol2 : ""; $errorcol1 = !empty($error1) ? colorize($error1) ."\n\n".$querycol1 : ""; $errorcol0 = !empty($error0) ? colorize($error0) ."\n\n".$querycol0 : ""; $has_error = empty($error_con) && empty($error0) && empty($error1) && empty($error2) ? 0 : 1; $intervalStyle = $histogram==1 && !$nohist ? 'boxes' : 'bars'; $pointSize = $histogram==1 && !$nohist ? 'pointSize:0,' : ''; $boxWidth = $histogram==1 && !$nohist ? 1.6 : 0; // boxWidth: Could be used as x error bar for equidistant points $uri = $_SERVER['REQUEST_URI']; $pos = strpos($uri, '?'); $arg = $pos===FALSE ? "" : substr($uri, $pos+1); $uri = $pos===FALSE ? $uri : substr($uri, 0, $pos); $min = isset($_GET["min"]) ? intval($_GET["min"]) : ""; $max = isset($_GET["max"]) ? intval($_GET["max"]) : ""; $listonly = isset($_GET["list-only"]) ? 1 : 0; $hiddenBeg = isset($_GET['bx']) ? $_GET['bx'] : ""; $hiddenEnd = isset($_GET['ex']) ? $_GET['ex'] : ""; $hiddenInput =""; //if (isset($_GET["t"])) // $hiddenInput .= "\n"; if (isset($_GET["db"])) $hiddenInput .= "\n"; if (isset($_GET["good"])) $hiddenInput .= "\n"; // -------------------------------------------------------------------- /* $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$uri); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $tinyurl = curl_exec($curl); curl_close($curl); */ // -------------------------------------------------------------------- /* [9:51:32 PM] Lamouette: mysql> explain ShortURL; +----------+------------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +----------+------------------+------+-----+-------------------+-----------------------------+ | Key | int(10) unsigned | NO | PRI | NULL | auto_increment | | URL | varchar(1024) | NO | | NULL | | | UserName | varchar(50) | NO | | NULL | | | LastUpd | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | +----------+------------------+------+-----+-------------------+-----------------------------+ 4 rows in set (0.00 sec) */ /* */ $tinyurl = ""; if ($has_error==0 && strlen($arg)>16 && empty($print) && !$db->connect_error) { $query2 = "INSERT INTO ShortURL.ShortURL (URL) VALUES ('".$arg."') ON DUPLICATE KEY UPDATE `Key`=LAST_INSERT_ID(`Key`) "; if ($result2 = $db->query($query2)) { $tiny = $_SERVER['HTTP_HOST'].$uri."?short=".base62_encode($db->insert_id); $tinyurl = "Short URL: ".$tiny.""; } } // -------------------------------------------------------------------- echo << Database Explorer


min $hiddenInput


$tinyurl



$data EOT; ?>