PHP Level: Beginner => Intermediate
V3.6 Feb 27 2021
- Edits to ensure PHP8 compliance
V3.5 - Jan 1st 2020
- bug fix - now is corrected to 'yesterday' (latest possible record)
CU possible error report is year report missing - fixed
If your server doesn't support PHP, a JavaScript version can be found HERE
First of all kudos to Ken True aka saratogaWX, probably the weather communitys most respected and magmanimous codester.
If you have a php script or an ajax page the chances are that it contains chunks of Kens code or reasoning.
This is a modified version of one his scripts which will display a WeatherLink or VWS created NOAA style report and produce a navigation menu for the reports it finds.
Functionality:
View a WL, VWS or Cumulus (default) report as a 'stand alone' web page (default) or as an 'include' within an existing php page.
Defaults can be overridden by 'post' (.php?type=CU) or as a declared variable in an 'include' page - this allows those with multiple weather software reports to create a menu system / links to read any of them all from the same script.
This and more is explained in the comments within the script file.
View Code
Stand Alone (with 'Drop Down')
Stand Alone (with 'Classic' style)
Stand Alone ('Drop Down' but JavaScript DISabled)
OK - Lets begin (php is allowed on your server isn't it ?)
In your servers weather directory, create a sub directory called NOAA-reports, then In Cumulus, generate NOAA monthly and annual reports for every month and year that you have data for, and save them using the default file names.
Upload all of the reports to the NOAA-reports directory on your web server (This year and latest month will be an ongoing upload)
(If you wish to have a different name for the directory you will need to change a variable which is explained in the script)
Download the zip file, unpack it, edit it with notepad or similar and change it to your local timezone and make any other alterations you may want.
Upload it to your server weather directory (change the file name if you want) and that's it for the default 'stand alone' options.
Just refer to it as (mywebspace/weather)/NOAA-reports.php (or whatever you have called it).
If you have used an earlier version, RENAME or DELETE noaarep.css on your webspace so that the script can rebuild it for the new nav system.
Once the script has been run, a stylesheet called noaarep.css will have been created, you may then edit this to suit your own layout as desired.
If for some reason the noaarep.css does NOT get created - see this post: viewtopic.php?p=55174#p55174
If your page / character format is giving � the 'black diamond' for the degree symbol - see this post: viewtopic.php?f=14&t=5754&start=117
Tip: If you have existing NOAA style reports from other softwares, then you should be able to copy them to the NOAA-reports directory and as long as you rename them in the Cumulus format they should be found and displayed OK

NOAA Style Reports:
The word Style is IMPORTANT - these are NOT NOAA reports !
It also means that the layout is 'fixed' and is meant to look like the old teleprinter output.
This is the way the software(s) have created them and is nothing to do with the script !
Intermediate Level:
Of course it's not very pretty - I suspect it was intended to produce pages for printing.
However; It does have the facility to be used as an "include" file.
When being used as an 'include', you will need to call noaarep.css in your <head> section.
NOTE: If you opt out of css, 'classic' full nav will be created.
So make a copy of one of your (web) Cumulus pages, rip out the unwanted bits and do this:
eg.
Code: Select all
....
<title>Beteljuice weather</title>
<link href="weatherstyle.css" rel="stylesheet" type="text/css" />
<link href="noaarep.css" rel="stylesheet" type="text/css" />
</head>
<body>
.......
<H3>NOAA Style Reports for beteljuiceton</H3>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<?php
// set the variable to tell the script not to create html headers etc.
$doInclude = true;
include 'NOAA-reports.php';
?>
</td>
</tr>
<tr>
<td class="td_navigation_bar">:<a href="index.htm">now</a>::<a href="gauges.htm">gauges</a>::<a href="today.htm">today</a>::<a href="yesterday.htm">yesterday</a>::<a href="record.htm">records</a>::<a href="trends.htm">trends</a>:</td>
</tr>
</table>
.......
Include Test and Bob's your cross-dressing auntie

PS: don't forget to update your other pages with the new link !
Now available an alternative stylesheet for use with 'include's which has the button highlights INSIDE the buttons. Useful for pages with a dark background. Intermediate Level: - Tweak
I had a request to 'Anglicise' the reports address, ie. State:
As mentioned earlier this is a function of the software(s) that generate the reports; However ..
Just one line of code needs to be added.
Look for (way down the script, just before JavaScript section):
Code: Select all
if($rpt){
echo "<pre>\n";
echo preg_replace('|<|Uis','<',$rpt);
echo "</pre>\n";
}
echo "</div> <!-- END noaa_rep_container -->\n";
Code: Select all
if($rpt){
echo "<pre>\n";
$rpt = preg_replace('/State: Kent/i', 'County: Kent Country: UK', $rpt, 1);
echo preg_replace('|<|Uis','<',$rpt);
echo "</pre>\n";
}
echo "</div> <!-- END noaa_rep_container -->\n";
It maybe that your replacement text is too long, you may have to play a bit.

