<file>lib/form/AbstractSecureForm.class.php</file>
<file>lib/form/MailForm.class.php</file>
<file>lib/form/MultifactorAuthenticationAbortForm.class.php</file>
+ <file>lib/form/RecaptchaForm.class.php</file>
<file>lib/page/CookiePolicyPage.class.php</file>
<file>lib/page/DashboardPage.class.php</file>
<file>lib/page/LessStylesheetsPage.class.php</file>
<file>lib/system/page/location/IPageLocation.class.php</file>
<file>lib/system/payment/method/SofortUeberweisungPaymentMethod.class.php</file>
<file>lib/system/recaptcha/RecaptchaHandler.class.php</file>
+ <file>lib/system/recaptcha/RecaptchaHandlerV2.class.php</file>
<file>lib/system/request/CmsLinkHandler.class.php</file>
<file>lib/system/request/FlexibleRoute.class.php</file>
<file>lib/system/request/IRoute.class.php</file>
+++ /dev/null
-<?php
-
-namespace wcf\form;
-
-use wcf\system\recaptcha\RecaptchaHandlerV2;
-use wcf\system\WCF;
-
-/**
- * RecaptchaForm is an abstract form implementation for the use of reCAPTCHA.
- *
- * @author Marcel Werk
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\Form
- * @deprecated 2.1
- */
-abstract class RecaptchaForm extends AbstractForm
-{
- /**
- * challenge
- * @var string
- */
- public $challenge = '';
-
- /**
- * response
- * @var string
- */
- public $response = '';
-
- /**
- * enable recaptcha
- * @var bool
- */
- public $useCaptcha = true;
-
- /**
- * @inheritDoc
- */
- public function readParameters()
- {
- parent::readParameters();
-
- if (WCF::getUser()->userID || WCF::getSession()->getVar('recaptchaDone')) {
- $this->useCaptcha = false;
- }
- }
-
- /**
- * @inheritDoc
- */
- public function readFormParameters()
- {
- parent::readFormParameters();
-
- if (isset($_POST['g-recaptcha-response'])) {
- $this->response = $_POST['g-recaptcha-response'];
- }
- }
-
- /**
- * @inheritDoc
- */
- public function validate()
- {
- parent::validate();
-
- $this->validateCaptcha();
- }
-
- /**
- * Validates the captcha.
- */
- protected function validateCaptcha()
- {
- if ($this->useCaptcha) {
- RecaptchaHandlerV2::getInstance()->validate($this->response);
-
- $this->useCaptcha = false;
- }
- }
-
- /**
- * @inheritDoc
- */
- public function save()
- {
- parent::save();
-
- WCF::getSession()->unregister('recaptchaDone');
- }
-
- /**
- * @inheritDoc
- */
- public function assignVariables()
- {
- parent::assignVariables();
-
- WCF::getTPL()->assign([
- 'recaptchaLegacyMode' => true,
- ]);
-
- WCF::getTPL()->assign([
- 'useCaptcha' => $this->useCaptcha,
- ]);
- }
-}
+++ /dev/null
-<?php
-
-namespace wcf\system\recaptcha;
-
-use wcf\system\exception\UserInputException;
-use wcf\system\SingletonFactory;
-use wcf\system\WCF;
-use wcf\util\HTTPRequest;
-use wcf\util\JSON;
-use wcf\util\UserUtil;
-
-/**
- * Handles reCAPTCHA V2 support.
- *
- * @author Tim Duesterhus
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Recaptcha
- * @deprecated 5.4 - This was an implementation detail of wcf\system\captcha\RecaptchaHandler.
- */
-class RecaptchaHandlerV2 extends SingletonFactory
-{
- /**
- * Validates response.
- *
- * @param string $response
- * @param string $type
- * @throws UserInputException
- */
- public function validate($response, $type = 'v2')
- {
- // fail if response is empty to avoid sending api requests
- if (empty($response)) {
- throw new UserInputException('recaptchaString', 'false');
- }
-
- if ($type === 'v2') {
- $key = RECAPTCHA_PRIVATEKEY;
- } elseif ($type === 'invisible') {
- $key = RECAPTCHA_PRIVATEKEY_INVISIBLE;
- } else {
- // The bot modified the `recaptcha-type` form field.
- throw new UserInputException('recaptchaString', 'false');
- }
-
- $request = new HTTPRequest(
- \sprintf(
- 'https://www.google.com/recaptcha/api/siteverify?secret=%s&response=%s&remoteip=%s',
- \rawurlencode($key),
- \rawurlencode($response),
- \rawurlencode(UserUtil::getIpAddress())
- ),
- ['timeout' => 10]
- );
-
- try {
- $request->execute();
- $reply = $request->getReply();
- $data = JSON::decode($reply['body']);
-
- if ($data['success']) {
- // yeah
- } else {
- throw new UserInputException('recaptchaString', 'false');
- }
- } catch (\Exception $e) {
- if ($e instanceof UserInputException) {
- throw $e;
- }
-
- // log error, but accept captcha
- \wcf\functions\exception\logThrowable($e);
- }
-
- WCF::getSession()->register('recaptchaDone', true);
- }
-}