New reliable currency rate provider, EXCHANGE-RATES.ORG added as default. @notrinos.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 17 Dec 2018 22:14:19 +0000 (23:14 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 17 Dec 2018 22:14:19 +0000 (23:14 +0100)
config.default.php
gl/includes/db/gl_db_rates.inc

index ab77a57bf5198464ad1011cfe20e1c0239e3df89..461a1be7ea33113de8a690ace7f33f6314316b88 100644 (file)
@@ -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;
 
 /*
index 5578cb331de24dad556a8218fed5a0b6ac42b5c9..2702c6599a7ffdfd4af848c534d4c2895b66d376 100644 (file)
@@ -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, '<span id="ctl00_M_lblToAmount">', '<');
+    }  
        return $val;
 }  /* end function get_extern_rate */