59.99) $sec=59.99; return sprintf("%02d:%02d:%05.2f", $hour,$min,$sec); } function deg2dms($d) { if ($d >= 0.) $s = '+'; else { $s = '-'; $d = -$d; } $deg = floor($d); $min = floor(($d-$deg)*60.); $sec = (($d-$deg)*60.-$min)*60.; $deg %= 360; if($sec>59.9) $sec=59.9; return sprintf ("%s%02d:%02d:%04.1f", $s,$deg,$min,$sec); } if(isset($_GET['last'])) $last = $_GET['last']; else $last=10; if($last<=0) $last=10; if(isset($_GET['offset'])) $offset = $_GET['offset']; else $offset=0; if($offset<0) $offset=0; if(isset($_GET['source'])) { $src_str = $_GET['source']; if($src_str === "all") unset($src_str); else $sources = explode(",",$src_str); } if($offset==0 && !isset($src_str)) echo "\n"; ?>
GCN/TAN events history (since 08-Feb-2020)
"All", "Swift" => "Swift satellite", "INTEGRAL" => "INTEGRAL satellite", "Fermi" => "Fermi satellite", "Swift,INTEGRAL" => "Swift + INTEGRAL", "Swift,Fermi" => "Swift + Fermi", "Fermi,INTEGRAL" => "Fermi + INTEGRAL", "ISS" => "I.S.S.", "AGILE" => "AGILE satellite", "IPN,WIND" => "IPN + WIND satellite", "AMON" => "AMON IceCube", "LVC" => "LIGO-Virgo", "Counterpart" => "Counterparts", "SNEWS" => "SNEWS" ); $heads = array('Local receive date','Source UTC date','Source','Instrument','TriggerId','GRB?','Sigma','R.A.','Decl.','ErrRad','URL1','URL2','Full Source Name','Description','last VOEvent'); $names = array('recvdate','sourcedate','sourceid','instrume','trigid','isgrb','detsignif','ra','decl','errradius','url1','url2','sourcename','sourcedescr'); $what = implode(", ", $names); $where = ''; if(isset($sources)) { $first = TRUE; foreach ($sources as $src_id) { if($first) { $where = " WHERE SourceId='$src_id'"; $first = FALSE; } else $where = $where." OR SourceId='$src_id'"; } } // Выполнение SQL-запроса $query = "SELECT $what FROM gcn_events".$where." ORDER BY RecvDate DESC LIMIT $last"; if($offset > 0) $query = $query." OFFSET $offset"; $query = $query.";"; $result = pg_query($query) or die('Ошибка запроса: '.pg_last_error()); $nrow = pg_num_rows($result); if($offset > 0) { if($last > 1) $noff = $offset - $last + 1; else $noff = $offset - 1; echo "Show previous page... (or "; echo "go to fist page)."; } else { echo "
\nLast "; echo "\n"; echo " event records for\n"; echo "\n"; echo "\n"; echo "
\n"; } if($nrow > 0) { // Вывод результатов в HTML echo "\n"; echo " \n"; foreach ($heads as $head) { echo " "; } echo "\n \n"; while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) { $srcid = $line['sourceid']; $trigid = $line['trigid']; $instrume = $line['instrume']; if(strlen($instrume)>0 && strstr($instrume,"(") && strstr($instrume,")")) $instr = strtok($instrume,"( )"); else $instr = $instrume; $ra = $line['ra']; $dec = $line['decl']; $err = $line['errradius']; echo "\t\n"; foreach ($line as $key => $value) { echo "\t\t\n"; } echo "\t\t\n"; echo "\t\n"; } echo "
$head
"; if(strlen($value)==0) echo " --- "; else if($key === "recvdate") echo substr($value,0,21); else if($key === "sourcedate") echo substr($value,0,21); else if($key === "instrume" && strstr($value,"(Subthr")) { echo substr($value,0,3)." (Subthresh.)"; } else if($key === "isgrb") { if($value === "t") echo " Yes "; else if($value === "f") echo " No "; else echo " --- "; } else if($key === "ra") { echo "".deg2hms($value).""; } else if($key === "decl") { echo "".deg2dms($value).""; } else if($key === "errradius") { if($value >= 1.) echo "$valueo"; else if($value >= 1./60.) { $min = $value * 60.; echo "$min'"; } else { $asec = $value * 3600.; echo "$asec\""; } } else if($key === "url1") { if($srcid === "LVC") echo "View"; else { // Checking for error in Swift LightCurve URL if(strpos($value,"/gcn/notices_s/sw00") === FALSE) { // Checking for wrong KONUS LightCurve URL if(strpos($value,"/gcn/notices_k/konus_lc") === FALSE) echo "LC"; else // Replace KONUS LightCurve URL echo "LC"; } else { // Making correct Swift LightCurve URL $swift_lc = str_replace("/gcn/notices_s/sw00", "/notices_s/sw0",$value); echo "LC"; } } } else if($key === "url2") { if($srcid === "Fermi") echo "Plot"; else echo "Map"; } else if($key === "sourcedescr") echo "ReadMe"; else echo "$value"; echo "XML
\n"; } else echo "
No rows found in GCN database..."; // Очистка результата pg_free_result($result); // Закрытие соединения pg_close($dbconn); if($nrow == $last) { if($last > 1) $noff = $offset + $last - 1; else $noff = $offset + 1; echo "Show next page...\n"; } ?>