cloudy

Author Topic: Major Problem with advforecast2.php script: NWS Site Redesign???  (Read 5505 times)

0 Members and 1 Guest are viewing this topic.

Offline 1080iAddict

  • Posts: 45
The icons are gone!  The printable forcast is gone!  NWS changed the site! This used to be for Glyndon, MD and now its gone!


http://forecast.weather.gov/MapClick.php?site=lwx&FcstType=text&MapType=3&site=lwx&CiTemplate=1&map.x=285&map.y=45&TextType=2

What is happening?  Am I going crazy?  It worked yesterday.  The site was down for 2 hours.  Now its all a different design. 

Adam

Offline jimmyb

  • Posts: 138
  • Tinley Park, Illinois USA
    • Will Cook Weather
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #1 on: June 29, 2007, 12:03:17 AM »
Wow .. you are right. Checked mine and also gone. Whole new forecast page at NWS .. w/o Icons!!!! Now what .. we start all over?
Check out my LIVE internet radio show (not weather related) The AnJ Show http://anj.westpm.net

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,336
  • Mauston, WI, USA
    • Juneau County Weather
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #2 on: June 29, 2007, 12:10:44 AM »
I suspect when Ken sees this he'll come up with something.

- Jim

 Home of NSLog NexStorm Lightning Data Manager

Offline JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,374
  • VP 2 w/FARS - WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #3 on: June 29, 2007, 12:27:44 AM »
Gotta Love the NWS....

Lets change everything just for fun...   :(

-Bob

Offline 1080iAddict

  • Posts: 45
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #4 on: June 29, 2007, 01:03:35 AM »
Man.  I think we are SCREWED.  Ken is the king of weather sites and scripts but I don't see how he'll pull a rabbit out of his arse for this one.  The entire foundation for the script is gone! 

mth

  • Guest
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #5 on: June 29, 2007, 01:20:44 AM »
Same here.......I'm sure Ken will come up with something.  Ken is a master at this forecast scripting.

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 22,156
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
    • http://www.realweatherstation.com
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #6 on: June 29, 2007, 01:26:03 AM »
Maybe no need for panic folks, that page currently has this message

"The NWS forecast web pages are currently defaulting to a zone based product due to technical difficulties. The point specific forecasts, with icons and the houly weather graph will return as soon as possible. Thanks for your patience.
NWS Baltimore, MD/Washington, D.C."

Offline jimmyb

  • Posts: 138
  • Tinley Park, Illinois USA
    • Will Cook Weather
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #7 on: June 29, 2007, 02:36:47 AM »
Thank you Niko. I tried to find something like that statement. The page just does not look right in my browser. Does not fit right.
Check out my LIVE internet radio show (not weather related) The AnJ Show http://anj.westpm.net

Offline saratogaWX

  • Posts: 4,672
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
    • Saratoga Weather
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #8 on: June 29, 2007, 04:23:17 AM »
Well, that's a new one for the transition.. before they did a 302 (temporary redirect) to the zone forecast out of www.crh.noaa.gov .. now they're just being "helpful" and pulling the text only.

Let me see what I can do about detecting that, then force a failover to the REAL zone forecast (hopefully with icons).

Ken

BTW... THANKS for all the kind words!  Let's see if there's a rabbit to find in this hat  :lol:
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline saratogaWX

  • Posts: 4,672
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
    • Saratoga Weather
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #9 on: June 29, 2007, 04:35:48 AM »
Ok, here's the quick fix to detect this and fail over to your REAL zone forecast.

Change:
Code: [Select]
  if (preg_match('/Temporary|Location:/Uis',$html)) {
to
Code: [Select]
  if (preg_match('/Temporary|Location:|defaulting to/Uis',$html)) { in the TWO places it occurs in the source.

I've updated advforecast2.php (for the faint of heart doing PHP updates ;-) )

http://saratoga-weather.org/advforecast2.php?sce=view

Tested the failover with 1080iaddicts settings (http://saratoga-weather.org/advforecast2-testing.php ) and works fine.

Best regards,
Ken
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline jimmyb

  • Posts: 138
  • Tinley Park, Illinois USA
    • Will Cook Weather
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #10 on: June 29, 2007, 10:56:45 AM »
Works like a charm Ken, thanks for your great coding. The Saratoga link does NOT work however!

Question though, is this an automatic check and re-direct and will go back to icon page when NWS fixes or we will have to change code again?
« Last Edit: June 29, 2007, 11:08:33 AM by jimmyb »
Check out my LIVE internet radio show (not weather related) The AnJ Show http://anj.westpm.net

Offline CNYWeather

  • Professional Trophymaker!
  • Posts: 1,440
  • Rome, New York
    • CNYWeather.com
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #11 on: June 29, 2007, 12:36:55 PM »
I'm a little confused (as always) with where to change it in my PHP Ajax code  :(

Code: [Select]
<?php
header
("Expires: " gmdate("D, d M Y H:i:s"time() - 150) . " GMT");
header("Last-Modified: " gmdate("D, d M Y H:i:s"time() - 150) . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0"false);
header("Pragma: no-cache");

require_once 
'getraw.php';
$wxdata get_raw("wx30.html");
$thisPage="Forecast"

if ( empty(
$_REQUEST['force']) ) 
        
$_REQUEST['force']="0";

$Force $_REQUEST['force'];

// Get the forecast.txt file

$cacheName "forecast.txt";
$fileName "http://forecast.weather.gov/MapClick.php?site=BGM&llon=-75.847083&rlon=-74.969583&tlat=43.520417&blat=42.645417&smap=1&mp=1&map.x=126&map.y=108&TextType=2";

if (
$Force==1) {
      
$fileData forecastfetchUrlWithoutHanging($fileName,$cacheName);
      
$fp fopen($cacheName"w");
      
$write fputs($fp$fileData);
      
fclose($fp);  }

if (
filemtime($cacheName) + 1800 time()) { 
      
$html implode(''file($cacheName)); 
    } else { 
      
$html fetchUrlWithoutHanging($fileName,$cacheName); 
      
$fp fopen($cacheName"w"); 
      
$write fputs($fp$html); 
      
fclose($fp);  } 

      
// Just get the top of the NWS page for editing 

      
preg_match('|<tr valign ="top" align="center">(.*)<table width="670"|s'$html$betweenspan); 
      
$forecastop  $betweenspan[1]; 

      
// Chop up each icon html and place in array 
      
preg_match_all("/<td.*>(.*)<\/td>/Uis"$forecastop$headers); 
      
$forecasticons $headers[1]; 

      
// Now get just the bottom of the NWS page for editing 
      
preg_match('|</table>(.*)<hr>|s'$html$betweenspan); 
      
$forecast  $betweenspan[1]; 

      
// Chop up each title text and place in array 
      
preg_match_all('|<b>(.*): </b>|Ui'$forecast$headers); 
      
$forecasttitles $headers[1]; 

      
// Chop up each forecast text and place in array 
      
preg_match_all('|</b>(.*)<br>|Ui'$forecast$headers); 
      
$forecasttext $headers[1]; 

      
// Grab the Last Update date and time. 
      
preg_match('|Last Update: (.*)|'$html$betweenspan); 
      
$lastupdate  $betweenspan[1]; 

function 
forecastfetchUrlWithoutHanging($url,$cacheurl)
   {
   
// Set maximum number of seconds (can have floating-point) to wait for feed before displaying page without feed
   
$numberOfSeconds=4;    

   
// Suppress error reporting so Web site visitors are unaware if the feed fails
   
error_reporting(0);

   
// Extract resource path and domain from URL ready for fsockopen

   
$url str_replace("http://","",$url);
   
$urlComponents explode("/",$url);
   
$domain $urlComponents[0];
   
$resourcePath str_replace($domain,"",$url);

   
// Establish a connection
   
$socketConnection fsockopen($domain80$errno$errstr$numberOfSeconds);

   if (!
$socketConnection)
       {

       
$html implode(''file($cacheurl));
       return(
$html);

       
// You may wish to remove the following debugging line on a live Web site
       // print("<!-- Network error: $errstr ($errno) -->");
       
}    // end if
   
else    {
       
$xml '';
       
fputs($socketConnection"GET $resourcePath HTTP/1.0\r\nHost: $domain\r\n\r\n");
   
       
// Loop until end of file
       
while (!feof($socketConnection))
           {
           
$xml .= fgets($socketConnection128);
           }    
// end while

       
fclose ($socketConnection);

       }    
// end else

   
return($xml);

   }    
// end function


?>
Tony

CNYWeather.com
CWOP: CW2352
WeatherUnderground: KNYWESTM1


http://www.CNYWeather.com

I Make Trophies Too!
http://www.speedyawards.com

Offline 1080iAddict

  • Posts: 45
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #12 on: June 29, 2007, 12:38:59 PM »
Ken,

That code works, i.e., I get the icons and the forecast.  But I also get this on the bottom of the page:

Code: [Select]

PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 222 PHP Notice: Undefined offset: 0 in c:\program files\webweaver\docs\WX\advforecast2.php on line 232 PHP Notice: Undefined offset: 13 in c:\program files\webweaver\docs\WX\advforecast2.php on line 429 PHP Notice: Undefined offset: 13 in c:\program files\webweaver\docs\WX\advforecast2.php on line 430


My hope is that the issue is in fact temporary and will revert soon.  But is there an easy fix for the scary gobbelygook?   8O

Thanks for your help by the way...

Adam

mth

  • Guest
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #13 on: June 29, 2007, 12:45:30 PM »
Ken,

I replaced the two lines..........works wonderfully!!   :D

I appreciate the time and effort!

Michael
http://www.relayweather.com

Offline JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,374
  • VP 2 w/FARS - WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Major Problem with advforecast2.php script: NWS Site Redesign???
« Reply #14 on: June 29, 2007, 01:02:09 PM »
Ken...

Sheer wizardry  8O

All fixed up here as well :)

Thanks,
Bob

 

cumulus