-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathaccount.php
More file actions
141 lines (118 loc) · 5.29 KB
/
Copy pathaccount.php
File metadata and controls
141 lines (118 loc) · 5.29 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
<?php
include("includes/core.php");
$content = "";
if($user){
$content .= "<h1>Account</h1>";
$content .= "<h3>Address</h3>";
$content .= ($user['address']) ? $user['address'] : $user['ec_userid'];
$content .= "<h3>Balance</h3>";
$content .= toSatoshi($user['balance'])." {$faucetCurrencies[$websiteCurrency][1]}<br /><br />";
$faucetpayApiToken = $mysqli->query("SELECT value FROM faucet_settings WHERE id = '19'")->fetch_assoc()['value'];
if($faucetpayApiToken){
$thresholdGateway = $mysqli->query("SELECT value FROM faucet_settings WHERE id = '23'")->fetch_assoc()['value'];
if($_GET['withdr'] == "fp"){
if(toSatoshi($user['balance']) < $thresholdGateway){
$content .= alert("warning", "Please reach firstly the withdrawal threshold of ".$thresholdGateway." {$faucetCurrencies[$websiteCurrency][1]}s.");
} else {
$mysqli->query("UPDATE faucet_user_list Set balance = '0' WHERE id = '{$user['id']}'");
$faucetpay = new FaucetPay($faucetpayApiToken, $faucetCurrencies[$websiteCurrency][0]);
$result = $faucetpay->send($user['address'], toSatoshi($user['balance']));
if($result["success"] === true){
$mysqli->query("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES ('{$user['id']}', 'Withdraw', '{$user['balance']}', '".time()."')");
$content .= $result["html"];
} else {
$mysqli->query("UPDATE faucet_user_list Set balance = '{$user['balance']}' WHERE id = '{$user['id']}'");
$content .= $result["html"];
}
}
} else {
if(toSatoshi($user['balance']) >= $thresholdGateway AND $user['address']){
$content .= '<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Withdraw <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="account.php?withdr=fp">FaucetPay</a></li>
</ul>
</div><br />';
} else {
$content .= alert("info", "Withdrawal threshold of ".$thresholdGateway." {$faucetCurrencies[$websiteCurrency][1]}s hasn't been reached yet.");
}
}
} else {
$content .= alert("warning", "The site owner hasn't configured any withdrawal methods yet.");
}
$content .= "<br /><br />";
// Total Stats
$TotalClaims = $mysqli->query("SELECT COUNT(id) FROM faucet_transactions WHERE type = 'Payout' AND userid = '{$user['id']}'")->fetch_row()[0];
$TotalClaimed = $mysqli->query("SELECT SUM(amount) FROM faucet_transactions WHERE type = 'Payout' AND userid = '{$user['id']}'")->fetch_row()[0];
$TotalClaimed = $TotalClaimed ? $TotalClaimed : 0;
// 24 Hours stats
$Last24Hours = time() - 86400;
$Last24HoursClaims = $mysqli->query("SELECT COUNT(id) FROM faucet_transactions WHERE type = 'Payout' AND userid = '{$user['id']}' AND timestamp > '$Last24Hours'")->fetch_row()[0];
$Last24HoursClaimed = $mysqli->query("SELECT SUM(amount) FROM faucet_transactions WHERE type = 'Payout' AND userid = '{$user['id']}' AND timestamp > '$Last24Hours'")->fetch_row()[0];
$Last24HoursClaimed = $Last24HoursClaimed ? $Last24HoursClaimed : 0;
// Referral
$TotalReferralPayout = $mysqli->query("SELECT SUM(amount) FROM faucet_transactions WHERE type = 'Referral' AND userid = '{$user['id']}'")->fetch_row()[0];
$TotalReferralPayout = $TotalReferralPayout ? $TotalReferralPayout : 0;
$Last24HoursReferralPayout = $mysqli->query("SELECT SUM(amount) FROM faucet_transactions WHERE type = 'Referral' AND userid = '{$user['id']}' AND timestamp > '$Last24Hours'")->fetch_row()[0];
$Last24HoursReferralPayout = $Last24HoursReferralPayout ? $Last24HoursReferralPayout : 0;
$content .= "<h3>Stats</h3>
<div class='row'>
<div class='col-md-12'>
<h3>All time</h3>
</div>
<div class='col-md-4'>
<h4>Total Claims</h4>
<b>".$TotalClaims."</b>
</div>
<div class='col-md-4'>
<h4>Total Claimed</h4>
<b>".toSatoshi($TotalClaimed)."</b><br />{$faucetCurrencies[$websiteCurrency][1]}
</div>
<div class='col-md-4'>
<h4>Total Referral Payout</h4>
<b>".toSatoshi($TotalReferralPayout)."</b><br />{$faucetCurrencies[$websiteCurrency][1]}
</div>
<div class='col-md-12'>
<h3>Last 24 Hours</h3>
</div>
<div class='col-md-4'>
<h4>Claims</h4>
<b>".$Last24HoursClaims."</b>
</div>
<div class='col-md-4'>
<h4>Claimed</h4>
<b>".toSatoshi($Last24HoursClaimed)."</b><br />{$faucetCurrencies[$websiteCurrency][1]}
</div>
<div class='col-md-4'>
<h4>Total Referral Payout</h4>
<b>".toSatoshi($Last24HoursReferralPayout)."</b><br />{$faucetCurrencies[$websiteCurrency][1]}
</div>
</div>";
$headTable = "<h3>Last 15 Transactions</h3><center><table class='table' style='text-align: center; width: 400px;'border='0' cellpadding='2' cellspacing='2'>
<thead>
<tr>
<td>Type</td>
<td>Time</td>
<td>Amount</td>
</tr>
</thead>";
$bodyTable = "<tbody>";
$UserTransactions = $mysqli->query("SELECT * FROM faucet_transactions WHERE userid = '{$user['id']}' ORDER BY id DESC LIMIT 15");
while($Tx = $UserTransactions->fetch_assoc()){
$bodyTable .= "<tr>
<td>".$Tx['type']."</td>
<td>".findTimeAgo($Tx['timestamp'])."</td>
<td>".$Tx['amount']."</td>
</tr>";
}
$footerTable = "</tbody></table></center>";
$content .= $headTable.$bodyTable.$footerTable;
} else {
header("Location: index.php");
exit;
}
$tpl->assign("content", $content);
$tpl->display();
?>