Topic: FA2.4.2 error getting exchange rate from Google

If you set $dflt_xr_provider = 2 to get exchange from Google system will show following errors:


Undefined variable: site_ip in file: C:\xampp\htdocs\fa242\gl\includes\db\gl_db_rates.inc at line 178
C:\xampp\htdocs\fa242\gl\includes\db\gl_db_rates.inc:125:    get_extern_rate('EUR','GOOGLE','10/25/2017')
C:\xampp\htdocs\fa242\gl\manage\exchange_rates.php:139:    retrieve_exrate('EUR','10/25/2017')
C:\xampp\htdocs\fa242\gl\manage\exchange_rates.php:218:    display_rate_edit()
number_format() expects parameter 1 to be double, string given in file: C:\xampp\htdocs\fa242\includes\current_user.inc at line 316
C:\xampp\htdocs\fa242\includes\current_user.inc:316:    number_format('','INF','.',',')
C:\xampp\htdocs\fa242\includes\current_user.inc:391:    number_format2('','max')
C:\xampp\htdocs\fa242\gl\manage\exchange_rates.php:139:    maxprec_format('')
C:\xampp\htdocs\fa242\gl\manage\exchange_rates.php:218:    display_rate_edit()

Fixes:

Line 178 of gl_db_rates.inc should be changed to if(isset($site_ip) $site = $site_ip;

Line 152 should be $site = "finance.google.com";

Phuong

Re: FA2.4.2 error getting exchange rate from Google

The first one has been done. However the last one remains.

Will have a look.

Joe

Re: FA2.4.2 error getting exchange rate from Google

Fixed today. Repo updated.

/Joe

Re: FA2.4.2 error getting exchange rate from Google

# nslookup finance.google.com

Non-authoritative answer:
Name:    www3.l.google.com
Address:  172.217.26.206
Aliases:  finance.google.com

# nslookup 172.217.26.206

Name:    maa03s23-in-f206.1e100.net
Address:  172.217.26.206

The IP address keeps changing since it is part of a set of ranges allotted to Google.

FA 2.3 users too can port it if they use GOOGLE as their exchange rate service provider with suitable changes in IP if necessary only if it keeps failing them with the errors listed in the first post here. It stands backported in my repo's FAMods for FA2.3.x.

Re: FA2.4.2 error getting exchange rate from Google

If it helps I'm getting the same errors for GOOGLE, YAHOO & BLOOMBERG:-
number_format() expects parameter 1 to be double, string given in file: .../includes/current_user.inc at line 316
.../includes/current_user.inc:316:     number_format('','INF','.',',')
.../includes/current_user.inc:391:     number_format2('','max')
.../gl/manage/exchange_rates.php:139:     maxprec_format('')
.../gl/manage/exchange_rates.php:218:     display_rate_edit()

But for ECB no errors but no exchange rate.

Servers currently located in Chicago

Re: FA2.4.2 error getting exchange rate from Google

We are aware of this error. It is fixed but not yet committed. This is a problem in newer php versions.

We are about to ship the next minor, that will be php 7 compatible.

In the meantime you can fix this in file /includes/current_user.inc, in function number_format2 line 310

...
if ($number == '')
    $number = 0;
if ($decimals === 'max') 
...

/Joe

Re: FA2.4.2 error getting exchange rate from Google

ok, thanks Joe.

Just checked PHP Version     5.6.32

Re: FA2.4.2 error getting exchange rate from Google

I guess php 5.6.32 is the last php version before php 7, right?

We have discovered other issues with the 5.6.X versions, that we are trying to fix too.

/Joe

Re: FA2.4.2 error getting exchange rate from Google

Ah, understand now, thank you.

Re: FA2.4.2 error getting exchange rate from Google

Is this now resolved?

I'm still getting same problem in 2.4.3

Re: FA2.4.2 error getting exchange rate from Google

Not yet.....

@joe: isn't it due?

Re: FA2.4.2 error getting exchange rate from Google

The fix was committed on Nov 9th. I hope it works.

/Joe

Re: FA2.4.2 error getting exchange rate from Google

Since it was among the construct/destruct changes it was not obvious. Thanks for the reference Joe.

Re: FA2.4.2 error getting exchange rate from Google

@joe probably a silly question, but what php version do I need for this to work? currently using 5.6.32, brief testing suggests its not working

Re: FA2.4.2 error getting exchange rate from Google

Well, I hope it works on all php versions.

Joe

Re: FA2.4.2 error getting exchange rate from Google

@poncho1234: hope you are using the FA 2.4.3+ bleeding edge code and not just the release.

Re: FA2.4.2 error getting exchange rate from Google

@apmuthu -

I'm using 2.43 + these extras from Release 2.4.3

apmuthu said...

Re: Release 2.4.3

Post Release FA 2.4.3+ fixes attached herein.

FA24_post_release_fixes_2017-12-09.zip 279.6 kb

That post was edited today? Have you changed something?

I'll create another clean install and test properly tomorrow.

Re: FA2.4.2 error getting exchange rate from Google

These incremental changes are to assist those who installed from a release. Just overwrite the corresponding files harmlessly with these files and you have "upgraded".

The CHANGELOG.txt file in it will provide all the necessary info on what has changed.

If you download from my repo, you will get the list of changes separately that have not been accepted yet by the devs. The files in the FA24Mods folder can be used to overwrite their counterparts in the core before install.

19 (edited by poncho1234 12/10/2017 09:12:51 pm)

Re: FA2.4.2 error getting exchange rate from Google

So, new install.
Currency decimal places set to 10
default theme
default currency COP
Servers in USA and i'm in...well you know where I am.

Just in case your dyslexic and cannot make head or tail of my beautifully formatted table below you can view a screenshot here ;-)

I'm very puzzled by the inconsistency of the results, google & Bloomberg get it right with some, but not with others?????

    Fault                       
ECB    None                       
Yahoo except euro

number_format() expects parameter 1 to be double, string given in file: /includes/current_user.inc at line 318

                       
GOOGLE None                       
BLOOMBERG euro and USD only

A non well formed numeric value encountered in file: /includes/current_user.inc at line 318

                       
                                                   
     CA Dollars    Euro                    Pounds    US Dollars    Chilean Peso    Mexican Peso    Peruvian Sol
ECB     Blank           1.1230000001    Blank    Blank    Blank            Blank             Blank

Yahoo Blank           1.1230000001    Blank     Blank     Blank             Blank              Blank
         + Above fault                           + Above fault+ Above fault+ Above fault+ Above fault+ Above fault

GOOGLE
     2500.0000000000    3333.3333333333 3333.3333333333 3333.3333333333 4.5024763620 156.2500000000    909.0909090909


BLOOMBERG   
        Blank             3.                     Blank         3.              4.5928              158.9162              930.6326
                      + Above Fault                      + Above Fault   
                           
MXN    1 Mexican Peso equals                       
    159.31     Colombian Peso        0.0062770699           
                           
PEN    1 Peruvian Sol equals                       
    935.48     Colombian Peso        0.0010689699           
                           
USD    1 US Dollar equals                       
    3016.02     Colombian Peso        0.0003315628           
                           
CLP    1 Chilean Peso equals                       
    4.61     Colombian Peso        0.2169197397           
                           
EUR    1 Euro equals                       
    3548.5     Colombian Peso        0.0002818092           
                           
CAD    1 Canadian Dollar equals                       
    2347.55     Colombian Peso        0.0004259760           
                           
GBP    1 British Pound equals                       
    4037.24     Colombian Peso        0.0002476940

Post's attachments

ULP9LsC.png 75.5 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: FA2.4.2 error getting exchange rate from Google

Try to replace line 318 of /includes/current_user.inc:

    $num = number_format($number, $dec, $dsep, $tsep);

with

    $num = number_format(floatval(trim($number)), $dec, $dsep, $tsep);

PHP's loose typing has been trampled upon in later versions like 7.0+ and hence type casting may be needed.
This may happen when some whitespace creeps into $number.

Re: FA2.4.2 error getting exchange rate from Google

No faults this time, but hardly any changes in results:-

    CA Dollars    Euro    Pounds    US Dollars    Chilean Peso    Mexican Peso    Peruvian Sol
ECB    Blank    Blank    Blank    Blank    Blank    Blank    Blank
Yahoo    Blank    Blank    Blank    Blank    Blank    Blank    Blank
GOOGLE    2,500    3333.3333333333    3333.3333333333    3333.3333333333    4.4903457566    158.7301587302    909.0909090909
BLOOMBERG    Blank    Blank    Blank    3    4.5964    158.8449    930.6075

22 (edited by poncho1234 12/11/2017 05:41:53 pm)

Re: FA2.4.2 error getting exchange rate from Google

For google and bb only:-

For exchange rates where an expected value is less than 1000, it works perfectly.

The problem is for exchange rates where an expected value is greater than 1000

Is there code which creates a 1000 separator? If so then removing this temporally will prove it?

I presume its $tsep

Re: FA2.4.2 error getting exchange rate from Google

Also we need to check if locale specific separators will have their say as well.

Re: FA2.4.2 error getting exchange rate from Google

I think just getting a number will be a result! ;-)

Re: FA2.4.2 error getting exchange rate from Google

YAHOO has blocked all access to FA's means of exchange rate acquisition.
Checkout:
http://download.finance.yahoo.com/d/quotes.csv?s=USDIDR=X&f=sl1d1t1ba&e=.csv
The widget js that does the job is at:
https://widget-yahoo.ofx.com/resources/1500309750700/js/app.js
The new page to look at is:
https://widget-yahoo.ofx.com/
and this sports the separator with locale as well.

ECB is still available with no separators:
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

Google is also still available with no separators:
http://finance.google.com/finance/converter?a=1&from=OMR&to=IDR

Bloomberg is available for select currency sets with a separator:
https://www.bloomberg.com/quote/USDIDR:CUR

Post's attachments

Yahoo_XCHG_Blocked.png 11.6 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.