Перейти к содержимому


Национальный Банк Узбекистана


  • Авторизуйтесь для ответа в теме
В теме одно сообщение

#1 Ulugbek

Ulugbek

    Новичок

  • Пользователи
  • Pip
  • 1 сообщений

Отправлено 10 сентября 2011 - 19:08

Здравствуйте, спасибо за отличный модуль.
Пожалуйста помогите мне, что и как нужно сделать чтоб можно было парсит курсы НБУз.
http://informer.uzre...aluta.fgi?lan=u

#2 admin

admin

    Администратор

  • Администраторы
  • 377 сообщений

Отправлено 11 сентября 2011 - 16:30

<?php
/**
* @author  	Darang
* @date    	11-September-2011
* @copyright   (c)2011 JExt.biz
*/
// no direct access
defined ( '_JEXEC' ) or die ( 'Restricted access' );
/**
* Official exchange rates of the bank of Uzbekistan
*/
class currency_data_uzreport extends currency_data {

function __construct() {
  parent::__construct ();
  $this->url = "http://informer.uzreport.com/xml_valuta.fgi?lan=u";
  $this->bank_name = "НБ Узбекистана";
  $this->bank_url = "http://currency.uzreport.com";
  $this->currency_name = " ";
  $this->before_flag = FALSE;
}

function get_array($xml, $day = '', $replace_currency_array) {
 
  // Handle no data received error
  if (! isset ( $xml->document->block )) {
   $error ['error'] = 1;
   return $error;
  }
 
  // Save currencies' rates in an associative array indexed by currency 3 char code
  $rates = array (); // array to store currencies exchange rates
  $rates ['date'] = $xml->document->block[0]->data [0]->data ();
  $data = $xml->document->block;
 
  foreach ( $data as $dt ) {
   $code = $dt->valyuta [0]->data ();
   // Store data for selected by user currencies only, if they are set
   if (empty ( $this->currencies ) || in_array ( $code, $this->currencies )) {
	$rates ['currency'] [$code] ['scale'] = 1; // units
	// Set currency name (array with replacement rules will be searched for the ISO code)
	$rates ['currency'] [$code] ['name'] = parent::replace_currency_name ( $dt->valyuta [0]->data (), $code, $replace_currency_array );
	$rates ['currency'] [$code] ['rate'] = $dt->kurs [0]->data (); // exchange rate
	$rates ['currency'] [$code] ['change'] = $dt->izmeneniya [0]->data (); // exchange rate
   }
  }
 
  // Save additional info (only one time)
  if ($day == 'today' || $this->before_flag == FALSE) {
   $rates ['info'] = array ("bank_name" => $this->bank_name, "bank_url" => $this->bank_url, "currency_name" => $this->currency_name );
  }
 
  return $rates;
}

}