Re: Currency Update (Automatic)
Hello Kuroi
I am trying to get this mod working on my site but I keep getting errors when I run the cron job.
I have a few websites on the same hosting package. Is it possible to get this to work with all the different website Knowing that they are all using Zen cart 1.38a?
At the moment I am trying to test the cron job on one website. but I keep getting an error in the cron job
Quote:
Warning: require_once(/ohiospeedshop/includes/configure.php) [function.require-once]: failed to open stream: No such file or directory in /home/coolcarp/public_html/currency_update_curled.php on line 20
Fatal error: require_once() [function.require]: Failed opening required '/ohiospeedshop/includes/configure.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/coolcarp/public_html/currency_update_curled.php on line 20
I have the file in the root of the public html ( /public_html/currency_update_curled.php/) The website I am trying to install this mod on is an addon domain so the link to the site is /public_html/ohiospeedshop/
This is the code I am using on my site
Code:
<?php
/**
* Automatic Currency Update v3.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)
*
* @package currencies
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: currency_update.php 1 2008-12-16 12:47:23Z kuroi $
*/
// This describes the path from the location where you install this file to the root directory of your Zen Cart
// It is normally the only line that you will need to edit. See readme for guidance.
DEFINE('PATH_TO_STORE_ROOT','/ohiospeedshop/');
// Get Zen Cart configuration data
require_once(PATH_TO_STORE_ROOT . 'includes/configure.php');
require_once(PATH_TO_STORE_ROOT . 'includes/database_tables.php');
//connet to database
$link = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die("Could not connect");
//get default currency
$currency_default = mysql_db_query(DB_DATABASE, "select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key='DEFAULT_CURRENCY' LIMIT 1 ", $link);
$currency_default= mysql_fetch_array($currency_default);
define('DEFAULT_CURRENCY', $currency_default[0]);
//get currency conversion ratio
$currency_uplift_ratio = mysql_db_query(DB_DATABASE, "select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key='CURRENCY_UPLIFT_RATIO' LIMIT 1 ", $link);
$currency_uplift_ratio= mysql_fetch_array($currency_uplift_ratio);
define('CURRENCY_UPLIFT_RATIO', $currency_uplift_ratio[0]);
// Define currency file
$ECBFile = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
$XMLContent = @file($ECBFile);
if (!is_array($XMLContent) && function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ECBFile);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$XMLContent = explode("\n", curl_exec ($ch));
curl_close($ch);
}
$currencyArray['EUR'] = 1;
foreach ($XMLContent as $line) {
if (ereg("currency='([[:alpha:]]+)'",$line,$currencyCode)) {
if (ereg("rate='([[:graph:]]+)'",$line,$rate)) {
$currencyArray[$currencyCode[1]] = (float)$rate[1];
}
}
}
if (sizeof($currencyArray) > 1)
{
$currencyQuery = mysql_db_query(DB_DATABASE, "select currencies_id, code from " . TABLE_CURRENCIES . "", $link);
while ($currency = mysql_fetch_array($currencyQuery)) {
if ($currency['code'] == DEFAULT_CURRENCY)
{
$rate = 1;
}
else
{
$rate = ($currencyArray[$currency['code']] / $currencyArray[DEFAULT_CURRENCY]) * CURRENCY_UPLIFT_RATIO;
}
$updateSql = "UPDATE " . TABLE_CURRENCIES . "
SET value = '" . $rate . "',
last_updated = now()
WHERE currencies_id = '" . $currency['currencies_id']. "'";
mysql_db_query(DB_DATABASE, $updateSql, $link);
}
}
mysql_close($link);
?>
I am sure I have something wrong somewhere maybe you can help?
Re: Currency Update (Automatic)
Quote:
Originally Posted by
Glamorousshoe
Code:
DEFINE('PATH_TO_STORE_ROOT','/ohiospeedshop/');
wouldn't the PATH_TO_STORE_ROOT need to be '/home/coolcarp/public_html/ohiospeedshop/'?
EDIT: I just checked mine and I have'./' for my root directory so you would need './ohiospeedshop/' but maybe I've always had it wrong and never noticed! :-)
Re: Currency Update (Automatic)
Hi, just a quick question, it is better to use the curled version by Nogal (post #85) than the one in the download area, correct?
Re: Currency Update (Automatic)
I haven't looked at the curled version, but if it works for you, go with it. It's less likely to stop working in the future as a result of upgrades by your host.
Re: Currency Update (Automatic)
Hi I have just uploaded currency_update_curled.php
I wrote on line 17 DEFINE('/public_html/magicmods','');
I created a a Cronjob
a Table shows
www.magicmods.com/images/Cron.tiff
It doesn't seem to work, I've put my email in but I'm not getting any error logs sent to me.
Are my paths correct?
Thanks
Iain
Re: Currency Update (Automatic)
I think you need to put the full path, something like
/home/username/public_html/magicmods
for the cronjob, again, you might need the full path plus might also need to define php.
Something like:
php /home/username/public_html/magicmods/currency_update_curled.php
Re: Currency Update (Automatic)
Quote:
Originally Posted by
Electrobumps
Hi I have just uploaded currency_update_curled.php
I wrote on line 17 DEFINE('/public_html/magicmods','');
I created a a Cronjob
a Table shows
www.magicmods.com/images/Cron.tiff
It doesn't seem to work, I've put my email in but I'm not getting any error logs sent to me.
Are my paths correct?
Thanks
Iain
Try
DEFINE('PATH_TO_STORE_ROOT','magicmods/');
Re: Currency Update (Automatic)
Just to double check... the ECB site that the live currency add-on uses... only updates once per day??
So is there a faster way to test if it's actually working besides waiting until tommorow?
Re: Currency Update (Automatic)
Correct. For testing you could set the CRON to run more frequently and edit the rates manually in your database.
Re: Currency Update (Automatic)
It's not working... where do I start to debug?