/
blockcount.php
32 lines (29 loc) · 1020 Bytes
/
blockcount.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
<?php
include 'config.php';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_PORT => $rpc_port,
CURLOPT_URL => $rpc_url . ":" . $rpc_port,
CURLOPT_USERPWD => $rpc_user . ":" . $rpc_password,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => "{\n\"jsonrpc\": \"1.0\",\n\"id\":\"curltest\",\n\"method\": \"getblockcount\"\n}",
));
$getblockcount = curl_exec($curl);
$getblockcount = json_decode($getblockcount);
$getblockcount = $getblockcount->{'result'};
curl_close($curl);
if(!empty($getblockcount)){
if((int)$getblockcount < (int)$getreportedblock){
echo '<div class="w3-container w3-border-bottom w3-border-white w3-orange w3-padding-16">';
}
elseif((int)$getblockcount >= (int)$getreportedblock){
echo '<div class="w3-container w3-border-bottom w3-border-white w3-green w3-padding-16">';
}
echo '<div class="w3-right">';
echo "<h3>" . $getblockcount . "</h3>";
echo '</div><div class="w3-clear"></div>';
echo "<h4>Blocks</h4>";
echo "</div>";
}
?>