From d3984ba646e017c6fd301e3e90d8ce0c7b584a1d Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Mon, 17 Dec 2018 23:14:19 +0100 Subject: [PATCH 1/1] New reliable currency rate provider, EXCHANGE-RATES.ORG added as default. @notrinos. --- config.default.php | 2 +- gl/includes/db/gl_db_rates.inc | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config.default.php b/config.default.php index ab77a57b..461a1be7 100644 --- a/config.default.php +++ b/config.default.php @@ -178,7 +178,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ Choose Exchange Rate Provider Default is ECB for backwards compatibility */ - $xr_providers = array("ECB", "YAHOO", "GOOGLE", "BLOOMBERG"); + $xr_providers = array("EXCHANGE-RATES.ORG", "ECB", "YAHOO", "GOOGLE", "BLOOMBERG"); $dflt_xr_provider = 0; /* diff --git a/gl/includes/db/gl_db_rates.inc b/gl/includes/db/gl_db_rates.inc index 5578cb33..2702c659 100644 --- a/gl/includes/db/gl_db_rates.inc +++ b/gl/includes/db/gl_db_rates.inc @@ -160,6 +160,13 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date) $proto = 'https://'; $contents=file_get_contents($proto.$site.$filename); } + elseif ($provider == 'EXCHANGE-RATES.ORG') + { + $filename = "/converter/{$curr_b}/{$curr_a}/1"; + $site = "exchange-rates.org"; + $proto = 'https://'; + $contents=file_get_contents($proto.$site.$filename); + } if (empty($contents)) { if (function_exists('curl_init')) { // first check with curl as we can set short timeout; @@ -230,6 +237,10 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date) { $val = getInnerStr($contents, ',"price":', ',"'); } + elseif ($provider == 'EXCHANGE-RATES.ORG') + { + $val = getInnerStr($contents, '', '<'); + } return $val; } /* end function get_extern_rate */ -- 2.30.2