forked from Someguy123/-Coin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
273 lines (256 loc) · 8.16 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
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
<?php
/**
* @author Chris S - AKA Someguy123
* @version 0.01 (ALPHA!)
* @license PUBLIC DOMAIN http://unlicense.org
* @package +Coin - Bitcoin & forks Web Interface
*/
ini_set("display_errors", false);
include ("header.php");
$trans = $nmc->listtransactions('*', 7);
$x = array_reverse($trans);
$bal = $nmc->getbalance("*", 6);
$bal3 = $nmc->getbalance("*", 0);
$bal2 = $bal - $bal3;
?>
<!-- Java Script -->
<script type='text/javascript'>
$(document).on("click", ".open-SetPassPhrase", function () {
$('#SetPassPhrase').modal('show');
});
$(document).on("click", ".open-ChangePassPhrase", function () {
$('#ChangePassPhrase').modal('show');
});
</script>
<?php
echo "
<div class='content'>
<div class='row'>
<div class='span12'>
<div class='row'>
<div class='span5'>
<h3>Current Balance: <font color='green'>{$bal}</font></h1>
<h4>Unconfirmed Balance: <font color='red'>{$bal2}</font></h2>
<hr />
<h3>Send coins:</h3>
<form action='send.php' method='POST'>";
?>
<table style="width: 100%;">
<tr>
<td>From account:</td>
<td>
<?php
$addr = $nmc->listaccounts();
// get account with max balance
$maxBalance = -1;
$maxAccount = null;
foreach ($addr as $account => $balance)
{
if ($balance > $maxBalance)
{
$maxBalance = $balance;
$maxAccount = $account;
}
}
echo "<select name='account'>";
foreach ($addr as $account => $balance)
{
echo "<option value='{$account}' ".($account === $maxAccount ? " selected='selected' " : "").">{$account} ({$balance})</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td>To address:</td>
<td>
<?php
// addressbook
$addressbook = file("addressbook.csv");
echo "<select name='addressbook'>";
echo "<option value='---'>Use custom to address:</option>";
foreach ($addressbook as $line)
{
$values = explode(";", $line);
$address = $values[0];
$name = str_replace("\n", "", $values[1]);
echo "<option value='{$address}'>{$name} ({$address})</option>";
}
echo "</select><br />";
echo "<input type='text' placeholder='To address' name='address'>";
?>
</td>
</tr>
<tr>
<td>Amount:</td>
<td>
<input type='text' placeholder='Amount' name='amount'>
</td>
</tr>
<tr>
<td>Passphrase:</td>
<td>
<?php
if (isset($_POST['PassPhrase']) && isset($_POST['PassPhrase2']))
{
//check both passwords are the same
if ($_POST['PassPhrase'] === $_POST['PassPhrase2'])
{
if (isset($_POST['CurrPassPhrase']))
{
// Change password
try {
$nmc->walletpassphrasechange($_POST['CurrPassPhrase'], $_POST['PassPhrase']);
echo "<div class='alert alert-success'>
<button type='button' class='close' data-dismiss='alert'>×</button>
Wallet passphrase successfully changed.
</div>";
} catch(Exception $e) {
echo "<div class='alert alert-error'><strong>Passphrase error!</strong> Wrong current passphrase entered.</div>";
}
}
else
{
// Set password
$nmc->encryptwallet($_POST['PassPhrase']);
echo "<div class='alert alert-success'>
<button type='button' class='close' data-dismiss='alert'>×</button>
Wallet is now encypted.<br>Keep that passphrase safe!
</div>";
}
}
else
{
echo "<div class='alert alert-error'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<strong>Warning!</strong> Passphrases do not match!<br>Wallet encryption not set.
</div>";
}
}
if ($wallet_encrypted)
echo "<div class='input-append'><input type='password' placeholder='Wallet Passphrase' name='walletpassphrase'>
<a href='#ChangePassPhrase' class='open-ChangePassPhrase btn btn-tiny'>Change</a></div>";
else
echo "Wallet un-encrypted <a href='#SetPassPhrase' class='open-SetPassPhrase btn btn-tiny'>Set</a>";
?>
</td>
</tr>
<tr>
<td></td>
<td>
<br><input class='btn btn-primary' type='submit' value='Send'>
</td>
</tr>
</table>
</form>
<hr />
<h3>Daemon Info</h3>
<table class="table-striped table-bordered table">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php $info = $nmc->getinfo(); ?>
<?php foreach ($info as $key => $val)
{
if ($val != "")
echo "<tr><td>".$key."</td><td>".$val."</td></tr>";
}
?>
</tbody>
</table>
</div>
<div class='span6'>
<table class='table-striped table-bordered table'>
<thead><tr><th>Method</th><th>Account and Address</th><th>Amount</th><th>Confirms</th></tr></thead>
<?php
// Load address book
$addresses_arr = array();
$addressbook = file("addressbook.csv");
foreach ($addressbook as $line)
{
$values = explode(";", $line);
$address = $values[0];
$name = str_replace("\n", "", $values[1]);
$addresses_arr[$address] = $name;
}
// Load my addresses
$myaddresses = file("myaddresses.csv");
foreach ($myaddresses as $line)
{
$values = explode(";", $line);
$address = $values[0];
$name = str_replace("\n", "", $values[1]);
$addresses_arr[$address] = $name;
}
foreach ($x as $x)
{
if($x['amount'] > 0) { $coloramount = "green"; } else { $coloramount = "red"; }
if($x['confirmations'] >= 6) { $colorconfirms = "green"; } else { $colorconfirms = "red"; }
// $date = date(DATE_RFC822, $x['time']);
echo "<tr>";
echo "<td>" . ucfirst($x['category']) . "</td>";
if (isset($x['address']))
{
if ($addresses_arr[$x['address']])
$name = $addresses_arr[$x['address']];
else
$name = $x['address'];
echo "<td>{$name} - {$x['account']}</td>";
}
else
echo "<td style='text-align: center'>Generated</td>";
echo "<td><font color='{$coloramount}'>{$x['amount']}</font></td><td><font color='{$colorconfirms}'>{$x['confirmations']}</font></td></tr>";
}
echo "</table>
<a href='btc.php'>More...</a>
</div>
</div>
</div>
</div>";
?>
<form action='index.php' method='POST'>
<!-- Modal --->
<div id="SetPassPhrase" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Set Wallet Pass Phrase</h3>
</div>
<div class="modal-body">
Choose a long, secure passphrase... Your wallet depends on it:
<br><input type="password" class="input-xxlarge" name="PassPhrase" id="PassPhrase" value="" />
<br>Re-type to confirm:
<br><input type="password" class="input-xxlarge" name="PassPhrase2" id="PassPhrase2" value="" />
<br>Passphrase can be changed later.
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">Close</button>
<button class="btn btn-primary">Save Changes</button>
</div>
</div>
<!-- Modal --->
<div id="ChangePassPhrase" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Change Wallet Pass Phrase</h3>
</div>
<div class="modal-body">
Enter your current passphrase:
<br><input type="password" class="input-xxlarge" name="CurrPassPhrase" id="CurrPassPhrase" value="" />
<br>Choose a new long, secure passphrase:
<br><input type="password" class="input-xxlarge" name="PassPhrase" id="PassPhrase" value="" />
<br>Re-type to confirm:
<br><input type="password" class="input-xxlarge" name="PassPhrase2" id="PassPhrase2" value="" />
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">Close</button>
<button class="btn btn-primary">Save Changes</button>
</div>
</div>
</form>
<?php
include("footer.php");
?>