No exchange rate working in FA now. Fixed ECB, CCA and EXCHANGE-RATES.ORG. @notrinos.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 20 Dec 2018 12:01:02 +0000 (13:01 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 20 Dec 2018 12:01:02 +0000 (13:01 +0100)
config.default.php
gl/includes/db/gl_db_rates.inc

index 461a1be7ea33113de8a690ace7f33f6314316b88..a1089866fefb298ba30f01d9b1a6b1e7ad811e4d 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("EXCHANGE-RATES.ORG", "ECB", "YAHOO", "GOOGLE", "BLOOMBERG");     
+       $xr_providers = array("ECB", "EXCHANGE-RATES.ORG", "CCA", "YAHOO", "GOOGLE", "BLOOMBERG");
        $dflt_xr_provider = 0;
 
 /*
index 2702c6599a7ffdfd4af848c534d4c2895b66d376..f067254c6433fe20dd93f5b5f2c4df44211b84bb 100644 (file)
@@ -137,11 +137,13 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
        $proto = 'http://';
        $curr_a = get_company_pref('curr_default');
        if ($provider == 'ECB')
-       {
-               $filename = "/stats/eurofxref/eurofxref-daily.xml";
-               $site = "www.ecb.europa.eu";
-               $site_ip="172.230.157.137";
-       }
+    {
+        $filename = "/stats/eurofxref/eurofxref-daily.xml";
+        $site = "www.ecb.europa.eu";
+        $proto = 'https://';
+        $site_ip="172.230.157.137";
+        $contents=file_get_contents($proto.$site.$filename);
+    }
        elseif ($provider == 'YAHOO')
        {
                $filename = "/d/quotes.csv?s={$curr_a}{$curr_b}=X&f=sl1d1t1ba&e=.csv"; // new URL's for YAHOO
@@ -167,6 +169,13 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
                $proto = 'https://';
                $contents=file_get_contents($proto.$site.$filename);
        }
+       elseif ($provider == 'CCA')
+       {
+               $filename = "/api/v6/convert?q={$curr_b}_{$curr_a}&compact=y&callback=sampleCallback";
+               $site = "free.currencyconverterapi.com";
+               $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;
@@ -240,7 +249,11 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
     elseif ($provider == 'EXCHANGE-RATES.ORG')
        {
                $val = getInnerStr($contents, '<span id="ctl00_M_lblToAmount">', '<');
-    }  
+    }
+    elseif ($provider == 'CCA')
+    {
+        $val = getInnerStr($contents, '"val":', '}');
+    }
        return $val;
 }  /* end function get_extern_rate */