-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathwithdraw.php
228 lines (212 loc) · 9.79 KB
/
withdraw.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
<?php
require_once 'withdraw_utils.php';
if (!$is_verified) {
throw new Error("Not Verified",
"Please <a href=\"?page=identity\">identify yourself</a> before initiating any withdrawal.");
}
if (isset($_POST['amount']) && isset($_POST['curr_type']))
{
if(isset($_POST['csrf_token']))
{
if($_SESSION['csrf_token'] != $_POST['csrf_token'])
{
throw new Error("csrf","csrf token mismatch!");
}
}
else
{
throw new Error("csrf","csrf token missing");
}
}
if (isset($_POST['amount']) && isset($_POST['curr_type'])) {
$curr_type = post('curr_type');
$amount_disp = post('amount');
do_withdraw($amount_disp, $curr_type, $voucher_code, $reqid);
echo "<div class='content_box'>\n";
echo "<h3>" . sprintf(_("Withdraw %s"), $curr_type) . "</h3>\n";
if (isset($_POST['voucher']))
echo "<p>" . sprintf(_("Your voucher for %s is:"),
"$amount_disp $curr_type") . "</p><p class='voucher'>$voucher_code</p>\n";
else
echo "<p>" . sprintf(_("Your request to withdraw %s has been submitted. Visit your %sprofile%s to check on the status of your request."),
"$amount_disp $curr_type",
"<a href='?page=profile'>",
"</a>") . "</p>\n";
echo "</div>\n";
}
else {
?>
<div class='content_box'>
<h3><?php printf(_("Withdraw %s"), CURRENCY); ?></h3>
<?php
$balances = fetch_balances($is_logged_in);
$fiat = $balances[CURRENCY];
$transferred = fiat_transferred_today($is_logged_in);
$limit = numstr_to_internal(MAXIMUM_DAILY_FIAT_TRANSFER);
$available = gmp_sub($limit, $transferred);
if (gmp_cmp($fiat, $available) > 0) {
echo " <p>" . sprintf(_("You can transfer up to %s each day"),
internal_to_numstr($limit) . " " . CURRENCY) . " (", day_time_range_string(), ")</p>\n";
if ($transferred) {
echo " <p>" . sprintf(_("You have transferred %s today"),
internal_to_numstr($transferred) . " " . CURRENCY) . "\n";
if (gmp_cmp($available, '0') > 0)
echo " " . sprintf(_("and so can transfer up to %s more."),
internal_to_numstr($available) . " " . CURRENCY);
else
echo " " . _("and so cannot transfer any more until tomorrow.");
echo "</p>\n";
}
}
if (gmp_cmp($fiat, '0') <= 0)
echo " <p>" . sprintf(_("You don't have any %s to withdraw."), CURRENCY) . "</p>\n";
else if (gmp_cmp($available, '0') > 0) {
echo " <p>" . sprintf(_("Enter an amount below to withdraw. You have %s."),
internal_to_numstr($fiat) . " " . CURRENCY) . "</p>\n";
?>
<p><?php echo _("We charge no fee for withdrawals."); ?></p>
<p>
<form action='' class='indent_form' method='post'>
<label for='input_name_holder'><?php echo _("PP Account Name"); ?></label>
<input type='text' id='input_name_holder' name='name_holder' maxlength='18' />
<label for='input_amount'><?php echo _("Amount"); ?></label>
<input type='text' id='input_amount' name='amount' value='0.00' />
<input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" />
<input type='hidden' name='curr_type' value='<?php echo CURRENCY; ?>' />
<input type='hidden' name='is_international' value='false' />
<input type='submit' value='<?php echo _("Submit"); ?>' />
</form>
</p>
<p><?php echo _("Allow 3-5 working days for payments to pass through clearing."); ?></p>
<?php } ?>
</div>
<?php
if (ENABLE_LOCAL_VOUCHERS) {
?>
<div class='content_box'>
<h3><?php printf(_("Withdraw %s to Voucher"), CURRENCY); ?></h3>
<p>
<?php printf(_("Alternatively, you can withdraw %s as a voucher.
This will give you a text code which can be redeemed for
%s credit by any user of this exchange."), CURRENCY, CURRENCY); ?>
</p>
<?php
if (gmp_cmp($fiat, $available) > 0) {
echo " <p>" . sprintf(_("You can withdraw up to %s each day"),
internal_to_numstr($limit) . " " . CURRENCY) . " (", day_time_range_string(), ")</p>\n";
if ($transferred) {
echo " <p>" . sprintf(_("You have withdrawn %s today"),
internal_to_numstr($transferred) . " " . CURRENCY) . "\n";
if (gmp_cmp($available, '0') > 0)
echo " " . sprintf(_("and so can withdraw up to %s more."),
internal_to_numstr($available) . " " . CURRENCY);
else
echo " " . _("and so cannot withdraw any more until tomorrow.");
echo "</p>\n";
}
}
if (gmp_cmp($fiat, '0') <= 0)
echo " <p>" . sprintf(_("You don't have any %s to withdraw."), CURRENCY) . "</p>\n";
else if (gmp_cmp($available, '0') > 0) {
echo " <p>" . sprintf(_("Enter an amount below to withdraw. You have %s."),
internal_to_numstr($fiat) . " " . CURRENCY) . "</p>\n";
?>
<p>
<form action='' class='indent_form' method='post'>
<label for='input_amount'><?php echo _("Amount"); ?></label>
<input type='text' id='input_amount' name='amount' value='0.00' />
<input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" />
<input type='hidden' name='curr_type' value='<?php echo CURRENCY; ?>' />
<input type='hidden' name='is_international' value='false' />
<input type='hidden' name='voucher' value='1' />
<input type='submit' value='<?php echo _("Submit"); ?>' />
</form>
</p>
<?php
}
?>
</div>
<?php
}
?>
<div class='content_box'>
<h3><?php echo _("Withdraw BTC to Bitcoin Address"); ?></h3>
<?php
$balances = fetch_balances($is_logged_in);
$btc = $balances['BTC'];
$withdrawn = btc_withdrawn_today($is_logged_in);
$limit = numstr_to_internal(MAXIMUM_DAILY_BTC_WITHDRAW);
$available = gmp_sub($limit, $withdrawn);
if (gmp_cmp($btc, $available) > 0) {
echo " <p>" . sprintf(_("You can withdraw up to %s BTC each day"), internal_to_numstr($limit)) .
" (", day_time_range_string(), ").</p>\n";
if ($withdrawn) {
echo " <p>" . sprintf(_("You have withdrawn %s BTC today"), internal_to_numstr($withdrawn)) . "\n";
if (gmp_cmp($available, '0') > 0)
echo " " . sprintf(_("and so can withdraw up to %s BTC more."), internal_to_numstr($available));
else
echo " " . _("and so cannot withdraw any more until tomorrow.");
echo "</p>\n";
}
}
if (gmp_cmp($btc, '0') <= 0)
echo " <p>" . _("You don't have any BTC to withdraw.") . "</p>\n";
else if (gmp_cmp($available, '0') > 0) {
echo " <p>" . sprintf(_("Enter an amount below to withdraw. You have %s BTC."), internal_to_numstr($btc)) . "</p>\n";
?>
<p>
<form action='' class='indent_form' method='post'>
<label for='input_address'><?php echo _("Address"); ?></label>
<input type='text' id='input_address' name='address' />
<label for='input_amount'><?php echo _("Amount"); ?></label>
<input type='text' id='input_amount' name='amount' value='0.00' />
<input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" />
<input type='hidden' name='curr_type' value='BTC' />
<input type='submit' value='<?php echo _("Submit"); ?>' />
</form>
</p>
<?php
}
echo " </div>\n";
if (ENABLE_LOCAL_VOUCHERS) { ?>
<div class='content_box'>
<h3><?php echo _("Withdraw BTC to Voucher"); ?></h3>
<p>
<?php echo _("Alternatively, you can withdraw Bitcoins as a voucher.
This will give you a text code which can be redeemed for
Bitcoins by any user of this exchange."); ?>
</p>
<?php
if (gmp_cmp($btc, $available) > 0) {
echo " <p>" . sprintf(_("You can withdraw up to %s BTC each day"), internal_to_numstr($limit)) .
" (", day_time_range_string(), ").</p>\n";
if ($withdrawn) {
echo " <p>" . sprintf(_("You have withdrawn %s BTC today"), internal_to_numstr($withdrawn)) . "\n";
if (gmp_cmp($available, '0') > 0)
echo " " . sprintf(_("and so can withdraw up to %s BTC more."), internal_to_numstr($available));
else
echo " " . _("and so cannot withdraw any more until tomorrow.");
echo "</p>\n";
}
}
if (gmp_cmp($btc, '0') <= 0)
echo " <p>" . _("You don't have any BTC to withdraw.") . "</p>\n";
else if (gmp_cmp($available, '0') > 0) {
echo " <p>" . sprintf(_("Enter an amount below to withdraw. You have %s BTC."), internal_to_numstr($btc)) . "</p>\n";
?>
<p>
<form action='' class='indent_form' method='post'>
<label for='input_amount'><?php echo _("Amount"); ?></label>
<input type='text' id='input_amount' name='amount' value='0.00' />
<input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" />
<input type='hidden' name='curr_type' value='BTC' />
<input type='hidden' name='voucher' value='1' />
<input type='submit' value='<?php echo _("Submit"); ?>' />
</form>
</p>
<?php
}
echo " </div>\n";
}
}
?>