Page 1 of 1
Error from currency.php
Posted: Tue Jun 16, 2009 4:13 am
by CodeBits
I don't think this is a problem with OpenCart, but all three of the sites I have running are returning this error from admin/home link
Code: Select all
Warning: file_get_contents(http://currencysource.com/RSS/USD.xml) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Access Forbidden/Abuse in /home/www/opencart.nwisg.net/admin/model/localisation/currency.php on line 76
Warning: array_combine() [function.array-combine]: Both parameters should have at least 1 element in /home/www/opencart.nwisg.net/admin/model/localisation/currency.php on line 80
Warning: Cannot modify header information - headers already sent by (output started at /home/www/opencart.nwisg.net/admin/model/localisation/currency.php:76) in /home/www/opencart.nwisg.net/system/library/response.php on line 65
Line 76 link to
http://currencysource.com/RSS/ is returning;
Directory Listing Denied
This Virtual Directory does not allow contents to be listed.
Now I shut off auto currency update and still have the error when clicking on the Home link from the breadcrum or dropdown menu.
Any Ideas?
Appears others are having similar problems
http://forum.opencart.com/viewtopic.php?f=20&t=4424
Re: Error from currency.php
Posted: Tue Jun 16, 2009 4:40 am
by Daniel
ask your host to allow fopen for external sites.
Re: Error from currency.php
Posted: Tue Jun 16, 2009 5:30 am
by CodeBits
Daniel these sites have been running for sometime now, in fact two of them I have been working on all day until just before this post of errors and nothing was wrong. I'm going to check with my server admin now to see if they shut down fopen for external sites, but I can't imagine why unless there is an abuse problem.
Re: Error from currency.php
Posted: Tue Jun 16, 2009 6:32 am
by CodeBits
Response from my server admin:
Hello,
Thank you for contacting our Technical Support Department.
No changes have been made on the server setup. The possible reasons for that problems could be recent update of the site script, change of the account settings (php version, php settings at php.ini) or a hacker attack that as modified some parts of the site. Please verify if everything with the files and the setup is correct.
If there is anything on our end that we could be of help with, just let us know.
I guess I'll check for script problems but...
Neither of these sites had any changes made to them from the point they were working correctly
Re: Error from currency.php
Posted: Tue Jun 16, 2009 6:34 am
by Daniel
ok,
the next version is using a different url. I think i can releqse it this week.
Re: Error from currency.php
Posted: Tue Jun 16, 2009 9:22 am
by CodeBits
Rather than try and search this out I did a complete new install on my demo site... Really wired, same errors.
The url the script tries to return
http://currencysource.com/RSS/USD.xml works.
Well I hope the new version solves the problem. This is just to strange as these sites have been running just fine for weeks.
Thanks for your attention to this problem.
Re: Error from currency.php
Posted: Tue Jun 16, 2009 9:28 am
by Daniel
I think they blocked php from parsing the information.
Re: Error from currency.php
Posted: Tue Jun 16, 2009 10:06 am
by CodeBits
Didn't think about that... bummer!
Lots of sites are gona be broken now.
Well we in you capable hands now Daniel...
Re: Error from currency.php
Posted: Wed Jun 17, 2009 9:55 pm
by andychoi
Open curency.php
comment line 73 to 91.,
basically, disable the ADAVNACE auto update exchange rate fucntion.
check the code and pay attention to the position of /* */
public function updateCurrencies() {
/*
$query = $this->db->query("SELECT * FROM currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified > '" . date(strtotime('-1 day')) . "'");
if ($query->num_rows) {
$xml = file_get_contents('
http://currencysource.com/RSS/' . $this->config->get('config_currency') . '.xml');
preg_match_all('/([A-Z]{3}) \((.*)\)/', $xml, $match);
$rate = array_combine($match[1], $match[2]);
foreach ($query->rows as $result) {
if (isset($rate[$result['code']])) {
$this->db->query("UPDATE currency SET value = '" . (float)$rate[$result['code']] . "', date_modified = NOW() WHERE currency_id = '" . (int)$result['currency_id'] . "'");
}
}
}
$this->cache->delete('currency');
*/
}
Re: Error from currency.php
Posted: Wed Jun 17, 2009 11:43 pm
by CodeBits
Piece of cake... Thanks for the tip!
In this thread
http://forum.opencart.com/viewtopic.php?f=20&t=4424 explains a problem with empty dollar values being sent.
And my Cart will add up but where it says total in the Checkout says 0.00 and when it transfers to paypal Site still says 0.00 you have to add the cost which it should already of added up, any idea why please.
I haven't experienced this as I'm just starting to build a store and don't have pay systems in place yet, but Will this resolve his or her problem?
Re: Error from currency.php
Posted: Tue Jun 30, 2009 10:16 am
by kdmp
Hey Dan,
Another post about this issue, eh?
The error message I am receiving by PHP provides this: failed to open stream:
HTTP request failed! HTTP/1.1 403 Access Forbidden/Abuse.
I would assume that opencart is being blocked. Now, why is opencart checking it each time the admin page is loaded? Would it not be better to create a entry in the database so that it can be logged that it was checked on the day? Or even limit it to checking it via a cronjob a certain amount of times a day?
My two cents...maybe a penny...maybe nothing..but hey.
Re: Error from currency.php
Posted: Tue Jun 30, 2009 11:14 am
by kdmp
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.
Re: Error from currency.php
Posted: Fri Nov 26, 2010 2:42 pm
by saima122
thanks...