-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpage-blocks.php
57 lines (54 loc) · 1.87 KB
/
page-blocks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
$getinfo = multichain_getinfo();
$highestBlock = $getinfo['blocks'];
$offset = isset($_GET['block']) ? (int)$_GET['block'] : $highestBlock;
if ($offset > $highestBlock) {
$offset = $highestBlock;
}
$chain = $_GET['chain'];
?>
<div class="row">
<div class="col-sm-12">
<h3>Blocks</h3>
<?php
echo <<<HEREDOC
<table class="table table-bordered table-condensed table-break-words table-striped">
<tr><th>Block</th>
<th>Hash</th>
<th>Miner</th>
<th>Time (UTC)</th>
<th>Size</th>
<th>Transactions</th>
</tr>
HEREDOC;
$numBlocksPerPage = 16;
$n = $numBlocksPerPage;
$i = $offset;
while ($i >= 0 && $n--) {
$res = no_displayed_error_result($hash, multichain('getblockhash', $i));
$hashShort = substr($hash, 0, 16);
$res = no_displayed_error_result($block, multichain('getblock', $hash));
$time = gmdate('Y-m-d H:i:s', $block['time']) . " GMT";
$minerShort = substr($block['miner'], 0, 16);
$confirmations = $block['confirmations'];
$size = $block['size'];
$txCount = 0;
foreach ($block['tx'] as $txid) {
$txCount++;
}
$hashUrl = "?chain=" . $chain . "&page=block&hash=" . $hash;
echo "<tr><td>$i</td><td><a href=\"$hashUrl\">$hashShort ...</a></td><td>$minerShort ...</td><td><a title=\"{$block['time']}\">$time</a></td><td>$size</td><td>$txCount</td></tr>";
$i--;
}
$urlStart = "?chain=" . $chain . "&page=blocks&block=";
$newer = $offset < $highestBlock ? '<a href="' . $urlStart . ($offset + $numBlocksPerPage) . '">< Newer</a>' : '< Newer';
$older = $i != - 1 ? '<a href="' . $urlStart . ($offset - $numBlocksPerPage) . '">Older ></a>' : 'Older >';
$i++;
$first = '';
if ($offset >= $numBlocksPerPage) {
$first = '- <a href="' . $urlStart . ($numBlocksPerPage - 1) . '">First</a>';
}
echo "<tr><td colspan='6'>$newer - $older $first</td></tr></table>";
?>
</div>
</div>