Author Topic: Ajax-Dashboard or Gizmo problems?  (Read 512 times)

0 Members and 1 Guest are viewing this topic.

Offline rlee171

  • Contributor
  • ***
  • Posts: 124
Ajax-Dashboard or Gizmo problems?
« on: May 05, 2019, 10:45:02 PM »
I have two issues on my home page (one I posted a couple of days ago with no replies). That one is "day since last rain" displaying -2386 days and today the weather icon above the thermostat is obviously incorrect due to the day being Sunny just as the NWS forecast icon showed, not Moderate drizzle! it's now 9:45 pm and it has not changed to the usual night time icon. Both problems appear to be generated from the ajax-dashboard, however I have thus far been unable to figure out where the data there is populated from. I have spent two days reviewing multiple scripts and I am stumped on this one. I have added a couple attachments in this post. I surely don't mind digging around, but would appreciate a hand pointing me in the right direction, I have exhausted my limited brain power!  ](*,)

Thanks,

Ralph
hsnpar.org

Davis VP2 
Blitzortung Stations: 1387  1445  2315
Cumulus
GRLevel3

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9282
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Ajax-Dashboard or Gizmo problems?
« Reply #1 on: May 05, 2019, 11:48:57 PM »
I think the real problem is with your webserver, it thinks the current date is:

Sun, 21 Oct 2012 16:00:50 GMT

If you're running your own webserver, please synchronize your system to an NTP source like time.nist.gov

When the date is correct on your webserver, the issue about last rain (and funny readings on wxstatus.php ) should all clear up.

edit:  I see you're hosted on GoDaddy at p3nlhg358c1358.shr.prod.phx3.secureserver.net (50.63.71.1)
Call their Tech Support to address the server's date/time issue (not synchronized to NTP time).
« Last Edit: May 05, 2019, 11:52:08 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline rlee171

  • Contributor
  • ***
  • Posts: 124
Re: Ajax-Dashboard or Gizmo problems?
« Reply #2 on: May 06, 2019, 11:52:46 AM »
All those hours spent and there wasn't anything wrong here, the thought of server problems never crossed my mind. Thanks for pulling another non-programmer back up on out of the weeds (about time for my annual contribution). Ken, would I be presumptuous to ask how you noticed that so quickly? It would help in the future as to avoid such huge wastes of time. Also, if GoDaddy is not a preferred hosting site, any recommendations?

Regardless, thanks for your prompt reply!

Ralph
Davis VP2 
Blitzortung Stations: 1387  1445  2315
Cumulus
GRLevel3

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9282
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Ajax-Dashboard or Gizmo problems?
« Reply #3 on: May 06, 2019, 02:57:01 PM »
It's like they used to say "the problem is not with the station, it's with your tv set" :)

Finding the issue was easy using the developer tools in your browser (for Firefox, a control-shift-K will open them).  Reload the page with the developer tools enabled, and the Console view will show all the requests/XHR accesses.
Browse the one for the page and look at the Response headers.  Most servers provide both:

Date:  and
Last-modified:

with timestamps.  Both your Date and Last-modified headers were showing the 2012 dates (wayback machine???).

Now they're showing properly:

HTTP/1.1 200 OK
Date: Mon, 06 May 2019 18:51:23 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 5500
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Content-Type: text/html; charset=ISO-8859-1

It's missing the Last-modified header (no biggie), but the Date: header is there.

For your realtime.txt, it does include (correctly) a Last-modified: header too.

HTTP/1.1 200 OK
Date: Mon, 06 May 2019 18:55:06 GMT
Server: Apache
Last-Modified: Mon, 06 May 2019 18:54:43 GMT
ETag: "112-5883ca22725bb-gzip"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 183
Keep-Alive: timeout=5, max=97
Connection: Keep-Alive
Content-Type: text/plain

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline rlee171

  • Contributor
  • ***
  • Posts: 124
Re: Ajax-Dashboard or Gizmo problems?
« Reply #4 on: May 06, 2019, 10:14:20 PM »
Ken, thanks for the detailed replay!

Ralph
Davis VP2 
Blitzortung Stations: 1387  1445  2315
Cumulus
GRLevel3

Offline kc1fx

  • Member
  • *
  • Posts: 15
    • Local Weather
Re: Ajax-Dashboard or Gizmo problems?
« Reply #5 on: May 07, 2019, 09:11:26 AM »
I am having the same/similar issue.... Wind and rain show December. I have seen this several times.

URL: kc1fx-weather.info/index.php

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9282
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Ajax-Dashboard or Gizmo problems?
« Reply #6 on: May 07, 2019, 11:38:22 AM »
You're using WXSolution to drive your template.

In WXS-defs.php there is
Code: [Select]
$dayswithnorain  = intval((time()-strtotime($WX['LAST_DATE_RAINFALL']))/86400); // from last rainfall date // calculated value
$dayswithrain = $WX['NUM_DAYS_RAIN_MTH'];
to calculate the days with no rain/days with rain.  In your WXStags.php?sce=dump shows
Code: [Select]
$WX['NUM_DAYS_RAIN_MTH'] = '5';
$WX['LAST_DATE_RAINFALL'] = 'May 5, 2019';

in ajax-dashboard.php there is code
Code: [Select]
                    if (isset($dayswithrain) and $dayswithrain > 0) {
   print "$dayswithrain " ;
   print ($dayswithrain > 1)?
    langtransstr('rain days in'):
    langtransstr('rain day in');
   print " " . $monthname . ".";
                    if (isset($dayswithrain) and $dayswithrain > 0) {
   print "$dayswithrain " ;
   print ($dayswithrain > 1)?
    langtransstr('rain days in'):
    langtransstr('rain day in');
   print " " . $monthname . ".";

So the '5' is correct, it's the $monthname that appears incorrect.  Back in WXS-defs.php, that is set by
Code: [Select]
list($date_year,$date_month,$date_day,$time_hour,$time_minute,$monthname,$dayname)
  = WXS_setDateTimes($date,$time,$SITE['WDdateMDY']);
where
Code: [Select]
$time = $WX['CURTIME_HM'];
$date  = $SITE['WDdateMDY']?$WX['CURDATE_SLASH_MDY']:$WX['CURDATE_SLASH_DMY']; // calculated value
and in WXStags.php, those values for $WX vars are
Code: [Select]
$WX['CURTIME_HM'] = '11:05 AM';
$WX['CURDATE_SLASH_MDY'] = '05/07/2019';
$WX['CURDATE_SLASH_DMY'] = '07/05/2019';
and in Settings.php
Code: [Select]
$SITE['WDdateMDY'] = true; // for WD date format of month/day/year.  =false for day/month/year
so the $WX['CURDATE_SLASH_MDY'] should be used.

Doing a view-source on your index.php?debug=y shows
Code: [Select]
<!-- WXS_setDateTimes date='05/07/2019' time=11:20 AM' MDY=1 -->
<!-- WXSfixupTime in='11:20 AM' tfixed='AM' out='' -->
<!-- WXS_setDateTimes WXStime='2019-05-07 :00' assembled -->
<!-- WXS_setDateTimes WXStime='1969 12 31 19 00 December Wednesday' values set -->
so it looks like the WXSfixupTime routine in WXS-tags.php isn't correctly handling your time, so it looks like I have some additional debugging to do with the WXSfixupTime() function coding...  The same coding is used in other *-defs.php plugins.  Hmmm...  I'll let you know.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9282
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Ajax-Dashboard or Gizmo problems?
« Reply #7 on: May 07, 2019, 12:02:37 PM »
Ok.. replicated the problem in my test setup.

Edit WXS-defs.php and change
Code: [Select]
  $tfixed = preg_replace('/^(\S+)\s+(\S+)$/is',"$2",$intime);
to
Code: [Select]
  $tfixed = preg_replace('/^(\S+)\s+(\S+)$/is',"$1",$intime);
and that fixes it.  Sorry for the issue.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline kc1fx

  • Member
  • *
  • Posts: 15
    • Local Weather
Re: Ajax-Dashboard or Gizmo problems?
« Reply #8 on: May 07, 2019, 06:07:29 PM »
Thank you very much Ken. I've been using the scripts for a number of years now and wanted to give this new PHP a try. YES, I used WXSolution. It's nice and it gives a "Heathkit" look on my local monitor.

Thanks again,

Gary