Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

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 drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Cumulus PHP-GD Banner

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

Moderator: daj

User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Banner

Post by beteljuice »

Are you sure you don't have TWO realtime.txt ?

http://mark014.beep.pl/realtime.txt is updating correctly, but as you say the banner seems to have a different 'period'.
Why is 'realtime' an extrafile - I don't remember that, but I could be wrong :roll:
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 12689
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Cumulus PHP-GD Banner

Post by mcrossley »

beteljuice wrote: Sun 07 Jul 2019 9:51 pm Why is 'realtime' an extrafile - I don't remember that, but I could be wrong :roll:
Correct, Cumulus will upload at the realtime interval so long as you tick the option in settings, no need to add it as an extra file.

Unless you want to upload at longer than the reltime interval I guess?
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Banner

Post by beteljuice »

Unless you want to upload at longer than the reltime interval I guess?
That's why I wandering if there were two files in different places ....
Image
......................Imagine, what you will KNOW tomorrow !
Mapantz
Posts: 1774
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Mapantz »

I had a similar problem when I first started using the banner. It's possible you may have it too.

It turned out to be a caching problem and to solve it, I added this to my .htaccess file

Code: Select all

<Files banner.php>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</Files>
Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Banner

Post by beteljuice »

Thanks mapantz - haven't seen that one before.

Does that mean the rest of 'the site' has a cache value set somewhere by hosting admin ?
Image
......................Imagine, what you will KNOW tomorrow !
Mark14
Posts: 79
Joined: Thu 23 Aug 2012 8:53 pm
Weather Station: Ecowitt HP3501
Operating System: Windows 10
Location: Konin, Poland

Re: Cumulus PHP-GD Banner

Post by Mark14 »

mcrossley wrote: Mon 08 Jul 2019 3:51 pm Correct, Cumulus will upload at the realtime interval so long as you tick the extrafile in settings, no need to add it as an extra file.

Unless you want to upload at longer than the reltime interval I guess?
No I want to upload the realtime file every 50 secs.

Maybe I put the extrafile when I had previous problems with paths. But I deleted the option and now it works. Thank you for your help.
Image
Mapantz
Posts: 1774
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Mapantz »

I was wondering if there were any clever folks (there's lots) that could help me with this banner?

I've been using it for years now, and something I would like to do is to have two separate background images, one for day and one for night.

I have done the same thing to the banner on my website, but it was quite easy to implement. However, the banner originally made by Kevin is a little bit more complicated than what I am used to. :lol:

I have been doing quite a bit of work to tidy up my site and in particular, reduce the amount of data I upload. I don't upload many pages any more, instead I have created a single php file with every CMX webtag that I use on my site. It has reduced my uploading by 80%.

The reason I mention that is, It has my sunrise and sunset times processed, so it might be easier to implement?

$sunrise = "07:53";
$sunset = "16:05";

etc

Many thanks!
Image
Mapantz
Posts: 1774
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Mapantz »

OK - Looks like I actually managed to do it by myself..

Code: Select all

include 'mytags.php';
date_default_timezone_set('Europe/London');
$current = time();
$daytime = strtotime('$sunrise');
$nighttime = strtotime('$sunset');
if($daytime <= $current && $current < $nighttime) {
	$baseimg = imagecreatefromjpeg("images/day_banner.jpg");
} else {
	$baseimg = imagecreatefromjpeg("images/night_banner.jpg");
}
I added that in and tested by changing $sunrise and $sunset to actual times.

I'm sure that small piece of code is about as bad as you can get, but it worked. :oops:
Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Banner

Post by beteljuice »

cross posted !!!

Like many others your banner version does not look for the later fields that have been added to realtime.txt.

in your case:
41 (field # 40) 36.0 10-minute high gust <#wgust>
42 (field # 41) 10.3 Heat index <#heatindex>
43 (field # 42) 10.5 Humidex <#humidex>
44 (field # 43) 13 UV Index <#UV>
45 (field # 44) 0.2 evapotranspiration today <#ET>
46 (field # 45) 14 solar radiation W/m2 <#SolarRad>
47 (field # 46) 260 10-minute average wind bearing (degrees) <#avgbearing>
48 (field # 47) 2.3 rainfall last hour <#rhour>
49 (field # 48) 3 The number of the current (Zambretti) forecast as per Strings.ini. <#forecastnumber>
50 (field # 49) 1 Flag to indicate that the location of the station is currently in daylight (1 = yes, 0 = No) <#isdaylight>
51 (field # 50) 1 If the station has lost contact with its remote sensors "Fine Offset only", a Flag number is given (1 = Yes, 0 = No) <#SensorContactLost>
52 (field # 51) NNW Average wind direction <#wdir>
53 (field # 52) 2040 Cloud base <#cloudbasevalue>
54 (field # 53) ft Cloud base units <#cloudbaseunit>
55 (field # 54) 12.3 Apparent temperature <#apptemp>
56 (field # 55) 11.1 Sunshine hours so far today <#SunshineHours>
57 (field # 56) 420.1 Current theoretical max solar radiation <#CurrentSolarMax>
58 (field # 57) 1 Is it sunny? 1 if the sun is shining, otherwise 0 (above or below threshold) <#IsSunny>

You can follow the existing logic and add these to $SITE['cvalues'] = array( ... OR you could simply refer to the array $DATA[#field number]

So your base image ....

Code: Select all

if($DATA[49] == 1) {
// OR if(ret_value("named field") == 1) {
    $baseimg = imagecreatefromjpeg("images/clouds_banner.jpg"); // daytime image
 } else {
     $baseimg = imagecreatefromjpeg("images/clouds__night_banner.jpg"); //night-time image
}
You may need the same logic to alter text colours .....
Last edited by beteljuice on Sun 12 Jan 2020 10:25 pm, edited 1 time in total.
Image
......................Imagine, what you will KNOW tomorrow !
Mapantz
Posts: 1774
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Mapantz »

ha!

I didn't realise that there were fields missing in the first place. :oops:

Thanks beteljuice. :)
Image
forestedge
Posts: 104
Joined: Sun 29 Jul 2012 11:46 am
Weather Station: Davis Vantage Pro2 Plus DFARS
Operating System: Windows 10 64 bit
Location: Ashurst Bridge, Hampshire UK
Contact:

Re: Cumulus PHP-GD Banner

Post by forestedge »

Returning to this again, I have been unable to change the white background on my banner to an image. :?: Current banner is www.tottonweather.co.uk/banner.php
The Image .NFWbanner is in both jpg and png format.
Any help appreciated.

Code: Select all

// Output the header to let the browser know we are
// sending a graphic file format
header("Content-type: image/" . $SITE['format'] );
$im = @imagecreate($SITE['image_width'], $SITE['image_height'])
    or die("Cannot Initialize new GD image stream");
    
// Set colors we want to use...
// first background is a white background
$background_color   = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black              = imagecolorallocate($im, 0x00, 0x00, 0x00);
$green              = imagecolorallocate($im, 0x00, 0x80, 0x00);
$blue               = imagecolorallocate($im, 0x00, 0x00, 0xff);
$red                = imagecolorallocate($im, 0xff, 0x00, 0x00);

$baseimg = imagecreatefromjpeg(".NFWbanner.jpg");
imagecopy($im,$baseimg,0,0,0,0,$SITE['image_width'], $SITE['image_height']);imagedestroy($baseimg);// Make a Border Around the box
ImageRectangle($im, 0, 0, $SITE['image_width'] -1 , 
    $SITE['image_height'] -1, $black);
User avatar
PaulMy
Posts: 3775
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Cumulus PHP-GD Banner

Post by PaulMy »

Code: Select all

$baseimg = imagecreatefromjpeg(".NFWbanner.jpg");
Could it be that the image file name has a leading dot (.)?

Your posted code looks very similar to mine other than the jpg file name

Code: Select all

$baseimg = imagecreatefromjpeg("komokaimage1.jpg");
Enjoy,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
User avatar
mcrossley
Posts: 12689
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Cumulus PHP-GD Banner

Post by mcrossley »

and your background image is in the same folder as the script?
User avatar
PaulMy
Posts: 3775
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Cumulus PHP-GD Banner

Post by PaulMy »

http://www.tottonweather.co.uk/.NFWbanner.jpg does not exist but http://www.tottonweather.co.uk/NFWbanner.jpg does http://www.tottonweather.co.uk/NFWbanner.jpg
so change your
$baseimg = imagecreatefromjpeg(".NFWbanner.jpg");
by removing the leading dot (.)

Enjoy,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
forestedge
Posts: 104
Joined: Sun 29 Jul 2012 11:46 am
Weather Station: Davis Vantage Pro2 Plus DFARS
Operating System: Windows 10 64 bit
Location: Ashurst Bridge, Hampshire UK
Contact:

Re: Cumulus PHP-GD Banner

Post by forestedge »

I finally managed to get most background images to work if they had a JPG suffix when jpg or png did not! The size of the image seemed irrelevant.

http://www.tottonweather.co.uk/banner.php
Could it be that the image file name has a leading dot (.)?
Removing the dot also helped thanks.
Post Reply