-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeposit.php
More file actions
361 lines (316 loc) · 12.2 KB
/
Copy pathdeposit.php
File metadata and controls
361 lines (316 loc) · 12.2 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
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
<?php
$page = "Deposit";
include'header.php';
$url = "https://www.blockonomics.co/api/";
$options = array(
'http' => array(
'header' => 'Authorization: Bearer '.$apikey,
'method' => 'POST',
'content' => '',
'ignore_errors' => true
)
);
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
function generateAddress(){
global $apikey;
global $url;
$options = array(
'http' => array(
'header' => 'Authorization: Bearer 8NKHIcDJ0zEdJy9lU97OY3ZhxW1UGaGvqKtDped7m4M',
'method' => 'POST',
'content' => '',
'ignore_errors' => true
)
);
$context = stream_context_create($options);
$contents = file_get_contents($url."new_address", false, $context);
$object = json_decode($contents);
// Check if address was generated successfully
if (isset($object->address)) {
$address = $object->address;
} else {
// Show any possible errors
$address = $http_response_header[0]."\n".$contents;
}
return $address;
}
function createInvoice($sold){
global $odb;
$getIp = file_get_contents("https://api.ipify.org");
$code = generateRandomString(25);
$address = generateAddress();
$status = -1;
$username = $_SESSION['username'];
$insertUser = $odb -> prepare("INSERT INTO `invoices` VALUES(NULL, :code, :address, :sold, :status, :username, :ip, UNIX_TIMESTAMP())");
$insertUser -> execute(array(':code' => $code, ':address' => $address, ':sold' => $sold, ':status' => $status, ':username' => $username, ':ip' => $getIp));
return $code;
}
?>
<div class="main-content">
<div class="page-content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
<h4 class="mb-sm-0 font-size-18">Deposit</h4><div class="ml-auto">
<nav aria-label="breadcrumb">
<ol class="breadcrumb m-0 p-0">
<li class="breadcrumb-item text-primary active" aria-current="page"><?php echo $info["nom"]; ?></li>
<li class="breadcrumb-item text-muted" aria-current="page">/ <?php echo $page; ?></li>
</ol>
</nav>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-6 col-lg-6">
<div class="card">
<div class="card-header">
<div class="card-title">
Deposit Balance
</div>
</div>
<div class="card-body">
<form method="POST">
<div class="form-group"><label class="form-label">Sold</label>
<input class="form-range" step="1" min="20" max="200" value="0" oninput="this.form.amonde.value=this.value" type="range"><input class="form-control" required="" name="amonde" type="number" placeholder="Min: 20$, Max: 200$" value="20">
</div>
<div class="form-group"><label class="form-label">Type amonde</label>
<select class="form-control" name="to" title="to" disabled="">
<option>BTC</option>
</select>
</div> </div>
<div class="card-footer text-right"><button type="submit" name="Depose" class="btn btn-primary">Depose</button></div></form>
</div>
</div>
<div class="col-xl-6 col-lg-6">
<div class="card">
<div class="card-header">
<div class="card-title">Current price
</div>
</div>
<div class="card-body">
<div class="table-responsive-lg">
<table class="table ">
<thead class="">
<tr>
<th scope="col">ID</th>
<th scope="col">Balance</th>
<th scope="col">Status</th>
<th scope="col">Last reply</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php
$SQLGetTickets = $odb -> prepare("SELECT * FROM `invoices` WHERE `username` = :username ORDER BY `id` DESC");
$SQLGetTickets -> execute(array(':username' => $_SESSION['username']));
while ($getInfo = $SQLGetTickets -> fetch(PDO::FETCH_ASSOC))
{
$id = $getInfo['id'];
$code = $getInfo['code'];
$sold = htmlspecialchars($getInfo['sold']);
$status = $getInfo['status'];
$date = $getInfo['date'];
if($status == 0){
$status = "PENDING";
$info = "You payment has been received. Invoice will be marked paid on two blockchain confirmations.";
}else if($status == 1){
$status = "<span style='color: orangered' id='status'>PENDING</span>";
$info = "You payment has been received. Invoice will be marked paid on two blockchain confirmations.";
}else if($status == 2){
$status = "PAID";
}else if($status == -1){
$status = "UNPAID";
}else if($status == -2){
$status = "Too little paid, please pay the rest.";
}else {
$status = "Error, expired";
}
?>
<tr>
<td><?php echo $id; ?></td>
<td>$<?php echo $sold; ?></td>
<td><?php echo $status; ?></td>
<td><?php echo strftime("%d %B - %H:%M", $date); ?></td>
<td><a class="btn btn-outline-primary btn-sm btn-block" href="invoice.php?code=<?php echo $code; ?>" type="button"><i class="mdi mdi-pencil"></i></a></td>
</tr>
<?php } ?> </tbody>
</table>
<div class="d-flex gap-2 flex-wrap">
<div class="btn-group">
<div class="dropdown-menu">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include'footer.php'; ?>
</div>
</div>
</body>
</html>
<?php
if (isset($_POST['Depose']))
{
$sold = ($_POST['amonde']);
if ($info["deposit"] != 0)
{
echo '
<script type="text/javascript">
toastr["error"]("this system is under maintenance.")
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
</script>';
}else{
if (empty($sold))
{
echo'<script type="text/javascript">
toastr["error"]("Please fill all.")
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
</script>';
}else{
if ($sold < 20)
{
echo' <script type="text/javascript">
toastr["error"]("Please choose a correct sold.")
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
</script>';
}else{ if ($sold < 20)
{
echo' <script type="text/javascript">
toastr["error"]("Please choose a correct Sold.")
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
</script>';
}else{ if ($sold > 200)
{
echo' <script type="text/javascript">
toastr["error"]("Please choose a correct Sold.")
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
</script>';
}else{
$SQLCount = $odb -> prepare("SELECT COUNT(*) FROM `invoices` WHERE `username` = :username AND `status` = '-1'");
$SQLCount -> execute(array(':username' => $_SESSION['username']));
if ($SQLCount -> fetchColumn(0) > 1)
{
echo' <script type="text/javascript">
toastr["error"]("you already have a pending deposit.")
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
</script>';
}else{
$code = createInvoice($sold);
echo "<script>window.location='invoice?code=".$code."'</script>";
{
}}
}
}
} }}
}
?>