*/ if (!isset($wfo)) { $wfo='JKL'; $divWidth = '656'; // They are used for testing only $leftMargin = 50; // Left margin to display text $cache = './cache/'; $color = 'darkmagenta'; // Color for dropdown state names with subordinate entries $siteOrder = false; // Use site names to alphabetize rather than states } /* End of testing code defaults and section to comment out */ if (isset($_POST['wfo'])) { # Are we using AJAX??? $wfo = $_POST['wfo']; # If so, set state. if ($_SERVER["REMOTE_ADDR"]=='127.0.0.1') { include ('Settings.php'); // AJAX forgets these on localhost! } } if (isset($_POST['divWidth'])) { # Are we using AJAX??? $divWidth = $_POST['divWidth']; # If so, set state. if ($_SERVER["REMOTE_ADDR"]=='127.0.0.1') { include ('Settings.php'); // AJAX forgets these on localhost! } } if (isset($_POST['leftMargin'])) { # Are we using AJAX??? $leftMargin = $_POST['leftMargin']; # If so, set state. if ($_SERVER["REMOTE_ADDR"]=='127.0.0.1') { include ('Settings.php'); // AJAX forgets these on localhost! } } if (isset($_POST['color'])) { # Are we using AJAX??? $color = $_POST['color']; # If so, set state. if ($_SERVER["REMOTE_ADDR"]=='127.0.0.1') { include ('Settings.php'); // AJAX forgets these on localhost! } } if (isset($_POST['siteOrder'])) { # Are we using AJAX??? $siteOrder = $_POST['siteOrder']; # If so, set state. if ($_SERVER["REMOTE_ADDR"]=='127.0.0.1') { include ('Settings.php'); // AJAX forgets these on localhost! } } $wfoNames = array( "ALY"=>"Albany, NY", "ABQ"=>"Albuquerque, NM", "AK"=>"Anchorage, AK", "EWX"=>"Austin/San Antonio, TX", "LWX"=>"Baltimore MD/Washington, DC", "BGM"=>"Binghamton, NY", "AL"=>"Birmingham, AL", "BIS"=>"Bismarck, ND", "ID"=>"Boise, ID", "BOX"=>"Boston, MA", "BTV"=>"Burlington, VT", "CHS"=>"Charleston, SC", "RLX"=>"Charleston, WV", "WY"=>"Cheyenne, WY", "IL"=>"Chicago, IL", "CLE"=>"Cleveland, OH", "CAE"=>"Columbia, SC", "CO"=>"Denver, CO", "IA"=>"Des Moines, IA", "MI"=>"Detroit, MI", "EKA"=>"Eureka, CA", "FWD"=>"Fort Worth, TX", "GGW"=>"Glasgow, MT", "GLD"=>"Goodland, KS", "FGF"=>"Grand Forks, ND", "GYX"=>"Gray, ME", "MT"=>"Great Falls, MT", "GRB"=>"Green Bay, WI", "GUM"=>"Guam", "HFO"=>"Honolulu, HI", "HUN"=>"Huntsville, AL", "IN"=>"Indianapolis, IN", "MS"=>"Jackson, MS", "JKL"=>"Jackson, KY", "EAX"=>"Kansas City, MO", "KEY"=>"Key West, FL", "LCH"=>"Lake Charles, LA", "LZK"=>"Little Rock, AR", "CA"=>"Sacramento, CA", "KY"=>"Louisville, KY", "LUB"=>"Lubbock, TX", "MLB"=>"Melbourne, FL", "MEG"=>"Memphis, TN", "MAF"=>"Midland, TX", "WI"=>"Milwaukee, WI", "MOB"=>"Mobile, AL (41)", "OHX"=>"Nashville, TN", "LIX"=>"New Orleans/Baton Rouge, LA", "MHX"=>"Newport, NC", "IWX"=>"Northern Indiana", "OK"=>"Norman, OK", "NE"=>"Omaha, NE", "GA"=>"Peachtree City, GA", "PDT"=>"Pendleton, OR", "PHI"=>"Philadelphia, PA", "AZ"=>"Phoenix, AZ", "OR"=>"Portland, OR", "RAH"=>"Raleigh, NC", "NV"=>"Reno, NV", "STO"=>"Sacramento, CA", "UT"=>"Salt Lake, UT", "SJT"=>"San Angelo, TX", "SGX"=>"San Diego, CA", "PR"=>"San Juan, PR", "WA"=>"Seattle, WA", "SHV"=>"Shreveport, LA", "FSD"=>"Sioux Falls, SD", "OTX"=>"Spokane, WA (198)", "CTP"=>"State College, PA", "MO"=>"Springfield, MO", "TBW"=>"Tampa Bay, FL", "KS"=>"Topeka, KS", "MN"=>"Twin Cities, MN", "OKX"=>"Upton, NY", "AKQ"=>"Wakefield, VA", "ILM"=>"Wilmington, NC" ); ?>

Regional Weather Roundup for

To Select Another Site Choose from List

Select Site:  
\n"; $cacheName = $cacheFileDir . $cacheName; print "\n"; $html = FD_fetchUrlWithoutHanging($fileName); $fp = fopen($cacheName, "w"); if ($fp) { $write = fputs($fp, $html); fclose($fp); $Status .= "\n"; } else { $Status .= "\n"; } // extract the RWR discussion $html2 = $html; // Make Virtual Copy preg_match_all('|]*>(.*)|Usi',$html,$matches); $discussion = isset($matches[0][0])?$matches[0][0]:''; // now have the forecast as a string with \n delimiters if (strlen($discussion)) $discussion = trim($matches[0][0]); // prevent extra white space at beginning and end print $Status; if ($discussion == '') { $discussion = 'NWS '.$productText.' for '.$wfoName.' not loaded. Refresh page and try again.'; } // Finds if no reports are listed preg_match_all('|(.*)
|Uis', $html, $noissue); // gets the noissue from NOAA $nonereported = is_array($noissue[1])?$noissue[1]:''; $noreport = "None issued by this office recently."; ?>
No reports issued by this office recently" . $nws_id . "

\n"; } else { // Prints the report // print "\n"; // variable width print "
\n"; // fixed width print "\n"; print ""; print "\n"; print "
" .$discussion ."
\n"; print "

 

\n"; } // Prints the previous version, or page print "\n"; print ''; print ''; print "\n"; print "
View Past Reports for '.$wfoNames[$wfo].'.
\n"; print "
\n"; ?> \n"; $ch = curl_init(); // initialize a cURL session curl_setopt($ch, CURLOPT_URL, $theURL); // connect to provided URL curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't verify peer certificate curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (forecast-discussion.php - saratoga-weather.org)'); curl_setopt($ch,CURLOPT_HTTPHEADER, // request LD-JSON format array ( "Accept: text/html,text/plain" )); 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 // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow Location: redirect // curl_setopt($ch, CURLOPT_MAXREDIRS, 1); // but only one time 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 $Status .= "\n"; } $data = curl_exec($ch); // execute session if(curl_error($ch) <> '') { // IF there is an error $Status .= "\n"; // display error notice } $cinfo = curl_getinfo($ch); // get info on curl exec. /* curl info sample Array ( [url] => https://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 ) */ $Status .= "\n"; //$Status .= "\n"; curl_close($ch); // close the cURL session //$Status .= "\n"; $i = strpos($data,"\r\n\r\n"); $headers = substr($data,0,$i); $content = substr($data,$i+4); if($cinfo['http_code'] <> '200') { $Status .= "\n"; } return $data; // return headers+contents } else { // print "\n"; $STRopts = array( 'http'=>array( 'method'=>"GET", 'protocol_version' => 1.1, 'header'=>"Cache-Control: no-cache, must-revalidate\r\n" . "Cache-control: max-age=0\r\n" . "Connection: close\r\n" . "User-agent: Mozilla/5.0 (forecast-discussion.php - saratoga-weather.org)\r\n" . "Accept: text/html,text/plain\r\n" ), 'https'=>array( 'method'=>"GET", 'protocol_version' => 1.1, 'header'=>"Cache-Control: no-cache, must-revalidate\r\n" . "Cache-control: max-age=0\r\n" . "Connection: close\r\n" . "User-agent: Mozilla/5.0 (forecast-discussion.php - saratoga-weather.org)\r\n" . "Accept: text/html,text/plain\r\n" ) ); $STRcontext = stream_context_create($STRopts); $T_start = FD_fetch_microtime(); $xml = file_get_contents($url,false,$STRcontext); $T_close = FD_fetch_microtime(); $headerarray = get_headers($url,0); $theaders = join("\r\n",$headerarray); $xml = $theaders . "\r\n\r\n" . $xml; $ms_total = sprintf("%01.3f",round($T_close - $T_start,3)); $Status .= "\n"; $Status .= "<-- get_headers returns\n".$theaders."\n -->\n"; // print " file() stats: total=$ms_total secs.\n"; $overall_end = time(); $overall_elapsed = $overall_end - $overall_start; $Status .= "\n"; // print "fetch function elapsed= $overall_elapsed secs.\n"; return($xml); } } // end FD_fetchUrlWithoutHanging // ------------------------------------------------------------------ function FD_fetch_microtime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } // ---------------------------------------------------------- function unique_multidim_array($array, $key) { $temp_array = array(); $i = 0; $key_array = array(); foreach($array as $val) { if (!in_array($val[$key], $key_array)) { $key_array[$i] = $val[$key]; $temp_array[$i] = $val; } $i++; } return $temp_array; } // --------------end of functions --------------------------------------- ?>