31 global $wgHCaptchaSiteKey;
33 $output = Html::element(
'div', [
36 'mw-confirmedit-captcha-fail' => (
bool)$this->error,
38 'data-sitekey' => $wgHCaptchaSiteKey
44 "<script src=\"https://hcaptcha.com/1/api.js\" async defer></script>"
53 if ( $info instanceof
Status ) {
54 $errors = $info->getErrorsArray();
56 } elseif ( is_array( $info ) ) {
57 $error = implode(
',', $info );
62 \wfDebugLog(
'captcha',
'Unable to validate response: ' .
$error );
85 global
$wgRequest, $wgHCaptchaSecretKey, $wgHCaptchaSendRemoteIP;
87 $url =
'https://hcaptcha.com/siteverify';
89 'secret' => $wgHCaptchaSecretKey,
92 if ( $wgHCaptchaSendRemoteIP ) {
102 $status = $request->execute();
103 if ( !$status->isOK() ) {
104 $this->error =
'http';
110 $this->error =
'json';
114 if ( isset(
$response[
'error-codes'] ) ) {
115 $this->error =
'hcaptcha-api';
133 global $wgHCaptchaSiteKey;
135 'type' =>
'hcaptcha',
136 'mime' =>
'application/javascript',
137 'key' => $wgHCaptchaSiteKey,
149 $msg = parent::getMessage(
$action );
150 if ( $this->error ) {
151 $msg =
new RawMessage(
'<div class="error">$1</div>', [ $msg ] );
185 return [
'index' => $index ];
209 array $requests, array $fieldInfo, array &$formDescriptor,
$action
211 global $wgHCaptchaSiteKey;
213 $req = AuthenticationRequest::getRequestByClass(
215 CaptchaAuthenticationRequest::class,
225 $formDescriptor[
'captchaWord'] = [
226 'class' => HTMLHCaptchaField::class,
227 'key' => $wgHCaptchaSiteKey,
228 'error' => $captcha->getError(),
229 ] + $formDescriptor[
'captchaWord'];
if(! $wgDBerrorLogTZ) $wgRequest
This abstract class implements many basic API functions, and is the base of all API classes.
Generic captcha authentication request class.
static getInstance()
Get the global Captcha instance.
This class is a collection of static functions that serve two purposes:
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for h...
static factory( $url, array $options=null, $caller=__METHOD__)
Generate a new request object.
The Message class provides methods which fulfil two basic services:
Variant of the Message class.
Demo CAPTCHA (not for production usage) and base class for real CAPTCHAs.
string $action
Used to select the right message.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it's not set.