Skip to content

Instantly share code, notes, and snippets.

@blackout314
Created November 27, 2016 13:28
Show Gist options
  • Save blackout314/c2bee5c1a64566d1d1a99654aa72b02e to your computer and use it in GitHub Desktop.
Save blackout314/c2bee5c1a64566d1d1a99654aa72b02e to your computer and use it in GitHub Desktop.
BitMixer Posts Count and EUR calculator
<?php
function extractValue($html) {
$v = explode('New posts:</td><td>',$html);
return explode('</td>', $v[1])[0];
}
function takeBtcTicker() {
$url = 'https://www.bitstamp.net/api/ticker/';
$url = 'https://blockchain.info/ticker';
$f = file_get_contents($url);
return json_decode($f);
}
function signaturePostsCount($uid) {
$url = 'https://bitmixer.io/signature.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"uid=".$uid);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
if ($server_output) {
return extractValue($server_output);
} else {
return 0;
}
}
function withLastEURValue() {
return takeBtcTicker()->EUR->last;
}
function calculatePaidPosts($btcEurValue, $posts) {
$signaturePay = 0.0007;
$total = $btcEurValue * $signaturePay * $posts;
return array(
'posts' => $posts,
'btc' => $btcEurValue,
'total' => $total,
);
}
$result = calculatePaidPosts( withLastEURValue(), signaturePostsCount($YOUR_UID_NUMBER_HERE) );
echo 'POSTS '.$result['posts'] .' x '. $result['btc'] .'E/B -> '. $result['total'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment