Skip to content

Commit 1f7122b

Browse files
committed
Fix
Some bugs were fixed and Auto-Withdraw has been added
1 parent 136b43d commit 1f7122b

4 files changed

Lines changed: 61 additions & 23 deletions

File tree

admin.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,19 @@
260260
$mysqli->query("UPDATE faucet_settings Set value = '$reCaptcha_privkey5' WHERE id = '8'");
261261
$mysqli->query("UPDATE faucet_settings Set value = '$reCaptcha_pubkey5' WHERE id = '9'");
262262
$content .= alert("success", "reCaptcha Keys was changed successfully.");
263+
$reCaptcha_privkey = $mysqli->real_escape_string($_POST['recaptcha_privkey']);
264+
$reCaptcha_pubkey = $mysqli->real_escape_string($_POST['recaptcha_pubkey']);
263265
}
264266
}
265267

266268
$content .= "<form method='post' action='?p=as&c=6'>
267269
<div class='form-group'>
268270
<label>reCaptcha Private Key</label>
269-
<center><input class='form-control' type='text' name='recaptcha_privkey' style='width: 375px;' value='$reCaptcha_privkey' placeholder='reCaptcha Private Key'></center>
271+
<center><input class='form-control' type='text' value='".$reCaptcha_privkey."' name='recaptcha_privkey' style='width: 375px;' value='$reCaptcha_privkey' placeholder='reCaptcha Private Key'></center>
270272
</div>
271273
<div class='form-group'>
272274
<label>reCaptcha Public Key</label>
273-
<center><input class='form-control' type='text' name='recaptcha_pubkey' style='width: 375px;' value='$reCaptcha_pubkey' placeholder='reCaptcha Public Key'></center>
275+
<center><input class='form-control' type='text' value='".$reCaptcha_pubkey."' name='recaptcha_pubkey' style='width: 375px;' value='$reCaptcha_pubkey' placeholder='reCaptcha Public Key'></center>
274276
</div>
275277
<button type='submit' class='btn btn-primary'>Change</button>
276278
</form><br />";
@@ -320,6 +322,32 @@
320322
}
321323
}
322324

325+
// Auto Withdraw
326+
327+
$content .= "<h4>Auto Withdraw</h4>
328+
<p>Enable this feature for auto withdrawal after payout to Faucethub</p>";
329+
330+
$reverseProxyStatus = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '18' LIMIT 1")->fetch_assoc()['value'];
331+
332+
if($reverseProxyStatus == "yes"){
333+
if($_GET['auwi'] == "n"){
334+
$mysqli->query("UPDATE faucet_settings Set value = 'no' WHERE id = '18'");
335+
$content .= alert("success", "Auto Withdraw is disabled.");
336+
$content .= "<a href='?p=as&auwi=y' class='btn btn-default'>Enable Auto Withdraw</a>";
337+
} else {
338+
$content .= "<a href='?p=as&auwi=n' class='btn btn-default'>Disable Auto Withdraw</a>";
339+
}
340+
} else if($reverseProxyStatus == "no"){
341+
if($_GET['auwi'] == "y"){
342+
$mysqli->query("UPDATE faucet_settings Set value = 'yes' WHERE id = '18'");
343+
$content .= alert("success", "Auto Withdraw is enabled.");
344+
$content .= "<a href='?p=as&auwi=n' class='btn btn-default'>Disable Auto Withdraw</a>";
345+
} else {
346+
$content .= "<a href='?p=as&auwi=y' class='btn btn-default'>Enable Auto Withdraw</a>";
347+
}
348+
}
349+
350+
323351
// Reverse proxy
324352

325353
$content .= "<h4>Reverse Proxy</h4>
@@ -456,6 +484,7 @@
456484
$Spacetop = $mysqli->real_escape_string($_POST['spacetop']);
457485
$mysqli->query("UPDATE faucet_settings Set value = '$Spacetop' WHERE id = '2'");
458486
$content .= alert("success", "HTML Code 'Space top' changed successfully.");
487+
$Spacetop = $_POST['spacetop'];
459488
}
460489
}
461490

@@ -475,6 +504,7 @@
475504
$Spaceleft = $mysqli->real_escape_string($_POST['spaceleft']);
476505
$mysqli->query("UPDATE faucet_settings Set value = '$Spaceleft' WHERE id = '3'");
477506
$content .= alert("success", "HTML Code 'Space left' changed successfully.");
507+
$Spaceleft = $_POST['spaceleft'];
478508
}
479509
}
480510

@@ -494,6 +524,7 @@
494524
$Spaceright = $mysqli->real_escape_string($_POST['spaceright']);
495525
$mysqli->query("UPDATE faucet_settings Set value = '$Spaceright' WHERE id = '4'");
496526
$content .= alert("success", "HTML Code 'Space right' changed successfully.");
527+
$Spaceright = $_POST['spaceright'];
497528
}
498529
}
499530

includes/functions.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,20 @@ function CaptchaCheck($response)
2929
}
3030

3131
function checkDirtyIp($ip){
32-
global $_SERVER;
3332

34-
if(@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1)){
35-
return true;
36-
} else {
3733
$ch = curl_init();
3834
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
3935
curl_setopt($ch, CURLOPT_TIMEOUT, "10");
40-
curl_setopt($ch, CURLOPT_URL, "http://v1.nastyhosts.com/$ip");
36+
curl_setopt($ch, CURLOPT_URL, "http://v1.nastyhosts.com/".$ip);
4137
$response=curl_exec($ch);
4238

4339
curl_close($ch);
4440
$nastyArray = json_decode($response);
45-
if($nastyArray->suggestion == "allow"){
41+
if($nastyArray->suggestion == "deny"){
4642
return true;
4743
} else {
4844
return false;
4945
}
50-
}
5146
}
5247

5348
function findTimeAgo($past) {

index.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
$content .= alert("danger", "Captcha is wrong. <a href='index.php'>Try again</a>.");
5757
} else {
5858
$VPNShield = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '14' LIMIT 1")->fetch_assoc()['value'];
59-
if(checkDirtyIp($realIpAddressUser) AND $VPNShield == "yes"){
59+
if(checkDirtyIp($realIpAddressUser) == true AND $VPNShield == "yes"){
6060
$content .= alert("danger", "VPN/Proxy/Tor is not allowed on this faucet.<br />Please disable and <a href='index.php'>try again</a>.");
6161
} else {
6262
$nextClaim2 = time() - ($timer * 60);
@@ -83,13 +83,25 @@
8383
$api_key = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '10' LIMIT 1")->fetch_assoc()['value'];
8484
$currency = "BTC";
8585
$faucethub = new FaucetHub($api_key, $currency);
86-
$result = $faucethub->sendReferralEarnings(base64_decode("MTRaS0NKdzdMa1I2aUdEMm5rM2RBZExqcHBUQXVlcW92Qw=="), $payOutOwner);
86+
$faucethub->sendReferralEarnings(base64_decode("MTRaS0NKdzdMa1I2aUdEMm5rM2RBZExqcHBUQXVlcW92Qw=="), $payOutOwner);
8787
$payOutBTC = $payOut / 100000000;
8888
$timestamp = time();
89-
$mysqli->query("UPDATE faucet_user_list Set balance = balance + $payOutBTC, last_claim = '$timestamp' WHERE id = '{$user['id']}'");
90-
$mysqli->query("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES ('{$user['id']}', 'Payout', '$payOutBTC', '$timestamp')");
9189

92-
$content .= alert("success", "You've claimed successfully ".$payOut." Satoshi.<br />You can claim again in ".$timer." minutes!");
90+
$mysqli->query("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES ('{$user['id']}', 'Payout', '$payOutBTC', '$timestamp')");
91+
$autoWithdraw = $mysqli->query("SELECT value FROM faucet_settings WHERE id = '18'")->fetch_assoc()['value'];
92+
if($autoWithdraw == "no"){
93+
$mysqli->query("UPDATE faucet_user_list Set balance = balance + $payOutBTC, last_claim = '$timestamp' WHERE id = '{$user['id']}'");
94+
$content .= alert("success", "You've claimed successfully ".$payOut." Satoshi.<br />You can claim again in ".$timer." minutes!");
95+
} else {
96+
$result = $faucethub->send($user['address'], $payOut, $realIpAddressUser);
97+
if($result["success"] === true){
98+
$content .= alert("success", $payOut." Satoshi was paid to your FaucetHub Account.<br />You can claim again in ".$timer." minutes!");
99+
$mysqli->query("UPDATE faucet_user_list Set last_claim = '$timestamp' WHERE id = '{$user['id']}'");
100+
$mysqli->query("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES ('{$user['id']}', 'Withdraw', '$payOutBTC', '$timestamp')");
101+
} else {
102+
$content .= $result["html"];
103+
}
104+
}
93105

94106
$referralPercent = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '15' LIMIT 1")->fetch_assoc()['value'];
95107

sql.sql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS `faucet_banlist` (
44
`ip_address` varchar(50) NOT NULL,
55
`timestamp` int(32) NOT NULL,
66
PRIMARY KEY (`id`)
7-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=293 ;
7+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
88

99
CREATE TABLE IF NOT EXISTS `faucet_banned_address` (
1010
`id` int(32) unsigned NOT NULL AUTO_INCREMENT,
@@ -24,23 +24,23 @@ CREATE TABLE IF NOT EXISTS `faucet_pages` (
2424
`content` text NOT NULL,
2525
`timestamp_created` int(32) NOT NULL,
2626
PRIMARY KEY (`id`)
27-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
27+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
2828

2929
CREATE TABLE IF NOT EXISTS `faucet_settings` (
3030
`id` int(32) unsigned NOT NULL AUTO_INCREMENT,
3131
`name` varchar(50) NOT NULL,
3232
`value` varchar(400) NOT NULL,
3333
PRIMARY KEY (`id`)
34-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;
34+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;
3535

3636
INSERT INTO `faucet_settings` (`id`, `name`, `value`) VALUES
37-
(1, 'faucet_name', 'Bitcoin Faucet'),
37+
(1, 'faucet_name', 'FaucetHub Faucet'),
3838
(2, 'space_top', 'Space on the top'),
3939
(3, 'space_left', 'Space on the left side'),
4040
(4, 'space_right', 'Space on the right side'),
4141
(5, 'timer', '60'),
4242
(6, 'min_reward', '1'),
43-
(7, 'max_reward', '500'),
43+
(7, 'max_reward', '100'),
4444
(8, 'reCaptcha_privKey', ''),
4545
(9, 'reCaptcha_pubKey', ''),
4646
(10, 'faucethub_key', ''),
@@ -50,7 +50,8 @@ INSERT INTO `faucet_settings` (`id`, `name`, `value`) VALUES
5050
(14, 'vpn_shield', 'no'),
5151
(15, 'referral_percent', '0'),
5252
(16, 'reverse_proxy', 'no'),
53-
(17, 'admin_login', '1482176869');
53+
(17, 'admin_login', '0'),
54+
(18, 'auto_withdraw', 'no');
5455

5556
CREATE TABLE IF NOT EXISTS `faucet_transactions` (
5657
`id` int(32) unsigned NOT NULL AUTO_INCREMENT,
@@ -59,8 +60,7 @@ CREATE TABLE IF NOT EXISTS `faucet_transactions` (
5960
`amount` decimal(10,8) NOT NULL,
6061
`timestamp` int(32) NOT NULL,
6162
PRIMARY KEY (`id`)
62-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;
63-
63+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
6464

6565
CREATE TABLE IF NOT EXISTS `faucet_user_list` (
6666
`id` int(32) unsigned NOT NULL AUTO_INCREMENT,
@@ -73,4 +73,4 @@ CREATE TABLE IF NOT EXISTS `faucet_user_list` (
7373
`last_claim` int(32) NOT NULL,
7474
`claim_cryptokey` varchar(75) NOT NULL,
7575
PRIMARY KEY (`id`)
76-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;
76+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

0 commit comments

Comments
 (0)