Jump to content



Photo
- - - - -

Auto Update Currencies


  • Please log in to reply
87 replies to this topic

#21   Jack_mcs

Jack_mcs
  • Members
  • 26,631 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 10 January 2009 - 15:13

It's a server problem. You'll need to talk to your host to see if they will allow it.

Jack

#22   BlindingLight

BlindingLight
  • Members
  • 72 posts
  • Real Name:MR. Ed
  • Gender:Male
  • Location:Sunny Florida

Posted 10 January 2009 - 15:28

It's a server problem. You'll need to talk to your host to see if they will allow it.

Jack


Let's see what they say. Thanks!
Ed

#23   BlindingLight

BlindingLight
  • Members
  • 72 posts
  • Real Name:MR. Ed
  • Gender:Male
  • Location:Sunny Florida

Posted 10 January 2009 - 17:45

It's a server problem. You'll need to talk to your host to see if they will allow it.

Jack


Yes. You were right.
My hosts says "The PHP parameter allow_url_fopen has been disabled in both our PHP4 and PHP5 environments"

"If enabled, allow_url_fopen allows PHP's file functions to retrieve data from remote locations such as an FTP server or web site, and could lead to code injection vulnerabilities. Typically these code injection vulnerabilities occur from improper input filtering when passing user-provided data to PHP functions. Disabling this function will help considerably in stopping your site(s) from being compromised, as well as help thwart the unauthorized use of our servers for abusive or malicious purposes."

I am still adding this info here in case some other people have the same problem.

#24   Jack_mcs

Jack_mcs
  • Members
  • 26,631 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 10 January 2009 - 17:57

If you go to admin->Localization->Currencies and click Update Currencies, does it work?

Jack

#25   markhere

markhere
  • Members
  • 16 posts
  • Real Name:Mark

Posted 11 February 2009 - 16:50

Brilliant Contribution. Very easy to install and does what it says on the box.
Thanks

WWW.Anniedays.2ya.com /smile.gif' class='bbc_emoticon' alt=':)' /> /smile.gif' class='bbc_emoticon' alt=':)' />

#26   oldcelt

oldcelt
  • Members
  • 161 posts
  • Real Name:Ken Wheeler
  • Gender:Male
  • Location:Herefordshire, UK

Posted 25 March 2009 - 16:37

Hi Jack

I've made the code change you suggested (return $nhours; instead of return $ndays;). I have 'HOURS_BETWEEN_UPDATES' , '12' and the Cron job set to 4 hours. It still seems to be unreliable in updating currencies. Sometimes updating and other times claiming it was updated within the specified period when I know it was not.

Ken

#27   Jack_mcs

Jack_mcs
  • Members
  • 26,631 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 25 March 2009 - 17:20

The only way for the code to update the currency is if it gets a valid response from one of the two currency converter sites it uses. There is no way to control if they respond or not. But if you are saying that the script says they were updated and they actually weren't, how are you determining that?

Jack

#28   oldcelt

oldcelt
  • Members
  • 161 posts
  • Real Name:Ken Wheeler
  • Gender:Male
  • Location:Herefordshire, UK

Posted 26 March 2009 - 10:37

The only way for the code to update the currency is if it gets a valid response from one of the two currency converter sites it uses. There is no way to control if they respond or not. But if you are saying that the script says they were updated and they actually weren't, how are you determining that?

Jack


It seems odd that I have three currencies to be updated. Sometimes the script says that two have been updated and one has not because it has been updated within the last time period. Since all three are subject to the same cron and script they should all either be updated or all stamped as updated at the same time shouldn't they?

Ken

#29   Jack_mcs

Jack_mcs
  • Members
  • 26,631 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 26 March 2009 - 11:20

They are all attempted at the same time initially but if the currency converter sites don't return a new rate for all of them, which they won't each time, then the next time the script is ran, only some of them will need to be updated.

Jack

#30   oldcelt

oldcelt
  • Members
  • 161 posts
  • Real Name:Ken Wheeler
  • Gender:Male
  • Location:Herefordshire, UK

Posted 26 March 2009 - 11:38

They are all attempted at the same time initially but if the currency converter sites don't return a new rate for all of them, which they won't each time, then the next time the script is ran, only some of them will need to be updated.

Jack


Ah, fairy nuff.

#31   marleenverbeek

marleenverbeek
  • Members
  • 70 posts
  • Real Name:marleen verbeek

Posted 27 July 2009 - 13:03

Hello all,

I am trying to use this contribution, but I don't understand the CRON job part.

Step 2: Add a cron job. The following syntax may not be correct for your server
(be sure to replace username). If not, you will need to contact your
host to get the correct syntax.

php /home/username/public_html/catalog/admin/auto_update_currencies.php


I never added a cron job, so I need a bit of more explanation. What do I do exactly? Do I fill this in into the address bar of my browser? php /home/username/public_html/catalog/admin/auto_update_currencies.php

My site is on a Apache server. The url is www.willy-condoms.com.

Hope someone can help!

Thanks in advance!

Regards,
Marleen

#32   FIMBLE

FIMBLE
  • Members
  • 6,604 posts
  • Real Name:Nic
  • Gender:Male

Posted 27 July 2009 - 13:20

You are better off asking your host to do it if you are not sure
Nic
Sometimes you're the dog and sometimes the lamp post

My Contributions

#33   sanbikes

sanbikes
  • Members
  • 19 posts
  • Real Name:Carlos

Posted 14 August 2009 - 16:19

I did a test with the script, and I came the following message appears to be an error, ie, the coins have not been updated.

Anyone know tell me how to fix the problem?




Telecartofilia Cards Digers

Currencies Update Report

Currencies for Telecartofilia Cards Digers updated on Fri Aug 14 3:00:17 2009

The exchange rate for Real WAS NOT successfully updated. It was last updated on
The exchange rate for U.S.Dollar WAS NOT successfully updated. It was last updated on
The exchange rate for Euro WAS NOT successfully updated. It was last updated on
The exchange rate for British Pound WAS NOT successfully updated. It was last updated on

#34   Jack_mcs

Jack_mcs
  • Members
  • 26,631 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 14 August 2009 - 16:47

Try clicking on the Update Currencies button in admin->Localization->Currencies. If that doesn't work, the problem is with your server.

Jack

#35   marleenverbeek

marleenverbeek
  • Members
  • 70 posts
  • Real Name:marleen verbeek

Posted 26 October 2009 - 14:10

If your shop offers more than one currency, you need this contribution. With excahnge rates changing daily, at times, it is important to keep them up-to-date. Many, if not most, shop owners are not aware that this needs to be done. This contribution can be ran as a cron job or semi-automatically and will handle the updates for you. The existing Update Currencies contribution uses an external site that has changed their policy which means the updates may not always work. It also uses code that will prevent cron jobs from working on all servers. This contribution uses changed code and the same sites that oscommerce has always used so those problems should not occur.

Jack


Hi Jack,

I installed currency update, but I keep on receiving emails saying:

US Dollar was not updated since it has been updated in the last 24 hours.
Euro was not updated since it has been updated in the last 24 hours.
Pounds was not updated since it has been updated in the last 24 hours.

Why is that? It has never worked.

Thanks,
Marleen

#36   Jack_mcs

Jack_mcs
  • Members
  • 26,631 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 26 October 2009 - 15:09

Try changing this code
$nhours = round($nseconds / 3600); // One hour has 3600 seconds
to this
$nhours = round($nseconds / 3600) * (($ndays > 1) ? $ndays : 1); // One hour has 3600 seconds

Edited by Jack_mcs, 26 October 2009 - 15:10.


#37   proimage

proimage
  • Members
  • 109 posts
  • Real Name:Fabian
  • Gender:Male

Posted 05 December 2009 - 10:27

Hi Jack,

Thanks for all your useful contribs. I having trouble [server side] that doesn't allow the Auto Update Currencies to work properly. Neither, when one clicks update currencies button from the adim section. I had to resolve this issue by altering the localization.php so that the admin/update currencies button, funtions as per following:-

<?php  
	function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {
	
	$alte_url = "http://www.oanda.com/convert/fxdaily";
	$alte_params = 'value=1&redirected=1&exch=' . $code .  '&format=CSV&dest=Get+Table&sel_list=' . $base;
	$alte_user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
	
	$alte_ch = curl_init();
	curl_setopt($alte_ch, CURLOPT_POST,1);   
	curl_setopt($alte_ch, CURLOPT_POSTFIELDS,$alte_params);   
	curl_setopt($alte_ch, CURLOPT_URL,$alte_url);   
	curl_setopt($alte_ch, CURLOPT_SSL_VERIFYHOST, 2);   
	curl_setopt($alte_ch, CURLOPT_USERAGENT, $alte_user_agent);   
	curl_setopt($alte_ch, CURLOPT_RETURNTRANSFER,1);   
	curl_setopt($alte_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	
	$alte_page=curl_exec ($alte_ch);   
	curl_close ($alte_ch);
	
	$page = explode("\n",$alte_page);
	
		$match = array();        
		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) {
	
	$alte_url = "http://www.xe.net/ucc/convert.cgi";
	$alte_params = 'Amount=1&From=' . $from . '&To=' . $to;
	$alte_user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
	
	$alte_ch = curl_init();
	curl_setopt($alte_ch, CURLOPT_POST,1);
	curl_setopt($alte_ch, CURLOPT_POSTFIELDS,$alte_params);
	curl_setopt($alte_ch, CURLOPT_URL,$alte_url);
	curl_setopt($alte_ch, CURLOPT_SSL_VERIFYHOST, 2);
	curl_setopt($alte_ch, CURLOPT_USERAGENT, $alte_user_agent);
	curl_setopt($alte_ch, CURLOPT_RETURNTRANSFER,1);
	curl_setopt($alte_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	
	$alte_page=curl_exec ($alte_ch);
	curl_close ($alte_ch);
	
	$page = explode("\n",$alte_page);
	
		$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;
		}
	}
?>

This works very fine.

Could you instruct me how to amaned your contrib so that it could run as well, basis on the tips from the attached localization.php script.

With best regards

Proimage

#38   Jack_mcs

Jack_mcs
  • Members
  • 26,631 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 05 December 2009 - 11:26

This contribution uses the localization.php so it should work with your changes.

#39   proimage

proimage
  • Members
  • 109 posts
  • Real Name:Fabian
  • Gender:Male

Posted 06 December 2009 - 15:44

Hi Jack,

Thanks for your reply.

I always get this error, by email.

US Dollar was not updated since it has been updated in the last 24 hours.
Euro was not updated since it has been updated in the last 24 hours.
Canada Dollar was not updated since it has been updated in the last 24 hours.
Japan Yen was not updated since it has been updated in the last 24 hours.
United Kingdom Pound was not updated since it has been updated in the last 24 hours.
Australia Dollar was not updated since it has been updated in the last 24 hours.

Then I have to resolve to update the currencies manually by clicking the admin, localization currencies, update button and see that the rates did change.

Still troubling... wish I could have it working.

Regs Proimage

#40   Jack_mcs

Jack_mcs
  • Members
  • 26,631 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 06 December 2009 - 19:22

Try replacing these lines
$nhours = round($nseconds / 3600); // One hour has 3600 seconds

    $nseconds = $nseconds % 3600;

    $nminutes = round($nseconds / 60); // One minute has 60 seconds, duh!

    $nseconds = $nseconds % 60;



    return $ndays;

with these
$nhours = round($nseconds / 3600) * (($ndays > 1) ? $ndays : 1); // One hour has 3600 seconds

    $nseconds = $nseconds % 3600;

    $nminutes = round($nseconds / 60); // One minute has 60 seconds, duh!

    $nseconds = $nseconds % 60;



    return $nhours;