# TNET Services, Inc. # # Copyright: (c) 1992-2007 Copyright TNET Services, Inc. ############################################################################ # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA ############################################################################ # This document uses Tab 4 Settings ############################################################################ /***************************** version 20220901 ***************************/ $viewSource = false; if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) { //--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; } ############################################################################ $standAlone = true; // false if we run in the template environment if ( $standAlone ) { ?> '.$TITLE.''; } ############################################################################ ############################# The Only Settings ############################# $divWidth = 656; // Width of Map $jQdir = 'jquery'; // Location of image-map.min.js ################################ End Settings ############################### ## $maxWidth = 1200; // Maximum Width of Map Until Excessive Line Distortion Occurs if ($divWidth>$maxWidth) $divWidth = $maxWidth; ?> '); if ($start !== false) { $content = substr($content, $start); //$content = str_replace('
','
',$content); // find the first list element $start = strpos($content, "
  • "); if ($start !== false) { $start += strlen("
  • "); // $finish = strpos($content, "
  • ", $start); $finish = strpos($content, "\n \n", $start); if ($finish !== false) { $length = $finish - $start; $usAlertsMapLegend = substr($content, $start, $length); // eliminate stuff we don't want $usAlertsMapLegend = str_replace("", "", $usAlertsMapLegend); $usAlertsMapLegend = str_replace("", "", $usAlertsMapLegend); $usAlertsMapLegend = str_replace("\n
    ", "", $usAlertsMapLegend); $usAlertsMapLegend = str_replace("
    \n
    ", "", $usAlertsMapLegend); $usAlertsMapLegend = str_replace("
    \n
    ", "", $usAlertsMapLegend); // $usAlertsMapLegend = str_replace('
    ', "", $usAlertsMapLegend); // $usAlertsMapLegend = str_replace('
    ', "", $usAlertsMapLegend); // $usAlertsMapLegend = str_replace('
    ', "", $usAlertsMapLegend); // replace the //forecast.weather.gov in the links with https://.... $usAlertsMapLegend = str_replace('href="//', 'href="https://', $usAlertsMapLegend); // change "&waa" in the URLs to use & $usAlertsMapLegend = str_replace("&wwa", "&wwa", $usAlertsMapLegend); /* Debug Code * echo "\n"; /* End Deubg Code */ // divvy up into separate links $legendLinks = explode("
  • ", $usAlertsMapLegend); // echo "\n"; $usAlertsMapLegend = ""; $columnBreak = round(sizeof($legendLinks) / 2); if (sizeof($legendLinks)%2) $oddLegend = true; else $oddLegend = false; foreach($legendLinks as $index => $legendLink) { // define div if needed if ( ($index == 0) || ($index == $columnBreak) ) { if ($index == $columnBreak) { $usAlertsMapLegend .= "
  • \n"; } $usAlertsMapLegend .= "\n" . '
    ' . "\n"; } // separate the div box and the link $linkStart = strpos($legendLink, "\n"; $url = str_replace(" ", "+", $url); echo "\n"; $link = substr_replace($link, $url, $urlStart + 1, $urlEnd); // finally, change the div in the box to a span $box = str_replace("
    ", "", $box); echo "\n"; $usAlertsMapLegend .= "

    " . $box . $link . "

    \n"; } // end foreach link // add target attribute to links so link open in separate window $usAlertsMapLegend = str_replace('\n"; ?>

    Clickable NWS National Advisory Maps

     

    ';?>

    Click on map to open a new tab zoomed to the area of interest where the local legend also decodes the colors and links to detailed local text alerts. The NWS map which opens is in turn clickable to then display VERY localized conditions and a 7 day forecast.
    All Maps and Data Are Courtesy of NOAA/NWS. (Current NWS Alerts Color Code Chart)
    Experimental Freeze Alert Status courtesy of MRCC Vegetation Impact Program (VIP).
    Special thanks to JJ Krawczyk aka jasiu for the map resizing code and the Legend fix.
    Full Size Maps

    '; } ?>
    '; } ############################################################################ # End of Page ############################################################################ // replacement for some of the "fetch data without hanging" routines in the code // get contents from one URL and return as string starting with data portion // returns array($headers, $content) function getRemoteDataWithoutHanging($url, $cacheName, $ldJson, $geoJson, $redirects) { global $needCookie, $SITE; $overall_start = time(); if (empty($url) ) { echo "\n"; $content = ""; $headers = ""; } else { $overall_start = time(); // Set maximum number of seconds to wait for feed before displaying page without feed $numberOfSeconds=6; // Thanks to Curly from ricksturf.com for the cURL fetch functions $curlVersion = curl_version(); // echo "\n"; if (!$curlVersion['features'] & CURL_VERSION_SSL) echo "\n"; $data = ''; $domain = parse_url($url,PHP_URL_HOST); // add cache-buster to URL if needed $theURL = str_replace('nocache','?'.$overall_start,$url); echo "\n"; $ch = curl_init(); // initialize a cURL session curl_setopt($ch, CURLOPT_URL, $theURL); // connect to provided URL // we will verify peer certificate... curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_USERAGENT,'AlertsFetch/1.1 (Web Application, www.gwwilkins.org)'); if ($ldJson) { curl_setopt($ch,CURLOPT_HTTPHEADER, // request LD-JSON format array ( "Accept: application/ld+json" )); } else if ($ldJson) { curl_setopt($ch,CURLOPT_HTTPHEADER, // request GEO-JSON format array ( "Accept: application/geo+json" )); } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $numberOfSeconds); // connection timeout curl_setopt($ch, CURLOPT_TIMEOUT, $numberOfSeconds); // data timeout curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the data transfer curl_setopt($ch, CURLOPT_NOBODY, false); // set nobody curl_setopt($ch, CURLOPT_HEADER, true); // include header information if (isset($redirects) && ($redirects > 0) ) { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow Location: redirect curl_setopt($ch, CURLOPT_MAXREDIRS, $redirects); // however many times requested } if (isset($needCookie[$domain])) { curl_setopt($ch, $needCookie[$domain]); // set the cookie for this request curl_setopt($ch, CURLOPT_COOKIESESSION, true); // and ignore prior cookies echo "\n"; } $data = curl_exec($ch); // execute session if(curl_error($ch) <> '') // IF there is an error { echo "\n"; // display error notice } $cinfo = curl_getinfo($ch); // get info on curl exec. /* curl info sample Array ( [url] => http://saratoga-weather.net/clientraw.txt [content_type] => text/plain [http_code] => 200 [header_size] => 266 [request_size] => 141 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.125 [namelookup_time] => 0.016 [connect_time] => 0.063 [pretransfer_time] => 0.063 [size_upload] => 0 [size_download] => 758 [speed_download] => 6064 [speed_upload] => 0 [download_content_length] => 758 [upload_content_length] => -1 [starttransfer_time] => 0.125 [redirect_time] => 0 [redirect_url] => [primary_ip] => 74.208.149.102 [certinfo] => Array ( ) [primary_port] => 80 [local_ip] => 192.168.1.104 [local_port] => 54156 ) */ echo "\n"; //echo "\n"; curl_close($ch); // close the cURL session //echo "\n"; $i = strpos($data,"\r\n\r\n"); $headers = substr($data,0,$i); $content = substr($data,$i+4); if($cinfo['http_code'] <> '200') { echo "\n"; $content = ""; // didn't get good data } } // if URL passed in if (empty($content) ) { // see if we have cached data we can return $headers = ""; echo "\n"; if (!empty($cacheName) ) { echo "\n"; if ( ! file_exists($cacheName) ) { echo "\n"; $content = ""; } else { echo "\n"; $content = file_get_contents($cacheName); } } // end if cache file name given } // end if no content else if (!empty($cacheName) ) { // write cache file if requested echo "\n"; $fp = fopen($cacheName, "w"); echo "\n"; $bytes = fwrite ($fp, $content); echo "\n"; fclose($fp); } $remoteData = array($headers, $content); return $remoteData; } // end getRemoteDataWithoutHanging ?>