-
Currency Update (Automatic)
This contribution was already posted by myself on the forums a long time ago, but it seems to be lost for the newer zenners not knowing about it.
Here is a link to this mod: Automatic Currency Update.
This script is designed to run via cronjob within certain interval you may/must set. Once done, the script will check oanda.com or xe.com server with the current conversion rate and update your store.
This is extremely useful, if you don't click on the update button every hour :wink2:
Installation is very easy - just drop in the file and set the directory path to your Zen-Cart setup, if this script is not running in your Zen-Cart's folder. After that, set up the cronjob.
This is one of the wonderful set it & forget it options that are quite useful to have!
-
Re: Currency Update (Automatic)
Hello! Can you tell me what I should put in when I'm doing the cron job and it asks for the Command to run? Also, should I be choosing the Standard or Advanced (Unix) mode when doing the cron job?
Thanks!
-
Re: Currency Update (Automatic)
Standard or Advanced one is self explaining. If you were in expert in this (cronjob) area, then ofcourse you would be choosing the advancded one, but I guess you wouldn't be asking.
The command to run is just the complete file path to this update script. A real "advancded" command is like this
Quote:
30 * * * * /full/path/to/cron/script/file.php
which runs every 30 mins. In the normal view, you are given the option to let the xpanle generator set up the complete command to run (additional to the file path).
-
Re: Currency Update (Automatic)
Thank you! So I can use the Standard mode and just put http://www.mysite.com/currency_update.php or wherever my script is located?
-
Re: Currency Update (Automatic)
Hmmm it's not working. It sends an e-mail each times it runs and says this: /bin/sh: line 1: http://www.babyplanet.ca/currency_update.php: No such file or directory
But the file is there...
-
Re: Currency Update (Automatic)
You will have to use the exact system file path to this file. You shouldn't be using the web location in your cron.
It should be something like this
/var/www/~user123/html/file.php
-
Re: Currency Update (Automatic)
Hmmm OK, I did that, then it said permission was denied, oops! So I set the permissions to 777. Now the e-mail that comes says this:
/home/dburgi2/public_html/currency_update.php: line 1: ?php: No such file or directory
/home/dburgi2/public_html/currency_update.php: line 2: /*: No such file or directory
/home/dburgi2/public_html/currency_update.php: line 3: //Currency: No such file or directory
/home/dburgi2/public_html/currency_update.php: line 4: //developed: No such file or directory
/home/dburgi2/public_html/currency_update.php: line 5: //donations: No such file or directory
/home/dburgi2/public_html/currency_update.php: line 6: //via: No such file or directory
/home/dburgi2/public_html/currency_update.php: line 7: syntax error near unexpected token `('
/home/dburgi2/public_html/currency_update.php: line 7: `//every little bit helps - why donate (http://www.modyourzencart.com/free-of-charge/why-donate)'
And the currencies aren't updating.
-
Re: Currency Update (Automatic)
Does anyone have this working successfully who would like to share how they did it :D
Thanks!!!
-
Re: Currency Update (Automatic)
You will need to talk to your host - it would seem that they do not allow the execution of php files via cron.
My server requires "nice -15 curl http://www...etc"
But this updater certainly works.
-
Re: Currency Update (Automatic)
Oh OK, I'll ask them, thank you! Nice to know that maybe it's not just something I'm doing wrong :blush: I have seen tons of posts from others who seem to have it working fine, so I don't at all think it's a problem with the mod itself, I was just hoping someone here had a similar experience and still got it working!
So if it is my host, I will have to set it up differently somehow to make it work?
-
Re: Currency Update (Automatic)
I think they will either have to make the changes - or tell you the correct command to use
-
Re: Currency Update (Automatic)
Yep, you were right, thanks! I just had the cron job set up incorrectly. Works wonderfully now!
-
Re: Currency Update (Automatic)
I am sorry I didn't see your questions before. Oh well at least you have it working now!
-
Re: Currency Update (Automatic)
Hi,
Today i install your module and it work fine,but i check rate of USD - VND and USD -GPB in xe.com and see it just 1 USD - 16020 VND and 1 USD - 0.50 GPB
When i click on update in admin ,the rate of high then in xe.com
1 USD - 17450 VND and 1 USD - 0.53 GPB
:cry: Can you tell me how to fix this?
KIMSON
-
Re: Currency Update (Automatic)
The difference is because the add-in module and Zen Cart work slightly differently.
The add-in module goes and gets the current mid-price for each currency and puts it in your database.
When you click on the update currency button to do a manual update, Zen Cart goes to the same places for the currencies but before putting them in your database, it applies a currency uplift factor to allow for the difference between the market mid-rate and the rate that you as a seller will actually get from your bank.
By default Zen Cart applies a 5% currency uplift equivalent to a whopping 10% currency spread. Unless you're working with an "exotic" currency, you will probably want to change this amount on the Admin > configuration > My Store page (near the bottom) to something more reasonable.
To apply the same uplift effect via the module would require some code changes.
-
Re: Currency Update (Automatic)
Hi Kimson.
As it's Christmas, I've updated the mod to take account of Zen Cart's currency conversion ratio and uploaded the new version to the Admin section of the downloads area. So that automated and manual currency updates now give the same results.
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
kuroi
Hi Kimson.
As it's Christmas, I've updated the mod to take account of Zen Cart's currency conversion ratio and uploaded the new version to the Admin section of the downloads area. So that automated and manual currency updates now give the same results.
I see CPU quote over 20% when use this add-ons....
-
Re: Currency Update (Automatic)
That's curious since it only has 44 lines of code and the only loop cycles only as many times as you have currencies. With what frequency are you running your CRON job?
-
Re: Currency Update (Automatic)
Hello,
The problem might not always be with cron. Generally, if you run php from console, you should define where php resides on your system. Locate your php binary and add this to the first line of the currency_update.php:
#!/usr/bin/php
When the file (with +x rights) is run, it will tell the system to use the /usr/bin/php to interpret its contents.
The plugin works extremely well, big thanks to the author :-)
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
Danielle
Yep, you were right, thanks! I just had the cron job set up incorrectly. Works wonderfully now!
:frusty:I get the exact same error as you. And my cron job command is
/home/emailname/public_html/currency_update.php
[FONT=Arial]
Is it correct? How did you get it right?
Hope to hear from anyone of you who knows.
Thank you
[/FONT]
-
Re: Currency Update (Automatic)
:clap: I GOT IT!. The command I use is;-
php /home/[your username]/public_html/rss/import_feeds.php
-
Re: Currency Update (Automatic)
Hmmm this has always been working fine, but now I've moved to a new server and the script and cron are working except they update my currency rate to 0 which makes everything in my store free if visitors are shopping in US $, eek!!! I didn't change the file at all, I can't understand why it's doing that. Any thoughts anyone?
TIA!
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
Danielle
Hmmm this has always been working fine, but now I've moved to a new server and the script and cron are working except they update my currency rate to 0 which makes everything in my store free if visitors are shopping in US $, eek!!! I didn't change the file at all, I can't understand why it's doing that. Any thoughts anyone?
TIA!
Why don't you Google the error message that comes out? The solution is somewhere out there in the WWW.
-
Re: Currency Update (Automatic)
There is no error message...everything appears to work great, but when I check the currency values in my admin, Canadian is correct and USD is changed to 0.
-
Re: Currency Update (Automatic)
What happens when you do a manual update? How do you know that CRON and the script are working?
-
Re: Currency Update (Automatic)
well, what should i do here
i think i read all the posts here but i can't find one thing
in the mod they said that you should change line 16
is it this one? define('CURRENCY_SERVER_BACKUP', 'oanda');
i doubt it
but i thought that it would be this one
$location = '/home/***/***/currency_update.php'; // location of zen-cart intall
i put my physical address here
and in the cron job i put the physical address my host supervisor gave it to me...
but still nothing is working!!!???
did i made the right change inside the script?
can you advice in it?
saher
-
Re: Currency Update (Automatic)
My host has allow_url_fopen disabled for security reasons, and I'm sort of loath to enable it since most of the advice I've found suggests leaving it alone unless you really know what you're doing. I know zilch about web security, so...
Several people have suggested using cURL as an alternative, but I don't know PHP from Hebrew and haven't figured out how to do it. Perhaps I'm revealing my ignorance here, but mightn't it be a good idea to make the switch in the next version of the script in the interest of maximum compatibility? It would at least eliminate one of the issues people are having. It's just these two lines that are causing problems, right?
Code:
$page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code . '&format=CSV&dest=Get+Table&sel_list=' . $base);
$page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);
-
Re: Currency Update (Automatic)
I spent a bunch of time searching tutorials and other various websites, trying to figure out how to replace the php file() function with cURL. Then I found the admin/includes/functions/localization.php file, which seems to be what this is based on. I just cut and pasted that code into the currency_update.php file, and it seems to have just updated my currencies okay on my server with allow_url_fopen disabled. Here it is if anyone wants to poke at it. I'm certainly not going to put it up on the Downloads page until someone who is more knowledgeable about these things checks and makes sure nothing is going to explode.
Currency Update (cURLed)
-
Re: Currency Update (Automatic)
Thank you kuroi and phreakymonkey for making those little changes to the script. I haven't given too much attention to it, since it *should* be working as a standalone script, regardless of the zen version.
Unfortunaly I didn't think of file() fopen() disallowed by a server when writing the script... The CURL method is the best alternative, which should work ok.
I will see if I can improve the script for now and make it available on my website by tomorrow.
-
Re: Currency Update (Automatic)
Hi,
I seem to be having a little difficulty getting this mod set up.
Please can someone advise me if these settings are correct:
the currency_update.php file is in directory /home/admin*****
the run command is in directory /etc/cron.hourly/hourlytasks
my store is in directory /var/www/html
I have the setting in the currency_update.php file set to /var/www/html
the run command is set to usr/bin/php /home/admin*****/currency_update.php
This should run the script every hour but when I look in admin->localization->currencies the displayed last update date was days ago.
Please can someone tell me what I'm doing wrong?
Thanks
-
Re: Currency Update (Automatic)
Hi,
I am having some difficulty using this mod as well.
I have installed the update_currency.php in the root for now, then set up the path
$location = '/home/[my-username]/public_html/';
Then tried to execute like this
www.vitalwares.ca/currency_update.php
(I have not even set up a cron job yet)
There were no errors on screen so I assumed that the file has run currectly but I donot see any change in the price of an item in a different currency i have tested this over 2 days and there have definately been changes in the currency vlaues , and whn I maually update currency using admin the price of the items changes even if i do it as frequesntly as every 5 mins.
This leads me to assume that there is something wrong ? Please help..
p.s. My default currency is Canadian dollars could this be an issue ?
:lookaroun
-
Re: Currency Update (Automatic)
Hi vitalwares,
I had a bit of trouble getting it set up but it's sorted now, I think the problem you are having is that the file currency_update.php is in your root directory, is this the same place that you have zen cart installed, if so I think your path should be:
$location = '/';
I'm not 100% sure if that is correct but give it a try and see what happens, you can tell if it works in your currencies page in admin the updated date will change to today (unless you've already updated it manually today)
-
1 Attachment(s)
Re: Currency Update (Automatic)
hi,
Now I am sure that there is something wrong.
Masterblaster/kuroi Please take a look at this modified file I have added some diagnostic code and run this file several times, It does return the currency rates but does not update them (it returns the same data 1 hr or 10 hrs later)
Please let me know if I have made a mistake or its the script that has an issue.
:smile:
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
Phil020782
Hi vitalwares,
I had a bit of trouble getting it set up but it's sorted now, I think the problem you are having is that the file currency_update.php is in your root directory, is this the same place that you have zen cart installed, if so I think your path should be:
$location = '/';
I'm not 100% sure if that is correct but give it a try and see what happens, you can tell if it works in your currencies page in admin the updated date will change to today (unless you've already updated it manually today)
Hi Phil,
Thanks for your help but if path was the issue it would have given an error response like:
Warning: require_once(/home/vita127/public_html/includes/configure.php) [function.require-once]: failed to open stream: No such file or directory in /home/[username]/public_html/currency_update.php on line 21
Fatal error: require_once() [function.require]: Failed opening required '/home/[username]/public_html/includes/configure.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/vita1275/public_html/currency_update.php on line 21
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
vitalwares
Hi Phil,
Thanks for your help but if path was the issue it would have given an error response like:
Warning: require_once(/home/vita127/public_html/includes/configure.php) [function.require-once]: failed to open stream: No such file or directory in /home/[username]/public_html/currency_update.php on line 21
Fatal error: require_once() [function.require]: Failed opening required '/home/[username]/public_html/includes/configure.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/vita1275/public_html/currency_update.php on line 21
OK, well like I said I don't really know much about it, I had problems with the path and never got an error message
-
Re: Currency Update (Automatic)
Hello all,
I use this modules a long time ago. But the trouble is it take my Host Cpu Resource too much. How to fix this trouble ?
Thanks you for let me know :D
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
vitalwares
hi,
Now I am sure that there is something wrong.
Masterblaster/kuroi Please take a look at this modified file I have added some diagnostic code and run this file several times, It does return the currency rates but does not update them (it returns the same data 1 hr or 10 hrs later)
Please let me know if I have made a mistake or its the script that has an issue.
:smile:
Hi somebody please help with this ? Kuroi ? Masterblaster ?
Its just not refreshing the numbers...
-
Re: Currency Update (Automatic)
I will be posting an update to this shortly
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
phreakymonkey
I spent a bunch of time searching tutorials and other various websites, trying to figure out how to replace the php file() function with cURL. Then I found the admin/includes/functions/localization.php file, which seems to be what this is based on. I just cut and pasted that code into the currency_update.php file, and it seems to have just updated my currencies okay on my server with allow_url_fopen disabled. Here it is if anyone wants to poke at it. I'm certainly not going to put it up on the Downloads page until someone who is more knowledgeable about these things checks and makes sure nothing is going to explode.
Currency Update (cURLed)
Phreakymonkey - you are my hero!!! :clap::clap::clap: I needed the CURL version as I was getting the following error: "URL file-access is disabled in the server configuration", pointing to the lines with the links. Anyone with the same problem - try phreakymonkey's version.
I'm not a good enough coder to vouch for the "safety" of your script, but it sure does work. Maybe add it to the downloads?
-
Re: Currency Update (Automatic) on version 1.3.8a
Does anyone have experience with the Automatic Currency Updates ver. 2.0?
I want to install the mod but I'm weary.
What can expect? :lookaroun
-
Re: Currency Update (Automatic)
It should work OK so no need to be wary. As long as you have no issues with running a php script with cron as I had.
I am in the final stages of making a variant of this that doesn't rely on traditional cron jobs to update the currencies and also adds yahoo finance in a way that doesn't rely on page scraping. (page scraping as currently used by the currency update functions in zencart is vulnerable to changes in page layout).
I am just waiting to see what actions the site admins take on existing contributions following a rather bizarre email full of what I think are unnecessary prescriptions on dos and donts they recently circulated to people that have contributed in the past.
The email contained a ultimatum to comply within 30 days with unspecified consequences.
If they start applying heavy handed censorship as the email suggested might be the case, then I guess I will have to review the point of uploading contributions.
One important point of open source is freedom to code as desired not marching to some totalitarian tune.
So, in summary, you should be able to use the existing contribution or keep a lookout for an improved version which will come depending on the way the site admins decide to go.
-
Re: Currency Update (Automatic)
looks like Curled version works for me
With the following location inserted into file:
'/var/www/vhosts/mywebsite.com/httpdocs/'
-
Re: Currency Update (Automatic)
I'm a real newbie, and would appreciate any help.
I've contacted our hosts, and they can set the cronjob up for me. I've got the file currency_update.php uploaded to the following folder /var/www/html/includes/ and have given these details to the host, and asked for it to be run once a day. Is this folder a goodplace toput the file?
They also wanted the name of the script, what should I give them?
Regrading the file - currency_update.php, I do not understand fully from the instructions what changes I need to do to this file.
The instructions say:
"Edit line 13 to define the path from the lcoation where you plan to put the file, to root directory for your store."
Line 13 is:
Code:
// and is normally the only line that you will need to edit
I presumbe it is line 14 that I need to change which is:
Code:
$location = './'; // location of zen-cart intall
but what do I need to change exactly?
-
Re: Currency Update (Automatic)
My line 14 looks like
$location = '/var/www/vhosts/xxxxxx.com/httpdocs/'; // location of zen-cart intall
-
Re: Currency Update (Automatic)
What should the CMOD be for file currency_update.php ? I have set it to 775 and get the error message when accessing the filethrough my browser:
Quote:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator,
[email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
The file is located in my root folder:
http://www.domainofcompany.com/currency_update.php
I have inserted the following in the file as location of Zen Cart install:
PHP Code:
$location = '/home/virtual/domainofcompany.com/var/www/html/'; // location of zen-cart intall
My host can setup the Cronjob, but say that there is no point as the script doesn't work. I would really appreciate any help!
-
Re: Currency Update (Automatic)
I get the following error message. Can anyone help?
Quote:
[FONT=Verdana][FONT=arial,helvetica,sans-serif] PHP Warning: require_once(/home/virtual/companydomain.com/var/www/html/includes/configure.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /var/www/html/currency_update.php on line 21
PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/home/virtual/[/FONT][/FONT][FONT=Verdana][FONT=arial,helvetica,sans-serif]companydomain.com[/FONT][/FONT][FONT=Verdana][FONT=arial,helvetica,sans-serif].com/var/www/html/includes/configure.php' (include_path='.:/php/includes:/usr/share/php') in /var/www/html/currency_update.php on line 21[/FONT][/FONT]
[FONT=Verdana][FONT=arial,helvetica,sans-serif][/FONT][/FONT]
-
Re: Currency Update (Automatic)
Can anyone help with this please? :dontgetit
-
Re: Currency Update (Automatic)
Any help please?? Sorry for asking again but I'm desperate to get this working. What am I doing wrong?
-
Re: Currency Update (Automatic)
I tried numerous times to get currency update to work but then I finally tried the curled version. with file uploaded to root directory.
It works ok now. I changed my location of file as I mentioned in post 44 above. Then ran the url and currency update is OK. Then I setup a cronjob to fully automate it further.
If you have problems setting up the currency update try the curled version it worked for me.
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
whitt
I tried numerous times to get currency update to work but then I finally tried the
curled version. with file uploaded to root directory.
It works ok now. I changed my location of file as I mentioned in post 44 above. Then ran the url and currency update is OK. Then I setup a cronjob to fully automate it further.
If you have problems setting up the currency update try the curled version it worked for me.
Thanks for your tips. Unfortunately it hasn't worked for me :dontgetit
The curled version gives out the same error. I do not understand the error myself, but it seems to suggest that there is a problem with [FONT=Verdana][FONT=arial,helvetica,sans-serif]/includes/configure.php ??[/FONT][/FONT]
-
Re: Currency Update (Automatic)
i think you may still have problems with the path?
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
whitt
i think you may still have problems with the path?
Many thanks for that tip. It was the problem!
My host told me to use:
'/home/virtual/domain.com/var/www/html/
Where I insert my domain where it is bold above. But I checked my ftp, and that wasn't the path I was getting, it was the following:
'/home/myusername/mainwebsite_html/'
Where I unser my usernamein the area marked as bold above. I've added the above, and the script works great.My host will now set up a Cron Job to run once a day.
How often has the rest of you set the cron job to execute the script? Should I ask to change it to happen more often than once a day? After all, the price in the other currencies is only a guide, and I have marked this clearly on our site!
-
Re: Currency Update (Automatic)
Prices in a currency other than your store's default are only guides if you don't actually allow them to purchase with those currencies. If you do allow purchases with these currencies then they are the actual amount that they will pay, not guides.
This is why Zen Cart has an a currency conversion ratio. It's set high by default (5%), which can make your product prices uncompetitive. If you're not allowing purchases in these currencies or want to price more competitively, I would recommend reducing the conversion ratio and increasing the frequency of the CRON job.
There's very little processing penalty to this. I have a client running it every hour on the half hour.
-
Re: Currency Update (Automatic)
mine updates once a day and i adjusted the 5% LOWER
-
Re: Currency Update (Automatic)
Hi,
Another possible reason for the cron job not working is that the cron command may have to reference php with an absolute path.
For example on my hosting server this command:
php /home/username/public_html/path/currency_update.php
gets passed to the interpreter so it appears to be working but then results in the script stopping when it tries to connect to the database with:
PHP Fatal error: Call to undefined function mysql_connect() in /home/username/public_html/path/currency_update.php on line 25
In fact the cron command needs to have the full path to php,
eg.
/usr/lib/php /home/username/public_html/path/currency_update.php
Embarrassingly I wasted ages discovering this as I have no experience with UNIX, but a question for those of you who do have UNIX server experience: is this thing about the full path common knowledge and totally obvious to all but the newly-born/senile? I ask because my hosting support did not spot this and I was wondering if they should have.
Regards
Steve
-
Re: Currency Update (Automatic)
I have noticed that this mod uses the currency rate which is higher (Oanda.com) , I would like this mod to use to use XE.com as it's primary for updates, this is what the script is designed for.
How do I get only the XE.com currency update and use the Oanda.com only as a backup .
Does the script use the higher currency update if yes how can I change this.
-
Re: Currency Update (Automatic)
I have the mod installed.
My host provider told me to use:
Code:
/usr/bin/php /home/(directory)/currency_update.php
I have the Cron job set to run every 4 hours. Does anyone have a suggestion about this?
-
Re: Currency Update (Automatic)
Hi,
Is there another way to schedule the currency_update.php file to run, besides using cron jobs. My host wants $55 to set up the cron job. Apart from the money issue I'd prefer to keep control of my web site. Depending on others to make changes for me puts me at a disadvantage.
-
Re: Currency Update (Automatic)
Do the currencies your site deals with actually change that frequently with a variance that's so drastic it requires real-time updating? Most of the time it's pretty safe to update it once a week manually, according to markets and your own needs.
And ... a hosting company that wants to charge $55 to set up a cron job ... is ripping you off. There are many hosting companies out there that let you do that yourself from within your hosting control panel for no extra charge. The Certified Hosts list at the top of this page shows a few such companies. If you are considering one of them, be sure to ask them about your specific question when doing your research before signing up.
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
DrByte
Do the currencies your site deals with actually change that frequently with a variance that's so drastic it requires real-time updating? Most of the time it's pretty safe to update it once a week manually, according to markets and your own needs.
And ... a hosting company that wants to charge $55 to set up a cron job ... is ripping you off. There are many hosting companies out there that let you do that yourself from within your hosting control panel for no extra charge. The Certified Hosts list at the top of this page shows a few such companies. If you are considering one of them, be sure to ask them about your specific question when doing your research before signing up.
Hi Drbyte.
Normally once a week would be ok, but the world is in panic mode at the moment. The Australian dollar has dropped from 85c US to around 60c in the past month and its jumping all over the place. I can manually do it once a day, but the weekends I'm away from the office.
My host, is fairly cheap and reliable. Despite them trying to gouge me this time I'm pretty pleased with them. But having briefly researched cron jobs before hand it didn't seem right to charge $55 for what seems to be a simple matter.
-
Re: Currency Update (Automatic)
Normally you should have some kind of access to server, such as cpanel, it should allow you to set up cron yourself.
Otherwise, there are websites out there offer free cronjobs, that can be a temporary solution before you find a better solution.
55usd is certainly a rip-off, maybe they just dodnt want to do it, so they just throw in a high price? :)
-
Re: Currency Update (Automatic)
You could add "pseudo-cron" to your site. Though my recommendation would also be to switch to a host who lets yor properly control your environment.
-
Re: Currency Update (Automatic)
Thanks Kuroi, and Drbyte.
I checked with my hosting company and they definitely don't allow me to set my own cron jobs. I checked my console and theres no provision for it.
My hosting company charges about $65 a year for hosting which is pretty good. I think I'd be worse of financially switching hosts. It would make more sense to pay the $55 and forget about it.
However I've had a look at the free cron jobs sites, and a quick look at psuedo-cron. The free cron jobs sites look pretty shifty, so I might give psuedo-cron ago. That looks very interesting, and would probably work best. I could set it up to run every time someone landed on my index page. I'll give it a try once I research it properly.
-
Re: Currency Update (Automatic)
I get the following error when i try and run the file manually. Anyone know why i might get this error.
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/delights/public_html/store/currency_update.php on line 63
preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', implode('', $page), $match); if (sizeof($match) > 0) { return $match[3]; } else { return false; } } function quote_xe_currency($to, $from = DEFAULT_CURRENCY) { $page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to); $match = array(); preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', implode('', $page), $match); if (sizeof($match) > 0) { return $match[1]; } else { return false; } } ?>h[3]; } else { return false; } } // // Function for currency lookup at XE // function quote_xe_currency($to, $from = DEFAULT_CURRENCY) { $page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to); $match = array(); preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', implode('', $page), $match); if (sizeof($match) > 0) { return $match[1]; } else { return false; } } ?>
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
Delights
I get the following error when i try and run the file manually. Anyone know why i might get this error.
It seems it was a bad install, i re-loaded the file and it is working now.
-
Re: Currency Update (Automatic)
The file runs and all that, but it is still saying last update was a day ago, it should be saying today.
-
Re: Currency Update (Automatic)
Could someone look at this please?
I have asked my host to set up a Cron Job on the above software.
It did not work, so I asked them to test it.
This was there reply:
Hi,
The problem lays with some pretty poor coding in the script. Firstly it used:
require_once($location.'includes/configure.php');
require_once($location.'includes/database_tables.php');
which caused the following error:
PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '../includes/configure.php' (include_path='.:/php/includes:/usr/share/php') in /var/www/html/currency_update_curled.php on line 26
and so I changed those lines to read:
require_once('includes/configure.php');
require_once('includes/database_tables.php');
and then it gave the following error:
PHP Notice: Use of undefined constant CURL_PROXY_REQUIRED - assumed 'CURL_PROXY_REQUIRED' in /var/www/html/currency_update_curled.php on line 124
We do not use a proxy for cURL.
I'm afraid we cannot help any more with this as it is clearly a problem with the script you are using.
Can anyone advise?
The server people are Terranetwork.
-
Re: Currency Update (Automatic)
The first problem raised by your host isn't a problem with the PHP, that's fine, it's a problem with your web host not reading the installation instructions.
The second is, I suspect, because you have asked your host to install the version of the updater intended for servers that use a proxy for CURL, so some of the environment constants are missing.
I would recommend that you aks her to install the original version (i.e. the one in the "free software add-ons" area, which is inteneded for normal setups.
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
kuroi
The first problem raised by your host isn't a problem with the PHP, that's fine, it's a problem with your web host not reading the installation instructions.
The second is, I suspect, because you have asked your host to install the version of the updater intended for servers that use a proxy for CURL, so some of the environment constants are missing.
I would recommend that you aks her to install the original version (i.e. the one in the "free software add-ons" area, which is inteneded for normal setups.
It was myself that installed the file :-)
I just asked them to set up the Cron Job, just to clarify.
I will have another go, I appreciate you taking the time to reply :-)
Mark
-
Re: Currency Update (Automatic)
Respect to you for admitting that. I was surprised by your host's comments, as I have great respect for her technical competence, but I can see how if she's seeing only the errors when she tries to run the script, she might jump to the conclusions she drew.
I'd recommend using the version of the script that you can download from this site and ensuring that the location variable is set as per the installation instructions. Hopefully that will go smoothly for you, otherwise let us know.
I'm rather assuming that sterling's current performance makes this a bit of a priority!
-
Re: Currency Update (Automatic)
require_once($location.'includes/configure.php');
gave the error: Failed opening required '../includes/configure.php'
which, as you can see, has it looking for the script in the wrong place.
Fixing that error it was then looking for a cURL Proxy, which would be fine if this were a GoDaddy server, or any other company that provides cURL via a Proxy, but we don't. Each site has cURL installed.
There is another major problem with the script. It is trying to access the XE and OANDA currency exchanges, both of which changed their policies about 2 years ago to disallow outside connections to their database unless you have a licence, which costs around $2,500 a year. In reality this means that you will occasionally be lucky and be able to connect to their db, but at other times the connection will be blocked.
Vger
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
Vger
require_once($location.'includes/configure.php');
gave the error: Failed opening required '../includes/configure.php'
which, as you can see, has it looking for the script in the wrong place.
...being why the installation instructions say to set the location to reflect the local installation.
Quote:
Originally Posted by
Vger
Fixing that error it was then looking for a cURL Proxy, which would be fine if this were a GoDaddy server, or any other company that provides cURL via a Proxy, but we don't. Each site has cURL installed.
Which is why I recommended to your client that he use the original, non-CURL version.
Quote:
Originally Posted by
Vger
There is another major problem with the script. It is trying to access the XE and OANDA currency exchanges, both of which changed their policies about 2 years ago to disallow outside connections to their database unless you have a licence, which costs around $2,500 a year. In reality this means that you will occasionally be lucky and be able to connect to their db, but at other times the connection will be blocked
With which I agree - though the original script was released before these changes. It's also worth noting that the code in this mod is basically the core Zen Cart code for currency updates with slight amendments to recognize that it may be installed in a different place and executed in a slightly different way.
There are now sites offering proper APIs that obviate the need for screen scrapping. Unfortunately nobody has yet contributed a mod based on this approach. Are you offering ...?
-
Re: Currency Update (Automatic)
Quote:
Unfortunately nobody has yet contributed a mod based on this approach. Are you offering ...?
I may have a few spare free minutes ....some time around the year 2020. And by that time I shall be well and truly retired.
Vger
-
Re: Currency Update (Automatic)
The helpful staff at Terranetwork have resolved this for me.
Once I set up the correct package (not the curled version).
I installed it in /var/www/html for anyone else looking to install it.
I also wanted to ask, as the currency exchange sites are now charging for connection, is Zen Cart now accessing them illegally?
I would not want anything running on my website that could be viewed as piracy or breaking copyright.
Zen Cart is great by the way.
I have no knowledge of css or php but have a fully functioning ecommerce website...
Brilliant.
(hard work at times - but that is the learning curve - learning to read the manual is a steep curve at times...)
Mark :-)
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
mtimber
I also wanted to ask, as the currency exchange sites are now charging for connection, is Zen Cart now accessing them illegally?
Glad to hear that Zen Cart is going well for you. It is a steep learning curve but well worth the effort.
In response to you question. No Zen Cart isn't accessing these rates illegally, but it is now unwittingly (since the ground rules were changed after Zen Cart's code was written) encouraging you to access them in contravention of the site owners' terms of use. Vger is absolutely correct on this.
Accordingly, I've updated the mod to use the European Central Bank's daily reference rates instead. It's actually easier, quicker, less likely to fail and unlikely to fall foul of a change in screen layout (as it no longer uses screen scrapping), as well as being completely above board and legal.
Look out for version 3.0 being enabled here.
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
kuroi
Glad to hear that Zen Cart is going well for you. It is a steep learning curve but well worth the effort.
In response to you question. No Zen Cart isn't accessing these rates illegally, but it is now unwittingly (since the ground rules were changed after Zen Cart's code was written) encouraging you to access them in contravention of the site owners' terms of use. Vger is absolutely correct on this.
Accordingly, I've updated the mod to use the European Central Bank's daily reference rates instead. It's actually easier, quicker, less likely to fail and unlikely to fall foul of a change in screen layout (as it no longer uses screen scrapping), as well as being completely above board and legal.
Look out for version 3.0 being enabled
here.
When do you think this will be ready?
:-)
I do not like the idea of breaking someones terms of use :-(
-
Re: Currency Update (Automatic)
Hello Kuroi,
This is an excellent update. For one site on a PHP 4.0 system, it works whereas previous versions didn't. I just had one thing. I have pounds (GBP) set as default currency. I have it set as 1.000000 . Today it was set at 1.04. So the prices on the website changed. I wondered if I can exclude the Default currency from increasing with the cron updates of the update page?
Heathenmagic
-
Re: Currency Update (Automatic)
@HeathenMagic
Eeek. That's a bug. Can't believe I missed it :blush: Guess I was too busy checking very precisely the other currencies in my test dB that I forgot the default!!
I'll submit a corrected version immediately, and until it's approved, here's the correction.
Change lines 58-61 from:
PHP Code:
$rate = $currencyArray[$currency['code']] / $currencyArray[DEFAULT_CURRENCY];
}
$updateSql = "UPDATE " . TABLE_CURRENCIES . "
SET value = '" . $rate * CURRENCY_UPLIFT_RATIO . "',
to:
PHP Code:
$rate = ($currencyArray[$currency['code']] / $currencyArray[DEFAULT_CURRENCY]) * CURRENCY_UPLIFT_RATIO;
}
$updateSql = "UPDATE " . TABLE_CURRENCIES . "
SET value = '" . $rate . "',
-
Re: Currency Update (Automatic)
Any chance someone will come up with an updated version using CURL to access European Central Bank? My server has allow_url_fopen disabled for security purposes. Thank you all.
-
Re: Currency Update (Automatic)
Hello Kuroi,
Thats okay. Thanks for the correction by the way. I imagine its difficult to check so much code.
Regards,
Heathenmagic
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
naturesartandgifts
Any chance someone will come up with an updated version using CURL to access European Central Bank? My server has allow_url_fopen disabled for security purposes. Thank you all.
The built-in currency update button works with CURL, and the ECB option is now part of the v1.4.0 core with CURL support. Just one more good thing about the next version, due out soon :)
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
DrByte
The built-in currency update button works with CURL, and the ECB option is now part of the v1.4.0 core with CURL support. Just one more good thing about the next version, due out soon :)
It is worth noting that unlike the Oanda and XE, the ECB based only publishes reference rates for a select set of currencies. If a user has a currency outside that set, the code sets the rate to 0 which can cause users some grief.
It is necessary to escape updating any currency that returns a null value and perhaps sending the site admin an email to inform of this issue.
-
Re: Currency Update (Automatic)
Agreed. And I certainly wouldn't recommend use of this mod for currencies not reported by the ECB. There's a link in the readme file bundled with the mod so that people can check what the currently reported currencies are.
That said, companies with access to the relevant foreign exchange information know that it is valuable and are generally trying to offer it at a price.
The ECB list was way ahead of the others that I could find that could be legitimately used in this way for this purpose. But if anybody knows of better, or even different, please do tell. Zen Cart's code is designed to support multiple provides of this information, so more sources could be added to fill in the gaps.
-
Re: Currency Update (Automatic)
Kuroi
Thanks for the work done. I only posted this because I read DrBytes' post that the mod was being included in the upcoming release.
You are correct that the ECB seems to actually encourage web developers to use them legally and I can't think of any other legit source.
Perhaps you can edit the mod to escape null rates. Something like below.
Code:
if ($rate != 0)
{
$updateSql = "UPDATE " . TABLE_CURRENCIES . "
SET value = '" . $rate . "',
last_updated = now()
WHERE currencies_id = '" . $currency['currencies_id']. "'";
mysql_db_query(DB_DATABASE, $updateSql, $link);
}
Simply skipping such rates might be better than setting them to zero.
-
1 Attachment(s)
Re: Currency Update (Automatic)
I have written a curled version of the 3.1 automatic currency update script.
Attachment 5131
-
Re: Currency Update (Automatic)
What are the improvements of this new curled version v3.1 over the previous v2.0.1
Is it worth me replacing my current one?
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
whitt
What are the improvements of this new curled version v3.1 over the previous v2.0.1
Is it worth me replacing my current one?
It does away with screen scraping, is more future proof, is the apporach now built into Zen Cart 2.0 and is legal. But it has less currencies.
-
Re: Currency Update (Automatic)
Thanks. I found some info in the readme file also.
I copy pasted the script into my old one then changed location line 17 to my server root etc. ( i used the location from old script and place between the ' ' )
It seems to work Ok.
Thank you
-
Re: Currency Update (Automatic)
Where can I adjust the spread?
(The difference between the actual rate and the one that is posted on the website?)
Thanks!
-
Re: Currency Update (Automatic)
Quote:
Originally Posted by
GoNinja
Where can I adjust the spread?
Admin > Configuration > My Store > Currency Conversion Ratio
-
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?