azer Posted February 11, 2006 Share Posted February 11, 2006 http://www.oscommerce.com/community/contributions,4006 This script will retrieve the latest exchange rates from the International Monetary Fund ( based on the US Dollar ), and then updates the currency values in your database to match. If you do a lot of international sales, this is a good way to keep those values current. im not the contributor , all credit goes to dynamoeffects HEre are my question : 1 . Automatic Currency Value Updater 0.2 dynamoeffects 10 Feb 2006 i got this error : Parse error: parse error, unexpected '.' in v:\easyphp\www\ms2fr\catalog\admin\update_currencies.php on line 78 line 78 is : echo "Updating Currency Value: <b>" . $rate_vals[0] . " to " . $rate_vals[1] - . "</b><br>"; maybe quote should be ' instead of " no ? i tried nothing change 2. i treid the previous version but then it s based on dollar so not so intersting .. i f the last version works , i m gonna try to improve it to give the choice to the shop owwner to update autoatically by cliking on a link , of jsut being able to see the international rate in the currencies page of admin , what do u think of taht ? Quote MS2 Link to comment Share on other sites More sharing options...
azer Posted February 11, 2006 Author Share Posted February 11, 2006 alos i can see in the currency tab in the admin the button " update currecny" and it seem to excatly what this contrib does , so what is the advabntage of this contrib ? Quote MS2 Link to comment Share on other sites More sharing options...
dynamoeffects Posted February 11, 2006 Share Posted February 11, 2006 i got this error : line 78 is : echo "Updating Currency Value: <b>" . $rate_vals[0] . " to " . $rate_vals[1] - . "</b><br>"; Looks like I left a little debugging code in there. I've just uploaded a new version, give it a shot. Instructions have also been added for replacing OSC's built-in updater. Quote Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail. Link to comment Share on other sites More sharing options...
dynamoeffects Posted February 11, 2006 Share Posted February 11, 2006 alos i can see in the currency tab in the admin the button " update currecny" and it seem to excatly what this contrib does , so what is the advabntage of this contrib ? I actually wrote this because the built-in function was failing, but seems to be working now. The main reason is that I'm setting up a server with many OSC installations and needed a way to update many databases at once. This is a scaled down version of that script. Quote Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail. Link to comment Share on other sites More sharing options...
Guest Posted February 11, 2006 Share Posted February 11, 2006 Thank you very kindly for this important contribution. This has been greatly needed in the community. Best Regards... :thumbsup: Quote Link to comment Share on other sites More sharing options...
yansfung Posted February 12, 2006 Share Posted February 12, 2006 Sorry !! My Php skill is at junior level. Can some expert show me the syntax to set the cron jobs with "update_currencies.php" Thanks a lot indeed! Quote YaNotCook !! Link to comment Share on other sites More sharing options...
Guest Posted February 12, 2006 Share Posted February 12, 2006 Hi! I am also a junior with OSC but getting the hang of it quite quickly. Question: Client does international business but Authorize.net only manages US sales in USdollars. Will this script help to convert other than US currency into USdollars? And, if not, what contrib do you recommend? Quote Link to comment Share on other sites More sharing options...
yansfung Posted February 12, 2006 Share Posted February 12, 2006 This script for mine can convert currencies among EURO, RMB, USD, HKD seamless through a single button click. But I do need to know how to set the cron job to update periodically. Sorry !! My Php skill is at junior level. Can some expert show me the syntax to set the cron jobs with "update_currencies.php" Thanks a lot indeed! Quote YaNotCook !! Link to comment Share on other sites More sharing options...
mr_absinthe Posted February 13, 2006 Share Posted February 13, 2006 Brian, thank you for this great contribution! I would like to ask you if there is a possibility of running it with register_globals disabled? When I call the file from my browser, currencies are updated just fine with output on the screen. However when I set up a cron job for it, I receive message: FATAL ERROR: register_globals is disabled in php.ini, please enable it! I don't have acess to php.ini, register globals are off by default and I have "php_flag register_globals on" in my .htaccess. Any ideas? Thank you. Yan, this might help you on setting up a cron job: learn cron here. Alex Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
dynamoeffects Posted February 22, 2006 Share Posted February 22, 2006 (edited) Whoa, sorry I haven't been following this thread. Question:Client does international business but Authorize.net only manages US sales in USdollars. Will this script help to convert other than US currency into USdollars? And, if not, what contrib do you recommend? This script will use your default currency as the basis for all of the conversions. If your base currency is Euro, it'll base everything off of the Euro. And with absinthe's problem: The error message he was receiving was from his application_top.php file. This script should work fine with register_globals off, but it loads up the application_top.php file to get the site's configuration and database settings. Edited February 22, 2006 by dynamoeffects Quote Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail. Link to comment Share on other sites More sharing options...
mr_absinthe Posted February 24, 2006 Share Posted February 24, 2006 And with absinthe's problem: The error message he was receiving was from his application_top.php file. This script should work fine with register_globals off, but it loads up the application_top.php file to get the site's configuration and database settings. That is quite correct. My host has register_globals off and this script was failing due to application_top.php. I've been trying to find my way around it by creating php.ini files but I've learned that the Register Globals contribution won't help me with this problem. The contribution only applies to website files, as does the .htaccess fix and the fix of installing your own local php.ini file in the root of your web. Cron jobs are run from outside the root of your web, and are a server-side function. So the only possible solution for me was to comment this line out: require_once('includes/application_top.php'); and include few functions from application_top.php file for this script to work. I've tested the new file and it works just fine! :-" I've uploaded that version here. Alex Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Guest Posted May 18, 2006 Share Posted May 18, 2006 Please Help ME i dont know if im doing something wrong here, i copy the update_currency.php file to catalog/admin/ folder and then run http://mydomain.com/catalog/admin/update_currency.php, to update the currency but instead i get this error: *********** Warning: file_get_contents(): URL file-access is disabled in the server configuration in /usr/www/users/adbmar/catalog/admin/update_currencies.php on line 77 Warning: file_get_contents(http://currencysource.com/RSS/ZAR.xml): failed to open stream: no suitable wrapper could be found in /usr/www/users/adbmar/catalog/admin/update_currencies.php on line 77 ********** could i have missed a step please help me Quote Link to comment Share on other sites More sharing options...
Leak-Proof Posted June 28, 2006 Share Posted June 28, 2006 Can someone please tell me what the "command to run" is for setting up a cron job to automatically run the currency update. There is no information on this anywhere. Please assist. Quote I like these mods, there fun! ...65 70 72 75 80 85 125+ contributions installed and counting... Tools I'm using: OSC2.2 milestone2, Filezilla for FTP, PHP Designer 2007PE (nice), Araxis Merge 6.5 to compare files, XP(my box), Remote Server is shared Apache 1.3 Cpanel, CURL, and PHPmyAdmin through my hosts Cpanel to mess up the database. Link to comment Share on other sites More sharing options...
DeadDingo Posted August 7, 2006 Share Posted August 7, 2006 My main currency is GBP I also display USD, JPY, EURO. All payments will be made in GBP. Will this contrib be suitable for me? Thanks Quote Link to comment Share on other sites More sharing options...
DeadDingo Posted August 21, 2006 Share Posted August 21, 2006 I am using this contrib and it works fine, apart from the Cron Job. It gives me loads of errors when it reads the update_currency.php. Should I be pointing the Cron to run thescript directly, or should I be doing something else? Any suggestions would be very helpful. Thanks Quote Link to comment Share on other sites More sharing options...
babsy Posted November 6, 2007 Share Posted November 6, 2007 hi, Just wondering does this contribution still work ok (am hoping it does :-) ) ? I am running the latest version of OSC, with php 5.2.4 and mysql 5.0.27 and currently testing on window 2000 locally and have allow_url_fopen = On. I installed the contribution and when I try running it either by loading it directly in the browser or from admin client I get the following displayed in the browser. Any ideas or suggestions ? Thanks, Babsy 200) { foreach ($rates as $rate) { //Another simple check to make sure we're reading the correct data if (strpos($rate, '', '', $rate); $rate = str_replace(' (', '|', $rate); $rate = str_replace(')', '', $rate); $rate = trim(substr($rate, 8)); $rate_vals = explode("|", $rate); //This isn't really necessary, but just a little added security $rate_vals[0] = trim(preg_replace('/[^A-Z]/i', '', $rate_vals[0])); $rate_vals[1] = @floatval($rate_vals[1]); //If the currency is numeric, update the database. if (is_numeric($rate_vals[1])) { //Because inputting the wrong information could really screw up a store, it needs an exact currency name match to work $currency_query = tep_db_query("SELECT currencies_id FROM " . TABLE_CURRENCIES . " WHERE code = '" . $rate_vals[0] . "'"); if (tep_db_num_rows($currency_query) > 0) { $report .= "\n" . 'Currency Value Updated: ' . $rate_vals[0] . ' to ' . $rate_vals[1] . '' . "\n"; tep_db_query("UPDATE " . TABLE_CURRENCIES . " SET value = '" . $rate_vals[1] . "', last_updated = NOW() WHERE code = '" . $rate_vals[0] . "' LIMIT 1"); } } } } } } //If there's anything to report and the user has outputting enabled, display the info if ($report && $output_report > 0) { $report .= "\n\n" . 'Currencies Updated Status: SUCCESS' . "\n" . 'Currency Used for Base Conversions: ' . DEFAULT_CURRENCY . "\n" . 'Updated from URL: ' . $er_url; $report = STORE_NAME . ' Currencies Updated on ' . date("D M j G:i:s Y") . "\n\n" . $report; if ($output_report != 2) { echo str_replace("\n", ' ', $report); } if ($output_report != 1) { tep_mail(STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, 'Currency Rates updated for ' . STORE_NAME, stripslashes($report), STORE_NAME, STORE_OWNER_EMAIL_ADDRESS); } } ?> Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 6, 2007 Share Posted November 6, 2007 I haven't tried it under mysql 5 but the problem you having hasn't anything to do with that. Your problem is a mistake in the code. One of your code changes has overwritten/deleted a php delimiter (<?php or ?>) so it is allowing the code to be seen as html and is being displayed as text. You need to go over your changes and find that mistake. Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
babsy Posted November 6, 2007 Share Posted November 6, 2007 I haven't tried it under mysql 5 but the problem you having hasn't anything to do with that. Your problem is a mistake in the code. One of your code changes has overwritten/deleted a php delimiter (<?php or ?>) so it is allowing the code to be seen as html and is being displayed as text. You need to go over your changes and find that mistake. Jack Hi Jack, Thanks for the reply the file causing the problem I did not update originally but it did get me thinking... the php tag was <? so I now changed it to to <?php and that ran the script but now the following appears in the apache error log:- [Tue Nov 06 13:16:47 2007] [error] [client 0.0.0.0] PHP Notice: Use of undefined constant curl_init - assumed 'curl_init' in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\catalog\\admin\\update_currencies.php on line 38 [Tue Nov 06 13:16:47 2007] [error] [client 0.0.0.0] PHP Notice: Use of undefined constant file_get_contents - assumed 'file_get_contents' in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\catalog\\admin\\update_currencies.php on line 38 [Tue Nov 06 13:16:47 2007] [error] [client 0.0.0.0] PHP Notice: Use of undefined constant file_get_contents - assumed 'file_get_contents' in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\catalog\\admin\\update_currencies.php on line 76 [Tue Nov 06 13:17:47 2007] [error] [client 0.0.0.0] PHP Warning: file_get_contents(http://currencysource.com/RSS/EUR.xml) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\r\n in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\catalog\\admin\\update_currencies.php on line 77 [Tue Nov 06 13:17:47 2007] [error] [client 0.0.0.0] PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\catalog\\admin\\update_currencies.php on line 77 Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 6, 2007 Share Posted November 6, 2007 The <? is a shorthand method that is not 100% compatible so it shouldn't be used. The errors are saying the script couldn't connect to the server it is using to get the updates from so it is timing out. I tried it here and it works fine. Maybe it is something on your server that is preventing it? Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
babsy Posted November 6, 2007 Share Posted November 6, 2007 The <? is a shorthand method that is not 100% compatible so it shouldn't be used. The errors are saying the script couldn't connect to the server it is using to get the updates from so it is timing out. I tried it here and it works fine. Maybe it is something on your server that is preventing it? Jack Hea Jack, Thanks again for your reply. I'll try on a diffent test PC later... as you say it could be a security setting on this server. will keep you posted thanks, Babsy Quote Link to comment Share on other sites More sharing options...
KandyEyedDancer Posted November 17, 2007 Share Posted November 17, 2007 This might be a stupid question, but I don't go into the admin section of my site every day....does your contribution automatically update the currency values? Does OSC do this itself? Or do I have to do updates manually every day to keep up with the changing exchange rates? Quote Link to comment Share on other sites More sharing options...
♥geoffreywalton Posted November 17, 2007 Share Posted November 17, 2007 A cron job can be set up to run at the interval set by you. so you can have the rates converted hourly, daily every other minute on alternate days. A link to how to set up cron jobs is mentioned earlier in this thread. Quote Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile Virus Threat Scanner My Contributions Basic install answers. Click here for Contributions / Add Ons. UK your site. Site Move. Basic design info. For links mentioned in old answers that are no longer here follow this link Useful Threads. If this post was useful, click the Like This button over there ======>>>>>. Link to comment Share on other sites More sharing options...
Irin Posted December 3, 2007 Share Posted December 3, 2007 Hello, I'm using the Automatic Currency Value Updater 0.6 by dynamoeffects. I have a problem with scheduling the automatic currency updates through the phpJobScheduler. I set the scheduler to run the /admin/update_currencies.php every 3 hours. The problem is the currencies are not updated even though the scheduler fires the script. The error-log shows: Script: /admin/update_currencies.php Execution time: 0.17527 seconds via PHP CURL Output: * NO data There is no problem with manual currency updates through the Localization box in admin panel. Does anybody have successfully set the automatic updates through either phpJobScheduler or cron? I'd appreciate any help. Quote Link to comment Share on other sites More sharing options...
babsy Posted March 23, 2008 Share Posted March 23, 2008 Hello, I'm using the Automatic Currency Value Updater 0.6 by dynamoeffects. I have a problem with scheduling the automatic currency updates through the phpJobScheduler. I set the scheduler to run the /admin/update_currencies.php every 3 hours. The problem is the currencies are not updated even though the scheduler fires the script. The error-log shows: Script: /admin/update_currencies.php Execution time: 0.17527 seconds via PHP CURL Output: * NO data There is no problem with manual currency updates through the Localization box in admin panel. Does anybody have successfully set the automatic updates through either phpJobScheduler or cron? I'd appreciate any help. I had the automatic updates running fine for about 2 months, great job! I ran it in cron as follows:- /usr/bin/php -q /home/mywebsite/public_html/catalog/admin/update_currencies.php but now i get the following error, currencysource.com must have change the website <br /> <b>Warning</b>: file_get_contents(http://currencysource.com/RSS/EUR.xml) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in <b>/home/mywebsite/public_html/catalog/admin/update_currencies.php</b> on line <b>77</b><br /> Quote Link to comment Share on other sites More sharing options...
babsy Posted March 27, 2008 Share Posted March 27, 2008 I had the automatic updates running fine for about 2 months, great job!I ran it in cron as follows:- /usr/bin/php -q /home/mywebsite/public_html/catalog/admin/update_currencies.php but now i get the following error, currencysource.com must have change the website <br /> <b>Warning</b>: file_get_contents(http://currencysource.com/RSS/EUR.xml) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in <b>/home/mywebsite/public_html/catalog/admin/update_currencies.php</b> on line <b>77</b><br /> Problem fixed itself, currencysource.com must have sorted out Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.