Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

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

Legacy Cumulus 1 release 1.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

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Day / Night graphic keeping current

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

Moderator: daj

RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Day / Night graphic keeping current

Post by RayProudfoot »

Many of us have added the Day / Night graphic to our websites over the years. It's a great way of seeing how much daylight the site has.

It also includes a marker for the current time but I have to manually refresh my page on Windows to show the current situation. On iOS it's a real pain as no refresh works.

Here's the code. Any chance of adding an instruction to my .htaccess file to keep it current? Thanks. :)

<td rowspan="5"><img id="img_sun"
src="http://cheadlehulmeweather.co.uk/heavens.php"
width="115" height="115"
alt="Day/Night/Twilight" title="Day/Night/Twilight" style="text-align:center" border="1"/></td>
<td rowspan="5">
Cheers,
Ray, Cheshire.

Image
User avatar
saratogaWX
Posts: 1238
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Day / Night graphic keeping current

Post by saratogaWX »

The issue is caused by caching being enabled by your webserver for the .png image file created by heavens.php script.

For a simple test solution, try changing

src="http://cheadlehulmeweather.co.uk/heavens.php"

to

src="http://cheadlehulmeweather.co.uk/heavens.php?t=<?php echo time();?>"

to try and defeat the browser caching the image.

Otherwise, you'll need to change the cache configuration of the webserver for .png images to either set it to 1 hour or disable it.
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

@saratogaWX, many thanks. I’ve updated my template and it will be executed in a few minutes.

It may take a little while to judge if it’s fixed. If further work is required I’ll come back as I’m unfamiliar with changing cache settings. Fingers crossed it works.
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

I’ve checked on my iPad and Android phone as well as my windows laptop and it looks like your code has fixed it. :clap:

Many thanks! That has been bugging me for years! :D
Cheers,
Ray, Cheshire.

Image
alexm2192
Posts: 1
Joined: Mon 29 Jan 2024 1:17 pm
Weather Station: Davis Vantage Pro2
Operating System: Windows XP

Re: Day / Night graphic keeping current

Post by alexm2192 »

Unfortunately, there's no simple .htaccess tweak that can automatically refresh that external image source. The heavens.php script would need modifying to add metadata headers allowing the image to cache for only a few seconds.

However, a workaround for self-refreshing the image would be to wrap it in some JavaScript. For example:

Code: Select all

<script>
  setInterval(function() {
    document.getElementById('img_sun').src = 'http://cheadlehulmeweather.co.uk/heavens.php?rand=' + Math.random();
  }, 10000); 
</script>
This would append a random query string to "trick" the image into refreshing every 10 seconds.

Not as seamless as having the PHP script handle expires headers but could save needing manual refreshes. Let me know if you give that a try or have any other questions! A contract template is a pre-written document that provides a standard format and outline for creating a contract.Stepping into the trucking industry as an owner-operator comes with several decisions, one of the most significant being the choice of a comprehensive Owner Operator Lease Agreement template.
Last edited by alexm2192 on Tue 30 Jan 2024 4:23 pm, edited 1 time in total.
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

@alexm2192, it looks like you didn’t see Saratoga’s suggestion which has solved it without the need to edit .htaccess. :)
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

I've made a small change to my home page. I increased the size of the day / night graphic and it appeared okay.

But stupidly I uploaded the source code - sun_banner.php - replacing the original on the server without backing the original up first.

Now when I visit my homepage all I see is a placeholder, not the graphic.

I see the original name in the php is heavens and I haven't changed that. Just the name of the file.

If I type https://www.cheadlehulmeweather.co.uk/heavens.php into my browser it shows the graphic and the time appears correct.

But changing my home page code to point to heavens.php only shows the placeholder.

Could someone help please?
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

An update... I used Notepad++ to compare two php files. sun_button.php and sun_banner.php. The former shows when its address is entered into a browser. The latter doesn't.

I have eliminated all differences with the exception of the size. Surely that can be the reason sun_button with 75x75 shows and sun_banner with 75x150 doesn't. Later: Just chenged sun_banner.php to 75x75 and still it doesn't show.

Arrgghh!!! I'm sure this is related to dimensions but why?
Cheers,
Ray, Cheshire.

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

Re: Day / Night graphic keeping current

Post by Mapantz »

Download a back-up from your cpanel.
Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

Mapantz wrote: Mon 01 Jul 2024 12:54 pm Download a back-up from your cpanel.
I've looked in my cPanel and cannot see any option to restore files.
Cheers,
Ray, Cheshire.

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

Re: Day / Night graphic keeping current

Post by Mapantz »

It should be under "Jet backup"

There should be daily backups for 30 days (for your whole site) and single file downloads are available for those 30 days.
Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

I’ve downloaded the file but where does it reside? Looking at my files on the server there’s nothing shown as a download.

I’ve raised a ticket with my host.
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

I was shown how to download my backup and have restored the original sun_banner.php and IndexT.html.

Image is back but I still don’t know what the problem was.

@Mapantz, thanks for that useful tip. :D
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Day / Night graphic keeping current

Post by RayProudfoot »

Before the clocks went back my Day / Night graphic was fine. But since it now appears offset so local noon appears to be at 11:00, not 12:00.

I don't understand how this could happen. I've looked at another site with it and it's fine there. Here's the link...

https://www.dmjsystems.co.uk/weatherbos/heavens.php

I can't read the source php file unfortunately. Here's mine https://www.cheadlehulmeweather.co.uk/on my home page.

Any help appreciated.
Cheers,
Ray, Cheshire.

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

Re: Day / Night graphic keeping current

Post by Mapantz »

Opened both on my phone and they're identical Ray. Looks fine to me, so it might be a caching issue on the device you're using to look at it.
Image
Post Reply