Sandaysoft

Support forum for Cumulus weather station software
It is currently Tue Jun 18, 2013 4:59 am
Please click here before posting. Help me to help you!
Useful Links: Cumulus FAQ • Enhancement requests • Wiki (documentation)
Please put your approximate location into your profile
Add your web site to the Cumulus user map
Vantage Pro2 users with firmware 3.00 should upgrade to fw 3.12 and Cumulus 1.9.4

All times are UTC




Post new topic Reply to topic  [ 171 posts ]  Go to page 1, 2, 3, 4, 5 ... 12  Next
Author Message
 Post subject: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 2:24 am 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1887
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
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



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)

Attachment:
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:
....

<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.
Attachment:
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:
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:
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.

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Last edited by beteljuice on Sun May 26, 2013 1:15 am, edited 20 times in total.

Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 10:00 am 
Offline
User avatar

Joined: Thu Dec 04, 2008 12:15 am
Posts: 298
Location: Tortosa-Baix Ebre- Catalonia
Weather Station: Davis Vantage Pro2 Plus
Operating System: Windows XP SP3
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


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 10:23 am 
Offline
User avatar

Joined: Thu Dec 17, 2009 2:03 pm
Posts: 787
Location: Hurstpierpoint, West Sussex, UK
Weather Station: WH1081
Operating System: Windows XP & 7 Pro
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

_________________
Neil
Hurstpierpoint Weather

Image


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 10:46 am 
Offline

Joined: Mon Aug 10, 2009 10:16 pm
Posts: 1698
Location: World...
Weather Station: No weather station
Operating System: No operating system
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


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 11:10 am 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1887
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
Nice job Ray, that's pretty much the way I was thinking of handling the menu.

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 11:14 am 
Offline
User avatar

Joined: Wed Dec 16, 2009 2:32 am
Posts: 152
Location: Wairoa, Hawkes Bay. New Zealand.
Weather Station: La Crosse WS1081
Operating System: Windows XP, XP Pro & Win 7
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
Image


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 12:31 pm 
Offline

Joined: Mon Aug 10, 2009 10:16 pm
Posts: 1698
Location: World...
Weather Station: No weather station
Operating System: No operating system
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.

Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 12:50 pm 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1887
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
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 !


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 1:39 pm 
Offline

Joined: Mon Aug 10, 2009 10:16 pm
Posts: 1698
Location: World...
Weather Station: No weather station
Operating System: No operating system
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:
$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:
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:
$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
???


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 4:52 pm 
Offline

Joined: Sun May 10, 2009 8:52 pm
Posts: 508
Location: Springfield, IL
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Hi ray Looks good is there a way the view the source of your code
thanks beau


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 6:26 pm 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1887
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
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 !


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Tue Aug 23, 2011 10:33 pm 
Offline

Joined: Thu Jun 26, 2008 5:51 am
Posts: 98
Location: Slov.Konjice, Slovenia
Weather Station: Davis VP2 + Solar
Operating System: Win2k SP4@VIA EPIA800
Great stuff :clap:

_________________
Image


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Wed Aug 24, 2011 12:05 am 
Offline

Joined: Mon Aug 10, 2009 10:16 pm
Posts: 1698
Location: World...
Weather Station: No weather station
Operating System: No operating system
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:
$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:
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:


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Wed Aug 24, 2011 12:52 am 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 300
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
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.


Top
 Profile  
 
 Post subject: Re: PHP Web 'viewer' for Cumulus NOAA Style reports
PostPosted: Wed Aug 24, 2011 1:02 am 
Offline

Joined: Mon Aug 10, 2009 10:16 pm
Posts: 1698
Location: World...
Weather Station: No weather station
Operating System: No operating system
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.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 171 posts ]  Go to page 1, 2, 3, 4, 5 ... 12  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group