WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: Mark / Ohio on August 08, 2017, 11:32:40 PM

Title: NOAA Climate Reports
Post by: Mark / Ohio on August 08, 2017, 11:32:40 PM
One of my loyal website viewers reported to me today that my June report was actually the same as my May report.  Turns out it also did the same for 2016.  Years before that are ok though.  I can bring up the correct report in WeatherLink but somehow the May report got loaded and filed as June the last two years.

Thoughts?

Click on June for both 2017 and 2016 and you'll see what I mean.

http://fairfieldcountyweather.com/NOAAarchive.php?yr=2017&mo=06

Actually your report for June 2017 is also showing the May report instead as well Ken but your 2016 report is OK.

http://saratoga-weather.org/scripts-NOAAtxt.php?yr=2017&mo=06

 ;)  So it must not be something I done to break it for a change.  :lol:
Title: Re: NOAA Climate Reports
Post by: saratogaWX on August 09, 2017, 12:38:21 AM
Oooh.. I'm embarrassed to have not caught that on my own site!  It looks like I was running some old code that didn't change the timezone properly, so it did the copy of NOAAPRMO.TXT early (before the month ended) instead of later (8 hrs after the month starts, and same for the yearly copy).

It started in April on my site (when I moved to a new VPS), so Apr, May, Jun, Jul were all incorrect (each containing the prior month).  Now it's all fixed (I hope).. that's the problem with debugging something that happens once per month or year.

What I changed in the script version was
Code: [Select]
putenv("TZ=$ourTZ");
to
Code: [Select]
if (!function_exists('date_default_timezone_set')) {

if (! ini_get('safe_mode') ) {
   putenv("TZ=$ourTZ");  // set our timezone for 'as of' date on file
}
  } else {
   date_default_timezone_set($ourTZ);
 }
so the timezone would be correctly set.  It was only with WeatherLink that this was important, as the script copies NOAAPRMO.TXT (and NOAAPRYR.TXT) to be the prior month (and year) NOAA reports.. for VWS or Cumulus, the files are named and handled by the weather software.

Thanks for spotting the issue(s) Mark!
Title: Re: NOAA Climate Reports
Post by: Mark / Ohio on August 10, 2017, 12:27:09 AM
As always thanks for such a quick fix Ken!   :grin:

I made the script changes and uploaded the correct pages for the prior months.
Title: Re: NOAA Climate Reports
Post by: spweather on August 10, 2017, 12:05:28 PM
Hi,

In what file are these changes applied?

I'm confused when to use/include include-NOAA-reports.php vs NOAA-reports-test.php

Thanks,
Dennis
Title: Re: NOAA Climate Reports
Post by: saratogaWX on August 10, 2017, 12:12:10 PM
That fix was for the standalone version of the script (NOAA-reports-test.php) -- the one in the Saratoga template (include-NOAA-reports.php) already had the fix :)
Title: Re: NOAA Climate Reports
Post by: spweather on August 10, 2017, 12:19:48 PM
Thanks for the clarification Ken.

Dennis
Title: Re: NOAA Climate Reports
Post by: Otis on August 10, 2017, 12:51:17 PM
Yes thanks for the clarification Ken, appreciate it  :-)