Welcome to the new home of the Cumulus Support forum.

Latest Cumulus release v1.9.4 (build 1099) - 28 November 2014
Latest Cumulus MX release v3.0.0 build 3046 - 02 January 2019. See the Wiki 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

Moderator: daj

User avatar
beteljuice
Posts: 2537
Joined: Tue 09 Dec 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

Post by beteljuice » Sun 11 Mar 2012 12:19 am

I'm glad you see that as well, I'm fed up of people telling me I'm seeing things when I get funny characters on their sites (Including ordinary html) !

The unproven response is the wrong charset is applied to the format in which the file was written and / or saved in.

The report itself is created by Cumulus, Notepad++ says "ANSI as UTF-8"
Notepad++ reports your page as "ANSI as UTF-8", and is declared as UTF-8 in it's META data.

Interestingly, in my browser, your .txt reports show the black diamond, but not in notepad++, the .txt reports on my site do not show the black diamond in my browser :bash:

Time for an experiment :shock:

Using notepad I want you to modify NOAA-reports.php :?
MAKE A BACKUP OF IT FIRST !

Go down to about line 430 and change from this:

Code: Select all

 
 if($rpt){
 	echo "<pre>\n";
	echo preg_replace('|<|Uis','<',$rpt);
	echo "</pre>\n";
}
echo "</div> <!-- END noaa_rep_container -->\n";
To this:

Code: Select all

 
 if($rpt){
 
// NASTY work-around, the ONLY way I find black diamond question mark (or deg character)
	$checkIt = explode("(", $rpt);
	$dodgy = substr($checkIt[1],0 , 1);

// the ONLY way I can replace when black diamond (unconditionally) to &deg
	$rpt = str_replace($dodgy,'&deg;',$rpt);
// END nasty work around
 
 
	echo "<pre>\n";
	echo preg_replace('|<|Uis','<',$rpt);
	echo "</pre>\n";
}
echo "</div> <!-- END noaa_rep_container -->\n";
Caution: I can't find the real code for the black diamond anywhere :( This will replace ALL instances of the 'black diamond' with ° (degree symbol)

Edit: a couple of silly errors removed.

Upload the modified file to your site and let's see what happens :roll: (Edit: It works !)

If anyone has a definitive answer as to why this kind of problem occurs and how to prevent it in the first place .....
Last edited by beteljuice on Sun 11 Mar 2012 3:47 pm, edited 4 times in total.
Image
......................Imagine, what you will KNOW tomorrow !

User avatar
duke
Posts: 840
Joined: Sun 03 Jul 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

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

Post by duke » Sun 11 Mar 2012 5:43 am

Thanks for the quick reply. Unfortunately that did not resolve it.

The result of that was a one line page in XAMPP:
Parse error: syntax error, unexpected T_VAR in W:\htdocs\weather\NOAA-reports.php on line 434
and live:
Parse error: syntax error, unexpected T_VAR in /home/night239/public_html/weather/NOAA-reports.php on line 434
Duke
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

User avatar
beteljuice
Posts: 2537
Joined: Tue 09 Dec 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

Post by beteljuice » Sun 11 Mar 2012 6:01 am

Sorry - I got a bit of a JavaScript head on, the two var shouldn't be there.

Previous post edited - try that.
Image
......................Imagine, what you will KNOW tomorrow !

User avatar
duke
Posts: 840
Joined: Sun 03 Jul 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

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

Post by duke » Sun 11 Mar 2012 6:11 am

beteljuice wrote:Sorry - I got a bit of a JavaScript head on.
:lol:

How's it look for you? Nightingale NOAA

All good here. thank you :D

Duke
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

User avatar
mcrossley
Posts: 5315
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley » Sun 11 Mar 2012 9:30 am

I 'think' this may be due to the page construction.

Duke is using a XHTML page, and has included a header META tag to specify the character set encoding, but no xml tag. The standard says...
Historically, the character encoding of an HTML document is either specified by a web server via the charset parameter of the HTTP Content-Type header, or via a meta element in the document itself. In an XML document, the character encoding of the document is specified on the XML declaration (e.g., <?xml version="1.0" encoding="EUC-JP"?>). In order to portably present documents with specific character encodings, the best approach is to ensure that the web server provides the correct headers. If this is not possible, a document that wants to set its character encoding explicitly must include both the XML declaration an encoding declaration and a meta http-equiv statement (e.g., <meta http-equiv="Content-type" content="text/html; charset=EUC-JP" />). In XHTML-conforming user agents, the value of the encoding declaration of the XML declaration takes precedence.

Note: be aware that if a document must include the character encoding declaration in a meta http-equiv statement, that document may always be interpreted by HTTP servers and/or user agents as being of the internet media type defined in that statement. If a document is to be served as multiple media types, the HTTP server must be used to set the encoding of the document.
Dukes web server is not providing any character encoding information in the header.

Code: Select all

RESPONSE HEADERS
Connection:Keep-Alive
Content-Type:text/html
Date:Sun, 11 Mar 2012 09:07:28 GMT
Keep-Alive:timeout=2, max=100
Server:Apache
Transfer-Encoding:chunked
X-Powered-By:PHP/5.3.10
Note, no charset after 'text/html'. So I think this statement applies
If this is not possible [server providing encoding in the header], a document that wants to set its character encoding explicitly must include both the XML declaration an encoding declaration and a meta http-equiv statement
But Dukes page does not have an <xml> declaration.

It would be interesting to know if that fixed the problem without beteljuices workaround. These encoding issues keep popping up.

User avatar
beteljuice
Posts: 2537
Joined: Tue 09 Dec 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

Post by beteljuice » Sun 11 Mar 2012 1:06 pm

Thank you both - a (sort of) result :clap:

First post has been updated to include link to work-around.

@ Mark, I remember when text was easy (single type face / size and with bold / underline and only in 'English' :lol:
Image
......................Imagine, what you will KNOW tomorrow !

User avatar
duke
Posts: 840
Joined: Sun 03 Jul 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

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

Post by duke » Sun 11 Mar 2012 5:15 pm

Mark, I will willingly try what you suggest. But, being a novice, how exactly do I put the "XML" in?

Currently
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
Duke
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

User avatar
mcrossley
Posts: 5315
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley » Mon 12 Mar 2012 10:29 am

I'm no expert either, but I think the top of you page needs to look like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
...
The standard also says:
An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16 and no encoding was determined by a higher-level protocol. Here is an example of an XHTML document. In this example, the XML declaration is included.
Which would imply that UTF-8 is the default encoding anyway - but your server seems to be treating the page as text/html rather than application/xhtml+xml.
And there is a warning about this situation! :
Be aware that processing instructions are rendered on some user agents. Also, some user agents interpret the XML declaration to mean that the document is unrecognized XML rather than HTML, and therefore may not render the document as expected. For compatibility with these types of legacy browsers, you may want to avoid using processing instructions and XML declarations. Remember, however, that when the XML declaration is not included in a document, the document can only use the default character encodings UTF-8 or UTF-16.
Argh! It's all too complicated. :bash:

User avatar
duke
Posts: 840
Joined: Sun 03 Jul 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

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

Post by duke » Mon 12 Mar 2012 6:24 pm

mcrossley wrote: Argh! It's all too complicated. :bash:
Blimey you're right. I'll try this the weekend and let you know the results. Thanks Mark.

Duke
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

malkie
Posts: 65
Joined: Sun 02 Jan 2011 9:38 am
Weather Station: Watson W-8681
Operating System: XP SP3
Location: Stevenage, Herts, UK

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

Post by malkie » Sun 29 Apr 2012 11:01 am

Just starting to get into NOAA reports. Thanks very much to beteljuice for all the effort you have put in here. I'm actually starting to get some benefit from the php support my GoDaddy account is charging me for!

My NOAA-reports.php page is here: http://www.elmnet-weather.net/NOAA_reports.php

I prefer the Classic menu, just my preference. Not linked it from my main pages yet until I am happy with it.

My menu shows an indent at the start of line for 2011, I note that the example pages from beteljuice do the same, but some of the pages linked on the thread don't have this. I've poured over the script but can't make enough sense of it to know what's going on.

Any suggestions anyone?

Late News: Just discovered it's a Google Chrome issue, in IE9 the menu lines up nicely! DOH!
Malcolm
North Herts, UK
http://www.elmnet-weather.net
Cumulus 3 on Raspberry Pi 2, running on Raspbian, from a Davis Vantage Vue.

User avatar
beteljuice
Posts: 2537
Joined: Tue 09 Dec 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

Post by beteljuice » Sun 29 Apr 2012 1:25 pm

I prefer the Classic menu, just my preference.
You may change your mind when you have 10+ years of reports :lol:
Image
......................Imagine, what you will KNOW tomorrow !

malkie
Posts: 65
Joined: Sun 02 Jan 2011 9:38 am
Weather Station: Watson W-8681
Operating System: XP SP3
Location: Stevenage, Herts, UK

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

Post by malkie » Sun 29 Apr 2012 3:08 pm

beteljuice wrote:
I prefer the Classic menu, just my preference.
You may change your mind when you have 10+ years of reports :lol:
Too true, but I don't have that much data yet. I'll worry about it if my Fine Offset lasts that long!
Malcolm
North Herts, UK
http://www.elmnet-weather.net
Cumulus 3 on Raspberry Pi 2, running on Raspbian, from a Davis Vantage Vue.

Matt.j5b
Posts: 438
Joined: Mon 28 Nov 2011 2:13 am
Weather Station: Davis VP2 DFARS+La Crosse WS2306
Operating System: Windows 10 64 Bit
Location: Ferny Grove, Brisbane, Australia
Contact:

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

Post by Matt.j5b » Sun 29 Apr 2012 7:57 pm

Thanks Betejuice for your work here. I have no konwledge of php but I have managed to set up this very useful page. Thanks

The page is here: http://www.localweatherdata.0glo.com/NOAA-reports.php
Regards, Matt of Brisbane, Australia
Ferny Grove Weather
Cumulus MX testing

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

Update

Post by beteljuice » Sun 29 Apr 2012 10:59 pm

Update: http://sandaysoft.com/forum/viewtopic.p ... 194#p49194

V3.2 available

A Chrome user has highlighted a small piece of 'malformed' html when more than one year of reports is in the 'nav menu'. For Chrome users it results in a small indent in subsequent 'year' lines.

The offending o/p results in ....<br /></span>.....
but needs to be corrected to ...</span><br />.....

The beteljuice has corrected his pilot error :bash:
Image
......................Imagine, what you will KNOW tomorrow !

malkie
Posts: 65
Joined: Sun 02 Jan 2011 9:38 am
Weather Station: Watson W-8681
Operating System: XP SP3
Location: Stevenage, Herts, UK

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

Post by malkie » Mon 30 Apr 2012 9:19 pm

Excellent Work beteljuice, Chrome display now sorted.

PS, my weather station PC is slartibartfast!
Malcolm
North Herts, UK
http://www.elmnet-weather.net
Cumulus 3 on Raspberry Pi 2, running on Raspbian, from a Davis Vantage Vue.

Post Reply