forked from xblau/node-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
208 lines (173 loc) · 7.07 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
$startscript = microtime( true );
define( 'NODEMON_RUNNING', true );
if( file_exists( 'config.php' ) ) {
require 'config.php';
} else {
die( 'Configuration file (config.php) not found.' );
}
require 'utils.php';
if( !isset( $formid ) ) {
require 'requests.php';
require 'forms.php';
}
$pruned = $getbcinfo['result']['pruned'] ? 'true' : 'false';
$cpeers = count( $getpeerinfo['result'] );
$bpeers = count( $listbanned['result'] );
$localservbits = hexdec('0x'.$getnetinfo['result']['localservices']);
$localservnames = decode_services($localservbits);
?>
<!DOCTYPE html>
<title><?php echo $nodeconfig['pagetitle']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" href="favicon.ico" >
<link rel="stylesheet" href="style.css">
<?php
if( !isset( $formid ) && $nodeconfig['autorefresh'] > 0 ) {
printf( '<meta http-equiv="refresh" content="%s" >', $nodeconfig['autorefresh'] );
}
?>
<body>
<h1><?php echo $nodeconfig['pagetitle']; ?></h1>
<?php
if( isset( $formresult ) ) {
echo $formresult;
echo '<br><br><a href="">Return to the main page</a>';
exit;
}
if( isset($getnetinfo['error']['code']) ) {
die( 'Request failed with message: ' . $getnetinfo['error']['message'] );
} elseif( !isset( $getnetinfo['result']['version'] ) ) {
die( 'Something went wrong (getnetworkinfo failed). Check your config and try again.' );
}
echo $nodeconfig['pagedesc'] . PHP_EOL;
?>
<br>
<a id="about"></a>
<fieldset>
<legend>ABOUT THIS NODE</legend>
<b>Node version:</b> <code><?php echo $getnetinfo['result']['version'].' ('.$getnetinfo['result']['protocolversion'].')';?></code><br>
<b>Subversion:</b> <code><?php echo $getnetinfo['result']['subversion']; ?></code><br>
<b>Local services:</b> <code><?php printf("%s (0x%s)", $localservnames, dechex($localservbits)); ?></code><br>
<b>Relay fee:</b> <code><?php echo $getnetinfo['result']['relayfee']; ?></code>
<?php
if( isset( $uptime ) ) {
printf( "<br><b>Uptime:</b> <code>%s</code>\n", seconds_to_time( $uptime['result'] ) );
}
?>
</fieldset><br>
<a id="blockchaininfo"></a>
<fieldset>
<legend>BLOCKCHAIN INFO</legend>
<b>Chain:</b> <code><?php echo $getbcinfo['result']['chain']; ?></code><br>
<b>Blocks:</b> <code><?php echo $getbcinfo['result']['blocks']; ?></code><br>
<b>Headers:</b> <code><?php echo $getbcinfo['result']['headers']; ?></code><br>
<b>Difficulty:</b> <code><?php echo $getbcinfo['result']['difficulty']; ?></code><br>
<b>Median time:</b> <code><?php echo date('d/m/Y H:i:s', $getbcinfo['result']['mediantime'] ); ?></code><br>
<?php
if(isset($getbcinfo['result']['size_on_disk'])) {
printf("<b>Size on disk:</b> <code>%s</code><br>\n", format_bytes($getbcinfo['result']['size_on_disk']));
}
?>
<b>Pruned:</b> <code><?php echo $pruned; ?></code>
</fieldset><br>
<a id="mempool"></a>
<fieldset>
<legend>TX MEMORY POOL INFO</legend>
<b>Transactions:</b> <code><?php echo $getmpinfo['result']['size']; ?></code><br>
<b>Size:</b> <code><?php
if( $getmpinfo['result']['size'] == 0 ) {
echo "empty";
} else {
echo format_bytes( $getmpinfo['result']['bytes'] );
}
?></code><br>
</fieldset><br>
<a id="netusage"></a>
<fieldset>
<legend>NETWORK USAGE</legend>
<b>Total received:</b> <code><?php echo format_bytes( $getnettotals['result']['totalbytesrecv'] ); ?></code><br>
<b>Total sent:</b> <code><?php echo format_bytes( $getnettotals['result']['totalbytessent'] ); ?></code><br>
</fieldset><br>
<?php echo $nodeconfig['broadcast'] ? '' : '<!--' ?>
<a id="broadcast"></a>
<fieldset>
<legend>BROADCAST RAW TRANSACTION</legend>
<form method="post">
<input type="hidden" name="formid" value="broadcast">
Raw transaction data:<br>
<textarea name="transaction" rows="4" cols="50" required></textarea><br><br>
<input type="submit" value="Broadcast">
</form>
</fieldset><br>
<?php echo $nodeconfig['broadcast'] ? '' : '-->' ?>
<a id="peers"></a>
<fieldset>
<legend><?php printf( 'CONNECTED PEERS (%s)', $cpeers ); ?></legend>
<table>
<tr>
<th>addr</th>
<th>services</th>
<th>conntime</th>
<th>version</th>
<th>subver</th>
<th>inbound</th>
<th>banscore</th>
</tr>
<?php
$tinbound = 0; $toutbound = 0;
foreach( $getpeerinfo['result'] as $peer ) {
$inbound = $peer['inbound'] ? 'true' : 'false';
$conntime = date('d/m/Y H:i:s', $peer['conntime'] );
$servbits = hexdec('0x' . $peer['services']);
$servnames = decode_services($servbits);
echo '<tr>';
printf( '<td>%s</td>', $peer['addr'] );
printf( '<td title="%s">0x%s</td>', $servnames, dechex($servbits) );
printf( '<td title="%s">%s</td>', $conntime, $peer['conntime'] );
printf( '<td>%s</td>', $peer['version'] );
printf( '<td>%s</td>', $peer['subver'] );
printf( '<td>%s</td>', $inbound );
printf( '<td>%s</td>', $peer['banscore'] );
echo '</tr>';
$peer['inbound'] ? $tinbound++ : $toutbound++;
}
?>
</table>
<br><b>Total inbound/outbound:</b> <?php echo "$tinbound/$toutbound"; ?>
</fieldset><br>
<a id="banned"></a>
<fieldset>
<legend><?php printf( 'BANNED PEERS (%s)', $bpeers ); ?></legend>
<table>
<tr>
<th>address</th>
<th>banned since</th>
<th>banned until</th>
<th>ban reason</th>
</tr>
<?php
foreach( $listbanned['result'] as $peer ) {
$bansince = date('d/m/Y H:i:s', $peer['ban_created'] );
$banuntil = date('d/m/Y H:i:s', $peer['banned_until'] );
echo '<tr>';
printf( '<td>%s</td>', $peer['address'] );
printf( '<td title="%s">%s</td>', $bansince, $peer['ban_created'] );
printf( '<td title="%s">%s</td>', $banuntil, $peer['banned_until'] );
printf( '<td>%s</td>', $peer['ban_reason'] );
echo '</tr>';
}
?>
</table>
</fieldset><br>
<?php
$endscript = microtime( true );
$loadtime = $endscript - $startscript;
?>
<div class="footer">
Made by <a href="https://github.com/xblau">xBlau</a>.
Powered by Core. Generated in <?php echo number_format( $loadtime, 4 ) ?> seconds.
Source code <a href="https://github.com/xblau/node-interface">here</a>.
<br><br>
</div>
</body>