forked from dirtyak/xuez_monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockcount.php
41 lines (39 loc) · 1.47 KB
/
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
33
34
35
36
37
38
39
40
41
<?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);
$reportedblock = curl_init();
curl_setopt_array($reportedblock, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => "http://explorer.nyxcoin.org/api/getblockcount"
));
$getreportedblock = curl_exec($reportedblock);
$getreportedblock = json_decode($getreportedblock);
$getreportedblock = $getreportedblock->{'result'};
curl_close($reportedblock);
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-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>";
}
?>