Weather station scripts - RSS advisories

They're free, but use at your own risk

The scripts in PHP and Perl referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

If you find one or more of the scripts useful to you, please consider making a small donation to help offset the routine expenses of operation of this website.
Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on WXForum.net and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

Latest postings about Saratoga-weather.org Weather PHP scripts on Twitter

follow Saratoga-Weather.org PHP script updates on Twitter

This page was updated Tuesday, 01-Sep-2009 5:41 PM

NOAA RSS Advisory PHP script

This PHP script accesses and formats the Zone advisory RSS feeds from www.weather.gov/alerts/ to allow easy inclusion into your website. The RSS feeds from NOAA include Advisory, Statement, Watch, and Warning type messages, but do not seem to include "Outlook" type statements (so no "Hazardous Weather Outlook" is available via the RSS feeds from weather.gov). The script has three optional arguments for the URL:

zone=ssZnnn
This allows override of the default Zone for the RSS feed to use.
inc=Y
If present, the script will not output surrounding HTML for the page returned. You should specify this if you invoke the script from within your webpage i.e.
<?php include("http://your.website/rss-advisory.php?inc=Y"); ?>
summary=Y
If present, the script will output only the titles and links for the alerts found. The links will open the page specified in the script to display the details.

There are two ways of including the script in your pages depending on whether your hoster has allow_url_include option set to on or off. The URL method only works if allow_url_fopen is on in your PHP settings. The File method works with allow_url_fopen in either on or off mode.

URL method:
Page with summary info:
<?php
include("http://your.website/rss-advisory.php?&inc=Y&summary=Y;detailpage=advdetail.php");
?>
Detail display page (advdetail.php in this example) :
<?php
include("http://your.website/rss-advisory.php?&inc=Y");
?>
File method:
Page with summary info:
<?php
$includeOnly = true;
$DefaultZone = 'WAZ021';
$doSummary = true;
$hurlURL = "advdetail.php";
include_once("rss-advisory.php");
?>
Detail display page (advdetail.php in this example) :
<?php
$includeOnly = true;
$DefaultZone = 'WAZ021';
$doSummary = false;
include_once("rss-advisory.php");
?>

You can try a test of this with your Zone (located from www.weather.gov/alerts/ RSS County/Zone feed) using this website http://saratoga-weather.org/index.php?zone=ssZnnn where ssZnnn is your Zone. The script contains the documentation for setting up operation.

New 16-Aug-2006: A second form of this script offers cacheing of the RSS feed for 10 minutes (adjustable in the script) to help reduce the accesses to the www.weather.gov website. A 'cache=refresh' parameter on the call will refresh the cache at any time. The cache file is stored as rss-advisory-ssZnnn.txt in the same directory as the script. Please make sure that your PHP configuration and/or file permissions allow read/write of the cache file.
New 17-Dec-2007: The non-cache version of the script is deprecated .. please use the updated caching script instead. A series of defensive measures were placed in the script to mitigate possible exploits. Thanks to Mike Challis of Long Beach, WA weather for the suggestions. Also, a new inclusion method (File method above) was added to support rollout of PHP5 at sites .. the PHP5 default is to have allow_url_include set to OFF.
New 27-Jan-2008: The script has been greatly improved by Mike Challis and we've reissued the script as
'rss-advisory.php' . New features include:
* accomodates a different CSS style for when there is no advisory,
* added the sample css (see settings notes),
* added invalid zone error code
* added option to lowercase the advisories
See comments in the code for more examples and descriptions.

NOAA RSS Advisory PHP (with cache) script: demo and download [ see version history ]


NOAA Top Advisory Warning PHP script

This PHP script reads the same XML feed (and uses the same cache file) as the NOAA RSS Advisory PHP (with Cache) described above. The main difference is it displays nothing if there are no advisories/watches/warnings for the zone specified. If there are one or more advisories/watches/warnings available, it picks the most severe one to display and uses a CSS stylable box/color to help separate the intensity of the warnings. This script is based on Jim McMurry's warnscroll.php and Tom of Carterlake's advisory.php. The order of decreasing severity is:

  • Tornado Warning
  • Other Warning
  • Watch
  • Advisory
  • Special Weather Statement
  • Short Term Forecast

This script works with the rss-advisory.php script to provide the details of the alert and can be easily incorporated on your page by using:

<?php include("rss-top-warning.php"); ?>

See the testpage and the source of the script for additional options to allow the Zone to be dynamically specified.

My thanks to Jim McMurry of jcweather.us for the coding of his warnscroll.php on which this script is based and his urging to add it to the script collection here. Thanks Jim!.

NOAA RSS Top Warning PHP (with cache) script (V1.01 - 04-Jan-2008) : demo and download [ see version history ]


Storm Prediction Center RSS PHP Script

This PHP script reads and formats the RSS feed for the Storm Prediction Center at http://www.spc.noaa.gov/products/md/ . The SPC provides one feed. The script follows the links in the feed to include the text and images of the discussions. The script has two optional arguments for the URL:

inc=Y
If present, the script will not output surrounding HTML for the page returned. You should specify this if you invoke the script from within your webpage i.e.
<?php include("http://your.website/rss-mesoscale-test.php?inc=Y"); ?>
summary=Y
If present, the script will output only the titles and links for the alerts found. The links will open the page specified in the script to display the details.

To show the summary on your homepage and the details in a separate page on your website, you include this in hour homepage: <?php include("http://your.website/rss-mesoscale-test.php?summary=Y&inc=Y"); ?> and on the details page on your website, just have <?php include("http://your.website.rss-mesoscale-test.php?&inc=Y"); ?> and the details will be displayed with the look/feel of your website.

SPC RSS mesoscale discussion PHP script: demo and download [ see version history ]


National Hurricane Center RSS PHP Script

This PHP script reads and formats the RSS feeds for Tropical Cyclone Forecasts and Advisories from the National Hurricane Center at http://www.nhc.noaa.gov/ . The NHC provides three feeds (Atlantic, Atlantic en Español, Eastern Pacific). The script comes in two 'flavors': the basic script which only formats the selected RSS feed, and a second version which follows the non-graphical links in the feed to include the text of the advisories. If the real RSS feed would include that content (like other NOAA feeds), then the second script wouldn't be necessary.The script has three optional arguments for the URL:

zone=[A|AS|P]
This allows override of the default Zone (A) for the RSS feed to use.
zone=A (default) is for Atlantic, Caribbean, and Gulf of Mexico tropical cyclones in English
zone=AS is for Atlantic, Caribbean, and Gulf of Mexico tropical cyclones in Spanish
zone=P is for Eastern Pacific tropical cyclones in English
inc=Y
If present, the script will not output surrounding HTML for the page returned. You should specify this if you invoke the script from within your webpage i.e.
<?php include("http://your.website/rss-tropical-test.php?inc=Y"); ?>
summary=Y
If present, the script will output only the titles and links for the alerts found. The links will open the page specified in the script to display the details.

To show the summary on your homepage and the details in a separate page on your website, you include this in hour homepage: <?php include("http://your.website/rss-tropical-test.php?summary=Y&inc=Y"); ?> and on the details page on your website, just have <?php include("http://your.website.rss-tropical-test.php?&inc=Y"); ?> and the details will be displayed with the look/feel of your website.

NHC RSS Advisory PHP script: demo and download [ see version history ]
NHC RSS Advisory PHP script with full texts: demo and download [ see version history ]