Okay,
They are definitely blocking our servers from accessing their xml. i decided to put my cURL idea to the test.
I changed:
Code: Select all
$xml = file_get_contents('http://currencysource.com/RSS/' . $this->config->get('config_currency') . '.xml');
and replaced it with:
Code: Select all
$data = curl_init('http://currencysource.com/RSS/' . $this->config->get('config_currency') . '.xml');
curl_setopt($data, CURLOPT_RETURNTRANSFER, true);
curl_setopt($data, CURLOPT_HEADER, 0);
$xml = curl_exec($data);
curl_close($data);
print $xml;
The out put from $xml is:
403 Access Forbidden/Abuse
Warning: array_combine() [function.array-combine]: Both parameters should have at least 1 element in /home/user/public_html/admin/model/localisation/currency.php on line 88
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/admin/model/localisation/currency.php:85) in /home/user/public_html/system/library/response.php on line 65
The expected result is not there, instead we are receiving a 403 Access error which then can not be broken down by the parser.
So I then added a useragent to the mix:
Code: Select all
$data = curl_init('http://currencysource.com/RSS/' . $this->config->get('config_currency') . '.xml');
// PRETEND TO BE FIREFOX
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
// CURL ADDITION - KEVIN DAVIDSON
curl_setopt($data, CURLOPT_USERAGENT, $useragent);
curl_setopt($data, CURLOPT_RETURNTRANSFER, true);
curl_setopt($data, CURLOPT_HEADER, 0);
$xml = curl_exec($data);
curl_close($data);
print $xml;
Voila, I can now see the xml data (edit - but it must have been more than 15 minutes since the last check - see below). Now my xml is shady, so I am not sure what the problem is with preg_match, because if you comment the print statement the last two original errors pop up.
Warning: array_combine() [function.array-combine]: Both parameters should have at least 1 element in /home/sinfulde/public_html/admin/model/localisation/currency.php on line 96
Warning: Cannot modify header information - headers already sent by (output started at /home/sinfulde/public_html/admin/model/localisation/currency.php:96) in /home/sinfulde/public_html/system/library/response.php on line 65
Now, I do have to agree with this post:
http://forum.opencart.com/viewtopic.php ... =15#p21469
They are preventing the page from being accessed too many times, see terms:
You may repeatedly pull this data during the hours specified above, but may not exceed once every 15 minutes (per individual currency). For example, you may download the GBP and AUD currencies every 15 minutes without problem, but you may not download the GBP currency itself every 2 minutes. If your computer/RSS reader is found to be pulling the data more frequently than 4 times per hour, we reserve the right to restrict your access to this information. CurrencySource.com reserves the right to move the feeds to alternate and/or multiple servers based on usage patterns (so the feed address may occasionally change). These terms of service are subject to change.
The solution is a cron job that runs every 15+ minutes.