Skip to content

Commit b5ceadb

Browse files
committed
Some implementations
1 parent b9c1798 commit b5ceadb

10 files changed

+451
-488
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea/
2+
*.DS*
3+

Diff for: adblocker.php

+34-40
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,39 @@
1-
<?php require("config.php"); ?>
1+
<?php
2+
require_once 'config.php';
3+
?>
24
<!DOCTYPE html>
3-
<html >
4-
<head>
5+
<html>
6+
<head>
57
<meta charset="UTF-8">
68
<title><?php echo $faucetTitle; ?></title>
7-
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
9-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
10-
<link rel="stylesheet" href="css/style.css">
11-
12-
13-
</head>
14-
15-
<body>
16-
17-
<div class="container">
18-
19-
<div id="login-form">
20-
21-
<h3><a href="./"><img src="<?php echo $logo; ?>" height="100"></a><br><?php echo $faucetSubtitle; ?></h3>
22-
<fieldset>
23-
<img src="images/abp.jpg" height="100">
24-
<h1>Please Disable your Adblocker</h1>
25-
<p><b>We love Adblockers</b> but we need ads to keep the faucet running, every cent we make from faucet ads is used to buy more BCN and give it away here. Please Help Us!</p>
26-
<a id="backFaucet" style="font-size:10px;" href="./?recheck">I have disabled my adblocker</a>
27-
28-
<hr>
29-
<p style="font-size:10px;">Please consider donating to keep the faucet alive. <br>Address: <?php echo $faucetAddress; ?></p></center>
30-
31-
<footer class="clearfix">
32-
</footer>
33-
</form>
34-
35-
</fieldset>
36-
37-
</div>
38-
9+
<meta name="viewport" content="width=device-width, initial-scale=1">
10+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
11+
<link rel="stylesheet" href="css/style.css">
12+
</head>
13+
14+
<body>
15+
<div class="container">
16+
<div id="login-form">
17+
18+
<h3><a href="./"><img src="<?php echo $logo; ?>" height="100"></a><br><?php echo $faucetSubtitle; ?></h3>
19+
<fieldset>
20+
<img src="images/abp.jpg" height="100">
21+
<h1>Please Disable your Adblocker</h1>
22+
<p><b>We love Adblockers</b> but we need ads to keep the faucet running, every cent we make from faucet ads
23+
is used to buy more BCN and give it away here. Please Help Us!</p>
24+
<a id="backFaucet" style="font-size:10px;" href="./?recheck">I have disabled my adblocker</a>
25+
26+
<hr>
27+
<p style="font-size:10px;">Please consider donating to keep the faucet alive.
28+
<br>Address: <?php echo $faucetAddress; ?></p></center>
29+
30+
<footer class="clearfix">
31+
</footer>
32+
</form>
33+
34+
</fieldset>
35+
</div>
3936
</div>
40-
41-
42-
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
43-
44-
</body>
37+
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
38+
</body>
4539
</html>

Diff for: classes/jsonRPCClient.php

+44-45
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?php
22
/*
33
COPYRIGHT
4-
4+
55
Copyright 2007 Sergio Vaccaro <[email protected]>
6-
6+
77
This file is part of JSON-RPC PHP.
8-
8+
99
JSON-RPC PHP is free software; you can redistribute it and/or modify
1010
it under the terms of the GNU General Public License as published by
1111
the Free Software Foundation; either version 2 of the License, or
1212
(at your option) any later version.
13-
13+
1414
JSON-RPC PHP is distributed in the hope that it will be useful,
1515
but WITHOUT ANY WARRANTY; without even the implied warranty of
1616
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717
GNU General Public License for more details.
18-
18+
1919
You should have received a copy of the GNU General Public License
2020
along with JSON-RPC PHP; if not, write to the Free Software
2121
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -27,7 +27,8 @@
2727
*
2828
* @author sergio <[email protected]>
2929
*/
30-
class jsonRPCClient {
30+
class jsonRPCClient
31+
{
3132

3233
/**
3334
* Debug state
@@ -61,8 +62,9 @@ class jsonRPCClient {
6162
* @param string $url
6263
* @param boolean $debug
6364
*/
64-
public function __construct($url,$debug = false) {
65-
// server URL
65+
public function __construct($url, $debug = false)
66+
{
67+
// server URL
6668
$this->url = $url;
6769
// proxy
6870
empty($proxy) ? $this->proxy = '' : $this->proxy = $proxy;
@@ -77,8 +79,9 @@ public function __construct($url,$debug = false) {
7779
*
7880
* @param boolean $notification
7981
*/
80-
public function setRPCNotification($notification) {
81-
empty($notification) ?
82+
public function setRPCNotification($notification)
83+
{
84+
empty($notification) ?
8285
$this->notification = false
8386
:
8487
$this->notification = true;
@@ -91,79 +94,75 @@ public function setRPCNotification($notification) {
9194
* @param array $params
9295
* @return array
9396
*/
94-
public function __call($method,$params) {
97+
public function __call($method, $params)
98+
{
9599

96100
// check
97101
if (!is_scalar($method)) {
98-
throw new Exception('Method name has no scalar value');
102+
throw new Exception('Method name has no scalar value');
99103
}
100104

101105
// check
102106
if (is_array($params)) {
103-
// no keys
107+
// no keys
104108
$params = array_values($params);
105109
} else {
106-
throw new Exception('Params must be given as array');
110+
throw new Exception('Params must be given as array');
107111
}
108112

109113
// sets notification or request task
110114
if ($this->notification) {
111-
$currentId = NULL;
115+
$currentId = null;
112116
} else {
113-
$currentId = $this->id;
117+
$currentId = $this->id;
114118
}
115119

116-
$request = array('jsonrpc' => '2.0',
120+
$request = array('jsonrpc' => '2.0',
117121
'method' => $method,
118122
'params' => $params
119123
);
120124

121-
if($method == "send_transaction" OR $method == "get_transaction" OR $method == "transfer"){
125+
if ($method == "send_transaction" or $method == "get_transaction" or $method == "transfer") {
122126
$request = str_replace(array('[', ']'), '', htmlspecialchars(json_encode($request), ENT_NOQUOTES));
123127
$this->debug && $this->debug.='***** Request *****'."\n".$request."\n".'***** End Of request *****'."\n\n";
124128

125-
if(preg_match("/\"destinations\":{/i",$request)){
126-
$request = str_replace("\"destinations\":{", "\"destinations\":[{", $request);
127-
$request = str_replace("},\"payment" ,"}],\"payment", $request);
128-
}
129-
130-
}else{
131-
$request = json_encode($request,JSON_FORCE_OBJECT);
129+
if (preg_match("/\"destinations\":{/i", $request)) {
130+
$request = str_replace("\"destinations\":{", "\"destinations\":[{", $request);
131+
$request = str_replace("},\"payment", "}],\"payment", $request);
132132
}
133+
} else {
134+
$request = json_encode($request, JSON_FORCE_OBJECT);
135+
}
133136

134137
// performs the HTTP POST
135138
$ch = curl_init($this->url);
136-
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
137-
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
138-
curl_setopt($ch, CURLOPT_POST, true);
139-
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
140-
$response = json_decode(curl_exec($ch),true);
141-
curl_close($ch);
139+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
140+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
141+
curl_setopt($ch, CURLOPT_POST, true);
142+
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
143+
$response = json_decode(curl_exec($ch), true);
144+
curl_close($ch);
142145
//print_r($response);
143146

144147
// debug output
145148
if ($this->debug) {
146-
echo nl2br($debug);
149+
echo nl2br($debug);
147150
}
148151

149152
// final checks and return
150153
if (!$this->notification) {
151-
152-
153-
if (!is_array($response)) {
154-
echo "Can't connect to wallet. Please try again later.";
155-
exit();
156-
}
154+
if (!is_array($response)) {
155+
echo "Can't connect to wallet. Please try again later.";
156+
exit();
157+
}
157158

158-
if (array_key_exists("error",$response)) {
159-
return $response['error']['message'];
160-
}
161-
162-
return $response['result'];
159+
if (array_key_exists("error", $response)) {
160+
return $response['error']['message'];
161+
}
163162

163+
return $response['result'];
164164
} else {
165-
return true;
165+
return true;
166166
}
167167
}
168168
}
169-
?>

Diff for: classes/recaptcha.php

+49-56
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,52 @@
11
<?php
22

3-
class Recaptcha {
4-
5-
6-
public function __construct($keys = array()) {
7-
$this->site_key = $keys['site_key'];
8-
$this->secret_key = $keys['secret_key'];
9-
}
10-
11-
public function set() {
12-
13-
if(isset($_POST['g-recaptcha-response'])) {
14-
return True;
15-
}
16-
17-
return False;
18-
19-
}
20-
21-
22-
public function render() {
23-
24-
//Create the html code
25-
$html = '<script src="https://www.google.com/recaptcha/api.js" async defer></script>';
26-
$html .= '<div class="g-recaptcha" data-sitekey="'.$this->site_key.'"></div>';
27-
28-
//return the html
29-
return $html;
30-
}
31-
32-
public function verify($response) {
33-
34-
//Get user ip
35-
$ip = $_SERVER['REMOTE_ADDR'];
36-
37-
//Build up the url
38-
$url = 'https://www.google.com/recaptcha/api/siteverify';
39-
$full_url = $url.'?secret='.$this->secret_key.'&response='.$response.'&remoteip='.$ip;
40-
41-
//Get the response back decode the json
42-
$data = json_decode(file_get_contents($full_url));
43-
44-
//Return true or false, based on users input
45-
if(isset($data->success) && $data->success == true) {
46-
return True;
47-
}
48-
49-
return False;
50-
}
51-
52-
53-
54-
3+
class Recaptcha
4+
{
5+
public function __construct($keys = array())
6+
{
7+
$this->site_key = $keys['site_key'];
8+
$this->secret_key = $keys['secret_key'];
9+
}
10+
11+
public function set()
12+
{
13+
if (isset($_POST['g-recaptcha-response'])) {
14+
return true;
15+
}
16+
17+
return false;
18+
}
19+
20+
21+
public function render()
22+
{
23+
24+
//Create the html code
25+
$html = '<script src="https://www.google.com/recaptcha/api.js" async defer></script>';
26+
$html .= '<div class="g-recaptcha" data-sitekey="'.$this->site_key.'"></div>';
27+
28+
//return the html
29+
return $html;
30+
}
31+
32+
public function verify($response)
33+
{
34+
35+
//Get user ip
36+
$ip = $_SERVER['REMOTE_ADDR'];
37+
38+
//Build up the url
39+
$url = 'https://www.google.com/recaptcha/api/siteverify';
40+
$full_url = $url.'?secret='.$this->secret_key.'&response='.$response.'&remoteip='.$ip;
41+
42+
//Get the response back decode the json
43+
$data = json_decode(file_get_contents($full_url));
44+
45+
//Return true or false, based on users input
46+
if (isset($data->success) && $data->success == true) {
47+
return true;
48+
}
49+
50+
return false;
51+
}
5552
}
56-
57-
58-
59-
?>

0 commit comments

Comments
 (0)