Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.6.10 (build 3086) - 24 June 2020 (please see important announcement regarding releases since 3.5.0)
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of the NOAA report and Snow Index drop-down menus to 2030)

See the Wiki to download the software or click on the Downloads link in the Forum Banner.

BT's Sager PHP Script V2 - For Cumulus

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

Moderator: daj

User avatar
ConligWX
Posts: 759
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis VPro2 Plus +DFARS
Operating System: MeteoBridge Nano SD
Location: Bangor, NI
Contact:

Re: BT's Sager PHP Script V2 - For Cumulus

Post by ConligWX »

OK i have it working, not the way you or BT have shown however.

bt-sager.php and sager_test.php worked when called directly.
bt-sager-wc.php showed the 24-48 forecast - though with "document.write" in front of it.

now using the code:

Code: Select all

<a href = "./bt-sager.php" style = "text-decoration:none;" target = "_blank"><b><font color = "#FF0000" face = "Tahoma" size = "4"><script src = "./bt-sager-wc.php"></script></font></b></a></p>
refuses to show a thing on my index.htm page. just totally blank.

I then thought why not use

Code: Select all

<?php include('./bt-sager-wc.php');?>
I then reformated the last line like so:

Code: Select all

//echo "document.write ('$sf');";
echo "$sf";
I then had an issue with the php code being commented out by the server!!!. <!-- --> a quick google search shows I needed to add the following into my .htaccess file

Code: Select all

AddType application/x-httpd-php .html .htm
it now works as intended!

https://www.conligwx.org/cmx/index.htm
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus + DFARS - Meteobrige Nano SD + CumulusMX + Saratoga Templates

User avatar
beteljuice
Posts: 2950
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

You do realise that:
.htaccess file

Code: Select all

AddType application/x-httpd-php .html .htm
Means that all htm / html files from that directory down can execute php without having to have .php extension ?

Something seems to have changed, because when I tried your bt-sager-wc.php before it did NOT give the forecast in any 'style' but it DID give what should have been the (html) commented out debug stuff as page content ???

<!-- bt-sager-wc loaded -->
<!-- server running PHP ver 7.4.7 -->
<!-- cURL is installed OK -->
<!-- Loading bt-sager-cu > success -->
<!-- Looking for language info -->
<!-- Trying to load bt-sager-en.php -->
<!-- Language file loaded .... -->
<!-- getting METAR for EGAC -->
<!-- METAR OK -->

All very odd.
Image
......................Imagine, what you will KNOW tomorrow !

Mapantz
Posts: 748
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: BT's Sager PHP Script V2 - For Cumulus

Post by Mapantz »

Try this in .htaccess

Code: Select all

<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73___lsphp .php .php7 .phtml
</IfModule>
Image

User avatar
HansR
Posts: 1090
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: Davis Vantage Pro 2+
Operating System: Raspbian GNU/Linux 10 (Buster)
Location: Wagenborgen (NL)
Contact:

Re: BT's Sager PHP Script V2 - For Cumulus

Post by HansR »

Tbh: if users must start editing their htaccess to accomplish things, I think that is not OK and it should not be propagated by any support but to some specialised users. Htaccess is a sensitive tool and as far as I can see, most users are not fit to meddle with it creating moore problems than they solve.
But OK, that's only IMHO.
https://meteo-wagenborgen.nl / Cumulus 3.6.8 (build: 3084)
Davis Vantage Pro 2+ / Raspberry Pi 3 Model B Plus Rev 1.3
Raspbian Linux 10 (buster) / 4.19.118-v7+ armv7l
Mono JIT compiler version 6.8.0.123 (tarball Tue May 12 15:31:43 UTC 2020)

Mapantz
Posts: 748
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: BT's Sager PHP Script V2 - For Cumulus

Post by Mapantz »

HansR wrote:
Sun 28 Jun 2020 5:48 am
Tbh: if users must start editing their htaccess to accomplish things, I think that is not OK and it should not be propagated by any support but to some specialised users. Htaccess is a sensitive tool and as far as I can see, most users are not fit to meddle with it creating moore problems than they solve.
But OK, that's only IMHO.
It's a universal way of getting PHP to work in .htm and .html pages. It's either that, or you change your files to .php

Whether you think it's ok or not, is irrelevant.
Image

User avatar
HansR
Posts: 1090
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: Davis Vantage Pro 2+
Operating System: Raspbian GNU/Linux 10 (Buster)
Location: Wagenborgen (NL)
Contact:

Re: BT's Sager PHP Script V2 - For Cumulus

Post by HansR »

Mapantz wrote:
Sun 28 Jun 2020 10:11 am
Whether you think it's ok or not, is irrelevant.
:lol: I am fully aware of that, but it does not stop me from expressing me. You never know...
https://meteo-wagenborgen.nl / Cumulus 3.6.8 (build: 3084)
Davis Vantage Pro 2+ / Raspberry Pi 3 Model B Plus Rev 1.3
Raspbian Linux 10 (buster) / 4.19.118-v7+ armv7l
Mono JIT compiler version 6.8.0.123 (tarball Tue May 12 15:31:43 UTC 2020)

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

Re: BT's Sager PHP Script V2 - For Cumulus

Post by mcrossley »

Though of course rather than globally processing all htm(l) files as beteljuice pointed out, it may better to just enable it for the one file - index.htm in this case?

User avatar
beteljuice
Posts: 2950
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

I just remembered ...
Simon wrote:... with PHP 7.4.7 ...
I wonder if the strange response to the script call (mime-type) is something 'new' to watch out for :(
Image
......................Imagine, what you will KNOW tomorrow !

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

Re: BT's Sager PHP Script V2 - For Cumulus

Post by mcrossley »

beteljuice wrote:
Mon 29 Jun 2020 12:34 am
I just remembered ...
Simon wrote:... with PHP 7.4.7 ...
I wonder if the strange response to the script call (mime-type) is something 'new' to watch out for :(
If you have strict MIME type enforcement, yes - though I think it is a web server thing rather than PHP?
I would try changing the <script> HTML to load a .js file (thus keeping the JS MIME type correct)...

Code: Select all

<script src = "./bt-sager-wc.js"></script>
Then add a translation in the .htaccess from the js to php file - which would then be passed to the PHP processor without any requirement for further fiddling in the .htaccess file.

Code: Select all

RewriteEngine On
RewriteRule bt-sager-wc.js$    bt-sager-wc.php [NC,L]

Post Reply