forked from Someguy123/-Coin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
420 lines (414 loc) · 11.5 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<?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);
$pageid = 1;
include ("header.php");
// 7 last transactions; any account
$trans = $nmc->listtransactions('*', 7);
$x = array_reverse($trans);
$bal = $nmc->getbalance("*", 6); // confirmed balance of wallet
$bal3 = $nmc->getbalance("*", 0); // unconfirmed balance of wallet
$bal2 = $bal - $bal3; // unconfirmed transactions underway
$pbal = number_format($bal,8);
$pbal2 = number_format($bal2,8);
$pbal3 = number_format($bal3,8);
// Calculate EUR balance
$arr = json_decode(file_get_contents("https://blockchain.info/ticker"),true);
$eur = $arr['EUR']['last'];
$peur = number_format($eur,2);
$pbaleur = number_format($bal*$eur,2);
// Calculate USD balance from Weighted Average Price
$usd = $arr['USD']['last'];
$pusd = number_format($usd,2);
$pbalusd = number_format($bal*$usd,2);
function data_uri($file, $mime)
{
$contents = file_get_contents($file);
$base64 = base64_encode($contents);
return ('data:' . $mime . ';base64,' . $base64);
}
?>
<!-- Java Script -->
<script type='text/javascript'>
$(document).on("click", ".open-SetPassPhrase", function () {
$('#SetPassPhrase').modal('show');
});
$(document).on("click", ".open-ChangePassPhrase", function () {
$('#ChangePassPhrase').modal('show');
});
$(document).on("click", ".open-ChangeTransactionFee", function () {
$('#ChangeTransactionFee').modal('show');
});
$(document).on("click", ".open-DeBitPay", function () {
window.open('https://dorpstraat.com/debitpay', '_blank');
});
</script>
<?php
// Show the wallet and exchange rates in BTC, EUR, and USD
echo "
<div class='content'>
<div class='row'>
<div class='span12'>
<div class='row'>
<div class='span5'>
<h3><div class='bitcoinsymbol'></div></h3>
<h3>Confirmed Balance: <font color='green'>{$pbal} BTC</font></h3>
<h4>Unconfirmed Balance: <font color='red'>{$pbal3} BTC</font></h4>
<h4>Awaiting Confirmation: <font color='red'>{$pbal2} BTC</font></h4>
<br>
<h3><div class='eurosymbol'></div></h3>
<h3>Confirmed Balance: <font color='green'>{$pbaleur} EUR</font></h3>
<h4>Trading Price: 1 BTC = <font color='blue'>{$peur} EUR</font></h4>
<br>
<h3><div class='usdollarsymbol'></div></h3>
<h3>Confirmed Balance: <font color='green'>{$pbalusd} USD</font></h3>
<h4>Trading Price: 1 BTC = <font color='blue'>{$pusd} USD</font></h4>
<br>
<h3>Send coins:</h3>
<form action='send.php' method='POST'>
";
?>
<table style="width:100%;">
<tr>
<td>From wallet balance total</td>
<td>
<?php
echo "
<input type='text' name='fmbalance' value={$bal} readonly></input>
";
?>
</td>
</tr>
<tr>
<td>To wallet 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='[BTC]' name='amount'>
</td>
</tr>
<tr>
<td>Transaction Fee:</td>
<?php
if ( isset($_POST['paytxfee']) )
{
// set the paytxfee; convert from Satoshis/Byte to BTC/kiloByte
$paytxfee = explode('|',$_POST['paytxfee']);
$fee = ( $paytxfee[1] / 1e5) ;
if ($fee != 0)
{
try
{
$nmc->settxfee($fee);
echo "
<div class='alert alert-success'>
<button type='button' class='close' data-dismiss='alert'>×</button>
Transaction Fee successfully changed :-)
</div>
";
}
catch(Exception $e)
{
echo "
<div class='alert alert-error'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<b>Error:</b> Something went wrong... Could not set the Transaction Fee :-(<br> {$e}
</div>
";
}
}
}
?>
<td>
<?php
$wainfo = $nmc->getwalletinfo();
echo "
$wainfo[paytxfee] [BTC.kB<sup>-1</sup>]
";
?>
</td>
<td>
<a href='#ChangeTransactionFee' class='open-ChangeTransactionFee btn btn-tiny'>Change</a>
</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'>
</td>
<td>
<a href='#ChangePassPhrase' class='open-ChangePassPhrase btn btn-tiny'>Change</a>
</div>
</td>
";
}
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='Move or Send'>
</td>
</tr>
</table>
</form>
</div><!--/.span5 -->
<div class='span6'>
<table class='table-striped table-bordered table'>
<thead>
<tr>
<th>Method</th>
<th>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 (in_array($x['address'], $addresses_arr))
{
$name = $addresses_arr[$x['address']];
}
else
{
$name = $x['address'];
}
echo "
<td>
{$name}
</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>
";
}
?>
</table>
<a href='btc.php'>More...</a>
</div><!--/.span6 -->
</div><!--/.row -->
</div><!--/.span12 -->
</div><!--/.row -->
<form action='index.php' method='POST'>
<!-- Modal --->
<div id="ChangeTransactionFee" 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 Transaction Fee [Satoshi.B<sup>-1</sup>]</h3>
</div>
<div class="modal-body">
<select name='paytxfee'>
<?php
// get three options for paytxfee from bitcoinfees.21.co
$recommended = json_decode(file_get_contents("https://bitcoinfees.earn.com/api/v1/fees/recommended"),true);
// {"fastestFee":240,"halfHourFee":210,"hourFee":120}
foreach ($recommended as $feetype => $fee)
{
$paytxfee = $feetype.'|'.$fee;
echo "
<option value='{$paytxfee}' ".($feetype == "halfHourFee" ? " selected='selected' " : "").">
\"{$feetype}\" ({$fee})
</option>
";
}
?>
</select>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">Close</button>
<button class="btn btn-primary">Save Changes</button>
</div>
</div>
</form>
<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"); // starts with closing div (.navbar navbar-fixed-top)
?>