-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.php
97 lines (97 loc) · 3.12 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
<?php
// Starter Faucet index page.
// This is currently the only page, the post request for the coins have been put into this page as well as the form.
// However this page is a little messy coded, maybe could be cleaned up just a little.
require_once('functions/loader.php');
$loader = new loader();
$api = $loader->load('selectapi');
$template = $loader->load('template');
$config = $loader->load('configuration');
$log = $loader->load('log');
$balance = $api->getBalance();
if (isset($_GET['next'])) {
$useraddr = $_POST['address'];
$terms = $_POST['terms'];
if (!empty($terms) && !empty($terms)) {
if ($config->enable_captcha()) {
require_once('functions/recaptchalib.php');
$resp = recaptcha_check_answer($config->recaptcha_private_key(), $_SERVER['REMOTE_ADDR'], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
$continue = true;
}
} else {
$continue = true;
}
if ($continue) {
$amount = $config->faucet_amount();
if ($balance >= $amount) {
if ($log->checkIP()) {
$send = $api->sendMoney($useraddr, $amount);
if ($send->success) {
$sent = $log->getLog('sent');
// This updates the log to show how much is sent.
$log->saveLog('sent', $sent + $amount);
// Update the log to put the wait period in place.
$this->logIP();
// Unset the variables to clear the form.
unset($useraddr);
unset($amount);
$msg = 'Successful, you should see the funds in your wallet shortly.';
} else {
$msg = 'Your funds were unable to be sent, please try again later.';
}
} else {
$msg = 'Please wait more time to request more funds.';
}
} else {
$msg = 'There are currently not enough funds in the faucet.';
}
} else {
$msg = 'The captcha is incorrect, please try again.';
}
} else {
$msg = 'Please fill out the address and agree to the terms of service.';
}
}
$template->header();
if (isset($msg)) {
echo '<div class="errormsg">'.$msg.'</div>';
}
echo '<form action="index.php?next" method="post">
<table style="width:75%">';
if ($config->show_balance()) {
echo '<tr><td align="right">'.$config->coin_name().' Balance:</td>';
if (empty($balance) || is_nan($balance)) {
$balance = 'Unknown';
}
echo '<td>'.$balance.' '.$config->coin_code().'</td>';
} else {
echo '<td></td>';
}
if (!empty($_POST['terms'])) {
$checked = ' checked="checked"';
}
echo '</tr>
<tr>
<td align="right">'.$config->coin_name().' Address:</td>
<td><input type="text" name="address" maxlength="100" style="width:300px" value="'.htmlspecialchars($useraddr, ENT_QUOTES).'"/></td>
</tr>
<tr>
<td align="right">Terms of Service</td>
<td><input id="terms" type="checkbox" name="terms"'.$checked.'/><label for="terms">I agree to the <a href="terms.php" target="_blank">Terms of Service</a></label></td>
</tr>';
if ($config->enable_captcha()) {
require_once('functions/recaptchalib.php');
echo '<tr>
<td></td>
<td>'.recaptcha_get_html($config->recaptcha_public_key()).'</td>
</tr>';
}
echo '<tr>
<td></td>
<td><input type="submit" value="Send '.$config->coin_name().'"/></td>
</tr>
</form>
</table>';
$template->footer();
?>