surrounding the output of the script .. change styling to suit. $boxStyle = 'style="border: dashed 1px black; background-color:#FFFFCC; margin: 5px; padding: 0 5px;"'; // $cacheFileDir = './'; // default cache file directory $cacheName = "radar-status.json"; // used to store the file so we don't have to // fetch it each time $refetchSeconds = 60; // refetch every nnnn seconds $showHMSAge = true; // =false for number of seconds, =true for H:M:S age display $showMsgCnt = 2; // show up to 2 most recent messages // end of settings // Constants // don't change $fileName or script may break ;-) $fileName = 'https://api.weather.gov/radar/stations/'; $fileName2 = 'https://api.weather.gov/products/types/FTM/locations/'; // end of constants // --------------------------------------------------------- // overrides from Settings.php if available global $SITE; if (isset($SITE['GR3radar'])) {$myRadar = $SITE['GR3radar'];} if (isset($SITE['tz'])) {$ourTZ = $SITE['tz'];} if (isset($SITE['timeFormat'])) {$timeFormat = $SITE['timeFormat'];} if (isset($SITE['showradarstatus'])) {$noMsgIfActive = ! $SITE['showradarstatus'];} if (isset($SITE['cacheFileDir'])) {$cacheFileDir = $SITE['cacheFileDir']; } // end of overrides from Settings.php if available // ------ start of code ------- if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' and strlen($_REQUEST['sce']) == 4) { //--self downloader -- $filenameReal = __FILE__; $download_size = filesize($filenameReal); header('Pragma: public'); header('Cache-Control: private'); header('Cache-Control: no-cache, must-revalidate'); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); header('Connection: close'); readfile($filenameReal); exit; } if (isset($_REQUEST['sce'])) { header("HTTP/1.1 403 Forbidden"); print "
Radar $myRadar station returns no data. RC=$RC
\n"; return(0); } print "\n"; list($content2,$RC2)= RS_fetchUrlWithoutHanging($fileName2.$myRadar3); print $Debug; $Debug = ''; // extract the messages $radarMsgs = array(); // for storing the messages in a 'cleansed' format by Radar key, then date # $radarMsgs[$thisRadar][$thisDate] = $thisMsg; // save away for later lookup /* "@graph": [ { "@id": "https://api.weather.gov/products/f1e89484-b954-43f8-97a4-6450e5aeaf9f", "id": "f1e89484-b954-43f8-97a4-6450e5aeaf9f", "wmoCollectiveId": "NOUS66", "issuingOffice": "KMTR", "issuanceTime": "2025-09-09T01:00:00+00:00", "productCode": "FTM", "productName": "WSR-88D Radar Outage Notification / Free Text Message" }, */ $FTM = json_decode($content2,true); foreach ($FTM['@graph'] as $n => $J) { #print "\n"; list($msg,$RC) = RS_fetchUrlWithoutHanging($J['@id']); /* { "@context": { "@version": "1.1", "@vocab": "https://api.weather.gov/ontology#" }, "@id": "https://api.weather.gov/products/f1e89484-b954-43f8-97a4-6450e5aeaf9f", "id": "f1e89484-b954-43f8-97a4-6450e5aeaf9f", "wmoCollectiveId": "NOUS66", "issuingOffice": "KMTR", "issuanceTime": "2025-09-09T01:00:00+00:00", "productCode": "FTM", "productName": "WSR-88D Radar Outage Notification / Free Text Message", "productText": "\n000\nNOUS66 KMTR 090100\nFTMMUX\nMessage Date: Sep 09 2025 01:00:57\n\nKMUX radar is back up and sending data. \n\n" } */ $T = json_decode($msg,true); $thisDate = strtotime($T['issuanceTime']); $rawMsg = $T['productText']; $mparts = explode("\n",$rawMsg); #print "\n"; foreach ($mparts as $k => $mp) { if(stripos($mp,'message') !== false or stripos($mp,'outage notif') !== false) {$k++; break;} } if($k >= count($mparts)) {$k=5;} $thisMsg = implode(' ',array_slice($mparts,$k)); $radarMsgs[$myRadar][$thisDate] = $thisMsg; // save away for later lookup } $content3 = json_encode($radarMsgs); if(strlen($content1) > 100 and strlen($content2) > 50) { $fp = fopen($cacheName, "w"); if ($fp) { $write = fputs($fp,$content1); $write = fputs($fp,"\n||||||\n"); $write = fputs($fp,$content2."\n"); $write = fputs($fp,"\n||||||\n"); $write = fputs($fp,$content3."\n"); fclose($fp); print "\n"; } else { print "\n"; } $html = $content1."\n||||||\n".$content2."\n||||||\n".$content3."\n"; } else { print "\n"; print "\n"; print "\n"; print "\n"; } } list($content1,$content2,$content3) = explode('||||||',$html); $MAIN = json_decode($content1,true); $FTM = json_decode($content2,true); $radarMsgs = json_decode($content3,true); #print "\n"; #print "\n"; #print "\n\n\n\n"; # Set timezone in PHP5/PHP4 manner if (!function_exists('date_default_timezone_set')) { putenv("TZ=" . $ourTZ); # $Status .= "\n"; } else { date_default_timezone_set("$ourTZ"); # $Status .= "\n"; } if(strlen($html) < 250) { print "\n"; return; } $lastUTCdate = $MAIN['latency']['levelTwoLastReceivedTime']; // print "\n"; $t=strtotime($lastUTCdate); $UTCdate = time(); $LCLdate = date($timeFormat,$UTCdate); print "\n"; $age = $UTCdate - $t; // if ($age < 0) { $age += (60*60*24); } // account for one day extra downtime if need be $ageHMS = gmdate('H:m:s',$age); print "\n"; #preg_match_all('||is',$rec,$matches); $curStatus = $MAIN['rda']['properties']['status']; $statColor = '#33FF33'; # Assume normal color = green if($age >= 5*60) {$statColor = '#FFFF00';} # delayed yellow if($age >= 30*60) {$statColor = '#FF0000';} # inop RED if ($statColor <> '#33FF33') { $curStatus .= ' - Data not recent'; } // Output the status $divStarted = false; if (isset($statColor) and (!$noMsgIfActive or $statColor != '#33FF33') ) { print "NEXRAD Radar $myRadar status: $curStatus [last data $pAge ago]
as of $LCLdate
Message date: " . date($timeFormat,$timestamp) . "
\n";
print $msg . "
NEXRAD radar $myRadar status not found.
\n"; } if($divStarted) { print "