3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /* Vircurex API Auto trader - functions.php Written by: Frozennova Version 1.1 Date: 23/12/2013 */ date_default_timezone_set("UTC"); function balance($cur,$user_name,$secret_word) { $t = date("Y-m-d\TH:i:s", time()); $year = date("Y", time()); $trx_id = hash("sha256", $t."-".rand()); // $tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";get_balance;" . $cur); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/get_balance.json?account=$user_name&id=$trx_id&token=$tok&timestamp=$t&currency=" .$cur); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); $resp = json_decode($resp,true); if (!isset($resp['availablebalance'])) { $resp['availablebalance'] = "0.00"; } return $resp['availablebalance']; } function get_sell_price($cur,$user_name,$secret_word) { $t = date("Y-m-d\TH:i:s", time()); $year = date("Y", time()); $trx_id = hash("sha256", $t."-".rand()); // $tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";get_balance;" . $cur); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/get_highest_bid.json?base=" . $cur . "&alt=BTC"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); $resp = json_decode($resp,true); return $resp['value']; } function get_buy_price($cur,$user_name,$secret_word) { $t = date("Y-m-d\TH:i:s", time()); $year = date("Y", time()); $trx_id = hash("sha256", $t."-".rand()); // $tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";get_balance;" . $cur); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/get_lowest_ask.json?base=" . $cur . "&alt=BTC"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); $resp = json_decode($resp,true); return $resp['value']; } function buy_coin($cur,$qty,$price,$user_name,$secret_word) { $t = date("Y-m-d\TH:i:s", time()); $year = date("Y", time()); $trx_id = hash("sha256", $t."-".rand()); // $tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";create_order;buy;$qty;$cur;$price;btc"); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/create_order.json?account=$user_name&id=$trx_id&token=$tok&timestamp=$t&ordertype=buy&amount=$qty&currency1=$cur&unitprice=$price&currency2=btc"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); return $resp; } function sell_coin($cur,$price,$qty,$user_name,$secret_word) { $t = date("Y-m-d\TH:i:s", time()); $year = date("Y", time()); $trx_id = hash("sha256", $t."-".rand()); // $tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";create_order;sell;$qty;$cur;$price;btc"); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/create_order.json?account=$user_name&id=$trx_id&token=$tok&timestamp=$t&ordertype=sell&amount=$qty&currency1=$cur&unitprice=$price&currency2=btc"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); return $resp; } function get_orders($user_name,$secret_word) { $t = date("Y-m-d\TH:i:s", time()); $year = date("Y", time()); $trx_id = hash("sha256", $t."-".rand()); // $tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";read_orders"); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/read_orders.json?account=$user_name&id=$trx_id&token=$tok&timestamp=$t&otype=0"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); $resp = json_decode($resp,true); $i = 0; if (isset($resp)) { foreach($resp as $val) { if (isset($val['orderid'])) { $unreleased_orders[$i] = $val['orderid']; $i++; } } } if(isset($unreleased_orders)){ return $unreleased_orders; } } function release_order($orderid,$user_name,$secret_word) { $t = date("Y-m-d\TH:i:s", time()); $year = date("Y", time()); $trx_id = hash("sha256", $t."-".rand()); // $tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";release_order;$orderid"); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/release_order.json?account=$user_name&id=$trx_id&token=$tok&timestamp=$t&orderid=$orderid"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); $resp = json_decode($resp,true); return $resp; } function read_order($orderid,$user_name,$secret_word) { $t = date("Y-m-d\TH:i:s", time()); $year = date("Y", time()); $trx_id = hash("sha256", $t."-".rand()); // $tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";read_order;$orderid"); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/read_order.json?account=$user_name&id=$trx_id&token=$tok&timestamp=$t&otype=0&orderid=$orderid"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); $resp = json_decode($resp,true); return $resp['order']; } ?>
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0