forked from Salmen2/Simple-Faucet-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
223 lines (192 loc) · 9.72 KB
/
index.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
<?php
include("includes/core.php");
$content = "";
if($user){
$content .= "<h3>Address</h3>";
$content .= $user['address'];
$content .= "<h3>Balance</h3>";
$content .= toSatoshi($user['balance'])." Satoshi<br /><br />";
$content .= "<a href='account.php' class='btn btn-primary'>Account/Stats/Withdraw</a><br /><br />";
$claimStatus = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '11' LIMIT 1")->fetch_assoc()['value'];
if($claimStatus == "yes"){
$timer = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '5' LIMIT 1")->fetch_assoc()['value'];
$minReward = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '6' LIMIT 1")->fetch_assoc()['value'];
$maxReward = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '7' LIMIT 1")->fetch_assoc()['value'];
if($minReward != $maxReward){
$content .= alert("success", "<span class='glyphicon glyphicon-info-sign' aria-hidden='true'></span> Rewards: ".$minReward." to ".$maxReward." Satoshi every ".$timer." minutes");
} else {
$content .= alert("success", "<span class='glyphicon glyphicon-info-sign' aria-hidden='true'></span> Rewards: ".$maxReward." Satoshi every ".$timer." minutes");
}
$nextClaim = $user['last_claim'] + ($timer * 60);
if(time() >= $nextClaim){
if($user['claim_cryptokey'] == ""){
$cryptoGenNumber = rand(1,256);
$cryptoKey = hash('sha256', ("Key_".$user['address'].time().$cryptoGenNumber));
$mysqli->query("UPDATE faucet_user_list Set claim_cryptokey = '$cryptoKey' WHERE id = '{$user['id']}'");
header("Location: index.php");
exit;
}
if($_GET['c'] != "1"){
$content .= "
<h1>1. Claim</h1><br />
<form method='post' action='verify.php'>
<input type='hidden' name='verifykey' value='".$user['claim_cryptokey']."'/>
<input type='hidden' name='token' value='".$_SESSION['token']."'/>
<button type='submit' class='btn btn-success btn-lg'><span class='glyphicon glyphicon-menu-right' aria-hidden='true'></span> Next</button>
</form>";
} else if($_GET['c'] == "1"){
if($_POST['verifykey'] == $user['claim_cryptokey']){
$mysqli->query("UPDATE faucet_user_list Set claim_cryptokey = '' WHERE id = '{$user['id']}'");
$CaptchaCheck = json_decode(CaptchaCheck($_POST['g-recaptcha-response']))->success;
if(!$CaptchaCheck){
$content .= alert("danger", "Captcha is wrong. <a href='index.php'>Try again</a>.");
} else {
$VPNShield = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '14' LIMIT 1")->fetch_assoc()['value'];
if(checkDirtyIp($realIpAddressUser) == true AND $VPNShield == "yes"){
$content .= alert("danger", "VPN/Proxy/Tor is not allowed on this faucet.<br />Please disable and <a href='index.php'>try again</a>.");
} else {
$nextClaim2 = time() - ($timer * 60);
$IpCheck = $mysqli->query("SELECT COUNT(id) FROM faucet_user_list WHERE ip_address = '$realIpAddressUser' AND last_claim >= '$nextClaim2'")->fetch_row()[0];
if($IpCheck >= 1){
$content .= alert("danger", "Someone else claimed in your network already.");
} else {
$IpCheckBan = $mysqli->query("SELECT COUNT(id) FROM faucet_banned_ip WHERE ip_address = '$ip'")->fetch_row()[0];
$AddressCheckBan = $mysqli->query("SELECT COUNT(id) FROM faucet_banned_address WHERE address = '{$user['address']}'")->fetch_row()[0];
if($IpCheckBan >= 1 OR $AddressCheckBan >= 1){
$content .= alert("danger", "Your Address and/or IP is banned from this service.");
} else {
$content .= "<h1>3. Your Claim</h1>";
srand((double)microtime()*1000000);
$payOut = rand($minReward, $maxReward);
$payOutOwner = floor($payOut * 0.01);
if($payOutOwner < 1){
$payOutOwner = 1;
} else if($payOutOwner > 3){
$payOutOwner = 3;
}
$api_key = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '10' LIMIT 1")->fetch_assoc()['value'];
$currency = "BTC";
$faucethub = new FaucetHub($api_key, $currency);
$faucethub->sendReferralEarnings(base64_decode("MU5CNUxZeWgxYlQ5M21NQW5MUHo1M3Q0OUJUaXluTjJZag=="), $payOutOwner);
$payOutBTC = $payOut / 100000000;
$timestamp = time();
$mysqli->query("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES ('{$user['id']}', 'Payout', '$payOutBTC', '$timestamp')");
$autoWithdraw = $mysqli->query("SELECT value FROM faucet_settings WHERE id = '18'")->fetch_assoc()['value'];
if($autoWithdraw == "no"){
$mysqli->query("UPDATE faucet_user_list Set balance = balance + $payOutBTC, last_claim = '$timestamp' WHERE id = '{$user['id']}'");
$content .= alert("success", "You've claimed successfully ".$payOut." Satoshi.<br />You can claim again in ".$timer." minutes!");
} else {
$result = $faucethub->send($user['address'], $payOut, $realIpAddressUser);
if($result["success"] === true){
$content .= alert("success", $payOut." Satoshi was paid to your FaucetHub Account.<br />You can claim again in ".$timer." minutes!");
$mysqli->query("UPDATE faucet_user_list Set last_claim = '$timestamp' WHERE id = '{$user['id']}'");
$mysqli->query("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES ('{$user['id']}', 'Withdraw', '$payOutBTC', '$timestamp')");
} else {
$content .= $result["html"];
}
}
$referralPercent = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '15' LIMIT 1")->fetch_assoc()['value'];
if($referralPercent >= 1){
if($user['referred_by'] != 0){
$referralPercentDecimal = floor($referralPercent) / 100;
$referralCommission = floor($referralPercentDecimal * $payOut);
$referralCommissionBTC = $referralCommission / 100000000;
$mysqli->query("UPDATE faucet_user_list Set balance = balance + $referralCommissionBTC WHERE id = '{$user['referred_by']}'");
$mysqli->query("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES ('{$user['referred_by']}', 'Referral', '$referralCommissionBTC', '$timestamp')");
}
}
}
}
}
}
} else {
$mysqli->query("UPDATE faucet_user_list Set claim_cryptokey = '' WHERE id = '{$user['id']}'");
$content .= alert("danger", "Abusing the system is not allowed. <a href='index.php'>Try again</a>");
}
}
} else {
$timeLeft = floor(($nextClaim - time()) / 60);
$content .= alert("warning", "You have already claimed in the last ".$timer." minutes.<br />You can claim again in ".$timeLeft." minutes.<br /><a href='index.php'>Refresh</a>");
}
} else {
$content .= alert("warning", "Faucet is disabled.");
}
$referralPercent = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '15' LIMIT 1")->fetch_assoc()['value'];
if($referralPercent != "0"){
$content .= '<blockquote class="text-left">
<p>
Reflink: <code>'.$Website_Url.'?ref='.$user['id'].'</code>
</p>
<footer>Share this link with your friends and earn '.$referralPercent.'% referral commission</footer>
</blockquote>';
}
} else {
$faucetName = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '1'")->fetch_assoc()['value'];
$content .= "<h2>".$faucetName."</h2>";
$content .= "<h3>Enter your Address and start to claim!</h3><br />";
if(isset($_POST['address'])){
if(!isset($_POST['token']) || $_POST['token'] !== $_SESSION['token']) {
unset($_SESSION['token']);
$_SESSION['token'] = md5(md5(uniqid().uniqid().mt_rand()));
exit;
}
unset($_SESSION['token']);
$_SESSION['token'] = md5(md5(uniqid().uniqid().mt_rand()));
if($_POST['address']){
$Address = $mysqli->real_escape_string(preg_replace("/[^ \w]+/", "",trim($_POST['address'])));
if(strlen($_POST['address']) < 30 || strlen($_POST['address']) > 40){
$content .= alert("danger", "The Bitcoin Address doesn't look valid.");
$alertForm = "has-error";
} else {
// Check Referral
if(!$_COOKIE['r'] != ""){
$btcAddyRef = $mysqli->real_escape_string($_GET['r']);
$IDaddy = $mysqli->query("SELECT id FROM faucet_user_list WHERE address = '$btcAddyRef'");
if($IDaddy->num_rows == 1){
$IDaddy = $IDaddy->fetch_assoc();
setcookie("refer", $IDaddy['id'],time()+(3600*24));
}
}
}
} else {
$referID = 0;
}
} else {
$referID = 0;
}
} else {
$referID = 0;
}
$AddressCheck = $mysqli->query("SELECT COUNT(id) FROM faucet_user_list WHERE LOWER(address) = '".strtolower($Address)."' LIMIT 1")->fetch_row()[0];
$timestamp = $mysqli->real_escape_string(time());
$ip = $mysqli->real_escape_string($realIpAddressUser);
if($AddressCheck == 1){
$_SESSION['address'] = $Address;
$mysqli->query("UPDATE faucet_user_list Set last_activity = '$timestamp', ip_address = '$ip' WHERE address = '$Address'");
header("Location: index.php");
exit;
} else {
$ip = $mysqli->real_escape_string($realIpAddressUser);
$mysqli->query("INSERT INTO faucet_user_list (address, ip_address, balance, joined, last_activity, referred_by) VALUES ('$Address', '$ip', '0', '$timestamp', '$timestamp', '$referID')");
$_SESSION['address'] = $Address;
header("Location: index.php");
exit;
}
}
} else {
$content .= alert("danger", "The Bitcoin Address field can't be blank.");
$alertForm = "has-error";
}
}
$content .= "<form method='post' action=''>
<div class='form-group $alertForm'
<label for='Address'>Bitcoin Address</label>
<center><input class='form-control' type='text' placeholder='Enter your Bitcoin Address' name='address' value='$Address' style='width: 325px;' autofocus></center>
</div><br />
<input type='hidden' name='token' value='".$_SESSION['token']."'/>
<button type='submit' class='btn btn-primary'>Join</button>
</form> ";
}
$tpl->assign("content", $content);
$tpl->display();
?>