3 * Table Definition for core_curr_rate
5 require_once 'DB/DataObject.php';
7 class Pman_Core_DataObjects_Core_curr_rate extends DB_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'core_curr_rate'; // table name
19 /* the code above is auto generated do not remove the tag below */
22 function applyFilters($q, $au, $roo)
28 * current rate fetching
30 * - we used to do historical rates... (but sources keep disappearing for that..)
32 * this just get's the current rates from the ecb..
41 // how often do we need to know this..?
44 if (!empty($this->rates)) {
47 // load our default rates to start with..
48 $dom = simplexml_load_file(dirname(__FILE__).'/eurofxref-daily.xml');
49 $this->rates['EUR'] = 1.0;
50 $this->rates['TWD'] = 46.7008412;
51 $this->rates['VND'] = 26405.3;
54 foreach($dom->Cube->Cube->Cube as $c) {
55 //echo '<PRE>';print_r($c );
56 $this->rates[(string)$c['currency']] = (string)$c['rate'];
58 $this->rates['RMB'] = $this->rates['CNY'] ;
59 // now try loading from latest..
60 $target = ini_get('session.save_path').'/eurofxref-daily.xml';
62 if (!file_exists($target) || filemtime($target) < (time() - 60*60*24)) {
64 $f = @file_get_contents('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
68 file_put_contents($target,$f);
71 $dom = simplexml_load_file($target);
72 $this->rates['EUR'] = 1.0;
73 $this->rates['TWD'] = 46.7008412;
74 $this->rates['VND'] = 26405.3;
76 foreach($dom->Cube->Cube->Cube as $c) {
77 //echo '<PRE>';print_r($c );
78 $this->rates[(string)$c['currency']] = (string)$c['rate'];
80 $this->rates['RMB'] = $this->rates['CNY'] ;