Renamed to atom-advisory.php to avoid confusion and allow coexistence with
rss-advisory.php which used the RSS feeds instead of the ATOM/CAP feeds.
What’s New:
Modified to use the Experimental XML/CAP 1.1 Feeds (these alerts are available now and are going to be the standard rss alerts beginning in Dec. 2009. The old alerts are to be phased put.)
Displays new information called “CAP codes”. The CAP codes provide: Last updated time, Effective time, Expires time, Urgency, Severity, Certainty, Status, Message type, Alert Category, and Areas affected. When there is an Urgency: “Immediate” alert, the word “Immediate” will be in red highlights to stand out better.
Added a link “…view the complete message” on each alert so you can read the complete message on the NWS web site.
When there is an alert, it automatically displays a header title at the top of the advisories page that includes the zone name and zone code. ie: “Current Watches, Warnings and Advisories for Midland (TXZ062) Texas Issued by the National Weather Service”. This new feature compliments the feature that lets you change the zone code by adding a query on the URL ie: rss-advisory.php?zone=TXZ062
When there is an active alert, it automatically displays a “source” url link at the bottom of the advisories page that links directly to the rss page where the script got the alerts. ie: “Source: NWS Watches, Warnings or Advisories for zone TXZ062”. This new feature compliments the feature that lets you change the zone code by adding a query on the URL ie: rss-advisory.php?zone=TXZ062
New setting: $fullMessagesMode = true; // fetches the complete message for each alert.
New setting: $doLongTitles = true; // adds the zone name to the Alert Title for each alert.
Better usage of $doLowerCase setting. It will now lowercase all, then attempt to uppercase first word of every sentence.
Cache file improvements - cache files are now only written to the server when there is a valid zone selected
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.”
Better error handling for when the NOAA servers are having problems. View the HTML source for debugging comments.
Misc. fixes and improvements
Known Issues: (all fixed)
[li]NWS provides this new feed with a shortened “summary”, this can cause the displayed message to be shorter than the complete message that is available, click the link “view the complete message” on the alert to read the complete message on the NWS web site. (This issue has been reported to NWS, but their intent is for you to click to read the complete message for more information and instructions. So this is actually working the way they designed it.) Fixed to workaround this problem, set $fullMessagesMode = true; [/li]
The alert message may be missing the “instructions” section. Because the NWS only provides this new feed with a shortened “summary”, you have to click the link “view the complete message” on the alert to read the complete message on the NWS web site. (This is the way the NWS designed the new alerts. This is to save resources by not showing the full details for some of the messages you may not be interested in viewing in detail.) Fixed to workaround this problem, set $fullMessagesMode = true;
[li]The short summary message text sometimes has run-together words (This issue has been reported to NWS, hopefully they will fix it before the beta stage ends in December 2009.) Fixed to workaround this problem, set $fullMessagesMode = true;[/li]
Note:
This version requires PHP5 and is not backwards compatible with the non-beta feeds.
Your NOAA RSS Advisory PHP script will require an upgrade to this version by December of 2009 (you can start using it now if you want).
Look here to find zones that have active warnings (hint: Alaska might some active ones now, or look on a national map for an area with warnings.) http://www.weather.gov/alerts-beta/
He said:
"I’d suggest that a detection for PHP5 be inserted in the script, since you’re using simple_xml function and that could save a few trouble calls
An option to ‘fetch-through’ to the real alert text would be nice so folks don’t get short-changed by the
text display (fetch the link and save the for display if the non-summary mode is active)."
I added detection for installations less than PHP5 and a failure message.
I just added a new feature/setting to workaround the short message problem:
You just download the latest version from the first post, then set $fullMessagesMode = true;
It will fetch (in realtime) the complete message and instructions(if available) for all the messages when alerts are viewed in non-summary mode.
I also added a fine versioning number after the word BETA so you can tell if I have made slight edits or not.
$Version = ‘V2.00 01-Jun-2009 BETA .002’;
Ok thanks for the suggestions. Some installations do not have CURL, but most do. I can do a CURL check, then fall back to other way if they do not have CURL.
If anybody still has PHP4 they probably have a compromised server. They need to ask web host to upgrade their account to a server with PHP5.
New Curl version is working on my test server, but I need to adjust a few minor things and have to go out for an hour. I will upload it later.
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
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.
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.
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.”
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 '