Display warnings, watches, advisories, and alerts provided by the ATOM XML/CAP 1.1 feeds provided by NOAA. Designed for multiple zones, this package can be used on a php capable web site with or without the Carter Lake template set.

The package contains a primary php file that fetches the alerts for the zones entered, icons for the top advisories and a complete set of icons used by the National Weather service to indicate the alert type. Also included are two sets of sample pages and a demo page to illustrate what you can do with the file output.

What's new...

Since the introduction of County codes in the ATOM/CAP feed, alerts for the county codes can be converted to the zone alerts without duplicating alert messages. This gives you a wider coverage if the county has an active alert while the zone does not. At times, there may be a zone alert while the county does not have one. The AtomFeed program covers both the county and zone alerts. This also handle counties that are split into two zones.

Acquiring the data has improved and all data is cached. Data for the county and zone codes are fetched, checked for alerts, and the full alert data is then downloaded. During the data fetch, if a network error occurs, or a time-out condition occurs, the previous data is retained preventing loss of information on the web pages. The data is updated at the next good fetch.

The Alert Box can be easily configured to suit your needs such as width, icons, background color, limiting alerts, create a table, and always show if there are no alerts. The 'top-warning' box is not need and no longer used.

A priority zone code can be used.

Headlines provided by the NWS can be used in the XML page to describe the alert or choose a short description.

A status page is produced that reports what occurred in the last AtomFeed run.

Filenames for the pages have not changed from the previous version of the AtomFeed program.

Log alerts for archiving

Multiple options to display the alert box

How does it work?

The AtomFeed script has three files to make it all work. The AtomFeedphp file will fetch the data for each zone and ends up producing a php file that your web pages will use to display the data.The fetching process of the php file can take several seconds depending on the number of county or zone codes and will copy a working file to the usable file after the process. This eliminates page loading errors during the process.

All configurable settings are in the AtomFeed-config.php file. Titles, filenames, paths, and icons. All county and zone codes are entered in this file.

AtomFeed-conversion.php is the file that converts the county codes and alerts to the zone codes. There are no settings in this file.

All data that is downloaded from the NWS is cached in a separate folder and used by the AtomFeed script. Outdated cache files are deleted so it doesn't accumulate un-needed files.

An XML file is also produced so a live-feed bookmark can be used by your visitors.

What is needed?

PHP 5.0 or better is required. Because of the length of time to fetch the data, the AtomFeed. php file needs to be called by a cron job to update the information. Most web hosts provide this feature while some don't. The easiest solution is to use the Windows Task Scheduler. You can download the instructions on how to set this up and comes with a template file. Window XP  Windows Vista

What's included?

Files include are   AtomFeed.php - AtomFeed-config.php - AtomFeed-conversion.php - AtomZone.php -  AtomSummary.php - AtomDemo.php - AtomAdvisories.php - noaa_logo.png - all icons in the images folder.

Server Permissions

This script may require special permissions on your server to create folders, create files, and delete files as this script performs all of these functions. Setting a cache/data ('work') folder chmod'ed to a maximum of 775 is required to perform these functions.


 I - Configuration - AtomFeed-config.php
   a - Setting County Codes and Zone Codes
   b - Functional Settings
   c - Filename and Paths
   d - Display Options
   e - XML Feed
   f - Alert Box Set Up
   g - Big Icon Set up
   h - Configuration and Installation
   i - Web Files Installation

II - Web Pages
   a - Types

III - Adding Alert Box and Icons On A Web Page
   a - Code

IV - Troubleshooting
   a - Script Errors

V - Contact
   a - Help and Support


Primary PHP Script

Main Settings in the AtomFeed-config.php

There are several settings in the script to accommodate your preferences and environment. To avoid errors, check the values of each main setting before using the script.

Open the file  AtomFeed-config.php.

County codes and Zone codes in the $Code_Location array

There are two ways to use this script for displaying the information and the best way is to gather the data from the county code and transfer it to the zone code data. The AtomFeed-conversion.php script checks the county code alerts against the zone code alerts and will add them to the zone code if that alert is not found. The zone may already have that alert, may not have the alert, or may have an alert that the county code doesn't have. This way, the alert data is double checked for the zone. Since the county codes are checked and transferred over to the zone code, the county alerts are not displayed on the web page eliminating dual or repeating alerts.

Another way to use this script is to list each county alert and/or the zone alert independently. If you use a county code and the zone code that is in that county, you will see two separate alerts that are usually identical. You can mix county codes along with the zone codes or use all of one and not the other.


County Code to Zone Code Conversion

For full zone coverage, each zone that you want to cover should have a county to zone conversion. County and Zone codes can be found here

The county/zone codes are entered in this array.

A priority zone is entered on the first line of the array. This is used for the Alert Box and is considered to be local.

"INZ005" => "Elkhart Co", // ELKHART

"INZ005" is the zone where the weather station is located. "Elkhart Co" is a short description on the location. "// ELKHART" is commented out and is just a reference.

Converting the county code data to the zone code is done a little differently in the array. A conversion array like this should not be the first line in the $code_Location array.

"INC039" => array(1 => "INC039",'a' => "INZ005"), // ELKHART

"INC039" is the county code. An array is made. 1 => "INC039" is the county code. 'a' => "INZ005" is the zone in the county. All zone codes must be entered in the array like the first example.

If your county is split up into two zones like Baltimore County MD, the array will contain both zones. ( 'a' + 'b' )

"MDC005" => array(1 => "MDC005",'a' => "MDZ011",'b' => "MDZ006"),  // BALTIMORE

This is similar to the above. "MDC005" is the county code. 1 => "MDC005" is the county code again. 'a' => "MDZ011" is one of the zones in Baltimore County. 'b' => "MDZ006" is the other zone code in Baltimore County.

Both of these zones will need to be entered in the array.

"MDZ006" => "No.Balt.Co.", // N Baltimore
"MDZ011" => "So.Balt.Co." // S Baltimore

Both of the lines in the array has the zone code, short description and a commented note.

* Note that the very last entry in the array does not have a comma while all of the others have the comma.


NO Conversion - List all codes

Each line in the array consists of the county/zone code and a short description. A commented note of the code is recommended to aid in identifying the code later on. The first entry is used as a priority.

"INZ005" => "Elkhart Co", // ELKHART
"MDC005" => "BALTIMORE", // Baltimore County
"MDZ006" => "No.Balt.Co.", // N Baltimore
"MDZ011" => "So.Balt.Co." // S Baltimore

* Note that the very last entry in the array does not have a comma while all of the others have the comma.


Functional Settings

These are default settings. You will need to adjust them to fit in your web environment.

The AtomFeed files are to be put in a sub folder unlike the previous version. There are two settings listed below that deal with the file paths and are noted in red.

$ourTZ = 'America/New_York';

Your time zone setting. Check this web site if you are unsure.

$log_alerts = false;

Log all alerts issued by the NWS for archiving on a daily basis.
true = Create a daily log of alert for archiving.
false = Do not log alerts.

Filenames and Paths

$AdvisURL = "AtomZone.php";

Filename for the page that will display the details and alert messages. Do not add the path to the actual file.

$AlertSummary = "AtomSummary.php";

Filename for the page that will display a summary of all the county/zone codes whether they have alerts or not. Do not add the path to the actual file.

$file_output = "../AtomArray.php";

Filename of the information array that is outputted by the AtomFeed script. This data is the supply for all the information and is included on all pages that have AtomFeed information.  **NOTE - The setting shown above puts that file in the root (parent) directory.

$log_folder = "./AtomLog/";

Folder name that stores the alert logs. You must manually create this folder and set the file permission to 775. Files will be written to this folder. See instructions listed below on setting this up.  **NOTE - The setting shown above puts that file in another directory. Special file permissions may be needed.

$a_arrays = "AtomWork.txt";

The data being collected may take several seconds to a few minutes and while in the process of doing this, the data is saved to this file. When the data is finished processing the information, it is then quickly copied to the information array file.

$icon_folder = '../images';

Folder where the icons are stored. You can add the icons in an existing folder as long as it doesn't contain wind direction icons.

$AlertURL = ''
$AlertURL2 = '';

URL's for acquiring data from the NWS. The first one is for preliminary data and the second one is used for full alert data.

Display Options

$timeFormat = 'D, M j, Y h:ia T';

Format the time display.

$no_alert = "No warnings, watches, or advisories";

Choose what you want to display when there are no alerts.

XML Feed

$xmlFilename = "../LiveFeed.xml";

Filename for the XML page.  This filename was changed from the previous versions of the AtomFeed program.**NOTE - The setting shown above puts that file in the root (parent) directory.

$titleA = "Area Weather Alerts";

Title to appear at the top of the XML page.

$xml_Link2message = true;

Link the alert title to either the summary page or the full message.
true = Link title to the full message.
false = Link the alert title to the summary page.

$xml_SortByDate = true;

Sort the alerts by date/time issued of sort by alert severity.
true = Sort alerts by date/time when they were issued in descending order. The most recent is listed at the top.
false = Sort alerts by severity with the most severe at the top.

$use_headline = false;

Type of alert title.
true = Use a long descriptive "headline' alert title as provided by the NWS.
false = Use a short description for the alert type.

$titleA = "Area Weather Alerts";

Title for the XML page.

Alert Box Set Up

The next three options sets the main layout of the Alert Box. Only one of the next three options can be set to true if you prefer that style and they can not be combined. If the next three options are all set to false, all county/zone code alerts will be displayed.

$local_alerts = false;

The local county or zone code is the first code that was entered in the $Code_Location array.
true = All alerts in the Alert Box will be for the local county/zone code only and will contain ALL alerts for that code and can not be regulated
false = All county/zone code alerts will display in the Alert Box.

$limit_topAlerts = false;

Either show all alerts for all codes or just the top ranking alerts for each code.
true = Display top ranked alerts for each county/zone code.
false = Display all alerts for each county or zone code.

$group_alerts = true;

Lists one alert type followed by each location or individually list alert type and location.
true = Display appropriate alert type followed by each location for that alert type.
false = Individually display each alert type and location.

$GroupAlerts_TitleBreak = true;

If $group_alerts is set to true, this option adjusts the alerts and locations to be either strung together or an alert title will start a new line.
true = breaks line so each title is on a new line
false=string titles with other titles & locations

$limit_GroupAlerts = false;

If $group_alerts is set to true, a location may have identical alerts titles with different information and will list the location for each alert.
true = remove duplicate locations if they have the same alert title
false = show all locations if they have the same alert title

$aBox_Width = '100%';

Sets the width of the alert box in pixels or percentage.
Examples - '600px'   '99%'   For the smallest width box, do not enter any value between the single quotes

$always_show = true;

If there are no alerts, the box can display or disappear.
true = If there are no alerts, the box will display stating that there are no alerts.
false = The box is not displayed when there are no alerts and the table for the Alert Box will not created.

$link2details = true;

When there is an alert, the alert type is linked either to the summary page or the page with the full details.
true = Link to the page with full details.
false = Link the alert type to the summary page. The summary page has the links to the full message page.

$limit_NoAlerts = true;

Either show a no alert for each code or display only one no alert.
true = Display one no alert message if all codes do not have alerts.
false = Display a no alert message for each code.

$line_break = false;

The Alert Box can display one alert per line or if the box is set to a width specified in $aBox_Width multiple zones will can be on one line.
true = One alert per line.
false = Multiple alerts can be on one line if the box is wide enough.

$align_left = true;

Center each line or align each line to the left. This is available only when $line_break is set to true.
true = Left align each line. The left and right margins are determined by the length of the longest line in the Alert Box.
false = Center each line.

$font_size = "100%";

Set the font size.
Examples -  "90%"   "0.8em"

$colorCode_bckgrnd = false;

Set the background color to a severity rated color for the highest ranked alert . Example - warnings = red    watch = orange   advisory = yellow
true = set the background color to a color-coded severity rating from the highest ranked active alert.
false = use the background color set in $aBox_Color.

$separator = '-';

Style of separator between locations.  Examples"  '-'   '|'   '*'  '•'

$aBox_Color = '#FFEEBB';

Set the background color of the Alert Box.   Examples - '#FFEEBB'   '#EEE'   'white'   'inherit'  (inherit is transparent)

$aBox_Border = '1';

Border size in pixels around the Alert Box. "1" = thin    "0" = no border

$aBox_Icon = true;

Allows the small icons to display next to the alert message.
true = Display small icons in the alert box.
false =Do not display the small icon before the alert type.

Big Icon Set Up

$icon2details = false;

The big icons can link to the summary page or the message page.
true = link icons to page with details
false = link icons to summary page

$icon_limit = "3";

Larger icons generally used in the menu bar. Limit how many icons to display.
Examples - 3 = Display three icons and then show a short message that there are more. Leave blank to display all icons.

$show_allBI = false;

When there are active alerts, choose to display no alert icons.
true = Display non alert icons, 'NONE', with active alert icons.
false = Do not display non active alert icons with actives icons.

$icon_textColor = "black";

Set the text color for the location name under the icon.  Examples - "#777"  "#00BB88"   "black"   "white"

$all_BIGicons = false;

Create an optional tag to list all big icons to use in different application other than a menu bar. Set to false if you do not use this feature. Instructions on how to use this feature is listed in the section Adding Alert Box and Icons on a Web Pages.
true = Create an array of all big icons. One for each code listed with the location listed below the icon.
false = Do not create the array.


The key factor for successful operation of the script is the way it gets executed or called. Normally small scripts are called every time a web page is entered and the page loads without any noticeable slow down. However, this script isn't small.

The script uses a CURL method to get the data from the ATOM XML feed which is faster than getting it from a URL socket connection. A normal CURL fetch takes about 0.100 to 0.200 of a second under ideal conditions. While fetching several zones at a time, the time period can exceed 3 seconds per zone due to internet traffic and NOAA's frequent updating. A cron job is needed to call the script so the pages that use the data can load fast using the file output.

CRON JOB - Depending on your web host, a cron job can be set up in the cron tab. Information on configuring the cron is supplied by your web host. Due to the volume of information collected, a timed interval of 10 minutes is recommended but you can change it to your preference.

Not all web hosts offer the ability to do crons. Windows Task Scheduler is the best solution and easy to set up. Download the instructions for Window XP  or Windows Vista.

If you use any type of a "pseudo-cron", the script will occasionally produce errors and will not work. This type of a cron is not supported.

File and folder permissions - The main script, files, and files produced work with chmod 664. If you get file writing errors, you will need to set the folder permission, or chmod, to 775.

Web Installation

With the amount of files that are produced by the AtomFeed program and the deleting of non-related files, these program files must be placed in a sub-folder. The original AtomFeed program was placed in the root directory and the files were mixed among all of the other files. Keeping the files separated will help you find the files when modifying the config file or updating. You can name the sub folder to any name that you want but you will need to change the path of the cron job or modify the Windows Task Scheduler vbs file to reflect the change.

If you already have the AtomFeed program installed, following these instructions will make the transitions a smooth one.

Step 1 - Create a folder off of your root folder on your web server for the AtomFeed files. You could name it 'AtomAlerts' .
Step 2 - A sub-folder will automatically be created named 'work' . You will end up with a folder structure like this  /wxwebfiles/AtomAlerts/work
Step 3 - Set the permission level (chmod) on both of these new folders to 775. A lower level may work on your server but this is the highest level needed.
Step 4 - Unzip the AtomFeed file, open AtomFeed-config.php and check the settings.
Step 5 - Upload AtomFeed.php, AtomFeed-config.php, AtomFeed-conversion.php to the newly created sub folder named 'AtomAlerts'.
Step 6 - Upload all of the files in either the CarterLakePages folder or StandardPages folder to the root, or main, directory.
Step 7 - If you already have the AtomFeed program, you most likely have the icons in the images folder uploaded on your server. If not upload the entire images folder. Be sure to check the path in the config file $icon_folder = '../images'; .
Step 8 - Manually run AtomFeed.php in the sub folder and check the screen for errors. Check file permissions and settings if there are errors. Network connection errors may occur and are not a problem.
Step 9 - Set the cron job or Windows Task Scheduler to call the AtomFeed.php file in the 'atomalert' folder at regular intervals and verify that the files were updated.
Step 10 - Run the AtomSummary.php page and make sure your the reports are listed.

After you check the operation of the new AtomFeed program and everything is running smoothly, you can delete the old AtomFeed.php file in your main (root) folder or save it as a back-up.

*There is an issue with creating a cron job if your web host is GoDaddy. Contact me if you use GoDaddy by clicking on the link at the bottom of this page.


Adding Alert Box and Icons on a Web Pages


The pages included in the package you downloaded can be edited to your preference.

Adding the Alert Box

There are a few different ways to put the Alert Box on a page depending on your settings in the config file.

The basic way to display the Alert Box is with this:

echo "\n<!-- AtomFeed Alert Box-->";
print $alert_box;
echo "\n<!-- end AtomFeed Alert Box-->\n";

If you have a title bar and want the big Alert Box and title bar to appear when there is an alert, use this:

echo "<!-- AtomFeed Alert Box -->";
if($alert_box !== '') {
print '
<table border="0" cellspacing="0" cellpadding="0" style="width: 724px; margin: 0px auto 0px auto;">
<td style="color: #FFFF99; background-color: #3AB; text-align: center">WEATHER ALERTS</td>
echo "\n<!-- end AtomFeed Alert Box -->\n";

Of coarse this is an example and you may want to change the markup or styles to match your web page. You can change the title bar text color by replacing #FFFF99with the color you prefer and the title bar, or background color, by changing #3AB
Set the following in the config file   $always_show = false;   $aBox_Width = '100%';


Adding the big icons to the menubar

If you use the Carter Lake template set, open menubar.php and find a spot where you want the icons displayed. Icons can be placed almost anywhere with the same code.

<!-- AtomFeed icons -->
<p class="sideBarTitle" style="text-align: center; text-decoration: none;">Alerts</p>
<?php include_once("AtomArray.php"); foreach($top_icons as $alertIcons){ print $alertIcons;} ?>
<!-- end AtomFeed icons -->

The middle line is the key to printing the icons from an array.


Using All Big Icons for other applications

This feature is intended to display all of the big icons in a page other than the menu bar whether an alert is issued or not. An array is created that has each county or zone code individually listed so it can be placed in a table and configured to your preference. For example, if you have a total of four county/zone codes and you want to display the alert status for each code in a table, you would set $all_BIGicons = true;and use the tag $all_icons in the following code.

<!-- AtomFeed icons -->
<?php include("AtomArray.php"); ?>
<table border="1" cellspacing="0" cellpadding="4" style="text-align:center; ">
<td><?php print $all_icons[0] ?>&nbsp;</td>
<td><?php print $all_icons[1] ?>&nbsp;</td>
<td><?php print $all_icons[2] ?>&nbsp;</td>
<td><?php print $all_icons[3] ?>&nbsp;</td>
<!-- end AtomFeed icons -->

$all_icons[0] is the first icon, $all_icons[1] is the second icon and so forth.  If you have a different amount of codes, you will need to add or delete the appropriate lines and tags. Setting up columns and rows will need some configuring on your part. If an active alert exists, the first icon will be the most severe followed by the less severe.


Active Alert Indication

A tag was added in the AtomArray.php file to indicate that there is an active alert.    $alert_status    This is handy if you want to display an icon or a customized message if there is at least one active alert. The only requirement is that you need to include the AtomArray.php file in the page. To use this feature for printing a text message, add the following code;

if($alert_status) {
  print "ALERT";

You can change "ALERT" to any text .

If you want an image or icon in an html environment, use the following;

if($alert_status) {
 print '<img src="path/and/filename.png" width="10" height="10" alt="Alert" style="border: none"/>';


Alert Logging

Archived daily alerts can be selected by a drop down menu that lists only the days that have had alerts. Because of the policies of each web host, a standard installation of files is not possble due to file permissions and accessing files in another folder. A simple way to do this is to have the log files generated in your root folder. This will work but it will cause a lot of clutter so it is best to keep these log files in a separate folder.

Step 1 - Create a folder off of the root folder named AtomLog.
Step 2 - Set the folder permission to 757.
Step 3 - Open the AtomFeed-config.php file and set $log_alerts to true.
Step 4 - Set $log_folder to the path and folder name. Default is "../AtomLog/"
Step 5 - Save, close, and upload the file.
Step 6 - Upload the file AtomAlertLog20100101.txt that is provided to the AtomLog folder.
Step 7 - Manually run AtomFeed.php and check for errors.
Step 8 - If there are no errors, a new file will be generated only if there is an active alert.
Step 9 - If there are errors, most likely it is a file permission error stating that a file can not be created.
Step 10 - Open AtomAlertLog.php and set the path to the log folder. $log_folder = "../AtomLog/";
Step 11 - Run AtomAlertLog.php. Errors will display if the path is not correct or the files can not be accessed due to folder/file permissions.
Step 12 - If there are no errors, a date of 01/01/2001 will be display or the current date if you have active alerts for a zone.
Step 13 - If the date of 01/01/2001 is displayed, leave the file AtomAlertLog20100101.txt in the folder until a current date appears.
                  It can be deleted when the menu does not default to 01/01/2010 or another date is in the menu.



Web Pages


Two sets of nearly identical web pages are included in the package. One set is for Carter Lake template users and the other set is for standard php pages. Both sets are working samples that validate as XHTML 1.0 Strict and can be modified to your likings.

Demo page - AtomDemo.php shows various ways you can display the information. Used as a reference for creating your own pages.

Summary page - AtomSummary.php contains the alert titles for all zones and links them to a detailed page for each zone. This page is linked from the top advisory icon(s).

AtomAdvisories.php - Lists all county and zones.

Alert message page - AtomZone.php displays all the alert information for each zone. Data includes title, area, date and times when issued, updated and expiration, severity, urgency, certainty, areas affected, alert message and instructions if applicable. This page is linked from the summary page, menu icons, and the alert box. You must access this page from one of those links otherwise no data will be displayed.

XML page - LiveFeed.xml is an XML page.

AtomAlertLog page - Display archived alerts.

AtomAlertLog20100101.txt - A dummy file to use when setting up the AtomAlertLog page.

If you have customized a web page with some code from the the pages listed above, update what you have from these new pages. The AtomSummary page is the only one that has not been changed. Here is a list of what was changed.

AtomDemo.php - The 'top-warnings' removed and is no longer supported.

AtomAdvisories.php - The NWS logo was added and the table was modified.

AtomZone.php - The NWS logo was added. Table modified. PHP code modified.



Extensive testing has been done on three different servers (Apache) to assure that this script runs without errors. Michael Holden (Relay Weather)  has beta-tested this on e-rice and also provided some of the code. This has not been test with Linux.

Script Errors

Errors can occur as with any php script. Listed below are common errors and possible ways to correct the issue.

The AtomFeed program generates a status page named Status.txt that displays what happened during the last execution of the Atomfeed.php file. Time-out errors and network connection errors are common and are due to issues that can not be controlled. These are expected.

County or Zone(s) not displayed in web pages - Check for a valid county code or zone code entered in the $Code_Location array. It is important to enter these correctly in the $Code_Location array in the config file.

AtomZone.php error - This page will display an error if you don't access the page from a link. An invalid zone can also cause a page error.

Date and Time is wrong -  Check the $ourTZ value in the config file for the correct zone listing.

Icons not displaying - The default folder for the icons are in a folder called images. Check $icon_folder and make sure the icons are there or change the setting to the path and folder where the icons are located. If you are not getting the big icons in the menubar, make sure $icon_limit is not set to "0". Check folder permission.

Data from AtomArray.php appears on the web page - The cron job times out and loops when using a "pseudo-cron".

"Copying work file to array file failed. Check file permissions if this persists" - File and/or folder permission is set too low.

There are limitations... Too many county codes and zone codes entered can bog down the fetching process. While fetching the data, the NWS may start updating their records and cause random connection errors. If you see these errors on a regular basis, reduce the number of codes.

* If you are having abnormal problems with alerts, it would be very helpful if you could send me all of the files in the work folder along with the AtomFeed-config.php file so I can troubleshoot the issue without guessing what is taking place. Also a link to your website and the folder where the AtomFeed.php file is located is very much appreciated.


Questions?  Comments??  Additions???  Help!!!!

Feel free to contact me, Curly