Go to the documentation of this file.
18 global $wgReCaptchaSiteKey,
$wgLang;
19 $lang = htmlspecialchars( urlencode(
$wgLang->getCode() ) );
24 'mw-confirmedit-captcha-fail' => (
bool)$this->error,
26 'data-sitekey' => $wgReCaptchaSiteKey
28 $htmlUrlencoded = htmlspecialchars( urlencode( $wgReCaptchaSiteKey ) );
32 <div style=
"width: 302px; height: 422px; position: relative;">
33 <div style=
"width: 302px; height: 422px; position: absolute;">
34 <iframe src=
"https://www.google.com/recaptcha/api/fallback?k={$htmlUrlencoded}&hl={$lang}"
35 frameborder=
"0" scrolling=
"no"
36 style=
"width: 302px; height:422px; border-style: none;">
40 <div style=
"width: 300px; height: 60px; border-style: none;
41 bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px;
42 background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
43 <textarea
id=
"g-recaptcha-response" name=
"g-recaptcha-response"
44 class=
"g-recaptcha-response"
45 style=
"width: 250px; height: 40px; border: 1px solid #c1c1c1;
46 margin: 10px 25px; padding: 0px; resize: none;" >
58 "<script src=\"https://www.google.com/recaptcha/api.js?hl={$lang}\" async defer></script>"
67 if ( $info instanceof
Status ) {
68 $errors = $info->getErrorsArray();
70 } elseif ( is_array( $info ) ) {
71 $error = implode(
',', $info );
89 $request->
getVal(
'captchaWord',
90 $request->
getVal(
'captchaword' )
106 global
$wgRequest, $wgReCaptchaSecretKey, $wgReCaptchaSendRemoteIP;
108 $url =
'https://www.google.com/recaptcha/api/siteverify';
111 'secret' => $wgReCaptchaSecretKey,
114 if ( $wgReCaptchaSendRemoteIP ) {
119 $status = $request->execute();
120 if ( !$status->isOK() ) {
121 $this->error =
'http';
127 $this->error =
'json';
131 if ( isset(
$response[
'error-codes'] ) ) {
132 $this->error =
'recaptcha-api';
152 global $wgReCaptchaSiteKey;
154 'type' =>
'recaptchanocaptcha',
155 'mime' =>
'image/png',
156 'key' => $wgReCaptchaSiteKey,
168 $msg = parent::getMessage(
$action );
169 if ( $this->error ) {
170 $msg =
new RawMessage(
'<div class="error">$1</div>', [ $msg ] );
183 $params[
'g-recaptcha-response'] = [
203 return [
'index' => $index ];
234 array $requests, array $fieldInfo, array &$formDescriptor,
$action
236 global $wgReCaptchaSiteKey;
238 $req = AuthenticationRequest::getRequestByClass( $requests,
239 CaptchaAuthenticationRequest::class,
true );
247 $formDescriptor[
'captchaWord'] = [
248 'class' => HTMLReCaptchaNoCaptchaField::class,
249 'key' => $wgReCaptchaSiteKey,
250 'error' => $captcha->getError(),
251 ] + $formDescriptor[
'captchaWord'];
retrieveCaptcha( $index)
Fetch this session's captcha info.
passCaptcha( $_, $word)
Check, if the user solved the captcha.
if(!isset( $args[0])) $lang
getCaptcha()
Returns an array with 'question' and 'answer' keys.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
getFormInformation( $tabIndex=1)
Get the captcha form.
getMessage( $action)
Show a message asking the user to enter a captcha on edit The result will be treated as wiki text.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
createAuthenticationRequest()
string $action
Used to select the right message.
static getInstance()
Get the global Captcha instance.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Authentication request for ReCaptcha v2.
getCaptchaParamsFromRequest(WebRequest $request)
Demo CAPTCHA (not for production usage) and base class for real CAPTCHAs.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
isAPICaptchaModule( $module)
getCaptchaInfo( $captchaData, $id)
getError()
Return the error from the last passCaptcha* call.
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it's not set.
addCaptchaAPI(&$resultArr)
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
if(! $wgDBerrorLogTZ) $wgRequest
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Variant of the Message class.
apiGetAllowedParams(&$module, &$params, $flags)
storeCaptcha( $info)
Generate a captcha session ID and save the info in PHP's session storage.
static factory( $url, array $options=null, $caller=__METHOD__)
Generate a new request object.