X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FCore_curr_rate.php;h=20d8f0fab9ce881dd7ba28d6408187e0aa6f6c19;hb=56a975bed5a4e7904a8457a75b3df2b8dd2928f5;hp=f8a33f9eb63283004ae4f259cf92a38bcfa8f407;hpb=8697465fab1db55eb102cb2faf6ea68e2ae1cd6e;p=Pman.Core diff --git a/DataObjects/Core_curr_rate.php b/DataObjects/Core_curr_rate.php index f8a33f9e..20d8f0fa 100644 --- a/DataObjects/Core_curr_rate.php +++ b/DataObjects/Core_curr_rate.php @@ -47,46 +47,45 @@ class Pman_Core_DataObjects_Core_curr_rate extends DB_DataObject return; } - - - - - if (!empty($this->rates)) { - return true; - } // load our default rates to start with.. - $dom = simplexml_load_file(dirname(__FILE__).'/eurofxref-daily.xml'); - $this->rates['EUR'] = 1.0; - $this->rates['TWD'] = 46.7008412; - $this->rates['VND'] = 26405.3; + $dom = simplexml_load_file(dirname(__FILE__).'/../eurofxref-daily.xml'); + $rates['EUR'] = 1.0; + $rates['TWD'] = 46.7008412; + $rates['VND'] = 26405.3; foreach($dom->Cube->Cube->Cube as $c) { //echo '
';print_r($c );
-            $this->rates[(string)$c['currency']] = (string)$c['rate'];
+            $rates[(string)$c['currency']] = (string)$c['rate'];
         }
-        $this->rates['RMB'] = $this->rates['CNY'] ;
-        // now try loading from latest..
-        $target = ini_get('session.save_path').'/eurofxref-daily.xml';
+        $rates['RMB'] = $rates['CNY'] ;
+        
         
-        if (!file_exists($target) || filemtime($target) < (time() - 60*60*24)) {
-            // this may fail...
-            $f = @file_get_contents('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
-            if (!strlen($f)) {
-                return;
-            } 
-            file_put_contents($target,$f);
         
-        } 
+        // now try loading from latest..
+       
+             // this may fail...
+        $f = @file_get_contents('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
+        if (!strlen($f)) {
+            return false;
+        }
+        
         $dom = simplexml_load_file($target);
-        $this->rates['EUR'] = 1.0;
-        $this->rates['TWD'] = 46.7008412;
-        $this->rates['VND'] = 26405.3;
+        $rates['EUR'] = 1.0;
+        $rates['TWD'] = 46.7008412;
+        $rates['VND'] = 26405.3;
        
         foreach($dom->Cube->Cube->Cube as $c) {
            //echo '
';print_r($c );
-            $this->rates[(string)$c['currency']] = (string)$c['rate'];
+            $rates[(string)$c['currency']] = (string)$c['rate'];
         }
-        $this->rates['RMB'] = $this->rates['CNY'] ;
+        $rates['RMB'] = $rates['CNY'] ;
+        
+        
+        
+        
+        
+        
+        
     }
 }