forked from verekia/initializr-website
-
Notifications
You must be signed in to change notification settings - Fork 20
/
get_transactions_by_blockhash.php
30 lines (29 loc) · 1.6 KB
/
get_transactions_by_blockhash.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
<?php
//Usage: domain.tld/get_transactions_by_blockhash.php?blockhash=blockchain_blockhash
//Provides an audit of all transactions for any specified blockhash
require_once 'config.php';
$conn = mysql_connect($db_host,$db_user,$db_pass)
or die ('Error connecting to mysql! Please check config.php and your database for any inconsistencies.');
//SQL query executed returning an array
//Use a while loop to print each line by ID then append with the newline character
//assign SQL to a variable for query execution
//GET blockhash
$blockhash = htmlspecialchars($_GET["blockhash"])
$sql = "SELECT id, crypto_symbol, crypto_address, external_address, is_inbound, rc_timestamp, finished, bc_blockhash, bc_amount, bc_txid FROM blockchain_transactions WHERE bc_blockhash = ". $blockhash .";";
//connect to the database, execute the $sql, store the returned array within $result
//script exits gracefully if connection cannot be established
$result = $conn->query($sql);
//if the returned array has data
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Crypto Symbol: " . $row["crypto_symbol"]. " - Cryptocurrency Address: " . $row["crypto_address"].
" - External Address: " . $row["external_address"].
" - Time-stamp: " . $row["rc_timestamp"]. " - Is Inbound: " . $row["is_inbound"]. " - Finished: " . $row["finished"]. " - Blockhash: ". $row["bc_blockhash"]. " Amount: " . $row["bc_txid"]. " TxID: " . $row["bc_txid"]. "<br />";
}
} else {
//else there were no results, notify RC operator
echo "0 results";
}
$conn->close();
?>