Author Topic: updated WU-History-inc.php for wxwuhistory.php on Saratoga template sites  (Read 5975 times)

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Jim McMurray of Juneau County Weather has updated his WU-History script to handle the recent changes in WeatherUnderground data. I've done some minor changes to his V3.3 script (4-Mar-2016) for the add-on wxwuhistory.php page.

The only script that changed is (for the Saratoga template with wxwuhistory installed) is the WU-History-inc.php

Download the updated script here or
Download the package for new installs here

Thanks to Jim (and Wim) for the update that restores functionality to this useful add-on page.

Best regards,
Ken 
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 Forever

  • Senior Contributor
  • ****
  • Posts: 211
I noticed my WU History page had stopped working correctly and found this new code but I'm having problems getting it to work. If I make all the code changes the page will not load.


I fount the following code to be the problem for me. Do you have any idea what could be wrong?
Code: [Select]
[/// $socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);
$socketConnection = fsockopen('ssl://'.$domain, 443, $errno, $errstr, $numberOfSeconds);code]

http://www.weathercat.net/wxwuhistory.php
« Last Edit: May 22, 2016, 12:34:22 PM by Forever »

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
I noticed my WU History page had stopped working correctly and found this new code but I'm having problems getting it to work. If I make all the code changes the page will not load.


I fount the following code to be the problem for me. Do you have any idea what could be wrong?
Code: [Select]
[/// $socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);
$socketConnection = fsockopen('ssl://'.$domain, 443, $errno, $errstr, $numberOfSeconds);code]

http://www.weathercat.net/wxwuhistory.php
As debug is switched off, it is difficult to pinpoint the error. There is a fatal error but which one is only guessing.
Please change line 1 of WU-History-inc.php from
Code: [Select]
<?phpto
Code: [Select]
<?php  ini_set('display_errors''On');  error_reporting(E_ALL);By changing that line, all errors will be displayed and maybe this gives us a clue what is happening.

Wim


Offline Forever

  • Senior Contributor
  • ****
  • Posts: 211
Thank for the reply Wim.

I did as you asked but don't see an error displayed.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Thank for the reply Wim.

I did as you asked but don't see an error displayed.
The only error I got with a dozen tries was:
PHP parse error: syntax error, unexpected '$domain' (T-VARABLE) in C:\inetpub\weathercat\WU-History-inc.php on line 1408
It is important as that line 1408 is in the changed code and that it is the same line you are referring to
and  it is also important that you are using Windows as a website-server.
I did not test the script in a Windows environment yet.

Maybe you could add the debug line just before the   include 'WU-History-inc.php' in wxwuhistory.php
It is now something like:
Code: [Select]
<?php include_once("WU-History-inc.php"); ?>change it to
Code: [Select]
<?php ini_set('display_errors''On');  error_reporting(E_ALL);
include_once(
"WU-History-inc.php"); ?>
It is a long shot, but we need an error message about what is happening.

The problem is that this script is working in Saratoga- and Leuven-templates at hundreds of locations without problems.
But I have no list of windows servers using it so I can not compare your site  to other windows-sites.

And the addition in the latest version needs an ssl connection. I do not know how to check that on windows.
Probably we have to add some debug code just before line 1408 with the fsockopen to check the used variables first.

Wim

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
This is maybe a clue: http://php.net/manual/en/openssl.installation.php


And at line 1402 just before the error we are looking for, the error reporting is switched off.
It reads now
Code: [Select]
error_reporting(0);please set it to comment
 
Code: [Select]
// error_reporting(0);
Wim
« Last Edit: May 22, 2016, 02:07:20 PM by wvdkuil »

Offline SpringHillWeather

  • Weather Hobbyist
  • Forecaster
  • *****
  • Posts: 533
  • Spring Hill, Florida
    • Spring Hill
Thank you Ken for posting this, I missed it and yes my site had the problem until I updated the file.

I noticed I had the same problem on the Leuven-Template so I also missed that there was fix too.  I applied the new upgraded files and it looks good now, thank you Wim.





Saratoga
HomeWeatherStation
Meteotemplate
Homebrew
Ambient 1001 | ObserverIP | Meteobridge | MeteoPlug

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 211
I made the additional edits and I'm still not getting an error.

I looked at the openssl setup and I think it's setup correctly.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
I made the additional edits and I'm still not getting an error.

I looked at the openssl setup and I think it's setup correctly.
I do not see a modification in the script. At this moment 2016-05-22 21:22 CEST these are the lines 1399-1403 in WU-History-inc.php
Code: [Select]
function getcsvWithoutHanging($url)   {

$numberOfSeconds=4;   
error_reporting(0);
$url = str_replace("http://","",$url);
line 1401 should be set to comment or better modified as in the following code snippet
Code: [Select]
function getcsvWithoutHanging($url)   {
 
$numberOfSeconds=4;   
error_reporting(E_ALL);
$url = str_replace("http://","",$url);
Please try again, we need an error message.

I will make a small test script with just the fsockopen tomorrow morning, my time and post it.
That is easier with testing.
Wim

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 211
I made the change in an old file.  #-o

Making the change in the correct file gives lots of errors.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
I made the change in an old file.  #-o

Making the change in the correct file gives lots of errors.
Yes, I saw that.
Code: [Select]
Warning: fsockopen(): SSL operation failed with code 1.
OpenSSL Error messages: error:14090086:
SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in C:\inetpub\weathercat\WU-History-inc.php on line 1408
The error is caused by  an invalid SSL verify.  All other errors are the result of the first one as no data can be loaded.

I have to find the correct header to omit SSL checking with fsockopen and windows.
Will be tomorrow my time, i think, sorry.

Wim

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 211
No rush, thanks for helping. :)

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
No rush, thanks for helping. :)
I adapted the code, but FIRST:
I did not find any code to suppress the CSS peer verify when using the fsockopen which raises the error .
All forums mention that this should not happen as it is caused by a badly configured webserver, missing the needed root certificates.

if it is your own web-server, please Google and install the certificates as more companies are only supplying information using https.

===
I adapted the script to use CURL as it has an option: CURLOPT_SSL_VERIFYPEER which can be set to false.

1. Make a copy of your current  WU-History-inc.php
2. unzip the attachment and upload the updates version of WU-History-inc.php

Success, Wim

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 211
Thanks, everything seems to be working. :)

http://www.weathercat.net/wxwuhistory.php