It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
require_once("bitcoinecdsa.php");
use BitcoinPHP\BitcoinECDSA\BitcoinECDSA;
function btc_balance($public_key)
{
$balance=curl("https://blockchain.info/q/getreceivedbyaddress/$public_key?confirmations=1");
if(is_numeric($balance))
{
$balance=btc8($balance);
return $balance;
}
return (int)0;
}
function btc_price($unit)
{
$cachefile = "cache/btc_usd.txt";
if($unit=='tl') { $cachefile = "cache/btc_tl.txt"; }
elseif($unit=='eur') { $cachefile = "cache/btc_eur.txt"; }
if (file_exists($cachefile) && (time() - 600 < filemtime($cachefile))) {
return file_get_contents($cachefile);
}
if($unit=='eur')
{
$balance=curl("http://preev.com/pulse/units:btc+eur/sources:btce");
}
else { $balance=curl("http://preev.com/pulse/units:btc+try/sources:bitstamp"); }
$balance=@json_decode($balance,1);
if(is_array($balance))
{
if($unit!='eur')
{
if(isset($balance['btc']['usd']['bitstamp']['last']))
{
//print_r($balance);
$usd_price=intval($balance['btc']['usd']['bitstamp']['last']);
$tl_price=intval(1/$balance['try']['usd']['other']['last']*$usd_price);
fwrite(fopen('cache/btc_usd.txt', 'w'), $usd_price);
fwrite(fopen('cache/btc_tl.txt', 'w'), $tl_price);
if($unit=='tl') { return $tl_price; }
return $usd_price;
}
}
else {
if(isset($balance['btc']['eur']['btce']['last']))
{
$eur_price=(int)$balance['btc']['eur']['btce']['last'];
fwrite(fopen('cache/btc_eur.txt', 'w'), $eur_price);
return $eur_price;
}
}
}
return file_get_contents($cachefile);
}
function curl($link, $post = null, $retries = 10){
$curl = curl_init($link);
if(is_resource($curl) === true){
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
if(isset($post) === true){
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, (is_array($post) === true) ? http_build_query($post, "", "&"): $post);
}
$result = false;
while(($result === false) && (--$retries > 0)){
$result = curl_exec($curl);
}
curl_close($curl);
}
return $result;
}
function check_if_paid_bitcoin($public_key,$fee)
{
$balance=btc_balance($public_key);
// 0.0002 transaction fee
if(($balance-0.0002)>=$fee)
{
return true;
}
return false;
}
function needs_to_pay_bitcoin($public_key,$fee)
{
$balance=btc_balance($public_key);
return $fee-$balance;
}
function btc8($val)
{
$a = bcmul($val, "1.0", 1);
return bcdiv($a, "100000000", 8);
}
function is_user_paid($uniqueid)
{
global $mysqli;
$stmt = $mysqli->prepare("SELECT is_paid,btc_public_key,fee FROM payments WHERE userid=?");
$stmt->bind_param("s", $uniqueid);
$stmt->execute();
$stmt->bind_result($is_paid,$btc_public_key,$fee);
$stmt->fetch();
return check_if_paid_bitcoin($btc_public_key,$fee);
}
function generate_bitcoin_wallet()
{
$bitcoinECDSA = new BitcoinECDSA();
$bitcoinECDSA->generateRandomPrivateKey();
return array($bitcoinECDSA->getWif(),$bitcoinECDSA->getAddress());
}
function fetch($result)
{
$array = array();
if($result instanceof mysqli_stmt)
{
$result->store_result();
$variables = array();
$data = array();
$meta = $result->result_metadata();
while($field = $meta->fetch_field())
$variables[] = &$data[$field->name]; // pass by reference
call_user_func_array(array($result, 'bind_result'), $variables);
$i=0;
while($result->fetch())
{
$array[$i] = array();
foreach($data as $k=>$v)
$array[$i][$k] = $v;
$i++;
}
}
elseif($result instanceof mysqli_result)
{
while($row = $result->fetch_assoc())
$array[] = $row;
}
return $array;
}
function percent($a,$b){
$c = $a / 100;
return floor($b / $c);
}