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

PHP5+ light / dark forecast icon switcher

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

Moderator: daj

Post Reply
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

PHP5+ light / dark forecast icon switcher

Post by beteljuice »

Utility to switch between a set of light / dark forecast icons with a user set 'lead' time

PHP / html Level: beginner => Intermediate

IMPORTANT ***
Your server MUST be running PHP ver 5+ and if 'safe_mode' exists it should be "off".
If you are unsure of the above, unzip and run the following file in your webspace:
fdebug.zip
If it suggests that safe_mode is enabled, check your web space control panel / settings and see if you can turn it "off", else contact your support.
If they say "Oh no can't do that its insecure", tell them its caused so much problems that it is depreciated in ver 5.3 and doesn't even exist in ver 5.4 ! - give them this link: http://uk.php.net/manual/en/features.safe-mode.php

You will also need a 'library' of day / night icons with the correct naming format such as available from jacquesD - if you are unable to fufil the requirements the prog should just return the 'light' version icon.
The naming convention and <#webtag> alternative using <#isdaylight> is discussed HERE

OK so far :lol: - enough scary stuff

Functionality:
The code 'pretends' to be a graphic and will accept time and forecast via a <#webtag> (Template) type page OR realtime.txt if you are uploading that. If no (report) time is forwarded it will assume 'now'.
It artifically advances the next twilight event by user defined number of hours (default 4)
In order to do this correctly you must set your timezone, longitude and latitude.
This also means that it should work in any town in the world at any time of year (think light or dark varying between minutes and months !)
If a (report) time has been forwarded and is older than 7 hours (can be set by user) then N/A icon graphic will be displayed.

V1.0 - August 2012
  • Initial release
ficon.zip
View Code:

Unzip the file and using a txt editor like Notepad++ change the user setting to your locale and upload to your web space - double-check you have the correct paths for your icons and (if used) realtime.txt (don't forget to upload icons if you haven't done so already ;) )

Usage:
minimal html coding for Template using <#webtag>s

Code: Select all

<!-- prefered, using report timestamp -->
   <img src="ficon.php?fno=<#forecastnumber>&event=<#date format="yyyy'-'mm'-'dd'*'hh:nn">" />

<!-- using 'now' timestamp -->  
   <img src="ficon.php?fno=<#forecastnumber>" />  
minimal html coding if using realtime.txt

Code: Select all

   <img src="ficon.php" /> 
I haven't been able to test this using <#webtag>s - I expect a lot of posts :shock: :lol: :lol:
You do not have the required permissions to view the files attached to this post.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
krmidas
Posts: 215
Joined: Sat 03 Jul 2010 9:03 pm
Weather Station: Davis Vantage Pro 2
Operating System: Windows 10
Location: Lake Zurich, IL; USA
Contact:

Re: PHP5+ light / dark forecast icon switcher

Post by krmidas »

On my website, all of my forecast icons are numbered with three parameters: <#lowtempalarm>_<#isdaylight>_<#forecast>.png. The <#lowtempalarm> tag will allow me to replace raindrop icons with snowflake icons.

I put in an enhancement request so I can replace <#lowtempalarm> with a proposed new tag: <#isfreezing>.

Other than doing lots of duplication of forecast icons, it's worked quite well...

-Tom
Tom Keramidas, Lake Zurich, IL, USA
Image
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: PHP5+ light / dark forecast icon switcher

Post by steve »

krmidas wrote:I put in an enhancement request so I can replace <#lowtempalarm> with a proposed new tag: <#isfreezing>.
Aha! I knew that I had lost a small change that I did last Wednesday night due to my hard disk crash on Thursday morning (my backup takes place at around midday each day) but I couldn't remember what it was, and you've now reminded me. I'll put it back in for next build.
Steve
User avatar
krmidas
Posts: 215
Joined: Sat 03 Jul 2010 9:03 pm
Weather Station: Davis Vantage Pro 2
Operating System: Windows 10
Location: Lake Zurich, IL; USA
Contact:

Re: PHP5+ light / dark forecast icon switcher

Post by krmidas »

Ha! When you posted the zip file yesterday that contained the enhancement to the Davis Transmitter Status tags, I quietly looked to see if, by chance, <#isfreezing> delivered a value. I was afraid of nagging!

Thanks, Steve!
Tom Keramidas, Lake Zurich, IL, USA
Image
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: PHP5+ light / dark forecast icon switcher

Post by gemini06720 »

beteljuice wrote:...tell them its caused so much problems that it is depreciated in ver 5.3 and doesn't even exist in ver 5.4 !
beteljuice, I learned something new from you ... I have heard that a car could depreciate rapidly (as in quickly loosing its original value) ... but I had never heard nor read that a PHP feature could 'depreciate'... :mrgreen:

Not to question (nor criticise) you ideas behind the code, but why make it so ... how should I put it ... complexe? :|

Could a few of the Cumulus produced web tags not been used to produce similar results?

But, but, there is something missing in the code ... the detection of the seasons ... so the length of the days can be adjusted accordingly... :D
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: PHP5+ light / dark forecast icon switcher

Post by beteljuice »

gemini06720 wrote: Could a few of the Cumulus produced web tags not been used to produce similar results?
No .... there are no astronomical tags for a future (after midnight) event, so there is nothing to make a comparisson against. To some degree the same thing happens with the php function but I can cycle through to find the 'next' event.
But, but, there is something missing in the code ... the detection of the seasons ... so the length of the days can be adjusted accordingly... :D
:?: I don't understand, (especially if taking a 'global' view). For any location at any time, the hours of 'light' and 'dark' are known to within a few minutes given the limitations of the approximating formula and local atmospheric conditions. Not only that, it auto adjusts for any local DST.
Image
......................Imagine, what you will KNOW tomorrow !
Post Reply