Permalink
Browse files

Use cURL Server Recommendation in localizations

By-pass all Server Errors if not found allowed function
Language file modified for it

Signed-off-by: Gergely <t-gely@freemail.hu>
  • Loading branch information...
1 parent 32f92a6 commit 86c25ec5f556a90122fcf27aeac94d75b0b91b27 @tgely committed Sep 8, 2010
@@ -1,23 +1,31 @@
<?php
/*
- $Id$
-
- osCommerce, Open Source E-Commerce Solutions
- http://www.oscommerce.com
-
- Copyright (c) 2003 osCommerce
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License v2 (1991)
as published by the Free Software Foundation.
*/
function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {
- $page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code . '&format=CSV&dest=Get+Table&sel_list=' . $base);
+ if (function_exists('curl_init')) {
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, 'http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code . '&format=CSV&dest=Get+Table&sel_list=' . $base);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_TRANSFERTEXT, 1);
+ $page = curl_exec($curl);
+ curl_close($curl);
+ } elseif (function_exists('allow_url_fopen')) {
+ $page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code . '&format=CSV&dest=Get+Table&sel_list=' . $base);
+ } else {
+ $page = "";
+ }
$match = array();
- preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', implode('', $page), $match);
+ preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', $page, $match);
if (sizeof($match) > 0) {
return $match[3];
@@ -27,11 +35,23 @@ function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {
}
function quote_xe_currency($to, $from = DEFAULT_CURRENCY) {
- $page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);
+ if (function_exists('curl_init')) {
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, 'http://www.xe.com/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_TRANSFERTEXT, 1);
+ $page = curl_exec($curl);
+ curl_close($curl);
+ } elseif (function_exists('allow_url_fopen')) {
+ $page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);
+ } else {
+ $page = "";
+ }
$match = array();
- preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', implode('', $page), $match);
+ preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', $page, $match);
if (sizeof($match) > 0) {
return $match[1];
@@ -45,4 +45,4 @@
ms_success_currency_updated = Success: The currency exchange rate for %s (%s) has been successfully updated.
-ms_error_invalid_currency = Error: The currency exchange rate for %s (%s) was not updated. Please verify the currency code and try again.
+ms_error_invalid_currency = Error: The currency exchange rate for %s (%s) was not updated. Please verify the currency code or server recommended functions and try again.

0 comments on commit 86c25ec

Please sign in to comment.