/
connectioncount.php
34 lines (32 loc) · 1.12 KB
/
connectioncount.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
<?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\": \"getconnectioncount\"\n}",
));
$getconnectioncount = curl_exec($curl);
$getconnectioncount = json_decode($getconnectioncount);
$getconnectioncount = $getconnectioncount->{'result'};
curl_close($curl);
if(!empty($getconnectioncount)){
if($getconnectioncount == 0){
echo '<div class="w3-container ww3-border-bottom w3-border-white w3-red w3-padding-16">';
}
elseif($getconnectioncount < 6){
echo '<div class="w3-container w3-border-bottom w3-border-white w3-orange w3-padding-16">';
}
elseif($getconnectioncount >= 6){
echo '<div class="w3-container w3-border-bottom w3-border-white w3-green w3-padding-16">';
}
echo '<div class="w3-right">';
echo "<h3>" . $getconnectioncount . "</h3>";
echo '</div><div class="w3-clear"></div>';
echo "<h4>Connections</h4>";
echo "</div>";
}
?>