Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/units/helpers/frny_currency_rates.php
Show All 20 Lines | |||||
parent::__construct(); | parent::__construct(); | ||||
} | } | ||||
function GetRatesData() | function GetRatesData() | ||||
{ | { | ||||
/** @var kCurlHelper $curl_helper */ | /** @var kCurlHelper $curl_helper */ | ||||
$curl_helper = $this->Application->recallObject('CurlHelper'); | $curl_helper = $this->Application->recallObject('CurlHelper'); | ||||
$curl_helper->followLocation = true; | |||||
for($i = 0; $i < 10; $i++) | for($i = 0; $i < 10; $i++) | ||||
{ | { | ||||
$time = adodb_mktime() - $i * 3600 * 24; | $time = adodb_mktime() - $i * 3600 * 24; | ||||
$source_file = sprintf($this->RateSource, adodb_date('Y-m-d', $time)); | $source_file = sprintf($this->RateSource, adodb_date('Y-m-d', $time)); | ||||
$xml = $curl_helper->Send($source_file); | $xml = $curl_helper->Send($source_file); | ||||
if ( !$curl_helper->isGoodResponseCode() || strlen($xml) == 0 ) { | |||||
continue; | |||||
} | |||||
$xml_parser = xml_parser_create(); | $xml_parser = xml_parser_create(); | ||||
xml_parse_into_struct($xml_parser, $xml, $struct, $index); | xml_parse_into_struct($xml_parser, $xml, $struct, $index); | ||||
foreach($struct as $element) | foreach($struct as $element) | ||||
{ | { | ||||
if($element['tag'] == 'FRBNY:DATASET') | if($element['tag'] == 'FRBNY:DATASET') | ||||
{ | { | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |