Version Description
- 28.08.2015 =
- Bugfix : We fixed the bug with Google Captcha (reCAPTCHA) version 2 working in PHP version lower than 5.3.
Download this release
Release Info
Developer | bestwebsoft |
Plugin | Google Captcha (reCAPTCHA) by BestWebSoft |
Version | 1.19 |
Comparing to | |
See all releases |
Code changes from version 1.18 to 1.19
- google-captcha.php +13 -15
- lib_v2/autoload.php +0 -38
- lib_v2/{LICENSE → license.txt} +0 -0
- lib_v2/recaptchalib.php +151 -0
- lib_v2/src/ReCaptcha/ReCaptcha.php +0 -97
- lib_v2/src/ReCaptcha/RequestMethod.php +0 -42
- lib_v2/src/ReCaptcha/RequestMethod/Curl.php +0 -47
- lib_v2/src/ReCaptcha/RequestMethod/Post.php +0 -75
- lib_v2/src/ReCaptcha/RequestMethod/Socket.php +0 -104
- lib_v2/src/ReCaptcha/RequestMethod/SocketPost.php +0 -120
- lib_v2/src/ReCaptcha/RequestParameters.php +0 -103
- lib_v2/src/ReCaptcha/Response.php +0 -102
- lib_v2/src/autoload.php +0 -38
- readme.txt +8 -2
google-captcha.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google Captcha (reCAPTCHA) by BestWebSoft
|
|
4 |
Plugin URI: http://bestwebsoft.com/products/
|
5 |
Description: Plugin Google Captcha intended to prove that the visitor is a human being and not a spam robot.
|
6 |
Author: BestWebSoft
|
7 |
-
Version: 1.
|
8 |
Author URI: http://bestwebsoft.com/
|
9 |
License: GPLv3 or later
|
10 |
*/
|
@@ -556,8 +556,6 @@ if ( ! function_exists( 'gglcptch_display' ) ) {
|
|
556 |
return $content;
|
557 |
}
|
558 |
if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
|
559 |
-
require_once( 'lib_v2/src/autoload.php' );
|
560 |
-
$reCaptcha = new \ReCaptcha\ReCaptcha( $privatekey );
|
561 |
$content .= '<style type="text/css" media="screen">
|
562 |
#gglcptch_error {
|
563 |
color: #F00;
|
@@ -661,12 +659,12 @@ if ( ! function_exists( 'gglcptch_login_check' ) ) {
|
|
661 |
}
|
662 |
|
663 |
if ( isset( $_REQUEST['g-recaptcha-response'] ) && isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
|
664 |
-
require_once( 'lib_v2/
|
665 |
-
$reCaptcha = new
|
666 |
$gglcptch_g_recaptcha_response = isset( $_POST["g-recaptcha-response"] ) ? $_POST["g-recaptcha-response"] : '';
|
667 |
-
$resp = $reCaptcha->
|
668 |
|
669 |
-
if ( $resp != null && $resp->
|
670 |
return $user;
|
671 |
else {
|
672 |
wp_clear_auth_cookie();
|
@@ -728,12 +726,12 @@ if ( ! function_exists( 'gglcptch_lostpassword_check' ) ) {
|
|
728 |
return;
|
729 |
|
730 |
if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
|
731 |
-
require_once( 'lib_v2/
|
732 |
-
$reCaptcha = new
|
733 |
$gglcptch_g_recaptcha_response = isset( $_POST["g-recaptcha-response"] ) ? $_POST["g-recaptcha-response"] : '';
|
734 |
-
$resp = $reCaptcha->
|
735 |
|
736 |
-
if ( $resp != null && $resp->
|
737 |
return;
|
738 |
else
|
739 |
wp_die( __( 'Error: You have entered an incorrect CAPTCHA value. Click the BACK button on your browser, and try again.', 'google_captcha' ) );
|
@@ -803,12 +801,12 @@ if ( ! function_exists( 'gglcptch_captcha_check' ) ) {
|
|
803 |
$privatekey = $gglcptch_options['private_key'];
|
804 |
|
805 |
if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
|
806 |
-
require_once( 'lib_v2/
|
807 |
-
$reCaptcha = new
|
808 |
$gglcptch_g_recaptcha_response = isset( $_POST["g-recaptcha-response"] ) ? $_POST["g-recaptcha-response"] : '';
|
809 |
-
$resp = $reCaptcha->
|
810 |
|
811 |
-
if ( $resp != null && $resp->
|
812 |
echo "success";
|
813 |
else
|
814 |
echo "error";
|
4 |
Plugin URI: http://bestwebsoft.com/products/
|
5 |
Description: Plugin Google Captcha intended to prove that the visitor is a human being and not a spam robot.
|
6 |
Author: BestWebSoft
|
7 |
+
Version: 1.19
|
8 |
Author URI: http://bestwebsoft.com/
|
9 |
License: GPLv3 or later
|
10 |
*/
|
556 |
return $content;
|
557 |
}
|
558 |
if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
|
|
|
|
|
559 |
$content .= '<style type="text/css" media="screen">
|
560 |
#gglcptch_error {
|
561 |
color: #F00;
|
659 |
}
|
660 |
|
661 |
if ( isset( $_REQUEST['g-recaptcha-response'] ) && isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
|
662 |
+
require_once( 'lib_v2/recaptchalib.php' );
|
663 |
+
$reCaptcha = new gglcptch_ReCaptcha( $privatekey );
|
664 |
$gglcptch_g_recaptcha_response = isset( $_POST["g-recaptcha-response"] ) ? $_POST["g-recaptcha-response"] : '';
|
665 |
+
$resp = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $gglcptch_g_recaptcha_response );
|
666 |
|
667 |
+
if ( $resp != null && $resp->success )
|
668 |
return $user;
|
669 |
else {
|
670 |
wp_clear_auth_cookie();
|
726 |
return;
|
727 |
|
728 |
if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
|
729 |
+
require_once( 'lib_v2/recaptchalib.php' );
|
730 |
+
$reCaptcha = new gglcptch_ReCaptcha( $privatekey );
|
731 |
$gglcptch_g_recaptcha_response = isset( $_POST["g-recaptcha-response"] ) ? $_POST["g-recaptcha-response"] : '';
|
732 |
+
$resp = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $gglcptch_g_recaptcha_response );
|
733 |
|
734 |
+
if ( $resp != null && $resp->success )
|
735 |
return;
|
736 |
else
|
737 |
wp_die( __( 'Error: You have entered an incorrect CAPTCHA value. Click the BACK button on your browser, and try again.', 'google_captcha' ) );
|
801 |
$privatekey = $gglcptch_options['private_key'];
|
802 |
|
803 |
if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
|
804 |
+
require_once( 'lib_v2/recaptchalib.php' );
|
805 |
+
$reCaptcha = new gglcptch_ReCaptcha( $privatekey );
|
806 |
$gglcptch_g_recaptcha_response = isset( $_POST["g-recaptcha-response"] ) ? $_POST["g-recaptcha-response"] : '';
|
807 |
+
$resp = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $gglcptch_g_recaptcha_response );
|
808 |
|
809 |
+
if ( $resp != null && $resp->success )
|
810 |
echo "success";
|
811 |
else
|
812 |
echo "error";
|
lib_v2/autoload.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/* An autoloader for ReCaptcha\Foo classes. This should be require()d
|
4 |
-
* by the user before attempting to instantiate any of the ReCaptcha
|
5 |
-
* classes.
|
6 |
-
*/
|
7 |
-
|
8 |
-
spl_autoload_register(function ($class) {
|
9 |
-
if (substr($class, 0, 10) !== 'ReCaptcha\\') {
|
10 |
-
/* If the class does not lie under the "ReCaptcha" namespace,
|
11 |
-
* then we can exit immediately.
|
12 |
-
*/
|
13 |
-
return;
|
14 |
-
}
|
15 |
-
|
16 |
-
/* All of the classes have names like "ReCaptcha\Foo", so we need
|
17 |
-
* to replace the backslashes with frontslashes if we want the
|
18 |
-
* name to map directly to a location in the filesystem.
|
19 |
-
*/
|
20 |
-
$class = str_replace('\\', '/', $class);
|
21 |
-
|
22 |
-
/* First, check under the current directory. It is important that
|
23 |
-
* we look here first, so that we don't waste time searching for
|
24 |
-
* test classes in the common case.
|
25 |
-
*/
|
26 |
-
$path = dirname(__FILE__).'/'.$class.'.php';
|
27 |
-
if (is_readable($path)) {
|
28 |
-
require_once $path;
|
29 |
-
}
|
30 |
-
|
31 |
-
/* If we didn't find what we're looking for already, maybe it's
|
32 |
-
* a test class?
|
33 |
-
*/
|
34 |
-
$path = dirname(__FILE__).'/../tests/'.$class.'.php';
|
35 |
-
if (is_readable($path)) {
|
36 |
-
require_once $path;
|
37 |
-
}
|
38 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/{LICENSE → license.txt}
RENAMED
File without changes
|
lib_v2/recaptchalib.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
+
* - Documentation and latest version
|
5 |
+
* https://developers.google.com/recaptcha/docs/php
|
6 |
+
* - Get a reCAPTCHA API Key
|
7 |
+
* https://www.google.com/recaptcha/admin/create
|
8 |
+
* - Discussion group
|
9 |
+
* http://groups.google.com/group/recaptcha
|
10 |
+
*
|
11 |
+
* @copyright Copyright (c) 2014, Google Inc.
|
12 |
+
* @link http://www.google.com/recaptcha
|
13 |
+
*
|
14 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 |
+
* of this software and associated documentation files (the "Software"), to deal
|
16 |
+
* in the Software without restriction, including without limitation the rights
|
17 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
18 |
+
* copies of the Software, and to permit persons to whom the Software is
|
19 |
+
* furnished to do so, subject to the following conditions:
|
20 |
+
*
|
21 |
+
* The above copyright notice and this permission notice shall be included in
|
22 |
+
* all copies or substantial portions of the Software.
|
23 |
+
*
|
24 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
25 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
26 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
27 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
28 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
29 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
30 |
+
* THE SOFTWARE.
|
31 |
+
*/
|
32 |
+
|
33 |
+
/**
|
34 |
+
* A gglcptch_ReCaptchaResponse is returned from checkAnswer().
|
35 |
+
*/
|
36 |
+
class gglcptch_ReCaptchaResponse
|
37 |
+
{
|
38 |
+
public $success;
|
39 |
+
public $errorCodes;
|
40 |
+
}
|
41 |
+
|
42 |
+
class gglcptch_ReCaptcha
|
43 |
+
{
|
44 |
+
private static $_signupUrl = "https://www.google.com/recaptcha/admin";
|
45 |
+
private static $_siteVerifyUrl =
|
46 |
+
"https://www.google.com/recaptcha/api/siteverify?";
|
47 |
+
private $_secret;
|
48 |
+
private static $_version = "php_1.0";
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Constructor.
|
52 |
+
*
|
53 |
+
* @param string $secret shared secret between site and ReCAPTCHA server.
|
54 |
+
*/
|
55 |
+
function gglcptch_ReCaptcha($secret)
|
56 |
+
{
|
57 |
+
if ($secret == null || $secret == "") {
|
58 |
+
die("To use reCAPTCHA you must get an API key from <a href='"
|
59 |
+
. self::$_signupUrl . "'>" . self::$_signupUrl . "</a>");
|
60 |
+
}
|
61 |
+
$this->_secret=$secret;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Encodes the given data into a query string format.
|
66 |
+
*
|
67 |
+
* @param array $data array of string elements to be encoded.
|
68 |
+
*
|
69 |
+
* @return string - encoded request.
|
70 |
+
*/
|
71 |
+
private function _encodeQS($data)
|
72 |
+
{
|
73 |
+
$req = "";
|
74 |
+
foreach ($data as $key => $value) {
|
75 |
+
$req .= $key . '=' . urlencode(stripslashes($value)) . '&';
|
76 |
+
}
|
77 |
+
|
78 |
+
// Cut the last '&'
|
79 |
+
$req=substr($req, 0, strlen($req)-1);
|
80 |
+
return $req;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Submits an HTTP GET to a reCAPTCHA server.
|
85 |
+
*
|
86 |
+
* @param string $path url path to recaptcha server.
|
87 |
+
* @param array $data array of parameters to be sent.
|
88 |
+
*
|
89 |
+
* @return array response
|
90 |
+
*/
|
91 |
+
private function _submitHTTPGet( $path, $data )
|
92 |
+
{
|
93 |
+
$req = $this->_encodeQS($data);
|
94 |
+
if ( version_compare( phpversion(), '5.6', '<' ) ) {
|
95 |
+
$response = file_get_contents( $path . $req );
|
96 |
+
} else {
|
97 |
+
$ctx = array(
|
98 |
+
'ssl' => array(
|
99 |
+
'verify_peer' => false,
|
100 |
+
'verify_peer_name' => false,
|
101 |
+
'allow_self_signed' => true
|
102 |
+
)
|
103 |
+
);
|
104 |
+
$response = file_get_contents( $path . $req, false, stream_context_create( $ctx ) );
|
105 |
+
}
|
106 |
+
return $response;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Calls the reCAPTCHA siteverify API to verify whether the user passes
|
111 |
+
* CAPTCHA test.
|
112 |
+
*
|
113 |
+
* @param string $remoteIp IP address of end user.
|
114 |
+
* @param string $response response string from recaptcha verification.
|
115 |
+
*
|
116 |
+
* @return gglcptch_ReCaptchaResponse
|
117 |
+
*/
|
118 |
+
public function verifyResponse($remoteIp, $response)
|
119 |
+
{
|
120 |
+
// Discard empty solution submissions
|
121 |
+
if ($response == null || strlen($response) == 0) {
|
122 |
+
$recaptchaResponse = new gglcptch_ReCaptchaResponse();
|
123 |
+
$recaptchaResponse->success = false;
|
124 |
+
$recaptchaResponse->errorCodes = 'missing-input';
|
125 |
+
return $recaptchaResponse;
|
126 |
+
}
|
127 |
+
|
128 |
+
$getResponse = $this->_submitHttpGet(
|
129 |
+
self::$_siteVerifyUrl,
|
130 |
+
array (
|
131 |
+
'secret' => $this->_secret,
|
132 |
+
'remoteip' => $remoteIp,
|
133 |
+
'v' => self::$_version,
|
134 |
+
'response' => $response
|
135 |
+
)
|
136 |
+
);
|
137 |
+
$answers = json_decode($getResponse, true);
|
138 |
+
$recaptchaResponse = new gglcptch_ReCaptchaResponse();
|
139 |
+
|
140 |
+
if (trim($answers ['success']) == true) {
|
141 |
+
$recaptchaResponse->success = true;
|
142 |
+
} else {
|
143 |
+
$recaptchaResponse->success = false;
|
144 |
+
$recaptchaResponse->errorCodes = isset( $answers["error-codes"] ) ? $answers["error-codes"] : '';
|
145 |
+
}
|
146 |
+
|
147 |
+
return $recaptchaResponse;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
?>
|
lib_v2/src/ReCaptcha/ReCaptcha.php
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2015, Google Inc.
|
6 |
-
* @link http://www.google.com/recaptcha
|
7 |
-
*
|
8 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
-
* of this software and associated documentation files (the "Software"), to deal
|
10 |
-
* in the Software without restriction, including without limitation the rights
|
11 |
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
-
* copies of the Software, and to permit persons to whom the Software is
|
13 |
-
* furnished to do so, subject to the following conditions:
|
14 |
-
*
|
15 |
-
* The above copyright notice and this permission notice shall be included in
|
16 |
-
* all copies or substantial portions of the Software.
|
17 |
-
*
|
18 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 |
-
* THE SOFTWARE.
|
25 |
-
*/
|
26 |
-
|
27 |
-
namespace ReCaptcha;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* reCAPTCHA client.
|
31 |
-
*/
|
32 |
-
class ReCaptcha
|
33 |
-
{
|
34 |
-
/**
|
35 |
-
* Version of this client library.
|
36 |
-
* @const string
|
37 |
-
*/
|
38 |
-
const VERSION = 'php_1.1.1';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Shared secret for the site.
|
42 |
-
* @var type string
|
43 |
-
*/
|
44 |
-
private $secret;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Method used to communicate with service. Defaults to POST request.
|
48 |
-
* @var RequestMethod
|
49 |
-
*/
|
50 |
-
private $requestMethod;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Create a configured instance to use the reCAPTCHA service.
|
54 |
-
*
|
55 |
-
* @param string $secret shared secret between site and reCAPTCHA server.
|
56 |
-
* @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
|
57 |
-
*/
|
58 |
-
public function __construct($secret, RequestMethod $requestMethod = null)
|
59 |
-
{
|
60 |
-
if (empty($secret)) {
|
61 |
-
throw new \RuntimeException('No secret provided');
|
62 |
-
}
|
63 |
-
|
64 |
-
if (!is_string($secret)) {
|
65 |
-
throw new \RuntimeException('The provided secret must be a string');
|
66 |
-
}
|
67 |
-
|
68 |
-
$this->secret = $secret;
|
69 |
-
|
70 |
-
if (!is_null($requestMethod)) {
|
71 |
-
$this->requestMethod = $requestMethod;
|
72 |
-
} else {
|
73 |
-
$this->requestMethod = new RequestMethod\Post();
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Calls the reCAPTCHA siteverify API to verify whether the user passes
|
79 |
-
* CAPTCHA test.
|
80 |
-
*
|
81 |
-
* @param string $response The value of 'g-recaptcha-response' in the submitted form.
|
82 |
-
* @param string $remoteIp The end user's IP address.
|
83 |
-
* @return Response Response from the service.
|
84 |
-
*/
|
85 |
-
public function verify($response, $remoteIp = null)
|
86 |
-
{
|
87 |
-
// Discard empty solution submissions
|
88 |
-
if (empty($response)) {
|
89 |
-
$recaptchaResponse = new Response(false, array('missing-input-response'));
|
90 |
-
return $recaptchaResponse;
|
91 |
-
}
|
92 |
-
|
93 |
-
$params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
|
94 |
-
$rawResponse = $this->requestMethod->submit($params);
|
95 |
-
return Response::fromJson($rawResponse);
|
96 |
-
}
|
97 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/src/ReCaptcha/RequestMethod.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2015, Google Inc.
|
6 |
-
* @link http://www.google.com/recaptcha
|
7 |
-
*
|
8 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
-
* of this software and associated documentation files (the "Software"), to deal
|
10 |
-
* in the Software without restriction, including without limitation the rights
|
11 |
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
-
* copies of the Software, and to permit persons to whom the Software is
|
13 |
-
* furnished to do so, subject to the following conditions:
|
14 |
-
*
|
15 |
-
* The above copyright notice and this permission notice shall be included in
|
16 |
-
* all copies or substantial portions of the Software.
|
17 |
-
*
|
18 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 |
-
* THE SOFTWARE.
|
25 |
-
*/
|
26 |
-
|
27 |
-
namespace ReCaptcha;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Method used to send the request to the service.
|
31 |
-
*/
|
32 |
-
interface RequestMethod
|
33 |
-
{
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Submit the request with the specified parameters.
|
37 |
-
*
|
38 |
-
* @param RequestParameters $params Request parameters
|
39 |
-
* @return string Body of the reCAPTCHA response
|
40 |
-
*/
|
41 |
-
public function submit(RequestParameters $params);
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/src/ReCaptcha/RequestMethod/Curl.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ReCaptcha\RequestMethod;
|
4 |
-
|
5 |
-
use ReCaptcha\RequestMethod;
|
6 |
-
use ReCaptcha\RequestParameters;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Sends cURL request to the reCAPTCHA service.
|
10 |
-
*/
|
11 |
-
class Curl implements RequestMethod
|
12 |
-
{
|
13 |
-
/**
|
14 |
-
* URL to which requests are sent via cURL.
|
15 |
-
* @const string
|
16 |
-
*/
|
17 |
-
const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Submit the cURL request with the specified parameters.
|
21 |
-
*
|
22 |
-
* @param RequestParameters $params Request parameters
|
23 |
-
* @return string Body of the reCAPTCHA response
|
24 |
-
*/
|
25 |
-
public function submit(RequestParameters $params)
|
26 |
-
{
|
27 |
-
$handle = curl_init(self::SITE_VERIFY_URL);
|
28 |
-
|
29 |
-
$options = array(
|
30 |
-
CURLOPT_POST => true,
|
31 |
-
CURLOPT_POSTFIELDS => $params->toQueryString(),
|
32 |
-
CURLOPT_HTTPHEADER => array(
|
33 |
-
'Content-Type: application/x-www-form-urlencoded'
|
34 |
-
),
|
35 |
-
CURLINFO_HEADER_OUT => false,
|
36 |
-
CURLOPT_HEADER => false,
|
37 |
-
CURLOPT_RETURNTRANSFER => true,
|
38 |
-
CURLOPT_SSL_VERIFYPEER => true
|
39 |
-
);
|
40 |
-
curl_setopt_array($handle, $options);
|
41 |
-
|
42 |
-
$response = curl_exec($handle);
|
43 |
-
curl_close($handle);
|
44 |
-
|
45 |
-
return $response;
|
46 |
-
}
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/src/ReCaptcha/RequestMethod/Post.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2015, Google Inc.
|
6 |
-
* @link http://www.google.com/recaptcha
|
7 |
-
*
|
8 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
-
* of this software and associated documentation files (the "Software"), to deal
|
10 |
-
* in the Software without restriction, including without limitation the rights
|
11 |
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
-
* copies of the Software, and to permit persons to whom the Software is
|
13 |
-
* furnished to do so, subject to the following conditions:
|
14 |
-
*
|
15 |
-
* The above copyright notice and this permission notice shall be included in
|
16 |
-
* all copies or substantial portions of the Software.
|
17 |
-
*
|
18 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 |
-
* THE SOFTWARE.
|
25 |
-
*/
|
26 |
-
|
27 |
-
namespace ReCaptcha\RequestMethod;
|
28 |
-
|
29 |
-
use ReCaptcha\RequestMethod;
|
30 |
-
use ReCaptcha\RequestParameters;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Sends POST requests to the reCAPTCHA service.
|
34 |
-
*/
|
35 |
-
class Post implements RequestMethod
|
36 |
-
{
|
37 |
-
/**
|
38 |
-
* URL to which requests are POSTed.
|
39 |
-
* @const string
|
40 |
-
*/
|
41 |
-
const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Submit the POST request with the specified parameters.
|
45 |
-
*
|
46 |
-
* @param RequestParameters $params Request parameters
|
47 |
-
* @return string Body of the reCAPTCHA response
|
48 |
-
*/
|
49 |
-
public function submit(RequestParameters $params)
|
50 |
-
{
|
51 |
-
/**
|
52 |
-
* PHP 5.6.0 changed the way you specify the peer name for SSL context options.
|
53 |
-
* Using "CN_name" will still work, but it will raise deprecated errors.
|
54 |
-
*/
|
55 |
-
$peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name';
|
56 |
-
$options = array(
|
57 |
-
'http' => array(
|
58 |
-
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
59 |
-
'method' => 'POST',
|
60 |
-
'content' => $params->toQueryString(),
|
61 |
-
// Force the peer to validate (not needed in 5.6.0+, but still works
|
62 |
-
'verify_peer' => true,
|
63 |
-
// Force the peer validation to use www.google.com
|
64 |
-
$peer_key => 'www.google.com',
|
65 |
-
),
|
66 |
-
'ssl' => array(
|
67 |
-
'verify_peer' => false,
|
68 |
-
'verify_peer_name' => false,
|
69 |
-
'allow_self_signed' => true
|
70 |
-
)
|
71 |
-
);
|
72 |
-
$context = stream_context_create($options);
|
73 |
-
return file_get_contents(self::SITE_VERIFY_URL, false, $context);
|
74 |
-
}
|
75 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/src/ReCaptcha/RequestMethod/Socket.php
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2015, Google Inc.
|
6 |
-
* @link http://www.google.com/recaptcha
|
7 |
-
*
|
8 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
-
* of this software and associated documentation files (the "Software"), to deal
|
10 |
-
* in the Software without restriction, including without limitation the rights
|
11 |
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
-
* copies of the Software, and to permit persons to whom the Software is
|
13 |
-
* furnished to do so, subject to the following conditions:
|
14 |
-
*
|
15 |
-
* The above copyright notice and this permission notice shall be included in
|
16 |
-
* all copies or substantial portions of the Software.
|
17 |
-
*
|
18 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 |
-
* THE SOFTWARE.
|
25 |
-
*/
|
26 |
-
|
27 |
-
namespace ReCaptcha\RequestMethod;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Convenience wrapper around native socket and file functions to allow for
|
31 |
-
* mocking.
|
32 |
-
*/
|
33 |
-
class Socket
|
34 |
-
{
|
35 |
-
private $handle = null;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* fsockopen
|
39 |
-
*
|
40 |
-
* @see http://php.net/fsockopen
|
41 |
-
* @param string $hostname
|
42 |
-
* @param int $port
|
43 |
-
* @param int $errno
|
44 |
-
* @param string $errstr
|
45 |
-
* @param float $timeout
|
46 |
-
* @return resource
|
47 |
-
*/
|
48 |
-
public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null)
|
49 |
-
{
|
50 |
-
$this->handle = fsockopen($hostname, $port, $errno, $errstr, (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout));
|
51 |
-
|
52 |
-
if ($this->handle != false && $errno === 0 && $errstr === '') {
|
53 |
-
return $this->handle;
|
54 |
-
} else {
|
55 |
-
return false;
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* fwrite
|
61 |
-
*
|
62 |
-
* @see http://php.net/fwrite
|
63 |
-
* @param string $string
|
64 |
-
* @param int $length
|
65 |
-
* @return int | bool
|
66 |
-
*/
|
67 |
-
public function fwrite($string, $length = null)
|
68 |
-
{
|
69 |
-
return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length));
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* fgets
|
74 |
-
*
|
75 |
-
* @see http://php.net/fgets
|
76 |
-
* @param int $length
|
77 |
-
*/
|
78 |
-
public function fgets($length = null)
|
79 |
-
{
|
80 |
-
return fgets($this->handle, $length);
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* feof
|
85 |
-
*
|
86 |
-
* @see http://php.net/feof
|
87 |
-
* @return bool
|
88 |
-
*/
|
89 |
-
public function feof()
|
90 |
-
{
|
91 |
-
return feof($this->handle);
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* fclose
|
96 |
-
*
|
97 |
-
* @see http://php.net/fclose
|
98 |
-
* @return bool
|
99 |
-
*/
|
100 |
-
public function fclose()
|
101 |
-
{
|
102 |
-
return fclose($this->handle);
|
103 |
-
}
|
104 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/src/ReCaptcha/RequestMethod/SocketPost.php
DELETED
@@ -1,120 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2015, Google Inc.
|
6 |
-
* @link http://www.google.com/recaptcha
|
7 |
-
*
|
8 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
-
* of this software and associated documentation files (the "Software"), to deal
|
10 |
-
* in the Software without restriction, including without limitation the rights
|
11 |
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
-
* copies of the Software, and to permit persons to whom the Software is
|
13 |
-
* furnished to do so, subject to the following conditions:
|
14 |
-
*
|
15 |
-
* The above copyright notice and this permission notice shall be included in
|
16 |
-
* all copies or substantial portions of the Software.
|
17 |
-
*
|
18 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 |
-
* THE SOFTWARE.
|
25 |
-
*/
|
26 |
-
|
27 |
-
namespace ReCaptcha\RequestMethod;
|
28 |
-
|
29 |
-
use ReCaptcha\RequestMethod;
|
30 |
-
use ReCaptcha\RequestParameters;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Sends a POST request to the reCAPTCHA service, but makes use of fsockopen()
|
34 |
-
* instead of get_file_contents(). This is to account for people who may be on
|
35 |
-
* servers where allow_furl_open is disabled.
|
36 |
-
*/
|
37 |
-
class SocketPost implements RequestMethod
|
38 |
-
{
|
39 |
-
/**
|
40 |
-
* reCAPTCHA service host.
|
41 |
-
* @const string
|
42 |
-
*/
|
43 |
-
const RECAPTCHA_HOST = 'www.google.com';
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @const string reCAPTCHA service path
|
47 |
-
*/
|
48 |
-
const SITE_VERIFY_PATH = '/recaptcha/api/siteverify';
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @const string Bad request error
|
52 |
-
*/
|
53 |
-
const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}';
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @const string Bad response error
|
57 |
-
*/
|
58 |
-
const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}';
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Socket to the reCAPTCHA service
|
62 |
-
* @var Socket
|
63 |
-
*/
|
64 |
-
private $socket;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Constructor
|
68 |
-
*
|
69 |
-
* @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing
|
70 |
-
*/
|
71 |
-
public function __construct(Socket $socket = null)
|
72 |
-
{
|
73 |
-
if (!is_null($socket)) {
|
74 |
-
$this->socket = $socket;
|
75 |
-
} else {
|
76 |
-
$this->socket = new Socket();
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Submit the POST request with the specified parameters.
|
82 |
-
*
|
83 |
-
* @param RequestParameters $params Request parameters
|
84 |
-
* @return string Body of the reCAPTCHA response
|
85 |
-
*/
|
86 |
-
public function submit(RequestParameters $params)
|
87 |
-
{
|
88 |
-
$errno = 0;
|
89 |
-
$errstr = '';
|
90 |
-
|
91 |
-
if ($this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) {
|
92 |
-
$content = $params->toQueryString();
|
93 |
-
|
94 |
-
$request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n";
|
95 |
-
$request .= "Host: " . self::RECAPTCHA_HOST . "\r\n";
|
96 |
-
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
97 |
-
$request .= "Content-length: " . strlen($content) . "\r\n";
|
98 |
-
$request .= "Connection: close\r\n\r\n";
|
99 |
-
$request .= $content . "\r\n\r\n";
|
100 |
-
|
101 |
-
$this->socket->fwrite($request);
|
102 |
-
$response = '';
|
103 |
-
|
104 |
-
while (!$this->socket->feof()) {
|
105 |
-
$response .= $this->socket->fgets(4096);
|
106 |
-
}
|
107 |
-
|
108 |
-
$this->socket->fclose();
|
109 |
-
|
110 |
-
if (0 === strpos($response, 'HTTP/1.1 200 OK')) {
|
111 |
-
$parts = preg_split("#\n\s*\n#Uis", $response);
|
112 |
-
return $parts[1];
|
113 |
-
}
|
114 |
-
|
115 |
-
return self::BAD_RESPONSE;
|
116 |
-
}
|
117 |
-
|
118 |
-
return self::BAD_REQUEST;
|
119 |
-
}
|
120 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/src/ReCaptcha/RequestParameters.php
DELETED
@@ -1,103 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2015, Google Inc.
|
6 |
-
* @link http://www.google.com/recaptcha
|
7 |
-
*
|
8 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
-
* of this software and associated documentation files (the "Software"), to deal
|
10 |
-
* in the Software without restriction, including without limitation the rights
|
11 |
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
-
* copies of the Software, and to permit persons to whom the Software is
|
13 |
-
* furnished to do so, subject to the following conditions:
|
14 |
-
*
|
15 |
-
* The above copyright notice and this permission notice shall be included in
|
16 |
-
* all copies or substantial portions of the Software.
|
17 |
-
*
|
18 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 |
-
* THE SOFTWARE.
|
25 |
-
*/
|
26 |
-
|
27 |
-
namespace ReCaptcha;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Stores and formats the parameters for the request to the reCAPTCHA service.
|
31 |
-
*/
|
32 |
-
class RequestParameters
|
33 |
-
{
|
34 |
-
/**
|
35 |
-
* Site secret.
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
private $secret;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Form response.
|
42 |
-
* @var string
|
43 |
-
*/
|
44 |
-
private $response;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Remote user's IP address.
|
48 |
-
* @var string
|
49 |
-
*/
|
50 |
-
private $remoteIp;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Client version.
|
54 |
-
* @var string
|
55 |
-
*/
|
56 |
-
private $version;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Initialise parameters.
|
60 |
-
*
|
61 |
-
* @param string $secret Site secret.
|
62 |
-
* @param string $response Value from g-captcha-response form field.
|
63 |
-
* @param string $remoteIp User's IP address.
|
64 |
-
* @param string $version Version of this client library.
|
65 |
-
*/
|
66 |
-
public function __construct($secret, $response, $remoteIp = null, $version = null)
|
67 |
-
{
|
68 |
-
$this->secret = $secret;
|
69 |
-
$this->response = $response;
|
70 |
-
$this->remoteIp = $remoteIp;
|
71 |
-
$this->version = $version;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Array representation.
|
76 |
-
*
|
77 |
-
* @return array Array formatted parameters.
|
78 |
-
*/
|
79 |
-
public function toArray()
|
80 |
-
{
|
81 |
-
$params = array('secret' => $this->secret, 'response' => $this->response);
|
82 |
-
|
83 |
-
if (!is_null($this->remoteIp)) {
|
84 |
-
$params['remoteip'] = $this->remoteIp;
|
85 |
-
}
|
86 |
-
|
87 |
-
if (!is_null($this->version)) {
|
88 |
-
$params['version'] = $this->version;
|
89 |
-
}
|
90 |
-
|
91 |
-
return $params;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Query string representation for HTTP request.
|
96 |
-
*
|
97 |
-
* @return string Query string formatted parameters.
|
98 |
-
*/
|
99 |
-
public function toQueryString()
|
100 |
-
{
|
101 |
-
return http_build_query($this->toArray(), '', '&');
|
102 |
-
}
|
103 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/src/ReCaptcha/Response.php
DELETED
@@ -1,102 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2015, Google Inc.
|
6 |
-
* @link http://www.google.com/recaptcha
|
7 |
-
*
|
8 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
-
* of this software and associated documentation files (the "Software"), to deal
|
10 |
-
* in the Software without restriction, including without limitation the rights
|
11 |
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
-
* copies of the Software, and to permit persons to whom the Software is
|
13 |
-
* furnished to do so, subject to the following conditions:
|
14 |
-
*
|
15 |
-
* The above copyright notice and this permission notice shall be included in
|
16 |
-
* all copies or substantial portions of the Software.
|
17 |
-
*
|
18 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 |
-
* THE SOFTWARE.
|
25 |
-
*/
|
26 |
-
|
27 |
-
namespace ReCaptcha;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* The response returned from the service.
|
31 |
-
*/
|
32 |
-
class Response
|
33 |
-
{
|
34 |
-
/**
|
35 |
-
* Succes or failure.
|
36 |
-
* @var boolean
|
37 |
-
*/
|
38 |
-
private $success = false;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Error code strings.
|
42 |
-
* @var array
|
43 |
-
*/
|
44 |
-
private $errorCodes = array();
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Build the response from the expected JSON returned by the service.
|
48 |
-
*
|
49 |
-
* @param string $json
|
50 |
-
* @return \ReCaptcha\Response
|
51 |
-
*/
|
52 |
-
public static function fromJson($json)
|
53 |
-
{
|
54 |
-
$responseData = json_decode($json, true);
|
55 |
-
|
56 |
-
if (!$responseData) {
|
57 |
-
return new Response(false, array('invalid-json'));
|
58 |
-
}
|
59 |
-
|
60 |
-
if (isset($responseData['success']) && $responseData['success'] == true) {
|
61 |
-
return new Response(true);
|
62 |
-
}
|
63 |
-
|
64 |
-
if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
|
65 |
-
return new Response(false, $responseData['error-codes']);
|
66 |
-
}
|
67 |
-
|
68 |
-
return new Response(false);
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Constructor.
|
73 |
-
*
|
74 |
-
* @param boolean $success
|
75 |
-
* @param array $errorCodes
|
76 |
-
*/
|
77 |
-
public function __construct($success, array $errorCodes = array())
|
78 |
-
{
|
79 |
-
$this->success = $success;
|
80 |
-
$this->errorCodes = $errorCodes;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Is success?
|
85 |
-
*
|
86 |
-
* @return boolean
|
87 |
-
*/
|
88 |
-
public function isSuccess()
|
89 |
-
{
|
90 |
-
return $this->success;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Get error codes.
|
95 |
-
*
|
96 |
-
* @return array
|
97 |
-
*/
|
98 |
-
public function getErrorCodes()
|
99 |
-
{
|
100 |
-
return $this->errorCodes;
|
101 |
-
}
|
102 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_v2/src/autoload.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/* An autoloader for ReCaptcha\Foo classes. This should be require()d
|
4 |
-
* by the user before attempting to instantiate any of the ReCaptcha
|
5 |
-
* classes.
|
6 |
-
*/
|
7 |
-
|
8 |
-
spl_autoload_register(function ($class) {
|
9 |
-
if (substr($class, 0, 10) !== 'ReCaptcha\\') {
|
10 |
-
/* If the class does not lie under the "ReCaptcha" namespace,
|
11 |
-
* then we can exit immediately.
|
12 |
-
*/
|
13 |
-
return;
|
14 |
-
}
|
15 |
-
|
16 |
-
/* All of the classes have names like "ReCaptcha\Foo", so we need
|
17 |
-
* to replace the backslashes with frontslashes if we want the
|
18 |
-
* name to map directly to a location in the filesystem.
|
19 |
-
*/
|
20 |
-
$class = str_replace('\\', '/', $class);
|
21 |
-
|
22 |
-
/* First, check under the current directory. It is important that
|
23 |
-
* we look here first, so that we don't waste time searching for
|
24 |
-
* test classes in the common case.
|
25 |
-
*/
|
26 |
-
$path = dirname(__FILE__).'/'.$class.'.php';
|
27 |
-
if (is_readable($path)) {
|
28 |
-
require_once $path;
|
29 |
-
}
|
30 |
-
|
31 |
-
/* If we didn't find what we're looking for already, maybe it's
|
32 |
-
* a test class?
|
33 |
-
*/
|
34 |
-
$path = dirname(__FILE__).'/../tests/'.$class.'.php';
|
35 |
-
if (is_readable($path)) {
|
36 |
-
require_once $path;
|
37 |
-
}
|
38 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://bestwebsoft.com/donate/
|
|
4 |
Tags: anti, anti-spam, antispam, antispam security, anti-spam security, antispambot, arithmetic actions, block spam, bot, bots, best google captcha, best recaptcha, best google recaptcha, best wordpress captcha, recaptcha, capcha, captha, catcha, captcha theme, captcha bank, captcha, captcha plugin, recaptcha plugin, captcha protection, recaptcha protection, comment captcha, comment, comments, cpatcha, digitize books, digitize newspapers, digitize radio shows, e-mail, email, email address, filter, form, forms, form captcha, forgot password captcha, free, gogle, google, google captcha, google recaptcha, login, lost password, login captcha, login recaptcha, mail, match captcha, plugin, protect, protection, popular captcha, popular recaptcha, protection shield, re captcha, re-captcha, register, registration, registration spam, robot, robots, register captcha, rest password captcha, registration captcha security, spam, secure, security, signup, signup spam, spam blocker, spam comments, spam filter, spambot, shield, simple captcha, simple recaptcha, spam control, spam protection, text captcha, user, user registration spam, users, web form protection, wordpress google captcha, wp google recapthca, wp recaptcha, wordpress protection, wordpress security loss password captcha, register captcha, wp captcha
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 4.3
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -27,7 +27,7 @@ http://www.youtube.com/watch?v=10ImOhmM0Cs
|
|
27 |
|
28 |
= Copyrights for resources used in this plugin =
|
29 |
|
30 |
-
1. In Google Captcha (reCAPTCHA) plugin we used "lib/recaptchalib.php" and "lib_v2"
|
31 |
2. Everything else used in this plugin has been created by Bestwebsoft team and is distributed under GPL license.
|
32 |
|
33 |
= Features =
|
@@ -158,6 +158,9 @@ Please make sure that the problem hasn't been discussed yet on our forum (<a hre
|
|
158 |
|
159 |
== Changelog ==
|
160 |
|
|
|
|
|
|
|
161 |
= V1.18 - 26.08.2015 =
|
162 |
* NEW : Ability to restore default settings.
|
163 |
* Update : BWS Menu was updated.
|
@@ -247,6 +250,9 @@ Please make sure that the problem hasn't been discussed yet on our forum (<a hre
|
|
247 |
|
248 |
== Upgrade Notice ==
|
249 |
|
|
|
|
|
|
|
250 |
= V1.18 =
|
251 |
Ability to restore default settings. BWS Menu was updated. We updated all functionality for wordpress 4.3.
|
252 |
|
4 |
Tags: anti, anti-spam, antispam, antispam security, anti-spam security, antispambot, arithmetic actions, block spam, bot, bots, best google captcha, best recaptcha, best google recaptcha, best wordpress captcha, recaptcha, capcha, captha, catcha, captcha theme, captcha bank, captcha, captcha plugin, recaptcha plugin, captcha protection, recaptcha protection, comment captcha, comment, comments, cpatcha, digitize books, digitize newspapers, digitize radio shows, e-mail, email, email address, filter, form, forms, form captcha, forgot password captcha, free, gogle, google, google captcha, google recaptcha, login, lost password, login captcha, login recaptcha, mail, match captcha, plugin, protect, protection, popular captcha, popular recaptcha, protection shield, re captcha, re-captcha, register, registration, registration spam, robot, robots, register captcha, rest password captcha, registration captcha security, spam, secure, security, signup, signup spam, spam blocker, spam comments, spam filter, spambot, shield, simple captcha, simple recaptcha, spam control, spam protection, text captcha, user, user registration spam, users, web form protection, wordpress google captcha, wp google recapthca, wp recaptcha, wordpress protection, wordpress security loss password captcha, register captcha, wp captcha
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 4.3
|
7 |
+
Stable tag: 1.19
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
27 |
|
28 |
= Copyrights for resources used in this plugin =
|
29 |
|
30 |
+
1. In Google Captcha (reCAPTCHA) plugin we used "lib/recaptchalib.php" and "lib_v2/recaptchalib.php" file. The Licence for this file is in "lib/license.txt" and "lib_v2/license.txt" file.
|
31 |
2. Everything else used in this plugin has been created by Bestwebsoft team and is distributed under GPL license.
|
32 |
|
33 |
= Features =
|
158 |
|
159 |
== Changelog ==
|
160 |
|
161 |
+
= V1.19 - 28.08.2015 =
|
162 |
+
* Bugfix : We fixed the bug with Google Captcha (reCAPTCHA) version 2 working in PHP version lower than 5.3.
|
163 |
+
|
164 |
= V1.18 - 26.08.2015 =
|
165 |
* NEW : Ability to restore default settings.
|
166 |
* Update : BWS Menu was updated.
|
250 |
|
251 |
== Upgrade Notice ==
|
252 |
|
253 |
+
= V1.19 =
|
254 |
+
We fixed the bug with Google Captcha (reCAPTCHA) version 2 working in PHP version lower than 5.3.
|
255 |
+
|
256 |
= V1.18 =
|
257 |
Ability to restore default settings. BWS Menu was updated. We updated all functionality for wordpress 4.3.
|
258 |
|