init
This commit is contained in:
28
user/plugins/form/vendor/google/recaptcha/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
28
user/plugins/form/vendor/google/recaptcha/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: PHP client issue
|
||||
about: Report an issue with the PHP client library
|
||||
|
||||
---
|
||||
|
||||
**Issue description**
|
||||
<!-- One or two sentences describing the problem -->
|
||||
|
||||
**Environment**
|
||||
<!-- The server or development environment where you're seeing the problem -->
|
||||
|
||||
* OS name and version:
|
||||
* PHP version:
|
||||
* Web server name and version:
|
||||
* `google/recaptcha` version:
|
||||
* Browser name and version:
|
||||
|
||||
**Reproducing the issue**
|
||||
<!-- Where possible link to a URL where the problem can be seen or show code that causes it -->
|
||||
|
||||
* URL (optional): <!-- if your integration is already deployed and the issue is visible -->
|
||||
* Code (optional): <!-- share a link to the code you're using or an example in a Gist -->
|
||||
|
||||
***User steps***
|
||||
<!-- Detail the necessary steps to reproduce the issue. Include the output of any error messages. -->
|
||||
|
||||
1. Visit page...
|
||||
7
user/plugins/form/vendor/google/recaptcha/.gitignore
vendored
Normal file
7
user/plugins/form/vendor/google/recaptcha/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/.php_cs.cache
|
||||
/.phpunit.result.cache
|
||||
/build
|
||||
/composer.lock
|
||||
/examples/config.php
|
||||
/nbproject/private/
|
||||
/vendor/
|
||||
33
user/plugins/form/vendor/google/recaptcha/.travis.yml
vendored
Normal file
33
user/plugins/form/vendor/google/recaptcha/.travis.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
dist: trusty
|
||||
|
||||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
php:
|
||||
- '5.5'
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
|
||||
before_script:
|
||||
- composer install
|
||||
- phpenv version-name | grep ^5.[34] && echo "extension=apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
|
||||
- phpenv version-name | grep ^5.[34] && echo "apc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
|
||||
|
||||
script:
|
||||
- mkdir -p build/logs
|
||||
- composer run-script lint
|
||||
- composer run-script test
|
||||
|
||||
after_success:
|
||||
- travis_retry php vendor/bin/php-coveralls
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.composer/cache/files"
|
||||
|
||||
git:
|
||||
depth: 5
|
||||
64
user/plugins/form/vendor/google/recaptcha/ARCHITECTURE.md
vendored
Normal file
64
user/plugins/form/vendor/google/recaptcha/ARCHITECTURE.md
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# Architecture
|
||||
|
||||
The general pattern of usage is to instantiate the `ReCaptcha` class with your
|
||||
secret key, specify any additional validation rules, and then call `verify()`
|
||||
with the reCAPTCHA response and user's IP address. For example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
|
||||
->verify($gRecaptchaResponse, $remoteIp);
|
||||
if ($resp->isSuccess()) {
|
||||
// Verified!
|
||||
} else {
|
||||
$errors = $resp->getErrorCodes();
|
||||
}
|
||||
```
|
||||
|
||||
By default, this will use the
|
||||
[`stream_context_create()`](https://secure.php.net/stream_context_create) and
|
||||
[`file_get_contents()`](https://secure.php.net/file_get_contents) to make a POST
|
||||
request to the reCAPTCHA service. This is handled by the
|
||||
[`RequestMethod\Post`](./src/ReCaptcha/RequestMethod/Post.php) class.
|
||||
|
||||
## Alternate request methods
|
||||
|
||||
You may need to use other methods for making requests in your environment. The
|
||||
[`ReCaptcha`](./src/ReCaptcha/ReCaptcha.php) class allows an optional
|
||||
[`RequestMethod`](./src/ReCaptcha/RequestMethod.php) instance to configure this.
|
||||
For example, if you want to use [cURL](https://secure.php.net/curl) instead you
|
||||
can do this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\CurlPost());
|
||||
```
|
||||
|
||||
Alternatively, you can also use a [socket](https://secure.php.net/fsockopen):
|
||||
|
||||
```php
|
||||
<?php
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
|
||||
```
|
||||
|
||||
## Adding new request methods
|
||||
|
||||
Create a class that implements the
|
||||
[`RequestMethod`](./src/ReCaptcha/RequestMethod.php) interface. The convention
|
||||
is to name this class `RequestMethod\`_MethodType_`Post` and create a separate
|
||||
`RequestMethod\`_MethodType_ class that wraps just the calls to the network
|
||||
calls themselves. This means that the `RequestMethod\`_MethodType_`Post` can be
|
||||
unit tested by passing in a mock. Take a look at
|
||||
[`RequestMethod\CurlPost`](./src/ReCaptcha/RequestMethod/CurlPost.php) and
|
||||
[`RequestMethod\Curl`](./src/ReCaptcha/RequestMethod/Curl.php) with the matching
|
||||
[`RequestMethod/CurlPostTest`](./tests/ReCaptcha/RequestMethod/CurlPostTest.php)
|
||||
to see this pattern in action.
|
||||
|
||||
### Error conventions
|
||||
|
||||
The client returns the response as provided by the reCAPTCHA services augmented
|
||||
with additional error codes based on the client's checks. When adding a new
|
||||
[`RequestMethod`](./src/ReCaptcha/RequestMethod.php) ensure that it returns the
|
||||
`ReCaptcha::E_CONNECTION_FAILED` and `ReCaptcha::E_BAD_RESPONSE` where
|
||||
appropriate.
|
||||
49
user/plugins/form/vendor/google/recaptcha/CONTRIBUTING.md
vendored
Normal file
49
user/plugins/form/vendor/google/recaptcha/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# Contributing
|
||||
|
||||
Want to contribute? Great! First, read this page (including the small print at
|
||||
the end).
|
||||
|
||||
## Contributor License Agreement
|
||||
|
||||
Before we can use your code, you must sign the [Google Individual Contributor
|
||||
License
|
||||
Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
|
||||
(CLA), which you can do online. The CLA is necessary mainly because you own the
|
||||
copyright to your changes, even after your contribution becomes part of our
|
||||
codebase, so we need your permission to use and distribute your code. We also
|
||||
need to be sure of various other things—for instance that you'll tell us if you
|
||||
know that your code infringes on other people's patents. You don't have to sign
|
||||
the CLA until after you've submitted your code for review (a link will be
|
||||
automatically added to your Pull Request) and a member has approved it, but you
|
||||
must do it before we can put your code into our codebase. Before you start
|
||||
working on a larger contribution, you should get in touch with us first through
|
||||
the issue tracker with your idea so that we can help out and possibly guide you.
|
||||
Coordinating up front makes it much easier to avoid frustration later on.
|
||||
|
||||
## Linting and testing
|
||||
|
||||
We use PHP Coding Standards Fixer to maintain coding standards and PHPUnit to
|
||||
run our tests. For convenience, there are Composer scripts to run each of these:
|
||||
|
||||
```sh
|
||||
composer run-script lint
|
||||
composer run-script test
|
||||
```
|
||||
|
||||
These are run automatically by [Travis
|
||||
CI](https://travis-ci.org/google/recaptcha) against your Pull Request, but it's
|
||||
a good idea to run them locally before submission to avoid getting things
|
||||
bounced back. That said, tests can be a little daunting so feel free to submit
|
||||
your PR and ask for help.
|
||||
|
||||
## Code reviews
|
||||
|
||||
All submissions, including submissions by project members, require review.
|
||||
Reviews are conducted on the Pull Requests. The reviews are there to ensure and
|
||||
improve code quality, so treat them like a discussion and opportunity to learn.
|
||||
Don't get disheartened if your Pull Request isn't just automatically approved.
|
||||
|
||||
### The small print
|
||||
|
||||
Contributions made by corporations are covered by a different agreement than the
|
||||
one above, the Software Grant and Corporate Contributor License Agreement.
|
||||
29
user/plugins/form/vendor/google/recaptcha/LICENSE
vendored
Normal file
29
user/plugins/form/vendor/google/recaptcha/LICENSE
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2019, Google Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
140
user/plugins/form/vendor/google/recaptcha/README.md
vendored
Normal file
140
user/plugins/form/vendor/google/recaptcha/README.md
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
# reCAPTCHA PHP client library
|
||||
|
||||
[](https://travis-ci.org/google/recaptcha)
|
||||
[](https://coveralls.io/github/google/recaptcha)
|
||||
[](https://packagist.org/packages/google/recaptcha)
|
||||
[](https://packagist.org/packages/google/recaptcha)
|
||||
|
||||
reCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse.
|
||||
This is a PHP library that wraps up the server-side verification step required
|
||||
to process responses from the reCAPTCHA service. This client supports both v2
|
||||
and v3.
|
||||
|
||||
- reCAPTCHA: https://www.google.com/recaptcha
|
||||
- This repo: https://github.com/google/recaptcha
|
||||
- Hosted demo: https://recaptcha-demo.appspot.com/
|
||||
- Version: 1.2.4
|
||||
- License: BSD, see [LICENSE](LICENSE)
|
||||
|
||||
## Installation
|
||||
|
||||
### Composer (recommended)
|
||||
|
||||
Use [Composer](https://getcomposer.org) to install this library from Packagist:
|
||||
[`google/recaptcha`](https://packagist.org/packages/google/recaptcha)
|
||||
|
||||
Run the following command from your project directory to add the dependency:
|
||||
|
||||
```sh
|
||||
composer require google/recaptcha "^1.2"
|
||||
```
|
||||
|
||||
Alternatively, add the dependency directly to your `composer.json` file:
|
||||
|
||||
```json
|
||||
"require": {
|
||||
"google/recaptcha": "^1.2"
|
||||
}
|
||||
```
|
||||
|
||||
### Direct download
|
||||
|
||||
Download the [ZIP file](https://github.com/google/recaptcha/archive/master.zip)
|
||||
and extract into your project. An autoloader script is provided in
|
||||
`src/autoload.php` which you can require into your script. For example:
|
||||
|
||||
```php
|
||||
require_once '/path/to/recaptcha/src/autoload.php';
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
```
|
||||
|
||||
The classes in the project are structured according to the
|
||||
[PSR-4](http://www.php-fig.org/psr/psr-4/) standard, so you can also use your
|
||||
own autoloader or require the needed files directly in your code.
|
||||
|
||||
## Usage
|
||||
|
||||
First obtain the appropriate keys for the type of reCAPTCHA you wish to
|
||||
integrate for v2 at https://www.google.com/recaptcha/admin or v3 at
|
||||
https://g.co/recaptcha/v3.
|
||||
|
||||
Then follow the [integration guide on the developer
|
||||
site](https://developers.google.com/recaptcha/intro) to add the reCAPTCHA
|
||||
functionality into your frontend.
|
||||
|
||||
This library comes in when you need to verify the user's response. On the PHP
|
||||
side you need the response from the reCAPTCHA service and secret key from your
|
||||
credentials. Instantiate the `ReCaptcha` class with your secret key, specify any
|
||||
additional validation rules, and then call `verify()` with the reCAPTCHA
|
||||
response and user's IP address. For example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
|
||||
->verify($gRecaptchaResponse, $remoteIp);
|
||||
if ($resp->isSuccess()) {
|
||||
// Verified!
|
||||
} else {
|
||||
$errors = $resp->getErrorCodes();
|
||||
}
|
||||
```
|
||||
|
||||
The following methods are available:
|
||||
|
||||
- `setExpectedHostname($hostname)`: ensures the hostname matches. You must do
|
||||
this if you have disabled "Domain/Package Name Validation" for your
|
||||
credentials.
|
||||
- `setExpectedApkPackageName($apkPackageName)`: if you're verifying a response
|
||||
from an Android app. Again, you must do this if you have disabled
|
||||
"Domain/Package Name Validation" for your credentials.
|
||||
- `setExpectedAction($action)`: ensures the action matches for the v3 API.
|
||||
- `setScoreThreshold($threshold)`: set a score threshold for responses from the
|
||||
v3 API
|
||||
- `setChallengeTimeout($timeoutSeconds)`: set a timeout between the user passing
|
||||
the reCAPTCHA and your server processing it.
|
||||
|
||||
Each of the `set`\*`()` methods return the `ReCaptcha` instance so you can chain
|
||||
them together. For example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
|
||||
->setExpectedAction('homepage')
|
||||
->setScoreThreshold(0.5)
|
||||
->verify($gRecaptchaResponse, $remoteIp);
|
||||
|
||||
if ($resp->isSuccess()) {
|
||||
// Verified!
|
||||
} else {
|
||||
$errors = $resp->getErrorCodes();
|
||||
}
|
||||
```
|
||||
|
||||
You can find the constants for the libraries error codes in the `ReCaptcha`
|
||||
class constants, e.g. `ReCaptcha::E_HOSTNAME_MISMATCH`
|
||||
|
||||
For more details on usage and structure, see [ARCHITECTURE](ARCHITECTURE.md).
|
||||
|
||||
### Examples
|
||||
|
||||
You can see examples of each reCAPTCHA type in [examples/](examples/). You can
|
||||
run the examples locally by using the Composer script:
|
||||
|
||||
```sh
|
||||
composer run-script serve-examples
|
||||
```
|
||||
|
||||
This makes use of the in-built PHP dev server to host the examples at
|
||||
http://localhost:8080/
|
||||
|
||||
These are also hosted on Google AppEngine Flexible environment at
|
||||
https://recaptcha-demo.appspot.com/. This is configured by
|
||||
[`app.yaml`](./app.yaml) which you can also use to [deploy to your own AppEngine
|
||||
project](https://cloud.google.com/appengine/docs/flexible/php/download).
|
||||
|
||||
## Contributing
|
||||
|
||||
No one ever has enough engineers, so we're very happy to accept contributions
|
||||
via Pull Requests. For details, see [CONTRIBUTING](CONTRIBUTING.md)
|
||||
8
user/plugins/form/vendor/google/recaptcha/app.yaml
vendored
Normal file
8
user/plugins/form/vendor/google/recaptcha/app.yaml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
runtime: php
|
||||
env: flex
|
||||
|
||||
skip_files:
|
||||
- tests
|
||||
|
||||
runtime_config:
|
||||
document_root: examples
|
||||
39
user/plugins/form/vendor/google/recaptcha/composer.json
vendored
Normal file
39
user/plugins/form/vendor/google/recaptcha/composer.json
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "google/recaptcha",
|
||||
"description": "Client library for reCAPTCHA, a free service that protects websites from spam and abuse.",
|
||||
"type": "library",
|
||||
"keywords": ["recaptcha", "captcha", "spam", "abuse"],
|
||||
"homepage": "https://www.google.com/recaptcha/",
|
||||
"license": "BSD-3-Clause",
|
||||
"support": {
|
||||
"forum": "https://groups.google.com/forum/#!forum/recaptcha",
|
||||
"source": "https://github.com/google/recaptcha"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11",
|
||||
"friendsofphp/php-cs-fixer": "^2.2.20|^2.15",
|
||||
"php-coveralls/php-coveralls": "^2.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ReCaptcha\\": "src/ReCaptcha"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2.x-dev"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "vendor/bin/php-cs-fixer -vvv fix --using-cache=no --dry-run .",
|
||||
"lint-fix": "vendor/bin/php-cs-fixer -vvv fix --using-cache=no .",
|
||||
"test": "vendor/bin/phpunit --colors=always",
|
||||
"serve-examples": "@php -S localhost:8080 -t examples"
|
||||
},
|
||||
"config": {
|
||||
"process-timeout": 0
|
||||
}
|
||||
}
|
||||
42
user/plugins/form/vendor/google/recaptcha/examples/appengine-https.php
vendored
Normal file
42
user/plugins/form/vendor/google/recaptcha/examples/appengine-https.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Redirect to HTTPS by default (for AppEngine)
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
|
||||
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'http') {
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
|
||||
exit(0);
|
||||
} else {
|
||||
header('Strict-Transport-Security: max-age=63072000; includeSubDomains; preload');
|
||||
}
|
||||
}
|
||||
46
user/plugins/form/vendor/google/recaptcha/examples/config.php.dist
vendored
Normal file
46
user/plugins/form/vendor/google/recaptcha/examples/config.php.dist
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
return [
|
||||
'v2-standard' => [
|
||||
'site' => '',
|
||||
'secret' => '',
|
||||
],
|
||||
'v2-invisible' => [
|
||||
'site' => '',
|
||||
'secret' => '',
|
||||
],
|
||||
'v3' => [
|
||||
'site' => '',
|
||||
'secret' => '',
|
||||
],
|
||||
];
|
||||
37
user/plugins/form/vendor/google/recaptcha/examples/examples.css
vendored
Normal file
37
user/plugins/form/vendor/google/recaptcha/examples/examples.css
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
p {
|
||||
margin: 0;
|
||||
padding: 0.5rem 0 0 0;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
color: #222244;
|
||||
}
|
||||
|
||||
header {
|
||||
padding: 0.5rem 2rem 0.5rem 2rem;
|
||||
background: #f0f0f4;
|
||||
border-bottom: 1px solid #aaaabb;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 0.5rem 2rem 0.5rem 2rem;
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: block;
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
1
user/plugins/form/vendor/google/recaptcha/examples/google0afd8760fd68f119.html
vendored
Normal file
1
user/plugins/form/vendor/google/recaptcha/examples/google0afd8760fd68f119.html
vendored
Normal file
@@ -0,0 +1 @@
|
||||
google-site-verification: google0afd8760fd68f119.html
|
||||
79
user/plugins/form/vendor/google/recaptcha/examples/index.php
vendored
Normal file
79
user/plugins/form/vendor/google/recaptcha/examples/index.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/appengine-https.php';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height,minimum-scale=1">
|
||||
<link rel="shortcut icon" href="https://www.gstatic.com/recaptcha/admin/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="canonical" href="https://recaptcha-demo.appspot.com/">
|
||||
<script type="application/ld+json">{ "@context": "http://schema.org", "@type": "WebSite", "name": "reCAPTCHA demo", "url": "http://recaptcha-demo.appspot.com/" }</script>
|
||||
<meta name="description" content="reCAPTCHA demo" />
|
||||
<meta property="og:url" content="https://recaptcha-demo.appspot.com/" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="reCAPTCHA demo" />
|
||||
<meta property="og:description" content="Examples of the reCAPTCHA client." />
|
||||
<link rel="stylesheet" type="text/css" href="/examples.css">
|
||||
<title>reCAPTCHA demo</title>
|
||||
|
||||
<header>
|
||||
<h1>reCAPTCHA demo</h1>
|
||||
</header>
|
||||
<main>
|
||||
<p>Try out the various forms of <a href="https://www.google.com/recaptcha/">reCAPTCHA</a>.</p>
|
||||
<p>You can find the source code for these examples on GitHub in <kbd><a href="https://github.com/google/recaptcha">google/recaptcha</a></kbd>.</p>
|
||||
<ul>
|
||||
<li><h2>reCAPTCHA v2</h2>
|
||||
<ul>
|
||||
<li><a href="/recaptcha-v2-checkbox.php">"I'm not a robot" checkbox</a></li>
|
||||
<li><a href="/recaptcha-v2-checkbox-explicit.php">"I'm not a robot" checkbox - Explicit render</a></li>
|
||||
<li><a href="/recaptcha-v2-invisible.php">Invisible</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h2>reCAPTCHA v3</h2>
|
||||
<ul>
|
||||
<li><a href="/recaptcha-v3-request-scores.php">Request scores</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h2>General</h2>
|
||||
<ul>
|
||||
<li><a href="/recaptcha-content-security-policy.php">Content Security Policy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</main>
|
||||
|
||||
<!-- Google Analytics - just ignore this -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123057962-1"></script>
|
||||
<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-123057962-1');</script>
|
||||
152
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-content-security-policy.php
vendored
Normal file
152
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-content-security-policy.php
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/appengine-https.php';
|
||||
|
||||
// Initiate the autoloader. The file should be generated by Composer.
|
||||
// You will provide your own autoloader or require the files directly if you did
|
||||
// not install via Composer.
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// This example shows the use of a Content Security Policy
|
||||
// https://developers.google.com/web/fundamentals/security/csp/
|
||||
|
||||
// First we generate a pseudorandom nonce for each included or inline script
|
||||
$nonce = base64_encode(openssl_random_pseudo_bytes(16));
|
||||
|
||||
// Send the CSP header
|
||||
// Try commenting out the various lines to see what effect it has
|
||||
|
||||
// NOTE: Always test your policy Content-Security-Policy-Report-Only first to
|
||||
// ensure you're not blocking any critical functionality. CSP is an important
|
||||
// security feature but you can break entire sections of your site if you
|
||||
// implement it incorrectly.
|
||||
header(
|
||||
"Content-Security-Policy: "
|
||||
."default-src 'none'; " // By default we will deny everything
|
||||
|
||||
."script-src 'nonce-".$nonce."' 'strict-dynamic'; " // nonce allowing the reCAPTCHA library and other third-party scripts to be included
|
||||
|
||||
."img-src https://www.gstatic.com/recaptcha/ https://www.google-analytics.com; " // allow images from these URLS
|
||||
."frame-src https://www.google.com/; " // allow frames from this URL
|
||||
|
||||
."style-src 'self'; " // allow style from our own origin
|
||||
."connect-src 'self'; " // allow the fetch calls to our own origin
|
||||
);
|
||||
|
||||
// Register API keys at https://www.google.com/recaptcha/admin
|
||||
$siteKey = '';
|
||||
$secret = '';
|
||||
|
||||
// Copy the config.php.dist file to config.php and update it with your keys to run the examples
|
||||
if ($siteKey == '' && is_readable(__DIR__ . '/config.php')) {
|
||||
$config = include __DIR__ . '/config.php';
|
||||
$siteKey = $config['v3']['site'];
|
||||
$secret = $config['v3']['secret'];
|
||||
}
|
||||
|
||||
// reCAPTCHA supports 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
|
||||
$lang = 'en';
|
||||
|
||||
// The v3 API lets you provide some context for the check by specifying an action.
|
||||
// See: https://developers.google.com/recaptcha/docs/v3
|
||||
$pageAction = 'examples/csp';
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height,minimum-scale=1">
|
||||
<link rel="shortcut icon" href="https://www.gstatic.com/recaptcha/admin/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="canonical" href="https://recaptcha-demo.appspot.com/recaptcha-content-security-policy.php">
|
||||
<script type="application/ld+json">{ "@context": "http://schema.org", "@type": "WebSite", "name": "reCAPTCHA demo - Content Security Policy", "url": "https://recaptcha-demo.appspot.com/recaptcha-content-security-policy.php" }</script>
|
||||
<meta name="description" content="reCAPTCHA demo - Content Security Policy" />
|
||||
<meta property="og:url" content="https://recaptcha-demo.appspot.com/recaptcha-content-security-policy.php" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="reCAPTCHA demo - Content Security Policy" />
|
||||
<meta property="og:description" content="reCAPTCHA demo - Content Security Policy" />
|
||||
<link rel="stylesheet" type="text/css" href="/examples.css">
|
||||
<title>reCAPTCHA demo - Content Security Policy</title>
|
||||
<header>
|
||||
<h1>reCAPTCHA demo</h1><h2>Content Security Policy</h2>
|
||||
<p><a href="/">↩️ Home</a></p>
|
||||
</header>
|
||||
<main>
|
||||
<?php
|
||||
if ($siteKey === '' || $secret === ''):
|
||||
?>
|
||||
<h2>Add your keys</h2>
|
||||
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
|
||||
<?php
|
||||
else:
|
||||
?>
|
||||
<p>This example is sending the <kbd>Content-Security-Policy</kbd> header. Look at the source and inspect the network tab for this request to see what's happening. The reCAPTCHA v3 API is being called here, however you can use the same approach for the v2 API calls as well.</p>
|
||||
<p><strong>NOTE:</strong>This is a sample implementation, the score returned here is not a reflection on your Google account or type of traffic. In production, refer to the distribution of scores shown in <a href="https://www.google.com/recaptcha/admin" target="_blank">your admin interface</a> and adjust your own threshold accordingly. <strong>Do not raise issues regarding the score you see here.</strong></p>
|
||||
<ol id="recaptcha-steps">
|
||||
<li class="step0">reCAPTCHA script loading</li>
|
||||
<li class="step1 hidden"><kbd>grecaptcha.ready()</kbd> fired, calling <pre>grecaptcha.execute('<?php echo $siteKey; ?>', {action: '<?php echo $pageAction; ?>'})'</pre></li>
|
||||
<li class="step2 hidden">Received token from reCAPTCHA service, sending to our backend with:
|
||||
<pre class="token">fetch('/recaptcha-v3-verify.php?token=abc123</pre></li>
|
||||
<li class="step3 hidden">Received response from our backend: <pre class="response">{"json": "from-backend"}</pre></li>
|
||||
</ol>
|
||||
<p><a href="/recaptcha-content-security-policy.php">⤴️ Try again</a></p>
|
||||
|
||||
<!-- Add the nonce for our inline script to this tag -->
|
||||
<script nonce="<?php echo $nonce; ?>">
|
||||
var onloadCallback = function() {
|
||||
const steps = document.getElementById('recaptcha-steps');
|
||||
grecaptcha.ready(function() {
|
||||
document.querySelector('.step1').classList.remove('hidden');
|
||||
grecaptcha.execute('<?php echo $siteKey; ?>', {action: '<?php echo $pageAction; ?>'}).then(function(token) {
|
||||
document.querySelector('.token').innerHTML = 'fetch(\'/recaptcha-v3-verify.php?action=<?php echo $pageAction; ?>&token=\'' + token;
|
||||
document.querySelector('.step2').classList.remove('hidden');
|
||||
|
||||
fetch('/recaptcha-v3-verify.php?action=<?php echo $pageAction; ?>&token='+token).then(function(response) {
|
||||
response.json().then(function(data) {
|
||||
document.querySelector('.response').innerHTML = JSON.stringify(data, null, 2);
|
||||
document.querySelector('.step3').classList.remove('hidden');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<!-- Add the nonce value for the reCAPTCHA library to its script tag -->
|
||||
<script async defer src="https://www.google.com/recaptcha/api.js?render=<?php echo $siteKey; ?>&onload=onloadCallback" nonce="<?php echo $nonce; ?>"></script>
|
||||
|
||||
<?php
|
||||
endif;?>
|
||||
</main>
|
||||
|
||||
<!-- Google Analytics - adding nonces here for the library and the inline code -->
|
||||
<script async defer src="https://www.googletagmanager.com/gtag/js?id=UA-123057962-1" nonce="<?php echo $nonce; ?>"></script>
|
||||
<script async nonce="<?php echo $nonce; ?>">window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-123057962-1');</script>
|
||||
148
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-checkbox-explicit.php
vendored
Normal file
148
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-checkbox-explicit.php
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/appengine-https.php';
|
||||
|
||||
// Initiate the autoloader. The file should be generated by Composer.
|
||||
// You will provide your own autoloader or require the files directly if you did
|
||||
// not install via Composer.
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Register API keys at https://www.google.com/recaptcha/admin
|
||||
$siteKey = '';
|
||||
$secret = '';
|
||||
|
||||
// Copy the config.php.dist file to config.php and update it with your keys to run the examples
|
||||
if ($siteKey == '' && is_readable(__DIR__ . '/config.php')) {
|
||||
$config = include __DIR__ . '/config.php';
|
||||
$siteKey = $config['v2-standard']['site'];
|
||||
$secret = $config['v2-standard']['secret'];
|
||||
}
|
||||
|
||||
// reCAPTCHA supports 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
|
||||
$lang = 'en';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height,minimum-scale=1">
|
||||
<link rel="shortcut icon" href="https://www.gstatic.com/recaptcha/admin/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="canonical" href="https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox-explicit.php">
|
||||
<script type="application/ld+json">{ "@context": "http://schema.org", "@type": "WebSite", "name": "reCAPTCHA demo - \"I'm not a robot\" checkbox - Explicit render", "url": "https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox-explicit.php" }</script>
|
||||
<meta name="description" content="reCAPTCHA demo - "I'm not a robot" checkbox - Explicit render" />
|
||||
<meta property="og:url" content="https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox-explicit.php" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="reCAPTCHA demo - "I'm not a robot" checkbox - Explicit render" />
|
||||
<meta property="og:description" content="reCAPTCHA demo - "I'm not a robot" checkbox - Explicit render" />
|
||||
<link rel="stylesheet" type="text/css" href="/examples.css">
|
||||
<title>reCAPTCHA demo - "I'm not a robot" checkbox - Explicit render</title>
|
||||
|
||||
<header>
|
||||
<h1>reCAPTCHA demo</h1><h2>"I'm not a robot" checkbox - Explicit render</h2>
|
||||
<p><a href="/">↩️ Home</a></p>
|
||||
</header>
|
||||
<main>
|
||||
<?php
|
||||
if ($siteKey === '' || $secret === ''):
|
||||
?>
|
||||
<h2>Add your keys</h2>
|
||||
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in the <kbd>config.php</kbd> file or directly to <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
|
||||
<?php
|
||||
elseif (isset($_POST['g-recaptcha-response'])):
|
||||
// The POST data here is unfiltered because this is an example.
|
||||
// In production, *always* sanitise and validate your input'
|
||||
?>
|
||||
<h2><kbd>POST</kbd> data</h2>
|
||||
<kbd><pre><?php var_export($_POST);?></pre></kbd>
|
||||
<?php
|
||||
// If the form submission includes the "g-captcha-response" field
|
||||
// Create an instance of the service using your secret
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
|
||||
// If file_get_contents() is locked down on your PHP installation to disallow
|
||||
// its use with URLs, then you can use the alternative request method instead.
|
||||
// This makes use of fsockopen() instead.
|
||||
// $recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
|
||||
// Make the call to verify the response and also pass the user's IP address
|
||||
$resp = $recaptcha->setExpectedHostname($_SERVER['SERVER_NAME'])
|
||||
->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if ($resp->isSuccess()):
|
||||
// If the response is a success, that's it!
|
||||
?>
|
||||
<h2>Success!</h2>
|
||||
<kbd><pre><?php var_export($resp);?></pre></kbd>
|
||||
<p>That's it. Everything is working. Go integrate this into your real project.</p>
|
||||
<p><a href="/recaptcha-v2-checkbox-explicit.php">⤴️ Try again</a></p>
|
||||
<?php
|
||||
else:
|
||||
// If it's not successful, then one or more error codes will be returned.
|
||||
?>
|
||||
<h2>Something went wrong</h2>
|
||||
<kbd><pre><?php var_export($resp);?></pre></kbd>
|
||||
<p>Check the error code reference at <kbd><a href="https://developers.google.com/recaptcha/docs/verify#error-code-reference">https://developers.google.com/recaptcha/docs/verify#error-code-reference</a></kbd>.
|
||||
<p><strong>Note:</strong> Error code <kbd>missing-input-response</kbd> may mean the user just didn't complete the reCAPTCHA.</p>
|
||||
<p><a href="/recaptcha-v2-checkbox-explicit.php">⤴️ Try again</a></p>
|
||||
<?php
|
||||
endif;
|
||||
else:
|
||||
// Add the g-recaptcha tag to the form you want to include the reCAPTCHA element
|
||||
?>
|
||||
<p>Complete the reCAPTCHA then submit the form.</p>
|
||||
<form action="/recaptcha-v2-checkbox-explicit.php" method="post">
|
||||
<fieldset>
|
||||
<legend>An example form</legend>
|
||||
<label class="form-field">Example input A: <input type="text" name="ex-a" value="foo"></label>
|
||||
<label class="form-field">Example input B: <input type="text" name="ex-b" value="bar"></label>
|
||||
<!-- Set up a container to render the widget -->
|
||||
<div class="g-recaptcha form-field"></div>
|
||||
<!-- Disable the button by default, will enable when the widget loads -->
|
||||
<button class="form-field" type="submit" disabled>Submit ↦</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
var onloadCallback = function() {
|
||||
var captchaContainer = document.querySelector('.g-recaptcha');
|
||||
grecaptcha.render(captchaContainer, {
|
||||
'sitekey' : '<?php echo $siteKey; ?>'
|
||||
});
|
||||
document.querySelector('button[type="submit"]').disabled = false;
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang; ?>&onload=onloadCallback&render=explicit" async defer></script>
|
||||
<?php
|
||||
endif;?>
|
||||
</main>
|
||||
|
||||
<!-- Google Analytics - just ignore this -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123057962-1"></script>
|
||||
<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-123057962-1');</script>
|
||||
139
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-checkbox.php
vendored
Normal file
139
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-checkbox.php
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/appengine-https.php';
|
||||
|
||||
// Initiate the autoloader. The file should be generated by Composer.
|
||||
// You will provide your own autoloader or require the files directly if you did
|
||||
// not install via Composer.
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Register API keys at https://www.google.com/recaptcha/admin
|
||||
$siteKey = '';
|
||||
$secret = '';
|
||||
|
||||
// Copy the config.php.dist file to config.php and update it with your keys to run the examples
|
||||
if ($siteKey == '' && is_readable(__DIR__ . '/config.php')) {
|
||||
$config = include __DIR__ . '/config.php';
|
||||
$siteKey = $config['v2-standard']['site'];
|
||||
$secret = $config['v2-standard']['secret'];
|
||||
}
|
||||
|
||||
// reCAPTCHA supports 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
|
||||
$lang = 'en';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height,minimum-scale=1">
|
||||
<link rel="shortcut icon" href="https://www.gstatic.com/recaptcha/admin/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="canonical" href="https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php">
|
||||
<script type="application/ld+json">{ "@context": "http://schema.org", "@type": "WebSite", "name": "reCAPTCHA demo - \"I'm not a robot\" checkbox", "url": "https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php" }</script>
|
||||
<meta name="description" content="reCAPTCHA demo - "I'm not a robot" checkbox" />
|
||||
<meta property="og:url" content="https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="reCAPTCHA demo - "I'm not a robot" checkbox" />
|
||||
<meta property="og:description" content="reCAPTCHA demo - "I'm not a robot" checkbox" />
|
||||
<link rel="stylesheet" type="text/css" href="/examples.css">
|
||||
<title>reCAPTCHA demo - "I'm not a robot" checkbox</title>
|
||||
|
||||
<header>
|
||||
<h1>reCAPTCHA demo</h1><h2>"I'm not a robot" checkbox</h2>
|
||||
<p><a href="/">↩️ Home</a></p>
|
||||
</header>
|
||||
<main>
|
||||
<?php
|
||||
if ($siteKey === '' || $secret === ''):
|
||||
?>
|
||||
<h2>Add your keys</h2>
|
||||
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in the <kbd>config.php</kbd> file or directly to <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
|
||||
<?php
|
||||
elseif (isset($_POST['g-recaptcha-response'])):
|
||||
// The POST data here is unfiltered because this is an example.
|
||||
// In production, *always* sanitise and validate your input'
|
||||
?>
|
||||
<h2><kbd>POST</kbd> data</h2>
|
||||
<kbd><pre><?php var_export($_POST);?></pre></kbd>
|
||||
<?php
|
||||
// If the form submission includes the "g-captcha-response" field
|
||||
// Create an instance of the service using your secret
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
|
||||
// If file_get_contents() is locked down on your PHP installation to disallow
|
||||
// its use with URLs, then you can use the alternative request method instead.
|
||||
// This makes use of fsockopen() instead.
|
||||
// $recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
|
||||
|
||||
// Make the call to verify the response and also pass the user's IP address
|
||||
$resp = $recaptcha->setExpectedHostname($_SERVER['SERVER_NAME'])
|
||||
->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
|
||||
if ($resp->isSuccess()):
|
||||
// If the response is a success, that's it!
|
||||
?>
|
||||
<h2>Success!</h2>
|
||||
<kbd><pre><?php var_export($resp);?></pre></kbd>
|
||||
<p>That's it. Everything is working. Go integrate this into your real project.</p>
|
||||
<p><a href="/recaptcha-v2-checkbox.php">⤴️ Try again</a></p>
|
||||
<?php
|
||||
else:
|
||||
// If it's not successful, then one or more error codes will be returned.
|
||||
?>
|
||||
<h2>Something went wrong</h2>
|
||||
<kbd><pre><?php var_export($resp);?></pre></kbd>
|
||||
<p>Check the error code reference at <kbd><a href="https://developers.google.com/recaptcha/docs/verify#error-code-reference">https://developers.google.com/recaptcha/docs/verify#error-code-reference</a></kbd>.
|
||||
<p><strong>Note:</strong> Error code <kbd>missing-input-response</kbd> may mean the user just didn't complete the reCAPTCHA.</p>
|
||||
<p><a href="/recaptcha-v2-checkbox.php">⤴️ Try again</a></p>
|
||||
<?php
|
||||
endif;
|
||||
else:
|
||||
// Add the g-recaptcha tag to the form you want to include the reCAPTCHA element
|
||||
?>
|
||||
<p>Complete the reCAPTCHA then submit the form.</p>
|
||||
<form action="/recaptcha-v2-checkbox.php" method="post">
|
||||
<fieldset>
|
||||
<legend>An example form</legend>
|
||||
<label class="form-field">Example input A: <input type="text" name="ex-a" value="foo"></label>
|
||||
<label class="form-field">Example input B: <input type="text" name="ex-b" value="bar"></label>
|
||||
<!-- Default behaviour looks for the g-recaptcha class with a data-sitekey attribute -->
|
||||
<div class="g-recaptcha form-field" data-sitekey="<?php echo $siteKey; ?>"></div>
|
||||
<!-- Submitting before the widget loads will result in a missing-input-response error so you need to verify server side -->
|
||||
<button class="form-field" type="submit">Submit ↦</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang; ?>"></script>
|
||||
<?php
|
||||
endif;?>
|
||||
</main>
|
||||
|
||||
<!-- Google Analytics - just ignore this -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123057962-1"></script>
|
||||
<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-123057962-1');</script>
|
||||
141
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-invisible.php
vendored
Normal file
141
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-invisible.php
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/appengine-https.php';
|
||||
|
||||
// Initiate the autoloader. The file should be generated by Composer.
|
||||
// You will provide your own autoloader or require the files directly if you did
|
||||
// not install via Composer.
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Register API keys at https://www.google.com/recaptcha/admin
|
||||
$siteKey = '';
|
||||
$secret = '';
|
||||
|
||||
// Copy the config.php.dist file to config.php and update it with your keys to run the examples
|
||||
if ($siteKey == '' && is_readable(__DIR__ . '/config.php')) {
|
||||
$config = include __DIR__ . '/config.php';
|
||||
$siteKey = $config['v2-invisible']['site'];
|
||||
$secret = $config['v2-invisible']['secret'];
|
||||
}
|
||||
|
||||
// reCAPTCHA supports 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
|
||||
$lang = 'en';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height,minimum-scale=1">
|
||||
<link rel="shortcut icon" href="https://www.gstatic.com/recaptcha/admin/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="canonical" href="https://recaptcha-demo.appspot.com/recaptcha-v2-invisible.php">
|
||||
<script type="application/ld+json">{ "@context": "http://schema.org", "@type": "WebSite", "name": "reCAPTCHA demo - Invisible", "url": "https://recaptcha-demo.appspot.com/recaptcha-v2-invisible.php" }</script>
|
||||
<meta name="description" content="reCAPTCHA demo - Invisible" />
|
||||
<meta property="og:url" content="https://recaptcha-demo.appspot.com/recaptcha-v2-invisible.php" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="reCAPTCHA demo - Invisible" />
|
||||
<meta property="og:description" content="reCAPTCHA demo - Invisible" />
|
||||
<link rel="stylesheet" type="text/css" href="/examples.css">
|
||||
<title>reCAPTCHA demo - Invisible</title>
|
||||
|
||||
<header>
|
||||
<h1>reCAPTCHA demo</h1><h2>Invisible</h2>
|
||||
<p><a href="/">↩️ Home</a></p>
|
||||
</header>
|
||||
<main>
|
||||
<?php
|
||||
if ($siteKey === '' || $secret === ''):
|
||||
?>
|
||||
<h2>Add your keys</h2>
|
||||
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
|
||||
<?php
|
||||
elseif (isset($_POST['g-recaptcha-response'])):
|
||||
// The POST data here is unfiltered because this is an example.
|
||||
// In production, *always* sanitise and validate your input'
|
||||
?>
|
||||
<h2><kbd>POST</kbd> data</h2>
|
||||
<kbd><pre><?php var_export($_POST);?></pre></kbd>
|
||||
<?php
|
||||
// If the form submission includes the "g-captcha-response" field
|
||||
// Create an instance of the service using your secret
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
|
||||
// If file_get_contents() is locked down on your PHP installation to disallow
|
||||
// its use with URLs, then you can use the alternative request method instead.
|
||||
// This makes use of fsockopen() instead.
|
||||
// $recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
|
||||
|
||||
// Make the call to verify the response and also pass the user's IP address
|
||||
$resp = $recaptcha->setExpectedHostname($_SERVER['SERVER_NAME'])
|
||||
->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
|
||||
if ($resp->isSuccess()):
|
||||
// If the response is a success, that's it!
|
||||
?>
|
||||
<h2>Success!</h2>
|
||||
<kbd><pre><?php var_export($resp);?></pre></kbd>
|
||||
<p>That's it. Everything is working. Go integrate this into your real project.</p>
|
||||
<p><a href="/recaptcha-v2-invisible.php">⤴️ Try again</a></p>
|
||||
<?php
|
||||
else:
|
||||
// If it's not successful, then one or more error codes will be returned.
|
||||
?>
|
||||
<h2>Something went wrong</h2>
|
||||
<kbd><pre><?php var_export($resp);?></pre></kbd>
|
||||
<p>Check the error code reference at <kbd><a href="https://developers.google.com/recaptcha/docs/verify#error-code-reference">https://developers.google.com/recaptcha/docs/verify#error-code-reference</a></kbd>.
|
||||
<p><strong>Note:</strong> Error code <kbd>missing-input-response</kbd> may mean the user just didn't complete the reCAPTCHA.</p>
|
||||
<p><a href="/recaptcha-v2-invisible.php">⤴️ Try again</a></p>
|
||||
<?php
|
||||
endif;
|
||||
else:
|
||||
// Add the g-recaptcha tag to the form you want to include the reCAPTCHA element
|
||||
?>
|
||||
<p>Submit the form and reCAPTCHA will run automatically.</p>
|
||||
<form action="/recaptcha-v2-invisible.php" method="post" id="demo-form">
|
||||
<fieldset>
|
||||
<legend>An example form</legend>
|
||||
<label class="form-field">Example input A: <input type="text" name="ex-a" value="foo"></label>
|
||||
<label class="form-field">Example input B: <input type="text" name="ex-b" value="bar"></label>
|
||||
<button class="g-recaptcha form-field" data-sitekey="<?php echo $siteKey; ?>" data-callback='onSubmit'>Submit ↦</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang; ?>" async defer></script>
|
||||
<script type="text/javascript">
|
||||
function onSubmit(token) {
|
||||
document.getElementById("demo-form").submit();
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
endif;?>
|
||||
</main>
|
||||
|
||||
<!-- Google Analytics - just ignore this -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123057962-1"></script>
|
||||
<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-123057962-1');</script>
|
||||
120
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v3-request-scores.php
vendored
Normal file
120
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v3-request-scores.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/appengine-https.php';
|
||||
|
||||
// Initiate the autoloader. The file should be generated by Composer.
|
||||
// You will provide your own autoloader or require the files directly if you did
|
||||
// not install via Composer.
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Register API keys at https://www.google.com/recaptcha/admin
|
||||
$siteKey = '';
|
||||
$secret = '';
|
||||
|
||||
// Copy the config.php.dist file to config.php and update it with your keys to run the examples
|
||||
if ($siteKey == '' && is_readable(__DIR__ . '/config.php')) {
|
||||
$config = include __DIR__ . '/config.php';
|
||||
$siteKey = $config['v3']['site'];
|
||||
$secret = $config['v3']['secret'];
|
||||
}
|
||||
|
||||
// reCAPTCHA supports 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
|
||||
$lang = 'en';
|
||||
|
||||
// The v3 API lets you provide some context for the check by specifying an action.
|
||||
// See: https://developers.google.com/recaptcha/docs/v3
|
||||
$pageAction = 'examples/v3scores';
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height,minimum-scale=1">
|
||||
<link rel="shortcut icon" href="https://www.gstatic.com/recaptcha/admin/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="canonical" href="https://recaptcha-demo.appspot.com/recaptcha-v3-request-scores.php">
|
||||
<script type="application/ld+json">{ "@context": "http://schema.org", "@type": "WebSite", "name": "reCAPTCHA demo - Request scores", "url": "https://recaptcha-demo.appspot.com/recaptcha-v3-request-scores.php" }</script>
|
||||
<meta name="description" content="reCAPTCHA demo - Request scores" />
|
||||
<meta property="og:url" content="https://recaptcha-demo.appspot.com/recaptcha-v3-request-scores.php" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="reCAPTCHA demo - Request scores" />
|
||||
<meta property="og:description" content="reCAPTCHA demo - Request scores" />
|
||||
<link rel="stylesheet" type="text/css" href="/examples.css">
|
||||
<title>reCAPTCHA demo - Request scores</title>
|
||||
<header>
|
||||
<h1>reCAPTCHA demo</h1><h2>Request scores</h2>
|
||||
<p><a href="/">↩️ Home</a></p>
|
||||
</header>
|
||||
<main>
|
||||
<?php
|
||||
if ($siteKey === '' || $secret === ''):
|
||||
?>
|
||||
<h2>Add your keys</h2>
|
||||
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
|
||||
<?php
|
||||
else:
|
||||
// Add the g-recaptcha tag to the form you want to include the reCAPTCHA element
|
||||
?>
|
||||
<p>The reCAPTCHA v3 API provides a confidence score for each request.</p>
|
||||
<p><strong>NOTE:</strong>This is a sample implementation, the score returned here is not a reflection on your Google account or type of traffic. In production, refer to the distribution of scores shown in <a href="https://www.google.com/recaptcha/admin" target="_blank">your admin interface</a> and adjust your own threshold accordingly. <strong>Do not raise issues regarding the score you see here.</strong></p>
|
||||
<ol id="recaptcha-steps">
|
||||
<li class="step0">reCAPTCHA script loading</li>
|
||||
<li class="step1 hidden"><kbd>grecaptcha.ready()</kbd> fired, calling <pre>grecaptcha.execute('<?php echo $siteKey; ?>', {action: '<?php echo $pageAction; ?>'})'</pre></li>
|
||||
<li class="step2 hidden">Received token from reCAPTCHA service, sending to our backend with:
|
||||
<pre class="token">fetch('/recaptcha-v3-verify.php?token=abc123</pre></li>
|
||||
<li class="step3 hidden">Received response from our backend: <pre class="response">{"json": "from-backend"}</pre></li>
|
||||
</ol>
|
||||
<p><a href="/recaptcha-v3-request-scores.php">⤴️ Try again</a></p>
|
||||
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo $siteKey; ?>"></script>
|
||||
<script>
|
||||
const steps = document.getElementById('recaptcha-steps');
|
||||
grecaptcha.ready(function() {
|
||||
document.querySelector('.step1').classList.remove('hidden');
|
||||
grecaptcha.execute('<?php echo $siteKey; ?>', {action: '<?php echo $pageAction; ?>'}).then(function(token) {
|
||||
document.querySelector('.token').innerHTML = 'fetch(\'/recaptcha-v3-verify.php?action=<?php echo $pageAction; ?>&token=\'' + token;
|
||||
document.querySelector('.step2').classList.remove('hidden');
|
||||
|
||||
fetch('/recaptcha-v3-verify.php?action=<?php echo $pageAction; ?>&token='+token).then(function(response) {
|
||||
response.json().then(function(data) {
|
||||
document.querySelector('.response').innerHTML = JSON.stringify(data, null, 2);
|
||||
document.querySelector('.step3').classList.remove('hidden');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
endif;?>
|
||||
</main>
|
||||
<!-- Google Analytics - just ignore this -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123057962-1"></script>
|
||||
<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-123057962-1');</script>
|
||||
59
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v3-verify.php
vendored
Normal file
59
user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v3-verify.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/appengine-https.php';
|
||||
|
||||
// Initiate the autoloader. The file should be generated by Composer.
|
||||
// You will provide your own autoloader or require the files directly if you did
|
||||
// not install via Composer.
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Register API keys at https://www.google.com/recaptcha/admin
|
||||
$siteKey = '';
|
||||
$secret = '';
|
||||
|
||||
// Copy the config.php.dist file to config.php and update it with your keys to run the examples
|
||||
if ($siteKey == '' && is_readable(__DIR__ . '/config.php')) {
|
||||
$config = include __DIR__ . '/config.php';
|
||||
$siteKey = $config['v3']['site'];
|
||||
$secret = $config['v3']['secret'];
|
||||
}
|
||||
|
||||
// Effectively we're providing an API endpoint here that will accept the token, verify it, and return the action / score to the page
|
||||
// In production, always sanitize and validate the input you retrieve from the request.
|
||||
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
$resp = $recaptcha->setExpectedHostname($_SERVER['SERVER_NAME'])
|
||||
->setExpectedAction($_GET['action'])
|
||||
->setScoreThreshold(0.5)
|
||||
->verify($_GET['token'], $_SERVER['REMOTE_ADDR']);
|
||||
header('Content-type:application/json');
|
||||
echo json_encode($resp->toArray());
|
||||
2
user/plugins/form/vendor/google/recaptcha/examples/robots.txt
vendored
Normal file
2
user/plugins/form/vendor/google/recaptcha/examples/robots.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow:
|
||||
20
user/plugins/form/vendor/google/recaptcha/phpunit.xml.dist
vendored
Normal file
20
user/plugins/form/vendor/google/recaptcha/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.4/phpunit.xsd"
|
||||
colors="true"
|
||||
verbose="true"
|
||||
bootstrap="src/autoload.php">
|
||||
<testsuites>
|
||||
<testsuite name="reCAPTCHA Test Suite">
|
||||
<directory>tests/ReCaptcha/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src/ReCaptcha/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
269
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php
vendored
Normal file
269
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha;
|
||||
|
||||
/**
|
||||
* reCAPTCHA client.
|
||||
*/
|
||||
class ReCaptcha
|
||||
{
|
||||
/**
|
||||
* Version of this client library.
|
||||
* @const string
|
||||
*/
|
||||
const VERSION = 'php_1.2.4';
|
||||
|
||||
/**
|
||||
* URL for reCAPTCHA siteverify API
|
||||
* @const string
|
||||
*/
|
||||
const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
|
||||
/**
|
||||
* Invalid JSON received
|
||||
* @const string
|
||||
*/
|
||||
const E_INVALID_JSON = 'invalid-json';
|
||||
|
||||
/**
|
||||
* Could not connect to service
|
||||
* @const string
|
||||
*/
|
||||
const E_CONNECTION_FAILED = 'connection-failed';
|
||||
|
||||
/**
|
||||
* Did not receive a 200 from the service
|
||||
* @const string
|
||||
*/
|
||||
const E_BAD_RESPONSE = 'bad-response';
|
||||
|
||||
/**
|
||||
* Not a success, but no error codes received!
|
||||
* @const string
|
||||
*/
|
||||
const E_UNKNOWN_ERROR = 'unknown-error';
|
||||
|
||||
/**
|
||||
* ReCAPTCHA response not provided
|
||||
* @const string
|
||||
*/
|
||||
const E_MISSING_INPUT_RESPONSE = 'missing-input-response';
|
||||
|
||||
/**
|
||||
* Expected hostname did not match
|
||||
* @const string
|
||||
*/
|
||||
const E_HOSTNAME_MISMATCH = 'hostname-mismatch';
|
||||
|
||||
/**
|
||||
* Expected APK package name did not match
|
||||
* @const string
|
||||
*/
|
||||
const E_APK_PACKAGE_NAME_MISMATCH = 'apk_package_name-mismatch';
|
||||
|
||||
/**
|
||||
* Expected action did not match
|
||||
* @const string
|
||||
*/
|
||||
const E_ACTION_MISMATCH = 'action-mismatch';
|
||||
|
||||
/**
|
||||
* Score threshold not met
|
||||
* @const string
|
||||
*/
|
||||
const E_SCORE_THRESHOLD_NOT_MET = 'score-threshold-not-met';
|
||||
|
||||
/**
|
||||
* Challenge timeout
|
||||
* @const string
|
||||
*/
|
||||
const E_CHALLENGE_TIMEOUT = 'challenge-timeout';
|
||||
|
||||
/**
|
||||
* Shared secret for the site.
|
||||
* @var string
|
||||
*/
|
||||
private $secret;
|
||||
|
||||
/**
|
||||
* Method used to communicate with service. Defaults to POST request.
|
||||
* @var RequestMethod
|
||||
*/
|
||||
private $requestMethod;
|
||||
|
||||
/**
|
||||
* Create a configured instance to use the reCAPTCHA service.
|
||||
*
|
||||
* @param string $secret The shared key between your site and reCAPTCHA.
|
||||
* @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
|
||||
* @throws \RuntimeException if $secret is invalid
|
||||
*/
|
||||
public function __construct($secret, RequestMethod $requestMethod = null)
|
||||
{
|
||||
if (empty($secret)) {
|
||||
throw new \RuntimeException('No secret provided');
|
||||
}
|
||||
|
||||
if (!is_string($secret)) {
|
||||
throw new \RuntimeException('The provided secret must be a string');
|
||||
}
|
||||
|
||||
$this->secret = $secret;
|
||||
$this->requestMethod = (is_null($requestMethod)) ? new RequestMethod\Post() : $requestMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the reCAPTCHA siteverify API to verify whether the user passes
|
||||
* CAPTCHA test and additionally runs any specified additional checks
|
||||
*
|
||||
* @param string $response The user response token provided by reCAPTCHA, verifying the user on your site.
|
||||
* @param string $remoteIp The end user's IP address.
|
||||
* @return Response Response from the service.
|
||||
*/
|
||||
public function verify($response, $remoteIp = null)
|
||||
{
|
||||
// Discard empty solution submissions
|
||||
if (empty($response)) {
|
||||
$recaptchaResponse = new Response(false, array(self::E_MISSING_INPUT_RESPONSE));
|
||||
return $recaptchaResponse;
|
||||
}
|
||||
|
||||
$params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
|
||||
$rawResponse = $this->requestMethod->submit($params);
|
||||
$initialResponse = Response::fromJson($rawResponse);
|
||||
$validationErrors = array();
|
||||
|
||||
if (isset($this->hostname) && strcasecmp($this->hostname, $initialResponse->getHostname()) !== 0) {
|
||||
$validationErrors[] = self::E_HOSTNAME_MISMATCH;
|
||||
}
|
||||
|
||||
if (isset($this->apkPackageName) && strcasecmp($this->apkPackageName, $initialResponse->getApkPackageName()) !== 0) {
|
||||
$validationErrors[] = self::E_APK_PACKAGE_NAME_MISMATCH;
|
||||
}
|
||||
|
||||
if (isset($this->action) && strcasecmp($this->action, $initialResponse->getAction()) !== 0) {
|
||||
$validationErrors[] = self::E_ACTION_MISMATCH;
|
||||
}
|
||||
|
||||
if (isset($this->threshold) && $this->threshold > $initialResponse->getScore()) {
|
||||
$validationErrors[] = self::E_SCORE_THRESHOLD_NOT_MET;
|
||||
}
|
||||
|
||||
if (isset($this->timeoutSeconds)) {
|
||||
$challengeTs = strtotime($initialResponse->getChallengeTs());
|
||||
|
||||
if ($challengeTs > 0 && time() - $challengeTs > $this->timeoutSeconds) {
|
||||
$validationErrors[] = self::E_CHALLENGE_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($validationErrors)) {
|
||||
return $initialResponse;
|
||||
}
|
||||
|
||||
return new Response(
|
||||
false,
|
||||
array_merge($initialResponse->getErrorCodes(), $validationErrors),
|
||||
$initialResponse->getHostname(),
|
||||
$initialResponse->getChallengeTs(),
|
||||
$initialResponse->getApkPackageName(),
|
||||
$initialResponse->getScore(),
|
||||
$initialResponse->getAction()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a hostname to match against in verify()
|
||||
* This should be without a protocol or trailing slash, e.g. www.google.com
|
||||
*
|
||||
* @param string $hostname Expected hostname
|
||||
* @return ReCaptcha Current instance for fluent interface
|
||||
*/
|
||||
public function setExpectedHostname($hostname)
|
||||
{
|
||||
$this->hostname = $hostname;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an APK package name to match against in verify()
|
||||
*
|
||||
* @param string $apkPackageName Expected APK package name
|
||||
* @return ReCaptcha Current instance for fluent interface
|
||||
*/
|
||||
public function setExpectedApkPackageName($apkPackageName)
|
||||
{
|
||||
$this->apkPackageName = $apkPackageName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an action to match against in verify()
|
||||
* This should be set per page.
|
||||
*
|
||||
* @param string $action Expected action
|
||||
* @return ReCaptcha Current instance for fluent interface
|
||||
*/
|
||||
public function setExpectedAction($action)
|
||||
{
|
||||
$this->action = $action;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a threshold to meet or exceed in verify()
|
||||
* Threshold should be a float between 0 and 1 which will be tested as response >= threshold.
|
||||
*
|
||||
* @param float $threshold Expected threshold
|
||||
* @return ReCaptcha Current instance for fluent interface
|
||||
*/
|
||||
public function setScoreThreshold($threshold)
|
||||
{
|
||||
$this->threshold = floatval($threshold);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a timeout in seconds to test against the challenge timestamp in verify()
|
||||
*
|
||||
* @param int $timeoutSeconds Expected hostname
|
||||
* @return ReCaptcha Current instance for fluent interface
|
||||
*/
|
||||
public function setChallengeTimeout($timeoutSeconds)
|
||||
{
|
||||
$this->timeoutSeconds = $timeoutSeconds;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
50
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod.php
vendored
Normal file
50
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha;
|
||||
|
||||
/**
|
||||
* Method used to send the request to the service.
|
||||
*/
|
||||
interface RequestMethod
|
||||
{
|
||||
|
||||
/**
|
||||
* Submit the request with the specified parameters.
|
||||
*
|
||||
* @param RequestParameters $params Request parameters
|
||||
* @return string Body of the reCAPTCHA response
|
||||
*/
|
||||
public function submit(RequestParameters $params);
|
||||
}
|
||||
82
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Curl.php
vendored
Normal file
82
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Curl.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha\RequestMethod;
|
||||
|
||||
/**
|
||||
* Convenience wrapper around the cURL functions to allow mocking.
|
||||
*/
|
||||
class Curl
|
||||
{
|
||||
|
||||
/**
|
||||
* @see http://php.net/curl_init
|
||||
* @param string $url
|
||||
* @return resource cURL handle
|
||||
*/
|
||||
public function init($url = null)
|
||||
{
|
||||
return curl_init($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see http://php.net/curl_setopt_array
|
||||
* @param resource $ch
|
||||
* @param array $options
|
||||
* @return bool
|
||||
*/
|
||||
public function setoptArray($ch, array $options)
|
||||
{
|
||||
return curl_setopt_array($ch, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see http://php.net/curl_exec
|
||||
* @param resource $ch
|
||||
* @return mixed
|
||||
*/
|
||||
public function exec($ch)
|
||||
{
|
||||
return curl_exec($ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see http://php.net/curl_close
|
||||
* @param resource $ch
|
||||
*/
|
||||
public function close($ch)
|
||||
{
|
||||
curl_close($ch);
|
||||
}
|
||||
}
|
||||
104
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/CurlPost.php
vendored
Normal file
104
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/CurlPost.php
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha\RequestMethod;
|
||||
|
||||
use ReCaptcha\ReCaptcha;
|
||||
use ReCaptcha\RequestMethod;
|
||||
use ReCaptcha\RequestParameters;
|
||||
|
||||
/**
|
||||
* Sends cURL request to the reCAPTCHA service.
|
||||
* Note: this requires the cURL extension to be enabled in PHP
|
||||
* @see http://php.net/manual/en/book.curl.php
|
||||
*/
|
||||
class CurlPost implements RequestMethod
|
||||
{
|
||||
/**
|
||||
* Curl connection to the reCAPTCHA service
|
||||
* @var Curl
|
||||
*/
|
||||
private $curl;
|
||||
|
||||
/**
|
||||
* URL for reCAPTCHA siteverify API
|
||||
* @var string
|
||||
*/
|
||||
private $siteVerifyUrl;
|
||||
|
||||
/**
|
||||
* Only needed if you want to override the defaults
|
||||
*
|
||||
* @param Curl $curl Curl resource
|
||||
* @param string $siteVerifyUrl URL for reCAPTCHA siteverify API
|
||||
*/
|
||||
public function __construct(Curl $curl = null, $siteVerifyUrl = null)
|
||||
{
|
||||
$this->curl = (is_null($curl)) ? new Curl() : $curl;
|
||||
$this->siteVerifyUrl = (is_null($siteVerifyUrl)) ? ReCaptcha::SITE_VERIFY_URL : $siteVerifyUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the cURL request with the specified parameters.
|
||||
*
|
||||
* @param RequestParameters $params Request parameters
|
||||
* @return string Body of the reCAPTCHA response
|
||||
*/
|
||||
public function submit(RequestParameters $params)
|
||||
{
|
||||
$handle = $this->curl->init($this->siteVerifyUrl);
|
||||
|
||||
$options = array(
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $params->toQueryString(),
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/x-www-form-urlencoded'
|
||||
),
|
||||
CURLINFO_HEADER_OUT => false,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_SSL_VERIFYPEER => true
|
||||
);
|
||||
$this->curl->setoptArray($handle, $options);
|
||||
|
||||
$response = $this->curl->exec($handle);
|
||||
$this->curl->close($handle);
|
||||
|
||||
if ($response !== false) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}';
|
||||
}
|
||||
}
|
||||
88
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php
vendored
Normal file
88
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha\RequestMethod;
|
||||
|
||||
use ReCaptcha\ReCaptcha;
|
||||
use ReCaptcha\RequestMethod;
|
||||
use ReCaptcha\RequestParameters;
|
||||
|
||||
/**
|
||||
* Sends POST requests to the reCAPTCHA service.
|
||||
*/
|
||||
class Post implements RequestMethod
|
||||
{
|
||||
/**
|
||||
* URL for reCAPTCHA siteverify API
|
||||
* @var string
|
||||
*/
|
||||
private $siteVerifyUrl;
|
||||
|
||||
/**
|
||||
* Only needed if you want to override the defaults
|
||||
*
|
||||
* @param string $siteVerifyUrl URL for reCAPTCHA siteverify API
|
||||
*/
|
||||
public function __construct($siteVerifyUrl = null)
|
||||
{
|
||||
$this->siteVerifyUrl = (is_null($siteVerifyUrl)) ? ReCaptcha::SITE_VERIFY_URL : $siteVerifyUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the POST request with the specified parameters.
|
||||
*
|
||||
* @param RequestParameters $params Request parameters
|
||||
* @return string Body of the reCAPTCHA response
|
||||
*/
|
||||
public function submit(RequestParameters $params)
|
||||
{
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'content' => $params->toQueryString(),
|
||||
// Force the peer to validate (not needed in 5.6.0+, but still works)
|
||||
'verify_peer' => true,
|
||||
),
|
||||
);
|
||||
$context = stream_context_create($options);
|
||||
$response = file_get_contents($this->siteVerifyUrl, false, $context);
|
||||
|
||||
if ($response !== false) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}';
|
||||
}
|
||||
}
|
||||
112
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Socket.php
vendored
Normal file
112
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Socket.php
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha\RequestMethod;
|
||||
|
||||
/**
|
||||
* Convenience wrapper around native socket and file functions to allow for
|
||||
* mocking.
|
||||
*/
|
||||
class Socket
|
||||
{
|
||||
private $handle = null;
|
||||
|
||||
/**
|
||||
* fsockopen
|
||||
*
|
||||
* @see http://php.net/fsockopen
|
||||
* @param string $hostname
|
||||
* @param int $port
|
||||
* @param int $errno
|
||||
* @param string $errstr
|
||||
* @param float $timeout
|
||||
* @return resource
|
||||
*/
|
||||
public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null)
|
||||
{
|
||||
$this->handle = fsockopen($hostname, $port, $errno, $errstr, (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout));
|
||||
|
||||
if ($this->handle != false && $errno === 0 && $errstr === '') {
|
||||
return $this->handle;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* fwrite
|
||||
*
|
||||
* @see http://php.net/fwrite
|
||||
* @param string $string
|
||||
* @param int $length
|
||||
* @return int | bool
|
||||
*/
|
||||
public function fwrite($string, $length = null)
|
||||
{
|
||||
return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length));
|
||||
}
|
||||
|
||||
/**
|
||||
* fgets
|
||||
*
|
||||
* @see http://php.net/fgets
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
public function fgets($length = null)
|
||||
{
|
||||
return fgets($this->handle, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* feof
|
||||
*
|
||||
* @see http://php.net/feof
|
||||
* @return bool
|
||||
*/
|
||||
public function feof()
|
||||
{
|
||||
return feof($this->handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* fclose
|
||||
*
|
||||
* @see http://php.net/fclose
|
||||
* @return bool
|
||||
*/
|
||||
public function fclose()
|
||||
{
|
||||
return fclose($this->handle);
|
||||
}
|
||||
}
|
||||
108
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/SocketPost.php
vendored
Normal file
108
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/SocketPost.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha\RequestMethod;
|
||||
|
||||
use ReCaptcha\ReCaptcha;
|
||||
use ReCaptcha\RequestMethod;
|
||||
use ReCaptcha\RequestParameters;
|
||||
|
||||
/**
|
||||
* Sends a POST request to the reCAPTCHA service, but makes use of fsockopen()
|
||||
* instead of get_file_contents(). This is to account for people who may be on
|
||||
* servers where allow_url_open is disabled.
|
||||
*/
|
||||
class SocketPost implements RequestMethod
|
||||
{
|
||||
/**
|
||||
* Socket to the reCAPTCHA service
|
||||
* @var Socket
|
||||
*/
|
||||
private $socket;
|
||||
|
||||
/**
|
||||
* Only needed if you want to override the defaults
|
||||
*
|
||||
* @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing
|
||||
* @param string $siteVerifyUrl URL for reCAPTCHA siteverify API
|
||||
*/
|
||||
public function __construct(Socket $socket = null, $siteVerifyUrl = null)
|
||||
{
|
||||
$this->socket = (is_null($socket)) ? new Socket() : $socket;
|
||||
$this->siteVerifyUrl = (is_null($siteVerifyUrl)) ? ReCaptcha::SITE_VERIFY_URL : $siteVerifyUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the POST request with the specified parameters.
|
||||
*
|
||||
* @param RequestParameters $params Request parameters
|
||||
* @return string Body of the reCAPTCHA response
|
||||
*/
|
||||
public function submit(RequestParameters $params)
|
||||
{
|
||||
$errno = 0;
|
||||
$errstr = '';
|
||||
$urlParsed = parse_url($this->siteVerifyUrl);
|
||||
|
||||
if (false === $this->socket->fsockopen('ssl://' . $urlParsed['host'], 443, $errno, $errstr, 30)) {
|
||||
return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}';
|
||||
}
|
||||
|
||||
$content = $params->toQueryString();
|
||||
|
||||
$request = "POST " . $urlParsed['path'] . " HTTP/1.0\r\n";
|
||||
$request .= "Host: " . $urlParsed['host'] . "\r\n";
|
||||
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
$request .= "Content-length: " . strlen($content) . "\r\n";
|
||||
$request .= "Connection: close\r\n\r\n";
|
||||
$request .= $content . "\r\n\r\n";
|
||||
|
||||
$this->socket->fwrite($request);
|
||||
$response = '';
|
||||
|
||||
while (!$this->socket->feof()) {
|
||||
$response .= $this->socket->fgets(4096);
|
||||
}
|
||||
|
||||
$this->socket->fclose();
|
||||
|
||||
if (0 !== strpos($response, 'HTTP/1.0 200 OK')) {
|
||||
return '{"success": false, "error-codes": ["'.ReCaptcha::E_BAD_RESPONSE.'"]}';
|
||||
}
|
||||
|
||||
$parts = preg_split("#\n\s*\n#Uis", $response);
|
||||
|
||||
return $parts[1];
|
||||
}
|
||||
}
|
||||
111
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestParameters.php
vendored
Normal file
111
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestParameters.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha;
|
||||
|
||||
/**
|
||||
* Stores and formats the parameters for the request to the reCAPTCHA service.
|
||||
*/
|
||||
class RequestParameters
|
||||
{
|
||||
/**
|
||||
* The shared key between your site and reCAPTCHA.
|
||||
* @var string
|
||||
*/
|
||||
private $secret;
|
||||
|
||||
/**
|
||||
* The user response token provided by reCAPTCHA, verifying the user on your site.
|
||||
* @var string
|
||||
*/
|
||||
private $response;
|
||||
|
||||
/**
|
||||
* Remote user's IP address.
|
||||
* @var string
|
||||
*/
|
||||
private $remoteIp;
|
||||
|
||||
/**
|
||||
* Client version.
|
||||
* @var string
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Initialise parameters.
|
||||
*
|
||||
* @param string $secret Site secret.
|
||||
* @param string $response Value from g-captcha-response form field.
|
||||
* @param string $remoteIp User's IP address.
|
||||
* @param string $version Version of this client library.
|
||||
*/
|
||||
public function __construct($secret, $response, $remoteIp = null, $version = null)
|
||||
{
|
||||
$this->secret = $secret;
|
||||
$this->response = $response;
|
||||
$this->remoteIp = $remoteIp;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array representation.
|
||||
*
|
||||
* @return array Array formatted parameters.
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$params = array('secret' => $this->secret, 'response' => $this->response);
|
||||
|
||||
if (!is_null($this->remoteIp)) {
|
||||
$params['remoteip'] = $this->remoteIp;
|
||||
}
|
||||
|
||||
if (!is_null($this->version)) {
|
||||
$params['version'] = $this->version;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query string representation for HTTP request.
|
||||
*
|
||||
* @return string Query string formatted parameters.
|
||||
*/
|
||||
public function toQueryString()
|
||||
{
|
||||
return http_build_query($this->toArray(), '', '&');
|
||||
}
|
||||
}
|
||||
218
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/Response.php
vendored
Normal file
218
user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/Response.php
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha;
|
||||
|
||||
/**
|
||||
* The response returned from the service.
|
||||
*/
|
||||
class Response
|
||||
{
|
||||
/**
|
||||
* Success or failure.
|
||||
* @var boolean
|
||||
*/
|
||||
private $success = false;
|
||||
|
||||
/**
|
||||
* Error code strings.
|
||||
* @var array
|
||||
*/
|
||||
private $errorCodes = array();
|
||||
|
||||
/**
|
||||
* The hostname of the site where the reCAPTCHA was solved.
|
||||
* @var string
|
||||
*/
|
||||
private $hostname;
|
||||
|
||||
/**
|
||||
* Timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ)
|
||||
* @var string
|
||||
*/
|
||||
private $challengeTs;
|
||||
|
||||
/**
|
||||
* APK package name
|
||||
* @var string
|
||||
*/
|
||||
private $apkPackageName;
|
||||
|
||||
/**
|
||||
* Score assigned to the request
|
||||
* @var float
|
||||
*/
|
||||
private $score;
|
||||
|
||||
/**
|
||||
* Action as specified by the page
|
||||
* @var string
|
||||
*/
|
||||
private $action;
|
||||
|
||||
/**
|
||||
* Build the response from the expected JSON returned by the service.
|
||||
*
|
||||
* @param string $json
|
||||
* @return \ReCaptcha\Response
|
||||
*/
|
||||
public static function fromJson($json)
|
||||
{
|
||||
$responseData = json_decode($json, true);
|
||||
|
||||
if (!$responseData) {
|
||||
return new Response(false, array(ReCaptcha::E_INVALID_JSON));
|
||||
}
|
||||
|
||||
$hostname = isset($responseData['hostname']) ? $responseData['hostname'] : null;
|
||||
$challengeTs = isset($responseData['challenge_ts']) ? $responseData['challenge_ts'] : null;
|
||||
$apkPackageName = isset($responseData['apk_package_name']) ? $responseData['apk_package_name'] : null;
|
||||
$score = isset($responseData['score']) ? floatval($responseData['score']) : null;
|
||||
$action = isset($responseData['action']) ? $responseData['action'] : null;
|
||||
|
||||
if (isset($responseData['success']) && $responseData['success'] == true) {
|
||||
return new Response(true, array(), $hostname, $challengeTs, $apkPackageName, $score, $action);
|
||||
}
|
||||
|
||||
if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
|
||||
return new Response(false, $responseData['error-codes'], $hostname, $challengeTs, $apkPackageName, $score, $action);
|
||||
}
|
||||
|
||||
return new Response(false, array(ReCaptcha::E_UNKNOWN_ERROR), $hostname, $challengeTs, $apkPackageName, $score, $action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param boolean $success
|
||||
* @param string $hostname
|
||||
* @param string $challengeTs
|
||||
* @param string $apkPackageName
|
||||
* @param float $score
|
||||
* @param string $action
|
||||
* @param array $errorCodes
|
||||
*/
|
||||
public function __construct($success, array $errorCodes = array(), $hostname = null, $challengeTs = null, $apkPackageName = null, $score = null, $action = null)
|
||||
{
|
||||
$this->success = $success;
|
||||
$this->hostname = $hostname;
|
||||
$this->challengeTs = $challengeTs;
|
||||
$this->apkPackageName = $apkPackageName;
|
||||
$this->score = $score;
|
||||
$this->action = $action;
|
||||
$this->errorCodes = $errorCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is success?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error codes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getErrorCodes()
|
||||
{
|
||||
return $this->errorCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hostname.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHostname()
|
||||
{
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get challenge timestamp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getChallengeTs()
|
||||
{
|
||||
return $this->challengeTs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get APK package name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getApkPackageName()
|
||||
{
|
||||
return $this->apkPackageName;
|
||||
}
|
||||
/**
|
||||
* Get score
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getScore()
|
||||
{
|
||||
return $this->score;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return array(
|
||||
'success' => $this->isSuccess(),
|
||||
'hostname' => $this->getHostname(),
|
||||
'challenge_ts' => $this->getChallengeTs(),
|
||||
'apk_package_name' => $this->getApkPackageName(),
|
||||
'score' => $this->getScore(),
|
||||
'action' => $this->getAction(),
|
||||
'error-codes' => $this->getErrorCodes(),
|
||||
);
|
||||
}
|
||||
}
|
||||
69
user/plugins/form/vendor/google/recaptcha/src/autoload.php
vendored
Normal file
69
user/plugins/form/vendor/google/recaptcha/src/autoload.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/* An autoloader for ReCaptcha\Foo classes. This should be required()
|
||||
* by the user before attempting to instantiate any of the ReCaptcha
|
||||
* classes.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
spl_autoload_register(function ($class) {
|
||||
if (substr($class, 0, 10) !== 'ReCaptcha\\') {
|
||||
/* If the class does not lie under the "ReCaptcha" namespace,
|
||||
* then we can exit immediately.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/* All of the classes have names like "ReCaptcha\Foo", so we need
|
||||
* to replace the backslashes with frontslashes if we want the
|
||||
* name to map directly to a location in the filesystem.
|
||||
*/
|
||||
$class = str_replace('\\', '/', $class);
|
||||
|
||||
/* First, check under the current directory. It is important that
|
||||
* we look here first, so that we don't waste time searching for
|
||||
* test classes in the common case.
|
||||
*/
|
||||
$path = dirname(__FILE__).'/'.$class.'.php';
|
||||
if (is_readable($path)) {
|
||||
require_once $path;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we didn't find what we're looking for already, maybe it's
|
||||
* a test class?
|
||||
*/
|
||||
$path = dirname(__FILE__).'/../tests/'.$class.'.php';
|
||||
if (is_readable($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
});
|
||||
198
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/ReCaptchaTest.php
vendored
Normal file
198
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/ReCaptchaTest.php
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ReCaptchaTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @dataProvider invalidSecretProvider
|
||||
*/
|
||||
public function testExceptionThrownOnInvalidSecret($invalid)
|
||||
{
|
||||
$rc = new ReCaptcha($invalid);
|
||||
}
|
||||
|
||||
public function invalidSecretProvider()
|
||||
{
|
||||
return array(
|
||||
array(''),
|
||||
array(null),
|
||||
array(0),
|
||||
array(new \stdClass()),
|
||||
array(array()),
|
||||
);
|
||||
}
|
||||
|
||||
public function testVerifyReturnsErrorOnMissingResponse()
|
||||
{
|
||||
$rc = new ReCaptcha('secret');
|
||||
$response = $rc->verify('');
|
||||
$this->assertFalse($response->isSuccess());
|
||||
$this->assertEquals(array(Recaptcha::E_MISSING_INPUT_RESPONSE), $response->getErrorCodes());
|
||||
}
|
||||
|
||||
private function getMockRequestMethod($responseJson)
|
||||
{
|
||||
$method = $this->getMockBuilder(\ReCaptcha\RequestMethod::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('submit'))
|
||||
->getMock();
|
||||
$method->expects($this->any())
|
||||
->method('submit')
|
||||
->with($this->callback(function ($params) {
|
||||
return true;
|
||||
}))
|
||||
->will($this->returnValue($responseJson));
|
||||
return $method;
|
||||
}
|
||||
|
||||
public function testVerifyReturnsResponse()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->verify('response');
|
||||
$this->assertTrue($response->isSuccess());
|
||||
}
|
||||
|
||||
public function testVerifyReturnsInitialResponseWithoutAdditionalChecks()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$initialResponse = $rc->verify('response');
|
||||
$this->assertEquals($initialResponse, $rc->verify('response'));
|
||||
}
|
||||
|
||||
public function testVerifyHostnameMatch()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true, "hostname": "host.name"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setExpectedHostname('host.name')->verify('response');
|
||||
$this->assertTrue($response->isSuccess());
|
||||
}
|
||||
|
||||
public function testVerifyHostnameMisMatch()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true, "hostname": "host.NOTname"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setExpectedHostname('host.name')->verify('response');
|
||||
$this->assertFalse($response->isSuccess());
|
||||
$this->assertEquals(array(ReCaptcha::E_HOSTNAME_MISMATCH), $response->getErrorCodes());
|
||||
}
|
||||
|
||||
public function testVerifyApkPackageNameMatch()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true, "apk_package_name": "apk.name"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setExpectedApkPackageName('apk.name')->verify('response');
|
||||
$this->assertTrue($response->isSuccess());
|
||||
}
|
||||
|
||||
public function testVerifyApkPackageNameMisMatch()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true, "apk_package_name": "apk.NOTname"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setExpectedApkPackageName('apk.name')->verify('response');
|
||||
$this->assertFalse($response->isSuccess());
|
||||
$this->assertEquals(array(ReCaptcha::E_APK_PACKAGE_NAME_MISMATCH), $response->getErrorCodes());
|
||||
}
|
||||
|
||||
public function testVerifyActionMatch()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true, "action": "action/name"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setExpectedAction('action/name')->verify('response');
|
||||
$this->assertTrue($response->isSuccess());
|
||||
}
|
||||
|
||||
public function testVerifyActionMisMatch()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true, "action": "action/NOTname"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setExpectedAction('action/name')->verify('response');
|
||||
$this->assertFalse($response->isSuccess());
|
||||
$this->assertEquals(array(ReCaptcha::E_ACTION_MISMATCH), $response->getErrorCodes());
|
||||
}
|
||||
|
||||
public function testVerifyAboveThreshold()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true, "score": "0.9"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setScoreThreshold('0.5')->verify('response');
|
||||
$this->assertTrue($response->isSuccess());
|
||||
}
|
||||
|
||||
public function testVerifyBelowThreshold()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": true, "score": "0.1"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setScoreThreshold('0.5')->verify('response');
|
||||
$this->assertFalse($response->isSuccess());
|
||||
$this->assertEquals(array(ReCaptcha::E_SCORE_THRESHOLD_NOT_MET), $response->getErrorCodes());
|
||||
}
|
||||
|
||||
public function testVerifyWithinTimeout()
|
||||
{
|
||||
// Responses come back like 2018-07-31T13:48:41Z
|
||||
$challengeTs = date('Y-M-d\TH:i:s\Z', time());
|
||||
$method = $this->getMockRequestMethod('{"success": true, "challenge_ts": "'.$challengeTs.'"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setChallengeTimeout('1000')->verify('response');
|
||||
$this->assertTrue($response->isSuccess());
|
||||
}
|
||||
|
||||
public function testVerifyOverTimeout()
|
||||
{
|
||||
// Responses come back like 2018-07-31T13:48:41Z
|
||||
$challengeTs = date('Y-M-d\TH:i:s\Z', time() - 600);
|
||||
$method = $this->getMockRequestMethod('{"success": true, "challenge_ts": "'.$challengeTs.'"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setChallengeTimeout('60')->verify('response');
|
||||
$this->assertFalse($response->isSuccess());
|
||||
$this->assertEquals(array(ReCaptcha::E_CHALLENGE_TIMEOUT), $response->getErrorCodes());
|
||||
}
|
||||
|
||||
public function testVerifyMergesErrors()
|
||||
{
|
||||
$method = $this->getMockRequestMethod('{"success": false, "error-codes": ["initial-error"], "score": "0.1"}');
|
||||
$rc = new ReCaptcha('secret', $method);
|
||||
$response = $rc->setScoreThreshold('0.5')->verify('response');
|
||||
$this->assertFalse($response->isSuccess());
|
||||
$this->assertEquals(array('initial-error', ReCaptcha::E_SCORE_THRESHOLD_NOT_MET), $response->getErrorCodes());
|
||||
}
|
||||
}
|
||||
123
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/CurlPostTest.php
vendored
Normal file
123
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/CurlPostTest.php
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha\RequestMethod;
|
||||
|
||||
use \ReCaptcha\ReCaptcha;
|
||||
use \ReCaptcha\RequestParameters;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CurlPostTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded('curl')) {
|
||||
$this->markTestSkipped(
|
||||
'The cURL extension is not available.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSubmit()
|
||||
{
|
||||
$curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('init', 'setoptArray', 'exec', 'close'))
|
||||
->getMock();
|
||||
$curl->expects($this->once())
|
||||
->method('init')
|
||||
->willReturn(new \stdClass);
|
||||
$curl->expects($this->once())
|
||||
->method('setoptArray')
|
||||
->willReturn(true);
|
||||
$curl->expects($this->once())
|
||||
->method('exec')
|
||||
->willReturn('RESPONSEBODY');
|
||||
$curl->expects($this->once())
|
||||
->method('close');
|
||||
|
||||
$pc = new CurlPost($curl);
|
||||
$response = $pc->submit(new RequestParameters("secret", "response"));
|
||||
$this->assertEquals('RESPONSEBODY', $response);
|
||||
}
|
||||
|
||||
public function testOverrideSiteVerifyUrl()
|
||||
{
|
||||
$url = 'OVERRIDE';
|
||||
|
||||
$curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('init', 'setoptArray', 'exec', 'close'))
|
||||
->getMock();
|
||||
$curl->expects($this->once())
|
||||
->method('init')
|
||||
->with($url)
|
||||
->willReturn(new \stdClass);
|
||||
$curl->expects($this->once())
|
||||
->method('setoptArray')
|
||||
->willReturn(true);
|
||||
$curl->expects($this->once())
|
||||
->method('exec')
|
||||
->willReturn('RESPONSEBODY');
|
||||
$curl->expects($this->once())
|
||||
->method('close');
|
||||
|
||||
$pc = new CurlPost($curl, $url);
|
||||
$response = $pc->submit(new RequestParameters("secret", "response"));
|
||||
$this->assertEquals('RESPONSEBODY', $response);
|
||||
}
|
||||
|
||||
public function testConnectionFailureReturnsError()
|
||||
{
|
||||
$curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('init', 'setoptArray', 'exec', 'close'))
|
||||
->getMock();
|
||||
$curl->expects($this->once())
|
||||
->method('init')
|
||||
->willReturn(new \stdClass);
|
||||
$curl->expects($this->once())
|
||||
->method('setoptArray')
|
||||
->willReturn(true);
|
||||
$curl->expects($this->once())
|
||||
->method('exec')
|
||||
->willReturn(false);
|
||||
$curl->expects($this->once())
|
||||
->method('close');
|
||||
|
||||
$pc = new CurlPost($curl);
|
||||
$response = $pc->submit(new RequestParameters("secret", "response"));
|
||||
$this->assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}', $response);
|
||||
}
|
||||
}
|
||||
149
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/PostTest.php
vendored
Normal file
149
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/PostTest.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha\RequestMethod;
|
||||
|
||||
use \ReCaptcha\ReCaptcha;
|
||||
use ReCaptcha\RequestParameters;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PostTest extends TestCase
|
||||
{
|
||||
public static $assert = null;
|
||||
protected $parameters = null;
|
||||
protected $runcount = 0;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->parameters = new RequestParameters('secret', 'response', 'remoteip', 'version');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
self::$assert = null;
|
||||
}
|
||||
|
||||
public function testHTTPContextOptions()
|
||||
{
|
||||
$req = new Post();
|
||||
self::$assert = array($this, 'httpContextOptionsCallback');
|
||||
$req->submit($this->parameters);
|
||||
$this->assertEquals(1, $this->runcount, 'The assertion was ran');
|
||||
}
|
||||
|
||||
public function testSSLContextOptions()
|
||||
{
|
||||
$req = new Post();
|
||||
self::$assert = array($this, 'sslContextOptionsCallback');
|
||||
$req->submit($this->parameters);
|
||||
$this->assertEquals(1, $this->runcount, 'The assertion was ran');
|
||||
}
|
||||
|
||||
public function testOverrideVerifyUrl()
|
||||
{
|
||||
$req = new Post('https://over.ride/some/path');
|
||||
self::$assert = array($this, 'overrideUrlOptions');
|
||||
$req->submit($this->parameters);
|
||||
$this->assertEquals(1, $this->runcount, 'The assertion was ran');
|
||||
}
|
||||
|
||||
public function testConnectionFailureReturnsError()
|
||||
{
|
||||
$req = new Post('https://bad.connection/');
|
||||
self::$assert = array($this, 'connectionFailureResponse');
|
||||
$response = $req->submit($this->parameters);
|
||||
$this->assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}', $response);
|
||||
}
|
||||
|
||||
public function connectionFailureResponse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public function overrideUrlOptions(array $args)
|
||||
{
|
||||
$this->runcount++;
|
||||
$this->assertEquals('https://over.ride/some/path', $args[0]);
|
||||
}
|
||||
|
||||
public function httpContextOptionsCallback(array $args)
|
||||
{
|
||||
$this->runcount++;
|
||||
$this->assertCommonOptions($args);
|
||||
|
||||
$options = stream_context_get_options($args[2]);
|
||||
$this->assertArrayHasKey('http', $options);
|
||||
|
||||
$this->assertArrayHasKey('method', $options['http']);
|
||||
$this->assertEquals('POST', $options['http']['method']);
|
||||
|
||||
$this->assertArrayHasKey('content', $options['http']);
|
||||
$this->assertEquals($this->parameters->toQueryString(), $options['http']['content']);
|
||||
|
||||
$this->assertArrayHasKey('header', $options['http']);
|
||||
$headers = array(
|
||||
'Content-type: application/x-www-form-urlencoded',
|
||||
);
|
||||
foreach ($headers as $header) {
|
||||
$this->assertContains($header, $options['http']['header']);
|
||||
}
|
||||
}
|
||||
|
||||
public function sslContextOptionsCallback(array $args)
|
||||
{
|
||||
$this->runcount++;
|
||||
$this->assertCommonOptions($args);
|
||||
|
||||
$options = stream_context_get_options($args[2]);
|
||||
$this->assertArrayHasKey('http', $options);
|
||||
$this->assertArrayHasKey('verify_peer', $options['http']);
|
||||
$this->assertTrue($options['http']['verify_peer']);
|
||||
}
|
||||
|
||||
protected function assertCommonOptions(array $args)
|
||||
{
|
||||
$this->assertCount(3, $args);
|
||||
$this->assertStringStartsWith('https://www.google.com/', $args[0]);
|
||||
$this->assertFalse($args[1]);
|
||||
$this->assertTrue(is_resource($args[2]), 'The context options should be a resource');
|
||||
}
|
||||
}
|
||||
|
||||
function file_get_contents()
|
||||
{
|
||||
if (PostTest::$assert) {
|
||||
return call_user_func(PostTest::$assert, func_get_args());
|
||||
}
|
||||
// Since we can't represent maxlen in userland...
|
||||
return call_user_func_array('file_get_contents', func_get_args());
|
||||
}
|
||||
136
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/SocketPostTest.php
vendored
Normal file
136
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/SocketPostTest.php
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha\RequestMethod;
|
||||
|
||||
use ReCaptcha\ReCaptcha;
|
||||
use ReCaptcha\RequestParameters;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SocketPostTest extends TestCase
|
||||
{
|
||||
public function testSubmitSuccess()
|
||||
{
|
||||
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'))
|
||||
->getMock();
|
||||
$socket->expects($this->once())
|
||||
->method('fsockopen')
|
||||
->willReturn(true);
|
||||
$socket->expects($this->once())
|
||||
->method('fwrite');
|
||||
$socket->expects($this->once())
|
||||
->method('fgets')
|
||||
->willReturn("HTTP/1.0 200 OK\n\nRESPONSEBODY");
|
||||
$socket->expects($this->exactly(2))
|
||||
->method('feof')
|
||||
->will($this->onConsecutiveCalls(false, true));
|
||||
$socket->expects($this->once())
|
||||
->method('fclose')
|
||||
->willReturn(true);
|
||||
|
||||
$ps = new SocketPost($socket);
|
||||
$response = $ps->submit(new RequestParameters("secret", "response", "remoteip", "version"));
|
||||
$this->assertEquals('RESPONSEBODY', $response);
|
||||
}
|
||||
|
||||
public function testOverrideSiteVerifyUrl()
|
||||
{
|
||||
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'))
|
||||
->getMock();
|
||||
$socket->expects($this->once())
|
||||
->method('fsockopen')
|
||||
->with('ssl://over.ride', 443, 0, '', 30)
|
||||
->willReturn(true);
|
||||
$socket->expects($this->once())
|
||||
->method('fwrite')
|
||||
->with($this->matchesRegularExpression('/^POST \/some\/path.*Host: over\.ride/s'));
|
||||
$socket->expects($this->once())
|
||||
->method('fgets')
|
||||
->willReturn("HTTP/1.0 200 OK\n\nRESPONSEBODY");
|
||||
$socket->expects($this->exactly(2))
|
||||
->method('feof')
|
||||
->will($this->onConsecutiveCalls(false, true));
|
||||
$socket->expects($this->once())
|
||||
->method('fclose')
|
||||
->willReturn(true);
|
||||
|
||||
$ps = new SocketPost($socket, 'https://over.ride/some/path');
|
||||
$response = $ps->submit(new RequestParameters("secret", "response", "remoteip", "version"));
|
||||
$this->assertEquals('RESPONSEBODY', $response);
|
||||
}
|
||||
|
||||
public function testSubmitBadResponse()
|
||||
{
|
||||
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'))
|
||||
->getMock();
|
||||
$socket->expects($this->once())
|
||||
->method('fsockopen')
|
||||
->willReturn(true);
|
||||
$socket->expects($this->once())
|
||||
->method('fwrite');
|
||||
$socket->expects($this->once())
|
||||
->method('fgets')
|
||||
->willReturn("HTTP/1.0 500 NOPEn\\nBOBBINS");
|
||||
$socket->expects($this->exactly(2))
|
||||
->method('feof')
|
||||
->will($this->onConsecutiveCalls(false, true));
|
||||
$socket->expects($this->once())
|
||||
->method('fclose')
|
||||
->willReturn(true);
|
||||
|
||||
$ps = new SocketPost($socket);
|
||||
$response = $ps->submit(new RequestParameters("secret", "response", "remoteip", "version"));
|
||||
$this->assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_BAD_RESPONSE.'"]}', $response);
|
||||
}
|
||||
|
||||
public function testConnectionFailureReturnsError()
|
||||
{
|
||||
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('fsockopen'))
|
||||
->getMock();
|
||||
$socket->expects($this->once())
|
||||
->method('fsockopen')
|
||||
->willReturn(false);
|
||||
$ps = new SocketPost($socket);
|
||||
$response = $ps->submit(new RequestParameters("secret", "response", "remoteip", "version"));
|
||||
$this->assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}', $response);
|
||||
}
|
||||
}
|
||||
70
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestParametersTest.php
vendored
Normal file
70
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestParametersTest.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RequestParametersTest extends Testcase
|
||||
{
|
||||
public function provideValidData()
|
||||
{
|
||||
return array(
|
||||
array('SECRET', 'RESPONSE', 'REMOTEIP', 'VERSION',
|
||||
array('secret' => 'SECRET', 'response' => 'RESPONSE', 'remoteip' => 'REMOTEIP', 'version' => 'VERSION'),
|
||||
'secret=SECRET&response=RESPONSE&remoteip=REMOTEIP&version=VERSION'),
|
||||
array('SECRET', 'RESPONSE', null, null,
|
||||
array('secret' => 'SECRET', 'response' => 'RESPONSE'),
|
||||
'secret=SECRET&response=RESPONSE'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidData
|
||||
*/
|
||||
public function testToArray($secret, $response, $remoteIp, $version, $expectedArray, $expectedQuery)
|
||||
{
|
||||
$params = new RequestParameters($secret, $response, $remoteIp, $version);
|
||||
$this->assertEquals($params->toArray(), $expectedArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidData
|
||||
*/
|
||||
public function testToQueryString($secret, $response, $remoteIp, $version, $expectedArray, $expectedQuery)
|
||||
{
|
||||
$params = new RequestParameters($secret, $response, $remoteIp, $version);
|
||||
$this->assertEquals($params->toQueryString(), $expectedQuery);
|
||||
}
|
||||
}
|
||||
173
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/ResponseTest.php
vendored
Normal file
173
user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/ResponseTest.php
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a PHP library that handles calling reCAPTCHA.
|
||||
*
|
||||
* BSD 3-Clause License
|
||||
* @copyright (c) 2019, Google Inc.
|
||||
* @link https://www.google.com/recaptcha
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace ReCaptcha;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ResponseTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @dataProvider provideJson
|
||||
*/
|
||||
public function testFromJson($json, $success, $errorCodes, $hostname, $challengeTs, $apkPackageName, $score, $action)
|
||||
{
|
||||
$response = Response::fromJson($json);
|
||||
$this->assertEquals($success, $response->isSuccess());
|
||||
$this->assertEquals($errorCodes, $response->getErrorCodes());
|
||||
$this->assertEquals($hostname, $response->getHostname());
|
||||
$this->assertEquals($challengeTs, $response->getChallengeTs());
|
||||
$this->assertEquals($apkPackageName, $response->getApkPackageName());
|
||||
$this->assertEquals($score, $response->getScore());
|
||||
$this->assertEquals($action, $response->getAction());
|
||||
}
|
||||
|
||||
public function provideJson()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'{"success": true}',
|
||||
true, array(), null, null, null, null, null,
|
||||
),
|
||||
array(
|
||||
'{"success": true, "hostname": "google.com"}',
|
||||
true, array(), 'google.com', null, null, null, null,
|
||||
),
|
||||
array(
|
||||
'{"success": false, "error-codes": ["test"]}',
|
||||
false, array('test'), null, null, null, null, null,
|
||||
),
|
||||
array(
|
||||
'{"success": false, "error-codes": ["test"], "hostname": "google.com"}',
|
||||
false, array('test'), 'google.com', null, null, null, null,
|
||||
),
|
||||
array(
|
||||
'{"success": false, "error-codes": ["test"], "hostname": "google.com", "challenge_ts": "timestamp", "apk_package_name": "apk", "score": "0.5", "action": "action"}',
|
||||
false, array('test'), 'google.com', 'timestamp', 'apk', 0.5, 'action',
|
||||
),
|
||||
array(
|
||||
'{"success": true, "error-codes": ["test"]}',
|
||||
true, array(), null, null, null, null, null,
|
||||
),
|
||||
array(
|
||||
'{"success": true, "error-codes": ["test"], "hostname": "google.com"}',
|
||||
true, array(), 'google.com', null, null, null, null,
|
||||
),
|
||||
array(
|
||||
'{"success": false}',
|
||||
false, array(ReCaptcha::E_UNKNOWN_ERROR), null, null, null, null, null,
|
||||
),
|
||||
array(
|
||||
'{"success": false, "hostname": "google.com"}',
|
||||
false, array(ReCaptcha::E_UNKNOWN_ERROR), 'google.com', null, null, null, null,
|
||||
),
|
||||
array(
|
||||
'BAD JSON',
|
||||
false, array(ReCaptcha::E_INVALID_JSON), null, null, null, null, null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsSuccess()
|
||||
{
|
||||
$response = new Response(true);
|
||||
$this->assertTrue($response->isSuccess());
|
||||
|
||||
$response = new Response(false);
|
||||
$this->assertFalse($response->isSuccess());
|
||||
|
||||
$response = new Response(true, array(), 'example.com');
|
||||
$this->assertEquals('example.com', $response->getHostName());
|
||||
}
|
||||
|
||||
public function testGetErrorCodes()
|
||||
{
|
||||
$errorCodes = array('test');
|
||||
$response = new Response(true, $errorCodes);
|
||||
$this->assertEquals($errorCodes, $response->getErrorCodes());
|
||||
}
|
||||
|
||||
public function testGetHostname()
|
||||
{
|
||||
$hostname = 'google.com';
|
||||
$errorCodes = array();
|
||||
$response = new Response(true, $errorCodes, $hostname);
|
||||
$this->assertEquals($hostname, $response->getHostname());
|
||||
}
|
||||
|
||||
public function testGetChallengeTs()
|
||||
{
|
||||
$timestamp = 'timestamp';
|
||||
$errorCodes = array();
|
||||
$response = new Response(true, array(), 'hostname', $timestamp);
|
||||
$this->assertEquals($timestamp, $response->getChallengeTs());
|
||||
}
|
||||
|
||||
public function TestGetApkPackageName()
|
||||
{
|
||||
$apk = 'apk';
|
||||
$response = new Response(true, array(), 'hostname', 'timestamp', 'apk');
|
||||
$this->assertEquals($apk, $response->getApkPackageName());
|
||||
}
|
||||
|
||||
public function testGetScore()
|
||||
{
|
||||
$score = 0.5;
|
||||
$response = new Response(true, array(), 'hostname', 'timestamp', 'apk', $score);
|
||||
$this->assertEquals($score, $response->getScore());
|
||||
}
|
||||
|
||||
public function testGetAction()
|
||||
{
|
||||
$action = 'homepage';
|
||||
$response = new Response(true, array(), 'hostname', 'timestamp', 'apk', '0.5', 'homepage');
|
||||
$this->assertEquals($action, $response->getAction());
|
||||
}
|
||||
|
||||
public function testToArray()
|
||||
{
|
||||
$response = new Response(true, array(), 'hostname', 'timestamp', 'apk', '0.5', 'homepage');
|
||||
$expected = array(
|
||||
'success' => true,
|
||||
'error-codes' => array(),
|
||||
'hostname' => 'hostname',
|
||||
'challenge_ts' => 'timestamp',
|
||||
'apk_package_name' => 'apk',
|
||||
'score' => 0.5,
|
||||
'action' => 'homepage',
|
||||
);
|
||||
$this->assertEquals($expected, $response->toArray());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user