18 global $wgReCaptchaSiteKey,
$wgLang;
19 $lang = htmlspecialchars( urlencode(
$wgLang->getCode() ) );
21 $output = Html::element(
'div', [
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 ) {
118 $request = MWHttpRequest::factory( $url, [
'method' =>
'GET' ] );
119 $status = $request->execute();
120 if ( !$status->isOK() ) {
121 $this->error =
'http';
125 $response = FormatJson::decode( $request->getContent(),
true );
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'] = [
184 ApiBase::PARAM_HELP_MSG =>
'renocaptcha-apihelp-param-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 );
245 $captcha = ConfirmEditHooks::getInstance();
247 $formDescriptor[
'captchaWord'] = [
248 'class' => HTMLReCaptchaNoCaptchaField::class,
249 'key' => $wgReCaptchaSiteKey,
250 'error' => $captcha->getError(),
251 ] + $formDescriptor[
'captchaWord'];
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(! $wgDBerrorLogTZ) $wgRequest
Variant of the Message class.
Authentication request for ReCaptcha v2.
apiGetAllowedParams(&$module, &$params, $flags)
getCaptchaInfo( $captchaData, $id)
getMessage( $action)
Show a message asking the user to enter a captcha on edit The result will be treated as wiki text.
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
getError()
Return the error from the last passCaptcha* call.
getCaptcha()
Returns an array with 'question' and 'answer' keys.
passCaptcha( $_, $word)
Check, if the user solved the captcha.
addCaptchaAPI(&$resultArr)
retrieveCaptcha( $index)
Fetch this session's captcha info.
getFormInformation( $tabIndex=1)
Get the captcha form.
storeCaptcha( $info)
Generate a captcha session ID and save the info in PHP's session storage.
getCaptchaParamsFromRequest(WebRequest $request)
createAuthenticationRequest()
Demo CAPTCHA (not for production usage) and base class for real CAPTCHAs.
isAPICaptchaModule( $module)
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.
if(!isset( $args[0])) $lang