From: Joe Hunt Date: Sun, 26 Nov 2017 23:09:15 +0000 (+0100) Subject: Adapting to google's error when getting exchange rates. Fixed. X-Git-Tag: v2.4.4~51 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=ff67198fa8d011c788e8fb6d6d726a1712b6597e Adapting to google's error when getting exchange rates. Fixed. --- diff --git a/gl/includes/db/gl_db_rates.inc b/gl/includes/db/gl_db_rates.inc index fc106023..8ba9e23c 100644 --- a/gl/includes/db/gl_db_rates.inc +++ b/gl/includes/db/gl_db_rates.inc @@ -222,6 +222,15 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date) if ($val != 0) $val = 1 / $val; } + if (empty($val)) { + $filename = "/finance/converter?a=1&from={$curr_b}&to={$curr_a}"; + $regexp = "%([\d|.]+)\s+{$curr_b}\s+=\s+([\d|.]+)\s+{$curr_a}\s*%s"; + $contents = url_get_contents("http://".$site.$filename); + if (preg_match($regexp, $contents, $matches)) { + $val = $matches[3]; + $val = str_replace(',', '', $val); + } + } } elseif ($provider == 'BLOOMBERG') {