Adapting to google's error when getting exchange rates. Fixed.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 26 Nov 2017 23:09:15 +0000 (00:09 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 26 Nov 2017 23:09:15 +0000 (00:09 +0100)
gl/includes/db/gl_db_rates.inc

index fc1060234cbfd758af3627154bdcc6e689701ac2..8ba9e23c6bf9c173a0660de736c03f71b5d499b0 100644 (file)
@@ -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+<span\sclass=(.*)>([\d|.]+)\s+{$curr_a}\s*</span>%s";
+            $contents = url_get_contents("http://".$site.$filename);
+            if (preg_match($regexp, $contents, $matches))  {
+                $val = $matches[3];
+                $val = str_replace(',', '', $val);
+            }
+        }
     }    
        elseif ($provider == 'BLOOMBERG')
        {