forked from Someguy123/-Coin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddress.php
More file actions
131 lines (108 loc) · 3.49 KB
/
address.php
File metadata and controls
131 lines (108 loc) · 3.49 KB
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
<?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");
?>
<!-- Java Script -->
<script type='text/javascript'>
$(document).on("click", ".open-EditAddrDialog", function () {
var myAddrId = $(this).data('id');
$("#myAddress").html(myAddrId);
$(".modal-body #myAddress").val( myAddrId );
var myAddrName = $(this).data('name');
$(".modal-body #AddrName").val( myAddrName );
$('#EditAddrDialog').modal('show');
});
</script>
<?php
if (isset($_POST['addaddr']) && isset($_POST['account']))
{
$nmc->getnewaddress($_POST['account']);
}
$myaddresses = file("myaddresses.csv");
$myaddress_arr = array();
foreach ($myaddresses as $line)
{
$values = explode(";", $line);
$address = $values[0];
$name = str_replace("\n", "", $values[1]);
$myaddress_arr[$address] = $name;
}
if (isset($_POST['AddrName']) && isset($_POST['myAddress']))
{
$myaddress_arr[$_POST['myAddress']] = $_POST['AddrName'];
$f = fopen("myaddresses.csv", "w");
foreach ($myaddress_arr as $address => $name)
{
$line = $address.";".$name."\n";
fputs($f, $line);
}
fclose($f);
}
$addr = $nmc->listaccounts();
// $addrkeys = array_keys($addr);
echo "<div class='content'>
<h2>Select an account to get a list of an addresses</h2>
<form action='address.php' method='POST'>
<select name='account'>";
foreach ($addr as $account => $balance)
{
$selected = "";
if (isset($_POST['account']))
{
settype($account, "string");
if ($_POST['account'] == $account)
$selected = "selected";
}
echo "<option value='{$account}' $selected>{$account} ({$balance})</option>";
}
echo "</select>
<input class='btn' type='submit' value='View addresses' />
<input class='btn' name='addaddr' type='submit' value='Add address' />
</form>";
if (isset($_POST['account']))
$account = $_POST['account'];
else
$account = "";
echo "<table class='table-striped table-bordered table-condensed table'>
<thead><tr><th colspan='2'>Addresses for Account '".$account."'</th></tr></thead>";
foreach ($nmc->getaddressesbyaccount($account) as $address)
{
$address_label = $myaddress_arr[$address];
echo "<tr><td>" . $address . "</td>
<td>" . $address_label . "</td>
<td><a data-id='".$address."' data-name='".$address_label."' data-toggle='modal' href='#EditAddrDialog' class='open-EditAddrDialog btn btn-mini'>Edit</a></td></tr>";
}
echo "</table>";
?>
<form action='address.php' method='POST'>
<!-- Modal --->
<div id="EditAddrDialog" 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 Address Name</h3>
</div>
<div class="modal-body">
<table><tr>
<td><div id="myAddress">Address to change</div></td>
<td> <input type="text" name="AddrName" id="AddrName" value="Name"/></td>
</tr></table>
<input type="hidden" name="myAddress" id="myAddress" value="Nothing"/>
<input type="hidden" name="account" id="account" value="<?php echo $account ?>"/>
</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
echo"</div>";
echo "</div>";
include ("footer.php");
?>