'; } ?> '; $standAlone = false; // Displays outside Saratoga template $sector = 'ne'; // Default sector type is set here /* "pnw" is Pacific Northwest "nr" is Northern Rockies "umv" is Upper Mississippi Valley "cgl" is Great Lakes "ne" is Northeast "psw" is Pacific Southwest "sr" is Southern Rockies "sp" is Southern Plains "smv" is Southern Mississippi Valley "se" is Southeast "taw" is Tropical Atlantic-Wide "gm" is Gulf of Mexico "car" is Caribbean "eus" is U.S. Atlantic Coast "pr" is Puerto Rico "CONUS" is Continental US "FD" is Full Disk */ $satBand = 'GEOCOLOR'; // IMPORTAMT!!! Default image type is set here $satBand = (($satBand!='GEOCOLOR')?($satBand<10?('0'.intval($satBand)):$satBand):$satBand); $autoRefresh = false; // Use Autorefresh? true or false -- Determines whether AutoRefresh even appears $autoRefreshTime = 10; // Number of minutes between autorefreshes. IMPORTANT: use 2, 3, 4, 5, 6, 8, 10, 15, 20, or 30 ONLY!!! $autoRefreshOff = false; // Begin with Autorefresh Off? true or false -- 'OFF' or 'ON" $bgndColor = 'silver'; // Set HAniS Background Color Here $btnColor = 'darkslategray'; // Set Button Color here $btnTextColor = 'white'; // Set Button Text Color here $pauseSeconds = 2; // Pause on last image, in seconds $animRate = 25; // Frame Rate of animation: 5 is glacial, 10 is slow, 15 is leisurely, 20 is good, and 50 is fast - set with integer $numbImages = 20; // Number of Radar Images to Animate - 3 to around 25 $smoothingOn = true; // Enable image smoothing - new in HAniS 2.5 $checkFiles = false; // Check images before adding them to the filename list? $addTime = true; // Add date & time to images $startTime = ''; $endTime = ''; $wideScreen = false; } /************************ End Test Parameters for Debugging Purposes ********************/ if (isset($_GET['sector'])) { $sector = $_GET['sector']; } if (isset($_GET['satBand'])) { $satBand = $_GET['satBand']; } if (isset($_GET['imageWidth'])) { $imageWidth = $_GET['imageWidth']; } if (isset($_GET['imageHeight'])) { $imageHeight = $_GET['imageHeight']; } if (isset($_GET['standAlone'])) { $standAlone = $_GET['standAlone']; } if (isset($_GET['bgndColor'])) { $bgndColor = $_GET['bgndColor']; } if (isset($_GET['btnColor'])) { $btnColor = $_GET['btnColor']; } if (isset($_GET['btnTextColor'])) { $btnTextColor = $_GET['btnTextColor']; } if (isset($_GET['animRate'])) { $animRate = $_GET['animRate']; } if (isset($_GET['pauseSeconds'])) { $pauseSeconds = $_GET['pauseSeconds']; } if (isset($_GET['autoRefresh'])) { $autoRefresh = $_GET['autoRefresh']; } if (isset($_GET['numbImages'])) { $numbImages = $_GET['numbImages']; } if (isset($_GET['smoothingOn'])) { $smoothingOn = $_GET['smoothingOn']; } if (isset($_GET['doDebug'])) { $doDebug = $_GET['doDebug']; if ($doDebug) $debugText = 'Setting $debug
'; } if (isset($_GET['checkFiles'])) { $checkFiles = $_GET['checkFiles']; } if (isset($_GET['wideScreen'])) { $wideScreen = $_GET['wideScreen']; } if (isset($_GET['addTime'])) { $addTime = $_GET['addTime']; } $sectorTypes = array('standard','FD','CONUS','gm-car-eus','taw'); if ($sector=='FD') $ourSectorType = $sectorTypes[1]; else if ($sector=='CONUS') $ourSectorType = $sectorTypes[2]; else if ($sector=='gm'||$sector=='car'||$sector=='eus') $ourSectorType = $sectorTypes[3]; else if ($sector=='taw') $ourSectorType = $sectorTypes[4]; else $ourSectorType = $sectorTypes[0]; $sectorDimensions = array('widthA','iframeWidthA','heightA','iframeHeightA','widthB','iframeWidthB','heightB','iframeHeightB'); $satBandSectors = array( 'standard'=>array( 'widthA'=>1200, 'iframeWidthA'=>1242, 'heightA'=>1200, 'iframeHeightA'=>1255, 'widthB'=>600, 'iframeWidthB'=>642, 'heightB'=>600, 'iframeHeightB'=>655), 'FD'=>array( 'widthA'=>678, 'iframeWidthA'=>678, 'heightA'=>678, 'iframeHeightA'=>733, 'widthB'=>339, 'iframeWidthB'=>339, 'heightB'=>339, 'iframeHeightB'=>440), 'CONUS'=>array( 'widthA'=>1250, 'iframeWidthA'=>1292, 'heightA'=>750, 'iframeHeightA'=>805, 'widthB'=>625, 'iframeWidthB'=>667, 'heightB'=>375, 'iframeHeightB'=>430), 'gm-car-eus'=>array( 'widthA'=>1000, 'iframeWidthA'=>1042, 'heightA'=>1000, 'iframeHeightA'=>1055, 'widthB'=>500, 'iframeWidthB'=>542, 'heightB'=>500, 'iframeHeightB'=>555), 'taw'=>array( 'widthA'=>900, 'iframeWidthA'=>942, 'heightA'=>540, 'iframeHeightA'=>595, 'widthB'=>450, 'iframeWidthB'=>492, 'heightB'=>270, 'iframeHeightB'=>325) ); /* Debug Code * if ($doDebug) { var_dump($satBandSectors); var_dump($satBandSectors['standard']['iframeHeightB']); foreach ($satBandSectors as $key1=>$value1) { foreach ($value1 as $key=>$value) echo '$key1: '.$key1.'=> '.$key.': '.$value.'
'; } echo '$ourSectorType: '.$ourSectorType.'
'; var_dump($satBandSectors[$ourSectorType]['iframeHeightB']); // exit; } /* End Debug Code */ $imageWidth = $satBandSectors[$ourSectorType][($wideScreen||$standAlone)?'widthA':'widthB']; $iframeWidth = $satBandSectors[$ourSectorType][($wideScreen||$standAlone)?'iframeWidthA':'iframeWidthB']; $imageHeight = $satBandSectors[$ourSectorType][($wideScreen||$standAlone)?'heightA':'heightB']; $iframeHeight = $satBandSectors[$ourSectorType][($wideScreen||$standAlone)?'iframeHeightA':'iframeHeightB']; $iframeHeight += $addTime?20:0; /* Debug Code */ if ($doDebug) { $debugText .= '$satBand: '.$satBand.', $sector: '.$sector.', $ourSectorType: '.$ourSectorType.'
'; $debugText .= '$imageWidth: '.$imageWidth.', $iframeWidth: '.$iframeWidth.', $imageHeight: '.$imageHeight.', $iframeHeight: '.$iframeHeight.'
'; // exit; } /* End Debug Code */ ?> Starting \'handiv\' declaration
'; } $fileNameList = ''; $startTime = ''; $endTime = ''; $fileTimes = ''; get_file_names($sector,', ',$imageWidth,$imageHeight); if ($doDebug) $debugText .= '
Raw FilenameList:
'.$fileNameList.'
'; $fileNames = $fileNameList.' '; if ($doDebug) { $debugText .= '
Filenames:
'.$fileNames.'
'; $debugText .= 'Filetimes: '.$fileTimes.'
'; } $sTime = substr($startTime, 7); $eTime = substr($endTime, 7); if ($Breezy) { $imageWidth = 320; $iframeWidth = 320; $imageHeight = 220; $iframeHeight = 240; } ?> ';?>
';?> /i",'',$theData); if ($doFileDebug) { $debugText .= $theData; } $needle = '(.*.'.$image_Width.'x'.$image_Height.'\.jpg.)'; if ($doDebug) $debugText.='
$needle: '.$needle.'
'; preg_match_all($needle, $theData, $matches, PREG_PATTERN_ORDER); if ($theSector !='FD' ) array_pop($matches[0]); // Remove '600x600', '1200x1200', etc. untimed image $imageNumber = count($matches[0]); for ($i=0; $i<$imageNumber; $i++) { $matches[0][$i]=substr_replace($matches[0][$i],0,-1); } if ($doDebug) { $debugText .= '
$imageNumber: '.$imageNumber.', count($matches[0]): '.count($matches[0]).'
'; // Debug Code $i=$imageNumber; foreach($matches[0] as $match) { $debugText .= 'File No '.$i.': '.$match . '
'; $i--; } } if ($imageNumber<$numbImages) { if ( $imageNumber==0) { $fileNameList = 'Satellite Images Currently Unavailable!'; return ; } else if ($imageNumber<$numbImages) { $fileNameList = 'Too Many Images Requested'; return; } } else { $imageFile = array(); for ($i=($imageNumber-1),$j=$numbImages; $j>0; $i--,$j--) { $hourMinute = ''; $imageFile[$j] = $matches[0][$i]; $imageFile[$j] = substr($imageFile[$j],0,-1); } for ($i=1; $i<=$numbImages; $i++) { $image = 'https://cdn.star.nesdis.noaa.gov/GOES16/ABI'.(($theSector=="CONUS"||$theSector=="FD")?("/".$theSector):("/SECTOR/".$theSector)).'/'.$satBand.'/'.$imageFile[$i].($i<($numbImages)?$separator:' '); $timeString = substr($imageFile[$i],0,11); $ourYear = substr($timeString,0,4); $dayofYear = (substr($timeString,4,3)); $minutes = substr($timeString,7,2); $seconds = substr($timeString,9,2); $date2epoch =mktime(0, 0, 0, 1, 1, $ourYear); // Find the seconds from 1/1/1970 to the current year if ($doDebug) { $debugText .= '$date2epoch: '.$date2epoch.'
'; } $imageTime = $date2epoch+(($dayofYear-1)*86400)+($minutes*60)+$seconds; // Add the year + the day of the year + minutes + seconds $dayYear = DateTime::createFromFormat('z',$imageTime); $ourDayMonth = date("M_j,",$imageTime); $hourMinute = substr($timeString,7,4); if ($doDebug) { $debugText.= '$timeString: '.$timeString.', $imageTime: '.$imageTime.', $ourYear: '.$ourYear.', $dayYear: '.$dayYear.', $ourDayMonth: '.$ourDayMonth.', $hourMinute: '.$hourMinute.'
'; $debugText .= 'date("M j, Y",$imageTime): '.date("M j, Y",$imageTime).'
'; } $fileTimes .= ($addTime?(date("M j Y",$imageTime).' '.$hourMinute.' Zulu,'):''); $fileNameList .= $image; if ($doDebug) { $debugText .= $image; } } } } /* end get_nile_names */ // ------------------------------------------------------------------ /* Begin Function get_data */ function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't verify peer certificate curl_setopt($ch, CURLOPT_TIMEOUT, 8); // data timeout curl_setopt($ch, CURLOPT_NOBODY, false); // set nobody curl_setopt($ch, CURLOPT_HEADER, true); // include header information curl_setopt($ch, CURLOPT_USERAGENT,'US Ridge Radars/1.1 (Web Application, www.gwwilkins.org)'); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } /* End Function get_data */ // ------------------------------------------------------------------ function checkExternalFile($url) { global $doDebug; global $debugText; $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_FAILONERROR,true); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,true); // catch output (do NOT print!) curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); $response = curl_exec($ch); $badCURL = curl_error($ch); $retCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($doDebug) { print curl_error($ch); $debugText .= '$CURL: '.($badCURL?$badCURL:'good').', $response: '.($response!==false?'true':'false').', $retCode: '.$retCode.'-File '.($retCode==200?'exists':'is absent').'
'; } curl_close($ch); return $retCode; } // ------------------------------------------------------------------ /* Begin rfile_exists - In Reserve - Not Currently Used */ function rfile_exists($address) { global $doDebug; global $debugText; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$address); curl_setopt($ch,CURLOPT_NOBODY,1); curl_setopt($ch,CURLOPT_FAILONERROR,1); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $fileExists = curl_exec($ch); if ($doDebug) { $debugText .= '$fileExists-r: '.($fileExists?'absent':'exists').'
'; } if($fileExists !== FALSE) { curl_close($ch); return true; } curl_close($ch); return false; } /* End rfile_exists */ // ------------------------------------------------------------------ ?>