-
Notifications
You must be signed in to change notification settings - Fork 11
/
index_audit.php
127 lines (102 loc) · 3.67 KB
/
index_audit.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
<?php include('header.php'); ?>
<?php include('constants.php'); ?>
<?php require_once 'check_db_ver.php';?>
<div class="jumbotron" style="text-align: center;">
<h1><?php echo $config['full-name'] ?></h1>
<p>Audit all past transactions.</p>
<?php if($show_version_msg): ?>
<span class="label label-warning" id="wrongversion"><strong>Attention:</strong> The database version does not match the code version. Please run "php update_db.php".</span>
<?php endif; ?>
</div>
<div class="jumbotron" style="text-align: center; padding: 20px;">
<h2>Last transactions</h2>
<h6 style="text-align: center; color: rgb(200,200,200)">See (<a href="audit_table.php">html</a>) or export (<a href="audit_csv.php">csv</a>) the raw data for external audit.</h6>
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<td style="width: 6%;"></td>
<td style="width: 34%">Transaction</td>
<td style="width: 20%">Amount</td>
<td style="width: 20%">Prize</td>
<td style="width: 15%">Date</td>
</tr>
</thead>
<tbody id="trans"></tbody>
</table>
</div>
</div>
<script>
// sets this tab as selected
$('#header-audit').addClass("active");
var what = "all";
function search()
{
what = $('#tid').val();
update();
}
function showall()
{
what = "all";
update();
}
function update()
{
$.get(
"json_audit.php",
{
what: what
},
function(data){
data = JSON.parse(data);
$('#trans').html('');
for(var i in data['transactions'])
{
var state = "";
if (data['transactions'][i]['audit'] == "SUCCESS")
state = '<span class="label label-success" id="collecting">Ok!</span>';
else
state = '<span class="label label-warning" id="collecting">' + data['transactions'][i]['audit'] + '</span>';
$tr = $('<tr></tr>');
$('#trans').append($tr);
$td = $('<td>' + state + '</td>');
$($tr).append($td);
var tx = "";
if (data['transactions'][i]['tx'])
tx = 'IN: <a href="<?php echo $config['blockchain-tx'] ?>' + data['transactions'][i]['tx'] + '">' + data['transactions'][i]['tx'].substring(0,18) + '...</a>';
var out = "";
if (data['transactions'][i]['out']) {
if (data['transactions'][i]['tx'])
out = "<br>";
out = out + 'OUT: <a href="<?php echo $config['blockchain-tx'] ?>' + data['transactions'][i]['out'] + '">' + data['transactions'][i]['out'].substring(0,18) + '...</a>';
}
$td = $('<td style="text-align: left;">' + tx + out + '</td>');
$($tr).append($td);
$td = $('<td>' + parseFloat(data['transactions'][i]['amount']).toFixed(<?php echo $config['precision'] ?>) + ' <?php echo $config['val'] ?></td>');
$($tr).append($td);
$td = $('<td>' + parseFloat(data['transactions'][i]['topay']).toFixed(<?php echo $config['precision'] ?>) + ' <?php echo $config['val'] ?></td>');
$($tr).append($td);
$td = $('<td>' + data['transactions'][i]['date'] + '</td>');
$($tr).append($td);
if (data['transactions'].length == 1)
{
$tr = $('<tr></tr>');
$('#trans').append($tr);
$td = $('<td colspan="4">In queue, actual position: <span class="label label-info">' + data['transactions'][i]['queue'] + '</span></td>');
$($tr).append($td);
}
}
if (data['transactions'].length == 0)
{
$tr = $('<tr></tr>');
$('#trans').append($tr);
$td = $('<td colspan="4">No transactions found.</td>');
$($tr).append($td);
}
setTimeout(update, 15 * 1000);
}
);
}
update();
</script>
<?php include('footer.php'); ?>