cloudy cloudy

Author Topic: Web Page full of Errors  (Read 710 times)

0 Members and 1 Guest are viewing this topic.

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 27,601
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Chrome 69.0.3497.100
Re: Web Page full of Errors
« Reply #15 on: October 07, 2018, 11:49:22 PM »
Gotta go now but I'll figure that out before new year  :lol:               

I really think the version of php changed, this issue would only arise with later versions.

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 27,601
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Chrome 69.0.3497.100
Re: Web Page full of Errors
« Reply #16 on: October 08, 2018, 01:09:23 AM »
Use the code from Ken's template settings.php, it uses gmdate which defaults to GMT so it doesn't depend on the time zone setting.

Code: [Select]
$SITE['copyr'] = '© ' . gmdate("Y",time()) . ', Your Weather Website';

Offline saratogaWX

  • Global Moderator
  • Posts: 5,822
  • Ken True
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
  • OS/Browser:
  • Win NT 10.0
  • Firefox 62.0
    • Saratoga Weather
Re: Web Page full of Errors
« Reply #17 on: October 08, 2018, 02:08:48 AM »
Change the line in Settings.php from

$SITE['copyr']         = '© ' . date("Y",time()) . ', www.deputydawgwx.com';

to

$SITE['copyr']         = '© ' . gmdate("Y",time()) . ', www.deputydawgwx.com';

to eliminate the warning.  The timezone is not set until later in Settings.php, but gmdate() is good to use anywhere.
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline R_o_B

  • Posts: 215
  • Maple Bay, British Columbia, Canada
  • OS/Browser:
  • Win NT 10.0
  • Firefox 52.0
    • Tzouhalem-Maple Bay Weather
Re: Web Page full of Errors
« Reply #18 on: October 08, 2018, 02:05:13 PM »
Just curious...  :?

Why not move the setting of the timezone [ie: 'date_default_timezone_set()'] up into the configuration file (before any of the date-related functions are used) rather than relying on the 'gmdate()' function as a 'bandage' solutions...  :roll:

More likely, in a (near) future version of PHP, the 'gmdate()' function will be displaying the same warning situation that the 'date()' function is now displaying...  :-k
R_o_B
---
eMail: weather@tzweather.org

Offline wvdkuil

  • Wim van der Kuil
  • Posts: 803
  • Leuven Belgium CEST
  • OS/Browser:
  • Mac OS X 10.13.6
  • Chrome 69.0.3497.100
    • My PWS at Leuven Belgium Europe
Re: Web Page full of Errors
« Reply #19 on: October 08, 2018, 02:14:07 PM »
Just curious...  :?

Why not move the setting of the timezone [ie: 'date_default_timezone_set()'] up into the configuration file (before any of the date-related functions are used) rather than relying on the 'gmdate()' function as a 'bandage' solutions...  :roll:

More likely, in a (near) future version of PHP, the 'gmdate()' function will be displaying the same warning situation that the 'date()' function is now displaying...  :-k
gmdate will never display a warning as, per definition, all times in PHP are UTC. So gmdate is always correct everywhere with any server, regardless of the server time-zone.
The only drawback is the few hours every new-year that the year in the copyright notice is off for the timezone difference. Somewhere there will be  a webserver to early displaying next year.  11 or 12 hours before the real new year.   
Someone will notice that and post a message here on the forum  :D
Wim
Leuven-Template&Scripts https://support.leuven-template.eu/
My PWS at home https://weer.sluispark.be/
And at my daughters house https://www.weerstation-herent.be/

Offline saratogaWX

  • Global Moderator
  • Posts: 5,822
  • Ken True
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
  • OS/Browser:
  • Win NT 10.0
  • Firefox 62.0
    • Saratoga Weather
Re: Web Page full of Errors
« Reply #20 on: October 08, 2018, 04:31:54 PM »
Wim's correct -- gmdate() will always work irrespective of date_default_timezone_set() being done or not.  He's also correct about the year-change display will be early for some/late for others :)

Ray.. to answer your question about "Why not move the setting of the timezone [ie: 'date_default_timezone_set()'] up into the configuration file..."

The Settings.php in the Saratoga template is 'supposed' to have just settings in the top part (for the website owner to adjust as needed) followed by code to act on those settings at the bottom.  The only exception to that was the copyright date automatically done as part of a setting.  The gmdate() change makes it work without having to embed a date_default_timezone_set earlier in the page.  That keeps configuration:execution placement in the file as it's been since the templates were released.
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 27,601
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Chrome 69.0.3497.100
Re: Web Page full of Errors
« Reply #21 on: October 08, 2018, 04:38:52 PM »
I think it's fine as it is, but as far as I can find it's only used in footer.php so settings.php could just define the website name and then footer.php could use a regular date expression. 

Offline saratogaWX

  • Global Moderator
  • Posts: 5,822
  • Ken True
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
  • OS/Browser:
  • Win NT 10.0
  • Firefox 62.0
    • Saratoga Weather
Re: Web Page full of Errors
« Reply #22 on: October 08, 2018, 07:18:49 PM »
In hindsight, you're correct Niko.  I'd done the templates originally to have the year (via the gmdate()) be part of the copyright info in Settings.php  so folks could elect to have/not have a copyright by just changing one setting.  It is only used in footer.php.

I don't tend to update the master Settings.php since it would be included in updates (via the updates.php) and people hate to redo all their customizations for that file.
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

 

cumulus