102 lines
2.5 KiB
PHP
102 lines
2.5 KiB
PHP
|
<?php
|
|||
|
|
|||
|
use Core\Config;
|
|||
|
use Core\Db;
|
|||
|
|
|||
|
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>.
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
*/
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(?!) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
Db::sql('update stats set transfers = 100 where transfers < 200');
|
|||
|
|
|||
|
function getCurs()
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> XML
|
|||
|
$xml = new DOMDocument();
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$url = 'https://www.cbr.ru/scripts/XML_daily.asp?date_req=' . date('d.m.Y');
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xml <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (!$xml->load($url)) {
|
|||
|
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xml <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false
|
|||
|
return false;
|
|||
|
}
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$result = [];
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xml
|
|||
|
$root = $xml->documentElement;
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> 'Valute' <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$items = $root->getElementsByTagName('Valute');
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> 'Valute' <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
foreach ($items as $item) {
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$code = $item->getElementsByTagName('CharCode')->item(0)->nodeValue;
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$value = $item->getElementsByTagName('Value')->item(0)->nodeValue;
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$nominal = $item->getElementsByTagName('Nominal')->item(0)->nodeValue;
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$result[$code] = round(str_replace(',', '.', $value), 5) / $nominal;
|
|||
|
}// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
return $result;
|
|||
|
}
|
|||
|
|
|||
|
$get = getCurs();
|
|||
|
if (Config::get('curency_name') === 'RUB') {
|
|||
|
$curency = Config::get('curency_value');
|
|||
|
} else {
|
|||
|
$curency = round($get[Config::get('curency_name')] * Config::get('curency_value'), 4);
|
|||
|
}
|
|||
|
|
|||
|
if ($get['USD'] > 0) {
|
|||
|
$price = [
|
|||
|
'AUD',
|
|||
|
'AZN',
|
|||
|
'AMD',
|
|||
|
'BYR',
|
|||
|
'BGN',
|
|||
|
'BRL',
|
|||
|
'HUF',
|
|||
|
'KRW',
|
|||
|
'DKK',
|
|||
|
'USD',
|
|||
|
'EUR',
|
|||
|
'INR',
|
|||
|
'KZT',
|
|||
|
'CAD',
|
|||
|
'KGS',
|
|||
|
'CNY',
|
|||
|
'LVL',
|
|||
|
'LTL',
|
|||
|
'MDL',
|
|||
|
'RON',
|
|||
|
'TMT',
|
|||
|
'NOK',
|
|||
|
'PLN',
|
|||
|
'XDR',
|
|||
|
'SGD',
|
|||
|
'TJS',
|
|||
|
'TRY',
|
|||
|
'UZS',
|
|||
|
'UAH',
|
|||
|
'GBP',
|
|||
|
'CZK',
|
|||
|
'SEK',
|
|||
|
'CHF',
|
|||
|
'ZAR',
|
|||
|
'JPY',
|
|||
|
];
|
|||
|
$r = '';
|
|||
|
foreach ($price as $value) {
|
|||
|
if (!$get[$value]) {
|
|||
|
continue;
|
|||
|
}
|
|||
|
$r .= ',`' . $value . '`="' . $get[$value] . '"';
|
|||
|
}
|
|||
|
|
|||
|
Db::sql('insert into bank_table set time = unix_timestamp(), cur = ?, data = ?', [$curency, date('d.m.Y') . $r]);
|
|||
|
}
|