-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
178 lines (125 loc) · 3.58 KB
/
Copy pathtest.php
File metadata and controls
178 lines (125 loc) · 3.58 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
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
<link rel="stylesheet" type="text/css" href="main.css"/>
<?php
require_once "db.inc";
require_once "bitcoin/bitcoin.inc";
require_once "poll.php";
$perform = $_POST["perform"];
if ($perform == "register"){
$new_name = $db->real_escape_string ($_POST["new_name"]);
$new_email = $db->real_escape_string ($_POST["new_email"]);
// get a deposit address for our new user
$btclient = new BitcoinClient("http",$btclogin["username"],$btclogin["password"],$btclogin["host"],$btclogin["port"],"",$rpc_debug);
$dep_addr = $btclient->GetAccountAddress($new_email); // create an address from their email :P
$result = $db->query("INSERT INTO user (name,email,dep_addr) VALUES ('$new_name','$new_email','$dep_addr');");
if (!$result){
printf("error inserting row: %s\n", mysqli_error($db));
} else {
print "New user created";
}
}
if ($perform == "checkbalance"){
$check_account = $db->real_escape_string ($_POST["check_account"]);
$btclient = new BitcoinClient("http",$btclogin["username"],$btclogin["password"],$btclogin["host"],$btclogin["port"],"",$rpc_debug);
$balance = $btclient-> getbalance($check_account);
//print "Balance: $balance";
//$btclient-> sendfrom($check_account, $safe_wallet_address, $balance, $minconf = 1);
//print "$balance forwarded to safe wallet";
if ($balance > 0.1){
$btclient-> move($check_account, "hotwallet", $balance);
print "$balance moved to hot wallet";
$credit_amount = $balance * 100;
$result = $db->query("UPDATE user SET balance = balance + $credit_amount WHERE email = '$check_account' LIMIT 1;");
} else {
print "No new confimed deposits above 0.1";
}
}
if ($perform == "sendsafe"){
$btclient = new BitcoinClient("http",$btclogin["username"],$btclogin["password"],$btclogin["host"],$btclogin["port"],"",$rpc_debug);
$balance = $btclient-> getbalance("hotwallet");
if ($balance > 1){
$amount_to_move = $balance - 0.1;
$btclient-> sendfrom("hotwallet", $safe_wallet_address, $amount_to_move, $minconf = 1);
print "$amount_to_move forwarded to safe wallet";
} else {
print "Hotwallet balance less than 1";
}
}
include_once "listusers.php";
?>
<h2>Register</h2>
<form action="." method="POST">
<table>
<tr>
<td>
<span>Name</span>
</td>
<td>
<input type="text" name="new_name"/>
</td>
</tr>
<tr>
<td>
<span>Email</span>
</td>
<td>
<input type="text" name="new_email"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Register"/>
</td>
</tr>
<input type="hidden" name="perform" value="register"/>
</table>
</form>
<h2>Check Balance</h2>
<form action="." method="POST">
<table>
<tr>
<td>
<span>Email</span>
</td>
<td>
<input type="text" name="check_account"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Check Balance"/>
</td>
</tr>
<input type="hidden" name="perform" value="checkbalance"/>
</table>
</form>
<h2>Hotwallet</h2>
<form action="." method="POST">
<table>
<tr>
<td colspan="2">
<input type="submit" value="Send to SafeWallet"/>
</td>
</tr>
<input type="hidden" name="perform" value="sendsafe"/>
</table>
</form>
<h2>GetInfo</h2>
<form action="." method="POST">
<table>
<tr>
<td colspan="2">
<input type="submit" value="GetInfo"/>
</td>
</tr>
<input type="hidden" name="perform" value="getinfo"/>
</table>
</form>
<?php
if ($perform == "getinfo"){
$btclient = new BitcoinClient("http",$btclogin["username"],$btclogin["password"],$btclogin["host"],$btclogin["port"],"",$rpc_debug);
$info = $btclient-> getinfo();
foreach ($info as $k => $v) {
print "<li>$k $v</li>";
}
}
?>