Esempio n. 1
0
<?
require_once('/var/www/midas/root/private/config.php');
require_once('/var/www/midas/root/private/init/mysql.php');

function cryptsy_price($id, $name){
	$i = @json_decode(file_get_contents("http://pubapi1.cryptsy.com/api.php?method=singlemarketdata&marketid=".$id), true);
	$pubapi = 'pubapi1';
	if($i == NULL){
		$i = json_decode(file_get_contents("http://pubapi2.cryptsy.com/api.php?method=singlemarketdata&marketid=".$id), true);
		$pubapi = 'pubapi2';
	}
	return ['price' => $i["return"]["markets"][$name]["lasttradeprice"], 'vol' => $i["return"]["markets"][$name]["volume"]];
}

$btc = cryptsy_price(2, 'BTC');
$dash = cryptsy_price(155, 'DRK');

$usd_dash = round($btc['price']*$dash['price'], 2);

$cur_cb = file_get_contents ("http://www.cbr.ru/scripts/XML_daily.asp");
preg_match_all("#<Valute ID=\"R01235\">.*<CharCode>(.*)</CharCode>.*<Value>(.*)</Value>.*</Valute>#sU", $cur_cb, $_usd);  
$usd = round(str_replace(',', '.', $_usd[2][0]), 2);

if(empty($usd)) die();

$data = ['rur' => $usd, 'dash_usd' => $usd_dash];

$query = $db->prepare("SELECT * FROM `params` WHERE `key` = 'rur'");
$query->execute();
if($query->rowCount() != 1){
	$query = $db->prepare("INSERT INTO `params` (`key`, `value`) VALUES ('rur', :value)");
Esempio n. 2
0
	$i = json_decode(file_get_contents("https://cex.io/api/ticker/DRK/BTC"), true);
	$j = json_decode(file_get_contents("https://cex.io/api/ticker/DRK/USD"), true);
	$v = json_decode(file_get_contents("https://cex.io/api/ticker/DRK/LTC"), true);
	return ['price' => $i["ask"], 'vol' => $i["volume"]+$j["volume"]+$v["volume"]];
}

function usecryptos_price(){
	$i = json_decode(file_get_contents("https://usecryptos.com/jsonapi/ticker/dash-btc"), true);
	//$j = json_decode(file_get_contents("https://usecryptos.com/jsonapi/ticker/dash-usd"), true);
	$k = json_decode(file_get_contents("https://usecryptos.com/jsonapi/ticker/dash-eur"), true);
	//return ['price' => $i["lastPrice"], 'vol' => $i["priVolume"]+$j["priVolume"]+$k["priVolume"]];
	return ['price' => $i["lastPrice"], 'vol' => $i["priVolume"]+$k["priVolume"]];
}

$btc = cryptsy_price(2, 'BTC');
$dash = cryptsy_price(155, 'DRK', 'lolka!');
$p_dash = poloniex_price('BTC_DASH');
$b_dash = bter_price();
$bi_dash = bitfinex_price();
$ce_dash = cex_price();
$bit_dash = bittrex_price();
$use_dash = usecryptos_price();

$c_val = round($dash['price']*$dash['vol']*$btc['price']);
$c_price= round($dash['price']*$btc['price'], 2);

$p_val = round($p_dash['vol']*$btc['price']);
$p_price= round($p_dash['price']*$btc['price'], 2);

$b_val = round($b_dash['vol']*$btc['price']);
$b_price= round($b_dash['price']*$btc['price'], 2);