diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ab42a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# Ignore directories generated by Composer +/vendor/ +autoload.php +composer.lock diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 8699d8d..0000000 --- a/composer.lock +++ /dev/null @@ -1,65 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "content-hash": "ec171eaa8654f73a3ec4f1238d7a2c46", - "packages": [ - { - "name": "google/recaptcha", - "version": "1.2.3", - "source": { - "type": "git", - "url": "https://github.com/google/recaptcha.git", - "reference": "98c4a6573b27e8b0990ea8789c74ea378795134c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/google/recaptcha/zipball/98c4a6573b27e8b0990ea8789c74ea378795134c", - "reference": "98c4a6573b27e8b0990ea8789c74ea378795134c", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.2.20|^2.15", - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "ReCaptcha\\": "src/ReCaptcha" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Client library for reCAPTCHA, a free service that protects websites from spam and abuse.", - "homepage": "https://www.google.com/recaptcha/", - "keywords": [ - "Abuse", - "captcha", - "recaptcha", - "spam" - ], - "time": "2019-08-16T15:48:25+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [] -} diff --git a/vendor/autoload.php b/vendor/autoload.php deleted file mode 100644 index 6036a0f..0000000 --- a/vendor/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - private $classMapAuthoritative = false; - private $missingClasses = array(); - private $apcuPrefix; - - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - return array(); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath.'\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE deleted file mode 100644 index f0157a6..0000000 --- a/vendor/composer/LICENSE +++ /dev/null @@ -1,56 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: Composer -Upstream-Contact: Jordi Boggiano -Source: https://github.com/composer/composer - -Files: * -Copyright: 2016, Nils Adermann - 2016, Jordi Boggiano -License: Expat - -Files: src/Composer/Util/TlsHelper.php -Copyright: 2016, Nils Adermann - 2016, Jordi Boggiano - 2013, Evan Coury -License: Expat and BSD-2-Clause - -License: BSD-2-Clause - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - . - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - . - * 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. - . - 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 OWNER 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. - -License: Expat - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is furnished - to do so, subject to the following conditions: - . - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php deleted file mode 100644 index 7a91153..0000000 --- a/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,9 +0,0 @@ - array($vendorDir . '/google/recaptcha/src/ReCaptcha'), -); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php deleted file mode 100644 index ad9808b..0000000 --- a/vendor/composer/autoload_real.php +++ /dev/null @@ -1,52 +0,0 @@ -= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require_once __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitb29ee68bf16457a17fd25b3f5a1c26cd::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } - - $loader->register(true); - - return $loader; - } -} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php deleted file mode 100644 index 0741009..0000000 --- a/vendor/composer/autoload_static.php +++ /dev/null @@ -1,31 +0,0 @@ - - array ( - 'ReCaptcha\\' => 10, - ), - ); - - public static $prefixDirsPsr4 = array ( - 'ReCaptcha\\' => - array ( - 0 => __DIR__ . '/..' . '/google/recaptcha/src/ReCaptcha', - ), - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitb29ee68bf16457a17fd25b3f5a1c26cd::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitb29ee68bf16457a17fd25b3f5a1c26cd::$prefixDirsPsr4; - - }, null, ClassLoader::class); - } -} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json deleted file mode 100644 index faaf4f2..0000000 --- a/vendor/composer/installed.json +++ /dev/null @@ -1,51 +0,0 @@ -[ - { - "name": "google/recaptcha", - "version": "1.2.3", - "version_normalized": "1.2.3.0", - "source": { - "type": "git", - "url": "https://github.com/google/recaptcha.git", - "reference": "98c4a6573b27e8b0990ea8789c74ea378795134c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/google/recaptcha/zipball/98c4a6573b27e8b0990ea8789c74ea378795134c", - "reference": "98c4a6573b27e8b0990ea8789c74ea378795134c", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.2.20|^2.15", - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11" - }, - "time": "2019-08-16T15:48:25+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "ReCaptcha\\": "src/ReCaptcha" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Client library for reCAPTCHA, a free service that protects websites from spam and abuse.", - "homepage": "https://www.google.com/recaptcha/", - "keywords": [ - "Abuse", - "captcha", - "recaptcha", - "spam" - ] - } -] diff --git a/vendor/google/recaptcha/ARCHITECTURE.md b/vendor/google/recaptcha/ARCHITECTURE.md deleted file mode 100644 index 13add26..0000000 --- a/vendor/google/recaptcha/ARCHITECTURE.md +++ /dev/null @@ -1,64 +0,0 @@ -# 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 -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 -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 theshold 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 -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) diff --git a/vendor/google/recaptcha/app.yaml b/vendor/google/recaptcha/app.yaml deleted file mode 100644 index b6ccaf1..0000000 --- a/vendor/google/recaptcha/app.yaml +++ /dev/null @@ -1,8 +0,0 @@ -runtime: php -env: flex - -skip_files: -- tests - -runtime_config: - document_root: examples diff --git a/vendor/google/recaptcha/composer.json b/vendor/google/recaptcha/composer.json deleted file mode 100644 index ab6b4f1..0000000 --- a/vendor/google/recaptcha/composer.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "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 - } -} diff --git a/vendor/google/recaptcha/examples/appengine-https.php b/vendor/google/recaptcha/examples/appengine-https.php deleted file mode 100644 index 039e2db..0000000 --- a/vendor/google/recaptcha/examples/appengine-https.php +++ /dev/null @@ -1,42 +0,0 @@ - [ - 'site' => '', - 'secret' => '', - ], - 'v2-invisible' => [ - 'site' => '', - 'secret' => '', - ], - 'v3' => [ - 'site' => '', - 'secret' => '', - ], -]; diff --git a/vendor/google/recaptcha/examples/examples.css b/vendor/google/recaptcha/examples/examples.css deleted file mode 100644 index cb3647b..0000000 --- a/vendor/google/recaptcha/examples/examples.css +++ /dev/null @@ -1,37 +0,0 @@ -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; -} diff --git a/vendor/google/recaptcha/examples/google0afd8760fd68f119.html b/vendor/google/recaptcha/examples/google0afd8760fd68f119.html deleted file mode 100644 index 457c471..0000000 --- a/vendor/google/recaptcha/examples/google0afd8760fd68f119.html +++ /dev/null @@ -1 +0,0 @@ -google-site-verification: google0afd8760fd68f119.html \ No newline at end of file diff --git a/vendor/google/recaptcha/examples/index.php b/vendor/google/recaptcha/examples/index.php deleted file mode 100644 index b715acc..0000000 --- a/vendor/google/recaptcha/examples/index.php +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - -reCAPTCHA demo - -
-

reCAPTCHA demo

-
-
-

Try out the various forms of reCAPTCHA.

-

You can find the source code for these examples on GitHub in google/recaptcha.

- -
- - - - diff --git a/vendor/google/recaptcha/examples/recaptcha-content-security-policy.php b/vendor/google/recaptcha/examples/recaptcha-content-security-policy.php deleted file mode 100644 index aaf7eb2..0000000 --- a/vendor/google/recaptcha/examples/recaptcha-content-security-policy.php +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - -reCAPTCHA demo - Content Security Policy -
-

reCAPTCHA demo

Content Security Policy

-

↩️ Home

-
-
- -

Add your keys

-

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in $siteKey and $secret. Reload the page after this.

- -

This example is sending the Content-Security-Policy 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.

-

NOTE: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 your admin interface and adjust your own threshold accordingly. Do not raise issues regarding the score you see here.

-
    -
  1. reCAPTCHA script loading
  2. - - - -
-

⤴️ Try again

- - - - - - - -
- - - - diff --git a/vendor/google/recaptcha/examples/recaptcha-v2-checkbox-explicit.php b/vendor/google/recaptcha/examples/recaptcha-v2-checkbox-explicit.php deleted file mode 100644 index fb429a2..0000000 --- a/vendor/google/recaptcha/examples/recaptcha-v2-checkbox-explicit.php +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - - - - - - -reCAPTCHA demo - "I'm not a robot" checkbox - Explicit render - -
-

reCAPTCHA demo

"I'm not a robot" checkbox - Explicit render

-

↩️ Home

-
-
- -

Add your keys

-

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in the config.php file or directly to $siteKey and $secret. Reload the page after this.

- -

POST data

-
- setExpectedHostname($_SERVER['SERVER_NAME']) - ->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); - - if ($resp->isSuccess()): - // If the response is a success, that's it! - ?> -

Success!

-
-

That's it. Everything is working. Go integrate this into your real project.

-

⤴️ Try again

- -

Something went wrong

-
-

Check the error code reference at https://developers.google.com/recaptcha/docs/verify#error-code-reference. -

Note: Error code missing-input-response may mean the user just didn't complete the reCAPTCHA.

-

⤴️ Try again

- -

Complete the reCAPTCHA then submit the form.

-
-
- An example form - - - -
- - -
-
- - - -
- - - - diff --git a/vendor/google/recaptcha/examples/recaptcha-v2-checkbox.php b/vendor/google/recaptcha/examples/recaptcha-v2-checkbox.php deleted file mode 100644 index 9395d59..0000000 --- a/vendor/google/recaptcha/examples/recaptcha-v2-checkbox.php +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - -reCAPTCHA demo - "I'm not a robot" checkbox - -
-

reCAPTCHA demo

"I'm not a robot" checkbox

-

↩️ Home

-
-
- -

Add your keys

-

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in the config.php file or directly to $siteKey and $secret. Reload the page after this.

- -

POST data

-
- setExpectedHostname($_SERVER['SERVER_NAME']) - ->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); - if ($resp->isSuccess()): - // If the response is a success, that's it! - ?> -

Success!

-
-

That's it. Everything is working. Go integrate this into your real project.

-

⤴️ Try again

- -

Something went wrong

-
-

Check the error code reference at https://developers.google.com/recaptcha/docs/verify#error-code-reference. -

Note: Error code missing-input-response may mean the user just didn't complete the reCAPTCHA.

-

⤴️ Try again

- -

Complete the reCAPTCHA then submit the form.

-
-
- An example form - - - -
- - -
-
- - -
- - - - diff --git a/vendor/google/recaptcha/examples/recaptcha-v2-invisible.php b/vendor/google/recaptcha/examples/recaptcha-v2-invisible.php deleted file mode 100644 index c3b9397..0000000 --- a/vendor/google/recaptcha/examples/recaptcha-v2-invisible.php +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - -reCAPTCHA demo - Invisible - -
-

reCAPTCHA demo

Invisible

-

↩️ Home

-
-
- -

Add your keys

-

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in $siteKey and $secret. Reload the page after this.

- -

POST data

-
- setExpectedHostname($_SERVER['SERVER_NAME']) - ->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); - if ($resp->isSuccess()): - // If the response is a success, that's it! - ?> -

Success!

-
-

That's it. Everything is working. Go integrate this into your real project.

-

⤴️ Try again

- -

Something went wrong

-
-

Check the error code reference at https://developers.google.com/recaptcha/docs/verify#error-code-reference. -

Note: Error code missing-input-response may mean the user just didn't complete the reCAPTCHA.

-

⤴️ Try again

- -

Submit the form and reCAPTCHA will run automatically.

-
-
- An example form - - - -
-
- - - -
- - - - diff --git a/vendor/google/recaptcha/examples/recaptcha-v3-request-scores.php b/vendor/google/recaptcha/examples/recaptcha-v3-request-scores.php deleted file mode 100644 index d9430bb..0000000 --- a/vendor/google/recaptcha/examples/recaptcha-v3-request-scores.php +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - -reCAPTCHA demo - Request scores -
-

reCAPTCHA demo

Request scores

-

↩️ Home

-
-
- -

Add your keys

-

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in $siteKey and $secret. Reload the page after this.

- -

The reCAPTCHA v3 API provides a confidence score for each request.

-

NOTE: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 your admin interface and adjust your own threshold accordingly. Do not raise issues regarding the score you see here.

-
    -
  1. reCAPTCHA script loading
  2. - - - -
-

⤴️ Try again

- - - -
- - - diff --git a/vendor/google/recaptcha/examples/recaptcha-v3-verify.php b/vendor/google/recaptcha/examples/recaptcha-v3-verify.php deleted file mode 100644 index 3b6517a..0000000 --- a/vendor/google/recaptcha/examples/recaptcha-v3-verify.php +++ /dev/null @@ -1,59 +0,0 @@ -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()); diff --git a/vendor/google/recaptcha/examples/robots.txt b/vendor/google/recaptcha/examples/robots.txt deleted file mode 100644 index eb05362..0000000 --- a/vendor/google/recaptcha/examples/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Disallow: diff --git a/vendor/google/recaptcha/phpunit.xml.dist b/vendor/google/recaptcha/phpunit.xml.dist deleted file mode 100644 index ae86610..0000000 --- a/vendor/google/recaptcha/phpunit.xml.dist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - tests/ReCaptcha/ - - - - - src/ReCaptcha/ - - - - - - diff --git a/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php b/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php deleted file mode 100644 index 177fa44..0000000 --- a/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php +++ /dev/null @@ -1,269 +0,0 @@ -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; - } -} diff --git a/vendor/google/recaptcha/src/ReCaptcha/RequestMethod.php b/vendor/google/recaptcha/src/ReCaptcha/RequestMethod.php deleted file mode 100644 index 0a2a671..0000000 --- a/vendor/google/recaptcha/src/ReCaptcha/RequestMethod.php +++ /dev/null @@ -1,50 +0,0 @@ -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.'"]}'; - } -} diff --git a/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php b/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php deleted file mode 100644 index a4ff716..0000000 --- a/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php +++ /dev/null @@ -1,88 +0,0 @@ -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.'"]}'; - } -} diff --git a/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Socket.php b/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Socket.php deleted file mode 100644 index 236bd5f..0000000 --- a/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Socket.php +++ /dev/null @@ -1,112 +0,0 @@ -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); - } -} diff --git a/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/SocketPost.php b/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/SocketPost.php deleted file mode 100644 index 7edffb8..0000000 --- a/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/SocketPost.php +++ /dev/null @@ -1,108 +0,0 @@ -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.1\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.1 200 OK')) { - return '{"success": false, "error-codes": ["'.ReCaptcha::E_BAD_RESPONSE.'"]}'; - } - - $parts = preg_split("#\n\s*\n#Uis", $response); - - return $parts[1]; - } -} diff --git a/vendor/google/recaptcha/src/ReCaptcha/RequestParameters.php b/vendor/google/recaptcha/src/ReCaptcha/RequestParameters.php deleted file mode 100644 index e9ba453..0000000 --- a/vendor/google/recaptcha/src/ReCaptcha/RequestParameters.php +++ /dev/null @@ -1,111 +0,0 @@ -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(), '', '&'); - } -} diff --git a/vendor/google/recaptcha/src/ReCaptcha/Response.php b/vendor/google/recaptcha/src/ReCaptcha/Response.php deleted file mode 100644 index 55838c0..0000000 --- a/vendor/google/recaptcha/src/ReCaptcha/Response.php +++ /dev/null @@ -1,218 +0,0 @@ -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(), - ); - } -} diff --git a/vendor/google/recaptcha/src/autoload.php b/vendor/google/recaptcha/src/autoload.php deleted file mode 100644 index 7947a10..0000000 --- a/vendor/google/recaptcha/src/autoload.php +++ /dev/null @@ -1,69 +0,0 @@ -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()); - } -} diff --git a/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/CurlPostTest.php b/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/CurlPostTest.php deleted file mode 100644 index 8fb17dc..0000000 --- a/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/CurlPostTest.php +++ /dev/null @@ -1,123 +0,0 @@ -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); - } -} diff --git a/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/PostTest.php b/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/PostTest.php deleted file mode 100644 index bdfb78e..0000000 --- a/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/PostTest.php +++ /dev/null @@ -1,149 +0,0 @@ -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()); -} diff --git a/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/SocketPostTest.php b/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/SocketPostTest.php deleted file mode 100644 index 8656be4..0000000 --- a/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/SocketPostTest.php +++ /dev/null @@ -1,136 +0,0 @@ -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.1 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.1 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.1 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); - } -} diff --git a/vendor/google/recaptcha/tests/ReCaptcha/RequestParametersTest.php b/vendor/google/recaptcha/tests/ReCaptcha/RequestParametersTest.php deleted file mode 100644 index fafded2..0000000 --- a/vendor/google/recaptcha/tests/ReCaptcha/RequestParametersTest.php +++ /dev/null @@ -1,70 +0,0 @@ - '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); - } -} diff --git a/vendor/google/recaptcha/tests/ReCaptcha/ResponseTest.php b/vendor/google/recaptcha/tests/ReCaptcha/ResponseTest.php deleted file mode 100644 index 7894c2a..0000000 --- a/vendor/google/recaptcha/tests/ReCaptcha/ResponseTest.php +++ /dev/null @@ -1,173 +0,0 @@ -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()); - } -}