Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

PHP Web 'viewer' for Cumulus NOAA Style reports

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderators: daj, TNETWeather

User avatar
beteljuice
Posts: 2455
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

PHP Web 'viewer' for Cumulus NOAA Style reports

Postby beteljuice » Tue Aug 23, 2011 2:24 am

Web reader of Cumulus generated NOAA style reports

PHP Level: Beginner => Intermediate

V3 - Sept 2011
    optional CSS
    optional reports nav menu
    optional 'drop-down' reports nav menu
    minor bug fix


V3.1 - Nov 2011
    minor bug fix for 'twitch' level error reporting


V3.2 - Apr 2012
    minor bug fix - malformed html picked up by Chrome browsers


V3.3 - Aug 2013
    bug fix - menu problem for non CU users


V3.4 - Feb 2015
    bug fix - corrupted var (affecting menu in some circumstances)



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)

NOAA-reports.zip


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>

.......

Save the (new) file with a .php extension, and the result is:

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.
noaarep_alt.txt


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','&lt;',$rpt);
   echo "</pre>\n";
}
echo "</div> <!-- END noaa_rep_container -->\n";
and change to:

Code: Select all

if($rpt){
   echo "<pre>\n";
   $rpt = preg_replace('/State: Kent/i', 'County: Kent   Country: UK', $rpt, 1);
   echo preg_replace('|<|Uis','&lt;',$rpt);
   echo "</pre>\n";
}
echo "</div> <!-- END noaa_rep_container -->\n";
N.B. 'State: Kent' and 'County: Kent ..... should naturally be replaced with whatever your reports are producing !
It maybe that your replacement text is too long, you may have to play a bit.

:oops: tweak code corrected, should work now :roll:
You do not have the required permissions to view the files attached to this post.
Last edited by beteljuice on Thu Feb 05, 2015 4:47 am, edited 23 times in total.
Image
......................Imagine, what you will KNOW tomorrow !

User avatar
meteotortosa
Posts: 323
Joined: Thu Dec 04, 2008 12:15 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Windows XP SP3
Location: Tortosa-Baix Ebre- Catalonia
Contact:

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby meteotortosa » Tue Aug 23, 2011 10:00 am

I have this script running on my web 1 year ago

http://www.meteotortosa.cat/web/index.p ... 65&lang=ca
Weather in Tortosa (NE Spain), updated every 15'
Image Image

User avatar
nking
Posts: 804
Joined: Thu Dec 17, 2009 2:03 pm
Weather Station: WH1081
Operating System: Windows 10
Location: Hurstpierpoint, West Sussex, UK
Contact:

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby nking » Tue Aug 23, 2011 10:23 am

Thank you to beteljuice and to Steve, I have it up and working fine, instructions are very good if I've been able to do it :lol:

Now, if David could just enhance the Toolkit so that it will automatically handle the updated reports that would be great, not too much to ask :P

gemini06720
Posts: 1700
Joined: Mon Aug 10, 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby gemini06720 » Tue Aug 23, 2011 10:46 am

beteljuice, the PHP script you have been using is very old (ie: version 1.06 - October 2008)... :roll:

Ken True has since updated the code to PHP 5 (ie: version 2.01 - June 2011) - the script is now named 'include-NOAA-reports.php' - the PHP script is part of two the 'PHP/AJAX Website Template Set' following plugins: 'VWS .ZIP and WeatherLink .ZIP

I have modified the 'newer' code, incorporating the the modifications you had made to the 'older' code and adding some (limited) CSS styling: NOAA-Style Climate Reports

User avatar
beteljuice
Posts: 2455
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby beteljuice » Tue Aug 23, 2011 11:10 am

Nice job Ray, that's pretty much the way I was thinking of handling the menu.
Image
......................Imagine, what you will KNOW tomorrow !

User avatar
JennyLeez
Posts: 283
Joined: Wed Dec 16, 2009 2:32 am
Weather Station: La Crosse WS3083
Operating System: Windows XP, Win7 & Win 10
Location: Wairoa, Hawkes Bay. New Zealand.
Contact:

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby JennyLeez » Tue Aug 23, 2011 11:14 am

Ok this is what I have.

Many thanks beteljuice, I even got the true true bit right this time :)

http://wairoa.net/weather/noaa-reports.htm

2minutes later - Oops while I was following betel's instructions there was more posts :)
Wairoa, Hawkes Bay, New Zealand Weather Station:
http://wairoa.net/weather/index.htm
Cumulus Topsites:
http://cumulussites.net/
Image

gemini06720
Posts: 1700
Joined: Mon Aug 10, 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby gemini06720 » Tue Aug 23, 2011 12:31 pm

beteljuice wrote:Nice job Ray, that's pretty much the way I was thinking of handling the menu.
Thanks beteljuice.

I noticed in your code a question mark at the end of the '$IncludeMode = false;' line - I believe you understand what the '$IncludeMode' does, but let me explain the 'raison d'être' for that variable...

On my site, for example, before including the 'include-NOAA-reports.php' script into my page ('noaaclimatereports.php'), I set the variable '$doInclude' to true. In my 'include-NOAA-reports.php' script, the value contained in (passed on from) the '$doInclude' variable is transferred over to the '$IncludeMode' variable (in my case the true value). Setting the '$IncludeMode' variable to true prevents the script from sending any HTML code (header and footer) and eliminate the 'Cannot modify header information - headers already sent...' error/warning message.

By default, by itself, my [link removed] script with the '$IncludeMode' variable set to false will display as a 'standard' web page, complete with the required HTML header/footer code. But, with the '$IncludeMode' variable set to [link removed], all the formatting/styling disappear, and the resulting 'pure' HTML code can thus be included into another page without risk of errors or warnings.
Last edited by gemini06720 on Sun Jun 09, 2013 9:18 am, edited 1 time in total.

User avatar
beteljuice
Posts: 2455
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby beteljuice » Tue Aug 23, 2011 12:50 pm

My thoughts were "... or even posting ?inc=y (why ? - beteljuice)". I could not see how a 'posted' request could be an 'include' in the current php page, but now I realise it's for the OPPOSITE purpose.
ie. The script default has been set to 'include', but you want to provide a link (possibly a seperate 'target') that creates it's own html - So usage in that case would be ?inc=n - that's the only way I can see it being used :?

On another note: I have not inspected the newer code in detail, but would I be correct in thinking that now It can set defaults from a parent ($SITE) script, but doesn't support the beteljuice functionality of setting the wxreport type on-the-fly ?
Image
......................Imagine, what you will KNOW tomorrow !

gemini06720
Posts: 1700
Joined: Mon Aug 10, 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby gemini06720 » Tue Aug 23, 2011 1:39 pm

beteljuice wrote:...that's the only way I can see it being used...
I am not too sure I understand your reasoning or explanation... :?

When the '$_REQUEST['inc']' is passed on to the script, the value it contains is used to change the state of the '$IncludeMode' - such is the case in the NOAA script with the '?inc=y' and the '$_REQUEST['inc']) == 'y''. This concept of using either the '$_GET' or the '$_POST' or the '$_REQUEST' in order to pass values has been greatly used throughout the weather templates (scripts) I have been using for the last 5+ years.

beteljuice wrote:...It can set defaults from a parent ($SITE) script...
Again, with the AJAX-PHP Saratoga templates (as well as with my Cumulus templates), most of the default parameters are defined into one file (the 'Settings.php' file):

Code: Select all

$SITE = array();
$SITE['tz'] = 'America/Vancouver';
$SITE['NOAAdir'] = 'NOAA-reports/';
$SITE['NOAACurDir'] = './';
$SITE['WXsoftware'] = 'CU';
...
Then, in the script, a test is made to check if the '$SITE' variables have been defined (set) and use their values instead:

Code: Select all

global $SITE;
if (isset($SITE['tz'])) { $ourTZ = $SITE['tz']; }
if (isset($SITE['NOAAdir'])) { $NOAAdir = $SITE['NOAAdir']; }
if (isset($SITE['NOAACurDir'])) { $NOAACurDir = $SITE['NOAACurDir']; }
if (isset($SITE['WXsoftware'])) { $NOAAsoft = $SITE['WXsoftware']; }
One thing to remember is that a default value for the variables has to be defined also within the script. In my script I have the following at the beginning of the script:

Code: Select all

$NOAAsoft = 'CU';
$NOAACurDir = './';
$NOAAdir = 'NOAA-reports/';
$ourTZ = 'America/Vancouver';
Defining and placing a value into the variables at the beginning of the script make the script 'portable', meaning it can be used by itself. But allowing the replacement of the values contained into the variables with the values contained into the '$SITE' 'global' variables allows the same script to be used on different systems with little or no modifications - easier when a script is distributed to a large number of people.

I hope I did not make things more confused... :oops:

Could you please explain what you mean by
beteljuice wrote:...but doesn't support the beteljuice functionality of setting the wxreport type on-the-fly
???

n9mfk
Posts: 845
Joined: Sun May 10, 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby n9mfk » Tue Aug 23, 2011 4:52 pm

Hi ray Looks good is there a way the view the source of your code
thanks beau

User avatar
beteljuice
Posts: 2455
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby beteljuice » Tue Aug 23, 2011 6:26 pm

Calm down beau.

Ray: "?inc=n - that's the only way I can see it being used "
What link could make use of .php?inc=y ?

"...but doesn't support the beteljuice functionality of setting the wxreport type on-the-fly"
As you stated above, there are possible 'setup' files, but not the ability to accept a 'posted' value for the wx system. ie. It is dedicated, whereas my code would allow (by link) the ability to pull different software reports.
Image
......................Imagine, what you will KNOW tomorrow !

TgT
Posts: 127
Joined: Thu Jun 26, 2008 5:51 am
Weather Station: Davis VP2 + Solar
Operating System: A20 TV box + CumulusMX
Location: Slov.Konjice, Slovenia
Contact:

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby TgT » Tue Aug 23, 2011 10:33 pm

Great stuff :clap:
Image

gemini06720
Posts: 1700
Joined: Mon Aug 10, 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby gemini06720 » Wed Aug 24, 2011 12:05 am

beteljuice wrote:Calm down beau.
Indeed... There is still some work to be done... :twisted: ...And, Beau, you could try modifying the script by yourself and see the results - how else will you learn more about PHP if you do not try doing things by yourself... ;) In order to find my way through a script (be it in one file or a dozen files), I place a lot of comment lines (and I mean a lot of them) to identify what a section of the code is doing and, in important sections of the code, I will place a lot of 'echo/print/exit' elements to find out what has been done to that stage (processed by the script functions) - there is a purpose to my madness ... learning by my mistakes... :lol:

beteljuice wrote:As you stated above, there are possible 'setup' files, but not the ability to accept a 'posted' value for the wx system. ie. It is dedicated, whereas my code would allow (by link) the ability to pull different software reports.
Again, I am not too sure what you are trying to accomplish? :?

Please, also forget this concept about the 'posted' value - for me, the concept of the 'posted' value is associated with the limited use of the HTML 'form/input' elements.

A lot of information (data) can be passed from one script to another script to another script through the use of the '$_GET' and '$_REQUEST' - it then just becomes a matter of checking if the HTTP 'passed-on' variable (preferably through '$_REQUEST' - more complete) has been set and is not null (contains a value) and processing that variable.

What type of data/values would you like to pass on to the script? Why could you not use something similar to the '?inc=y' - the script is already using two 'modifiable' variables, '$mo' and '$yr'. The two variables are, at the present time, modified by the script itself when one click on one of the year or one of the month link - this is the code used within the script to obtain the values for the 'modifiable' variables:

Code: Select all

$yr = isset($_REQUEST['yr']) ? $_REQUEST['yr'] : '';
$mo = isset($_REQUEST['mo']) ? $_REQUEST['mo'] : '';
When a value is passed on through the external 'yr' global variable (such as '.php?yr=2011') then the value will be passed on to the internal '$yr' for further processing - if the external 'yr' global variable does not exist (has not be set up) or is empty, then the internal '$yr' is set to null.

And this is how the values are passed on from one script to another by the browser:

Code: Select all

noaaclimatereports.php?yr=2011&mo=08

Note: I am using the script 'noaaclimatereports.php' to include the script 'include-NOAA-reports.php' - so, for example quoted above, the year and month values (ie: 2011 and 08) are passed on from the 'noaaclimatereports.php' script to the 'include-NOAA-reports.php' script and, inside the 'include-NOAA-reports.php' script, the values are transferred over to the '$yr' and '$mo' variables for further processing.

It is my belief that the script is already written for your purpose, 'to pull different software reports' - but only two variables can be modified, the years and/or the months - obviously, the script cannot and will not give you the time of day ... although I included some code to my script to automatically activate the espresso coffee machine every few hours for a fresh cup of java... :D

OK, if I completely misunderstood your goals/needs, please explain again, this time using a few additional words and not those short cryptic sentences... :mrgreen:

User avatar
captzero
Posts: 363
Joined: Wed Mar 03, 2010 10:20 am
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows 10
Location: Brisbane, Australia
Contact:

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby captzero » Wed Aug 24, 2011 12:52 am

TgT wrote:I included some code to my script to automatically activate the espresso coffee machine every few hours for a fresh cup of java

Now that's a bit of code I'd be interested in. :lol:
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.

gemini06720
Posts: 1700
Joined: Mon Aug 10, 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: PHP Web 'viewer' for Cumulus NOAA Style reports

Postby gemini06720 » Wed Aug 24, 2011 1:02 am

gemini06720 wrote:I included some code to my script to automatically activate the espresso coffee machine every few hours for a fresh cup of java
captzero wrote:Now that's a bit of code I'd be interested in. :lol:
Dan, the code is very espresso-machine-specific...
Last edited by gemini06720 on Sun Jun 09, 2013 9:19 am, edited 1 time in total.


Return to “Web site - General”

Who is online

Users browsing this forum: weatherist34 and 3 guests