forked from CallMeJake/BlockCrawler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bc_layout.php
285 lines (257 loc) · 8.55 KB
/
bc_layout.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<?php
function site_header ($title, $auth_list="")
{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n\n";
echo "<head>\n\n";
echo " <title>".$title."</title>\n\n";
echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"block_crawler.css\">\n\n";
echo "</head>\n";
echo "<body>\n";
echo "\n";
echo " <div id=\"site_head\">\n";
echo "\n";
echo " <div id=\"site_head_logo\">\n";
echo "\n";
echo " <h1><a href=\"".$_SERVER["PHP_SELF"]."\" title=\"Home Page\">\n";
echo " Block Crawler\n";
echo " </a></h1>\n";
echo " <h3><a href=\"".$_SERVER["PHP_SELF"]."\" title=\"Home Page\">\n";
echo " Block Chain Viewer\n";
echo " </a></h3>\n";
echo "\n";
echo " </div>\n";
echo "\n";
echo " </div>\n";
echo "\n";
echo " <div id=\"page_wrap\">\n";
echo "\n";
}
function site_footer ()
{
// The page_wrap div is opened in the last line of the site_header function.
echo " </div>\n";
echo "\n";
echo " <div id=\"donor_box\">\n";
echo "\n";
echo " Donations: 1939BZFZnHEdKyHn2cYrg8kbUPz1UgkuqQ \n";
echo " </div>\n";
echo "\n";
echo "</body>\n";
echo "</html>";
exit;
}
function block_detail ($block_id, $hash=FALSE)
{
if ($hash == TRUE)
{
$raw_block = getblock ($block_id);
}
else
{
$block_hash = getblockhash (intval ($block_id));
$raw_block = getblock ($block_hash);
}
echo " <div class=\"block_banner\">\n";
echo "\n";
echo " <div class=\"blockbanner_left\">\n";
echo " Block Height: ".$raw_block["height"]."\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blockbanner_right\">\n";
echo " Block Time: ".date ("F j, Y, H:i:s", $raw_block["time"])."\n";
echo " </div>\n";
echo "\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blockdetail\">\n";
echo "\n";
echo " <div class=\"blockdetail_detail\">\n";
echo " <div class=\"blockdetail_header\">Block Version</div>\n";
echo " <div class=\"blockdetail_content\">\n";
echo " ".$raw_block["version"]."\n";
echo " </div>\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blockdetail_detail\">\n";
echo " <div class=\"blockdetail_header\">Block Size</div>\n";
echo " <div class=\"blockdetail_content\">\n";
echo " ".$raw_block["size"]."\n";
echo " </div>\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blockdetail_detail\">\n";
echo " <div class=\"blockdetail_header\"># of Confirmations</div>\n";
echo " <div class=\"blockdetail_content\">\n";
echo " ".$raw_block["confirmations"]."\n";
echo " </div>\n";
echo " </div>\n";
echo "\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blockdetail\">\n";
echo "\n";
echo " <div class=\"blockdetail_detail\">\n";
echo " <div class=\"blockdetail_header\">Block Bits</div>\n";
echo " <div class=\"blockdetail_content\">\n";
echo " ".$raw_block["bits"]."\n";
echo " </div>\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blockdetail_detail\">\n";
echo " <div class=\"blockdetail_header\">Block Nonce</div>\n";
echo " <div class=\"blockdetail_content\">\n";
echo " ".$raw_block["nonce"]."\n";
echo " </div>\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blockdetail_detail\">\n";
echo " <div class=\"blockdetail_header\">Block Difficulty</div>\n";
echo " <div class=\"blockdetail_content\">\n";
echo " ".$raw_block["difficulty"]."\n";
echo " </div>\n";
echo " </div>\n";
echo "\n";
echo " </div>\n";
echo "\n";
detail_display ("Merkle Root", $raw_block["merkleroot"]);
detail_display ("Block Hash", blockhash_link ($raw_block["hash"]));
echo " <div class=\"blocknav\">\n";
echo "\n";
echo " <div class=\"blocknav_prev\">\n";
echo " <a href=\"".$_SERVER["PHP_SELF"]."?block_hash=".$raw_block["previousblockhash"]."\" title=\"View Previous Block\"><- Previous Block</a>\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blocknav_news\">\n";
echo " Block Time: ".date ("F j, Y, g:i a", $raw_block["time"])."\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"blocknav_next\">\n";
echo " <a href=\"".$_SERVER["PHP_SELF"]."?block_hash=".$raw_block["nextblockhash"]."\" title=\"View Next Block\">Next Block -></a>\n";
echo " </div>\n";
echo "\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"txlist_header\">\n";
echo " Transactions In This Block\n";
echo " </div>\n";
echo "\n";
echo " <div class=\"txlist_wrap\">\n";
foreach ($raw_block["tx"] as $index => $tx)
{
echo " <div class=\"txlist_showtx\" id=\"showtx_".$index."\">\n";
echo " <a href=\"".$_SERVER["PHP_SELF"]."?transaction=".$tx."\" title=\"Transaction Details\">\n";
echo " ".$tx."\n";
echo " </a>\n";
echo " </div>\n\n";
}
echo " </div>\n";
echo "\n";
}
function tx_detail ($tx_id)
{
$raw_tx = getrawtransaction ($tx_id);
section_head ("Transaction: ".$raw_tx["txid"]);
section_subhead ("Detailed Description");
detail_display ("TX Version", $raw_tx["version"]);
detail_display ("TX Time", date ("F j, Y, H:i:s", $raw_tx["time"]));
detail_display ("Lock Time", $raw_tx["locktime"]);
detail_display ("Confirmations", $raw_tx["confirmations"]);
detail_display ("Block Hash", blockhash_link ($raw_tx["blockhash"]));
// Florin Coin Feature
if (isset ($raw_tx["tx-comment"]) && $raw_tx["tx-comment"] != "")
{
detail_display ("TX Message", htmlspecialchars ($raw_tx["tx-comment"]));
}
detail_display ("HEX Data", $raw_tx["hex"], 50);
section_head ("Transaction Inputs");
foreach ($raw_tx["vin"] as $key => $txin)
{
section_subhead ("Input Transaction ".$key);
if (isset ($txin["coinbase"]))
{
detail_display ("Coinbase", $txin["coinbase"]);
detail_display ("Sequence", $txin["sequence"]);
}
else
{
detail_display ("TX ID", tx_link ($txin["txid"]));
detail_display ("TX Output", $txin["vout"]);
detail_display ("TX Sequence", $txin["sequence"]);
detail_display ("Script Sig (ASM)", $txin["scriptSig"]["asm"], 50);
detail_display ("Script Sig (HEX)", $txin["scriptSig"]["hex"], 50);
}
}
section_head ("Transaction Outputs");
foreach ($raw_tx["vout"] as $key => $txout)
{
section_subhead ("Output Transaction ".$key);
detail_display ("TX Value", $txout["value"]);
detail_display ("TX Type", $txout["scriptPubKey"]["type"]);
detail_display ("Required Sigs", $txout["scriptPubKey"]["reqSigs"]);
detail_display ("Script Pub Key (ASM)", $txout["scriptPubKey"]["asm"], 50);
detail_display ("Script Pub Key (HEX)", $txout["scriptPubKey"]["hex"], 50);
if (isset ($txout["scriptPubKey"]["addresses"]))
{
foreach ($txout["scriptPubKey"]["addresses"] as $key => $address);
{
detail_display ("Address ".$key, $address);
}
}
}
section_head ("Raw Transaction Detail");
echo " <textarea name=\"rawtrans\" rows=\"25\" cols=\"80\" style=\"text-align:left;\">\n";
print_r ($raw_tx);
echo " \n</textarea><br><br>\n";
}
function detail_display ($title, $data, $wordwrap=0)
{
echo " <div class=\"detail_display\">\n";
echo " <div class=\"detail_title\">\n";
echo " ".$title."\n";
echo " </div>\n";
if ($wordwrap > 0)
{
echo " <div class=\"detail_data\">\n";
echo " ".wordwrap ($data, $wordwrap, "<br>", TRUE)."\n";
echo " </div>\n";
}
else
{
echo " <div class=\"detail_data\">\n";
echo " ".$data."\n";
echo " </div>\n";
}
echo " </div>\n";
}
function tx_link ($tx_id)
{
return "<a href=\"".$_SERVER["PHP_SELF"]."?transaction=".$tx_id."\" title=\"View Transaction Details\">".$tx_id."</a>\n";
}
function blockheight_link ($block_height)
{
return "<a href=\"".$_SERVER["PHP_SELF"]."?block_height=".$block_height."\" title=\"View Block Details\">".$block_height."</a>\n";
}
function blockhash_link ($block_hash)
{
return "<a href=\"".$_SERVER["PHP_SELF"]."?block_hash=".$block_hash."\" title=\"View Block Details\">".$block_hash."</a>\n";
}
function section_head ($heading)
{
echo " <div class=\"section_head\">\n";
echo " ".$heading."\n";
echo " </div>\n";
echo "\n";
}
function section_subhead ($heading)
{
echo " <div class=\"section_subhead\">\n";
echo " ".$heading."\n";
echo " </div>\n";
echo "\n";
}
/******************************************************************************
This script is Copyright © 2013 Jake Paysnoe.
I hereby release this script into the public domain.
Jake Paysnoe Jun 26, 2013
******************************************************************************/
?>