Guest User

MtGox Calculator for BTCguild

a guest
Aug 26th, 2011
1,060
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     //first fetch the current rate from MtGox
  3.         $ch = curl_init('https://mtgox.com/api/0/data/ticker.php');
  4.         curl_setopt($ch, CURLOPT_REFERER, 'Mozilla/5.0 (compatible; MtGox PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
  5.         curl_setopt($ch, CURLOPT_USERAGENT, "CakeScript/0.1");
  6.         curl_setopt($ch, CURLOPT_HEADER, 0);
  7.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  9.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  10.             $mtgoxjson = curl_exec($ch);
  11.             curl_close($ch);
  12.        
  13.     //decode from an object to array
  14.         $output_mtgox = json_decode($mtgoxjson);
  15.         $output_mtgox_1 = get_object_vars($output_mtgox);
  16.         $mtgox_array = get_object_vars($output_mtgox_1['ticker']);
  17.  
  18.        
  19.     //next, BTC Guild API
  20.         $ch = curl_init('http://www.btcguild.com/api.php?api_key=' . $_GET['api_key'] . '');
  21.         curl_setopt($ch, CURLOPT_REFERER, 'Mozilla/5.0 (compatible; BTCGuild PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
  22.         curl_setopt($ch, CURLOPT_USERAGENT, "CakeScript/0.1");
  23.         curl_setopt($ch, CURLOPT_HEADER, 0);
  24.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  25.             $btcjson = curl_exec($ch);
  26.             curl_close($ch);
  27.            
  28.  
  29.             $output_btc = json_decode($btcjson);
  30.             $output_btc_1 = get_object_vars($output_btc);
  31.             $btc_array = get_object_vars($output_btc_1['user']);
  32. ?>
  33. <html>
  34.     <head>
  35.         <title>MtGox calculator for BTCguild</title>
  36.     </head>
  37.     <body>
  38.         <h2>Live Info</h2>
  39.         Right now MtGox is trading at <b>$<?php echo $mtgox_array['buy']; ?></b> for 1 Bitcoin.</br />
  40.         You currently have <b><?php echo $btc_array['confirmed_rewards']; ?></b> In confirmed rewards on BTC Guild.<br />
  41.         That means, you have <b>~$<?php echo round($mtgox_array['buy'] * $btc_array['confirmed_rewards'], 2); ?></b> in the pool.<br />
  42.         <h2>Estimates</h2>
  43.         Next round you will make <b>~$<?php echo round($mtgox_array['buy'] * $btc_array['estimated_rewards'], 2); ?></b>
  44.             (<?php echo $btc_array['estimated_rewards']; ?> BTC)<br />
  45.         In the last 24 hours, you have made <b>~$<?php echo round($mtgox_array['buy'] * $btc_array['24hour_rewards'], 2); ?></b> at the current exchange rate.
  46.             (<?php echo $btc_array['24hour_rewards']; ?> BTC)<br />
  47.         Since you have started mining with BTC Guild, you have made <b>~$<?php echo round($mtgox_array['buy'] * $btc_array['payouts'], 2); ?></b> at the current exchange rate.
  48.             (<?php echo $btc_array['payouts']; ?> BTC)<br />
  49.     </body>
  50. </html>
RAW Paste Data