NOAA RSS Advisory 2.0 PHP Script

Just uploaded the new version with CURL support. It took awhile to test all the debugging info you see if you view the source.
V2.00 01-Jun-2009 BETA .004

Any testers?

V2.00 01-Jun-2009 BETA .004 The CURL feature checks out OK with multiple alerts, one alert, no alerts and a bad zone entered.

V2.00 01-Jun-2009 BETA .005 - added proper fail message for when an invalid advisory zone is selected.

update - protect zone value input. allowed zone = [2letters][Z][3numbers]
this is critical because the zone input determines part of the cache file names that are written on the server.

Thanks Mike,

V2.00 01-Jun-2009 BETA .005 installed and seems to be working fine.

John

Mike,

Excellent work! :slight_smile:

I will install tonight to help with the feedback process.

Michael

Wow, ace job there Mike :smiley:

V2.00 02-Jun-2009 BETA .006

file cache improvement - cache files are never written to the server unless there is a valid zone selected or set in settings. Before it would make an empty cache file anyway.

Hi Mike,

Added to a temporary area of my site: http://www.relayweather.com/wxadvisory-2009.php

One thing I noticed is that I loose my background color. Upon investigation, it seems like the script pulls some extra data.

Here is my call:

<?php include("http://www.relayweather.com/rss-advisory-2009.php"); ?>

Take a look at the source of my code. When the script is called it pulls the following “extra” information:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>RSS Advisory Script</title>
</head>
 
<body style="background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;">
<!-- rss-advisory-2009.php - V2.00 02-Jun-2009 BETA .006 -->
<!-- getting new file from http://www.weather.gov/alerts-beta/wwaatmget.php?x=MDZ011 -->
<!-- CURL GET /alerts-beta/wwaatmget.php?x=MDZ011 HTTP/1.0 Host: www.weather.gov -->
<!-- Time to fetch: 0.697 sec -->
<!-- cache saved to rss-advisory-2009-MDZ011.txt -->

Is this normal for the script?

Michael

Michael,
Instead of this on your page

 <?php include("http://www.relayweather.com/rss-advisory-2009.php"); ?>

Try this


<?php
 $_REQUEST['zone'] = 'MDZ011';
 $_REQUEST['inc'] = 'Y';
 $_REQUEST['noprint'] = 1;
 include 'rss-advisory-2009.php';
 if (preg_match("|There are no active|i",$advisory_html) ||
     preg_match("|Advisory Information Unavailable|i",$advisory_html)) {
       echo '<div class="advisoryBoxnoactive">' .$advisory_html .'</div>';
 }else{
       echo $advisory_html;
 }
?>

This corrected the problem. Thanks Curly!

V2.00 02-Jun-2009 BETA .007

added a code fix suggested by curly: Sometimes the word " issued" isn’t included in the entry title so it won’t explode properly to “Tornado Watch”.

added more fixes for handling invalid zones - now checks both input and default zone configuration for both syntax and actual existence of the NOAA zone. If a bogus zone is offered, it does not write any cache files and then displays “Advisory Information Unavailable, invalid advisory zone selected.”

Various code cleanup.

I’m using $_REQUEST[‘summary’] = ‘Y’; on a test page (http://www.harpersferry-weather.com/wxadvisory-2009.php). There are no watches, warnings, and advisories. What is returned is a link “Source: NWS Watches, Warnings or Advisories for zone WVZ053” only. I was expecting it should return something like "There are no active watches, warnings or advisories for zone WVZ053. "

<?php $_REQUEST['zone'] = 'WVZ053'; $_REQUEST['inc'] = 'Y'; $_REQUEST['summary'] = 'Y'; $_REQUEST['noprint'] = 1; include 'rrs-advisory-2009.php'; if (preg_match("|There are no active|i",$advisory_html) || preg_match("|Advisory Information Unavailable|i",$advisory_html)) { echo '
' .$advisory_html .'
'; }else{ echo '
' . $advisory_html .'
'; } ?>

John

Thanks for testing. :smiley:
I may have broke something in my last update. 8O
I will test it some more and let you know.

Edit: found the problem… new beta soon.

All the prior beta versions had summary mode broken, this one should be better.

V2.00 02-Jun-2009 BETA .008

Fixed all reported issues:

  • various issues with summary mode, fixed
  • detail page link was not working, fixed

Thanks for testing and reporting errors,
everybody please keep testing. Thanks :slight_smile: :smiley:

Mike,

V2.00 01-Jun-2009 BETA .008 installed and seems to be working fine.

Thanks,
John

Seems to work for me. No errors. Only thing im getting that is odd, is a double advisory box.

http://www.snoqualmieweather.com/wxtest.php

Good Job Mike. Thanks for your time on making a fix for this.

Mark, when I view your source I see this version V 1.09 25-Mar-2008, not the BETA

Just realized that. Fixing that now.

yea, this is so nice I want to start using it as soon as we test it well. :slight_smile:

I think I got it now…

http://www.snoqualmieweather.com/wxtest.php