<?php require_once dirname(__FILE__) . '/../../../lib/common.lib.php'; require_once dirname(__FILE__) . '/../../config.inc.php'; session_start(); $getinfo = $_SESSION[$rpc_client]->getinfo(); $newest_hash = $_SESSION[$rpc_client]->getblockhash($getinfo['blocks']); $newest_block = $_SESSION[$rpc_client]->getblock($newest_hash); rpc_error_check(); $block[0] = $newest_block; $txs = array(); echo '<h2>Latest Blocks</h2> <table class="table table-striped"> <tr> <th>Number</th> <th>Time</th> <th>Difficulty</th> <th>Nonce</th> <th>Transactions</th> <th>Size (kB)</th> </tr>'; echo "<tr><td><a href='./?block=" . $newest_block['hash'] . "'>" . $newest_block['height'] . "</a></td><td>" . date("Y-m-d h:i A e", $newest_block['time']) . "</td><td>" . $newest_block['difficulty'] . "</td><td>" . $newest_block['nonce'] . "</td><td>" . count($newest_block['tx']) . "</td><td>" . round($newest_block['size'] / 1024, 2) . "</td></tr>"; foreach ($newest_block['tx'] as $key => $value) { $txs[] = $value; } for ($i = 1; $i < 5; $i++) { $block[$i] = $_SESSION[$rpc_client]->getblock($block[$i - 1]['previousblockhash']); echo "<tr><td><a href='./?block=" . $block[$i]['hash'] . "'>" . $block[$i]['height'] . "</a></td><td>" . date("Y-m-d h:i A e", $block[$i]['time']) . "</td><td>" . $block[$i]['difficulty'] . "</td><td>" . $block[$i]['nonce'] . "</td><td>" . count($block[$i]['tx']) . "</td><td>" . round($block[$i]['size'] / 1024, 2) . "</td></tr>"; foreach ($block[$i]['tx'] as $key => $value) { $txs[] = $value;
//////////////////////////////////////////// if (empty($_GET['arg1'])) { die('address not specified'); } else { $address = preg_replace("/[^a-z0-9]/i", '', $_GET['arg1']); $confs = empty($_GET['arg2']) ? 1 : (int) $_GET['arg2']; $ainfo = $_SESSION[$rpc_client]->listbalances($confs, array($address)); unset($ainfo[0]['ours']); unset($ainfo[0]['account']); header('Content-Type: application/json'); echo json_encode($ainfo[0]); exit; } case 'blockinfo': //////////////////////////////////////////// if (empty($_GET['arg1'])) { die('block hash not specified'); } else { $block = $_SESSION[$rpc_client]->getblock($_GET['arg1']); header('Content-Type: application/json'); echo json_encode($block); exit; } default: //////////////////////////////////////////// die('unknown command'); } if (rpc_error_check() && $result !== '') { echo $result; } }
<h1>Raw Block</h1> <br /> <?php $block_id = preg_replace("/[^a-f0-9]/", '', strtolower($_GET['rawblock'])); $raw_block = $_SESSION[$rpc_client]->getblock($block_id); if (rpc_error_check(false)) { echo '<pre>' . json_encode($raw_block, JSON_PRETTY_PRINT) . '</pre>'; }
} } elseif (isset($_GET['block'])) { $bhash = preg_replace("/[^a-f0-9]/", '', strtolower($_GET['block'])); $block = $_SESSION[$rpc_client]->getblock($bhash); if (!empty($block)) { $chash = $_SESSION[$rpc_client]->getblockhash($block['height']); if ($bhash === $chash) { $chain_info = "<sup class='main_info'>[main chain]</sup>"; } else { $chain_info = "<sup class='orphan_info'>[orphan chain]</sup>"; } } else { $break = true; } } if (!isset($break) || rpc_error_check(false)) { echo "<h1><a href='./?b=" . $block['height'] . "'>Block #" . $block['height'] . "</a> {$chain_info}</h1>"; echo "<div class='row-fluid'><div class='span5'>"; echo "<h3>Summary:</h3><table class='table table-striped table-condensed'>"; echo "<tr><td><b>Version:</b></td><td>" . $block['version'] . "</td></tr>"; echo "<tr><td><b>Size:</b></td><td>" . round($block['size'] / 1024, 2) . " kB</td></tr>"; echo "<tr><td><b>Transactions:</b></td><td>" . count($block['tx']) . "</td></tr>"; echo "<tr><td><b>Confirmations:</b></td><td>" . $block['confirmations'] . "</td></tr>"; echo "<tr><td><b>Difficulty:</b></td><td>" . $block['difficulty'] . "</td></tr>"; echo "<tr><td><b>Nonce:</b></td><td>" . $block['nonce'] . "</td></tr>"; echo "<tr><td><b>Timestamp:</b></td><td>" . date("Y-m-d h:i:s A e", $block['time']) . "</td></tr>"; echo "</table>"; echo '</div><div class="span7">'; echo '<h3>Hashes:</h3><table class="table table-striped">'; if (isset($block['previousblockhash'])) { echo "<tr><td><b>Previous Block:</b></td><td><a href='./?block=" . $block['previousblockhash'] . "'>" . $block['previousblockhash'] . "</a></td></tr>";