Page 25 of 26

Re: Cumulus PHP-GD Banner

Posted: Sun 07 Jul 2019 2:00 pm
by Mark14
To some extent, because I see a banner. It's probably not a wrong path issue.
However, on my main webpage I normally see updated data every minute: http://mark014.beep.pl

The banner is not updated on a regular basis. At the moment, I see measurements from 15 minutes ago: http://mark014.beep.pl/pogoda.php. Strange thing. I did not have such a situation so far.
It looks like the banner refreshed only every hour...

Re: Cumulus PHP-GD Banner

Posted: Sun 07 Jul 2019 9:51 pm
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:

Re: Cumulus PHP-GD Banner

Posted: Mon 08 Jul 2019 3:51 pm
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?

Re: Cumulus PHP-GD Banner

Posted: Mon 08 Jul 2019 9:20 pm
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 ....

Re: Cumulus PHP-GD Banner

Posted: Tue 09 Jul 2019 12:49 pm
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>

Re: Cumulus PHP-GD Banner

Posted: Tue 09 Jul 2019 2:51 pm
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 ?

Re: Cumulus PHP-GD Banner

Posted: Sun 14 Jul 2019 11:49 am
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.

Re: Cumulus PHP-GD Banner

Posted: Thu 05 Dec 2019 10:16 pm
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!

Re: Cumulus PHP-GD Banner

Posted: Thu 05 Dec 2019 10:56 pm
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:

Re: Cumulus PHP-GD Banner

Posted: Thu 05 Dec 2019 11:00 pm
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 .....

Re: Cumulus PHP-GD Banner

Posted: Fri 06 Dec 2019 4:53 pm
by Mapantz
ha!

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

Thanks beteljuice. :)

Re: Cumulus PHP-GD Banner

Posted: Tue 07 Jan 2020 7:24 pm
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);

Re: Cumulus PHP-GD Banner

Posted: Tue 07 Jan 2020 10:51 pm
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

Re: Cumulus PHP-GD Banner

Posted: Wed 08 Jan 2020 10:19 am
by mcrossley
and your background image is in the same folder as the script?

Re: Cumulus PHP-GD Banner

Posted: Wed 08 Jan 2020 3:14 pm
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