Re: Currency Update (Automatic)
Quote:
Originally Posted by
Design75
Was used in version 4 and presumably earlier. As of version 5 it is no longer in the currency_update.php file.
That's what I figured. Do you have any insight to thie error I am getting emailed?
Quote:
/home2/redsauto/public_html/currency_update.php: line 1: ?php: No such file or directory
/home2/redsauto/public_html/currency_update.php: line 2: /0: Permission denied
/home2/redsauto/public_html/currency_update.php: line 3: access-logs: command not found
/home2/redsauto/public_html/currency_update.php: line 4: syntax error near unexpected token `('
/home2/redsauto/public_html/currency_update.php: line 4: ` * Originally by Richard Fink (masterblaster) based on Zen Cart manual currency update'
It looks like the cron job isn't recognizing that it is a php file.
Re: Currency Update (Automatic)
Quote:
Originally Posted by
vanhorn_s
That's what I figured. Do you have any insight to thie error I am getting emailed?
It looks like the cron job isn't recognizing that it is a php file.
Can you past the contents of your currency_update.php? I suspect you are missing some characters at the start of the file
Re: Currency Update (Automatic)
Quote:
Originally Posted by
Design75
Can you past the contents of your currency_update.php? I suspect you are missing some characters at the start of the file
Code:
<?php
/*
* Automatic Currency Update v5.0
* Originally by Richard Fink (masterblaster) based on Zen Cart manual currency update
* updated by Kuroi to include Zen Cart's currency uplift ratio
* further updated by Kuroi to use European Central Bank reference rates (adapted from ECB-supplied code)
* updated by Zen4All (design75) use Zen Cart standard coding
*
* Rework for PHP 5.3 compatibility (ereg and mysql_db_query functions deprecated in PHP 5.3.0)
* switched to using SimpleXML and mysqli instead.
* JeRo www.jero.co.nz 18/06/2010
*
* license: GNU Public License V2.0
*
*/
require_once('includes/application_top.php');
/*
* Get default currency.
*/
$defaulCurrency = $db->Execute("SELECT configuration_value
FROM " . TABLE_CONFIGURATION . "
WHERE configuration_key = 'DEFAULT_CURRENCY' LIMIT 1 ");
/*
* Get currency conversion ratio.
*/
$currencyUpliftRatio = $db->Execute("SELECT configuration_value
FROM " . TABLE_CONFIGURATION . "
WHERE configuration_key = 'CURRENCY_UPLIFT_RATIO' LIMIT 1 ");
/*
* Create new SimpleXML element from the Euro zone file
* If your PHP configuration does not have allow_url_fopen, you may need to
* write a script to pick it up using wget:
* wget -O eurofxref-daily.xml www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
* and then uncomment/comment these next two lines:
* $xml = new SimpleXMLElement(file_get_contents("eurofxref-daily.xml"));
*/
$xml = new SimpleXMLElement(file_get_contents("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"));
/*
* extract your preferred currency's exchange rate.
*/
$nzd = $xml->xpath("//*[@currency='" . $defaulCurrency->fields['configuration_value'] . "']");
$base = (float)$nzd[0]['rate'];
# If our default currency is the Euro, it won't be in the XML,
# so set the base exchange rate to 1
if ($defaulCurrency->fields['configuration_value'] == 'EUR') {
$base = (float)1;
}
/*
* Get array of currency data from the XML file.
*/
$currencies = $xml->xpath("//*[@currency]");
/*
* Iterate over array, pulling out currency code and rate.
* Convert into your preferred currency.
* Pump it into the database.
*/
foreach ($currencies as $curr) {
$cc = $curr[0]['currency'];
$rr = (float)$curr[0]['rate'] * $currencyUpliftRatio->fields['configuration_value'];
$new = $rr / $base;
/*
* But don't uplift your default currency!
*/
if ($cc != $defaulCurrency->fields['configuration_value']) {
$sql_data_array = array('value' => $new,
'last_updated' => 'now()',
'code' => $cc);
zen_db_perform(TABLE_CURRENCIES, $sql_data_array, 'update', "code = '" . $cc . "'");
}
}
/*
* Feed is based on the Euro, which is not included in the feed,
* therefore we need to update it manually,
* unless of course our preferred currency is the Euro
*/
$cc = 'EUR';
$rr = 1 / $base * CURRENCY_UPLIFT_RATIO;
if ($defaulCurrency->fields['configuration_value'] != $cc) {
$sql_data_array = array('value' => $rr,
'last_updated' => 'now()',
'code' => $cc);
zen_db_perform(TABLE_CURRENCIES, $sql_data_array, 'update', "code = '" . $cc . "'");
}
Re: Currency Update (Automatic)
The error YOU yourself postd:
Code:
/home2/redsauto/public_html/currency_update.php: line 1: ?php: No such file or directory
Seemingly indicates that line 1 is missing the very first character... the "<" before "?php".
You said you upgraded to V6 (my code) but you just posted code from V5.
I *think* what you did was copy all but the first character from my code.
Re: Currency Update (Automatic)
Quote:
Originally Posted by
s_mack
The error YOU yourself postd:
Code:
/home2/redsauto/public_html/currency_update.php: line 1: ?php: No such file or directory
Seemingly indicates that line 1 is missing the very first character... the "<" before "?php".
You said you upgraded to V6 (my code) but you just posted code from V5.
I *think* what you did was copy all but the first character from my code.
The v6 was a typo. I meant v5. I downloaded the latest one last week from here: https://www.zen-cart.com/downloads.php?do=file&id=286
I did not edit it, I only uploaded the file as I downloaded it. What I posted above, is the contents of that file.
Re: Currency Update (Automatic)
Should this work with Zencart v 1.5.6 and PHP v8.0?
I ran it through a PHP tester and got the following:
Warning: require_once(): open_basedir restriction in effect. File(includes/application_top.php) is not within the allowed path(s): (/var/tmp/) in /tmp/31yrgpkae1ktco5pkq/tester.php on line 17 Warning: require_once(includes/application_top.php): Failed to open stream: Operation not permitted in /tmp/31yrgpkae1ktco5pkq/tester.php on line 17 Fatal error: Uncaught Error: Failed opening required 'includes/application_top.php' (include_path='.:') in /tmp/31yrgpkae1ktco5pkq/tester.php:17 Stack trace: #0 {main} thrown in /tmp/31yrgpkae1ktco5pkq/tester.php on line 17
Re: Currency Update (Automatic)
Anyone have an updated version for 1.5.8 (1.5.8a)? or will this current version 5.0 work with it?
Re: Currency Update (Automatic)
As mentioned on the plugin page, this is now built-in:
Quote:
NOTE: In Zen Cart 1.5.5 and above, the admin/currency_cron.php facility can be used.