Go to the documentation of this file.
3 use MediaWiki\Auth\AuthenticationRequest;
18 global $wgReCaptchaPublicKey, $wgReCaptchaTheme;
21 $useHttps = ( isset( $_SERVER[
'HTTPS'] ) && $_SERVER[
'HTTPS'] ==
'on' );
23 [
'theme' => $wgReCaptchaTheme,
'tabindex' => $tabIndex ]
39 $challenge =
$request->getVal(
'recaptcha_challenge_field',
$request->getVal(
'captchaId' ) );
62 recaptcha_check_answer( $wgReCaptchaPrivateKey, $ip, $challenge,
$response );
64 if ( !$recaptcha_response->is_valid ) {
65 $this->recaptcha_error = $recaptcha_response->error;
86 global $wgReCaptchaPublicKey;
88 'type' =>
'recaptcha',
89 'mime' =>
'image/png',
90 'key' => $wgReCaptchaPublicKey,
102 $params[
'recaptcha_challenge_field'] = [
105 $params[
'recaptcha_response_field'] = [
118 if ( in_array( $this->recaptcha_error, [
119 'invalid-request-cookie',
'incorrect-captcha-sol',
135 return [
'index' => $index ];
168 global $wgReCaptchaPublicKey, $wgReCaptchaTheme;
179 $formDescriptor[
'captchaInfo'] = [
181 'key' => $wgReCaptchaPublicKey,
182 'theme' => $wgReCaptchaTheme,
183 'secure' => isset( $_SERVER[
'HTTPS'] ) && $_SERVER[
'HTTPS'] ===
'on',
184 'error' => $captcha->getError(),
185 ] + $formDescriptor[
'captchaInfo'];
189 $formDescriptor[
'captchaId'] = [
191 'name' =>
'recaptcha_challenge_field',
193 $formDescriptor[
'captchaWord'] = [
195 'name' =>
'recaptcha_response_field',
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
this hook is for auditing only $req
getCaptchaInfo( $captchaData, $id)
string $action
Used to select the right message.
static getInstance()
Get the global Captcha instance.
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
static encodeJsVar( $value, $pretty=false)
Encode a variable of arbitrary type to JavaScript.
retrieveCaptcha( $index)
Fetch this session's captcha info.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
passCaptcha( $challenge, $response)
Calls the library function recaptcha_check_answer to verify the users input.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
recaptcha_get_html( $pubkey, $error=null, $use_ssl=false)
Gets the challenge HTML (javascript and non-javascript version).
Authentication request for ReCaptcha v1.
when a variable name is used in a it is silently declared as a new masking the global
getCaptchaParamsFromRequest(WebRequest $request)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Demo CAPTCHA (not for production usage) and base class for real CAPTCHAs.
this hook is for auditing only $response
APIGetAllowedParams(&$module, &$params, $flags)
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
isAPICaptchaModule( $module)
createAuthenticationRequest()
addCaptchaAPI(&$resultArr)
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead. & $feedLinks hooks can tweak the array to change how login etc forms should look $requests
getFormInformation( $tabIndex=1)
Displays the reCAPTCHA widget.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
getCaptcha()
Returns an array with 'question' and 'answer' keys.
if(! $wgDBerrorLogTZ) $wgRequest
it s the revision text itself In either if gzip is the revision text is gzipped $flags
the array() calling protocol came about after MediaWiki 1.4rc1.
storeCaptcha( $info)
Generate a captcha session ID and save the info in PHP's session storage.