I wonder if someone can spare a few lines of code to alter admin/includes/functions/localization.php so that exchange rates are taken from timegenie's xml file rather than ecb's.
I've added this to init_general_funcs.php
PHP Code:
define('CURRENCY_SERVER_PRIMARY', 'timegenie');
and have this at the top of localization.php
PHP Code:
function quote_timegenie_currency($currencyCode = '', $base = DEFAULT_CURRENCY)
{
$requested = $currencyCode;
$url = 'http://rss.timegenie.com/forex.xml';
$data = '';
// check via file() ... may fail if php file Wrapper disabled.
$XMLContent = @file($url);
if (! is_object($XMLContent) && function_exists('curl_init')) {
// check via CURL instead.
$XMLContent = doCurlCurrencyRequest('POST', $url, $data);
$XMLContent = explode("\n", $XMLContent);
}
$currencyArray = array();
$rate = 1;
$line = '';
// $currencyCode = '';
$currencyArray['EUR'] = 1;
foreach ($XMLContent as $line) {
if (preg_match("/currency='([[:alpha:]]+)'/", $line, $currencyCode)) {
if (preg_match("/rate='([[:graph:]]+)'/", $line, $rate)) {
$currencyArray[$currencyCode[1]] = (float)$rate[1];
}
}
}
if ($requested == $base) {
$rate = 1;
} else {
$rate = (string)((float)$currencyArray[$requested] / $currencyArray[DEFAULT_CURRENCY]);
}
return $rate;
}
timegenie's xml format is
Code:
<credit>
<!--
In order to use this data feed from timegenie.com, you have to display the following text, or something similar, clearly visible on your web page. The text should be a link to www.timegenie.com
-->
<!--
Please read more about our conditions and guidelines at http://rss.timegenie.com/free_xml_csv_feeds
-->
<text>Courtesy of Time Genie</text>
<url>http://www.timegenie.com/</url>
<title>foreign exchange rates courtesy of Time Genie</title>
</credit>
<data>
<code>BSD</code>
<description>Bahamas Dollar</description>
<rate>1.3176</rate>
</data>
whereas the existing ecb's format was
Code:
<Cube currency="USD" rate="1.3160"/>
I'm unsure as to how to make the necessary edits, although this has prompted me to start learning more about php.
Bookmarks