24 protected function keyMatch( $answer, $info ) {
25 if ( is_array( $info[
'answer'] ) ) {
26 return in_array( strtolower( $answer ), array_map(
'strtolower', $info[
'answer'] ) );
28 return strtolower( $answer ) == strtolower( $info[
'answer'] );
39 $resultArr[
'captcha'][
'id'] = $index;
40 $resultArr[
'captcha'][
'question'] = $captcha[
'question'];
49 'mime' =>
'text/html',
57 global $wgCaptchaQuestions;
60 if ( $wgCaptchaQuestions === array_values( $wgCaptchaQuestions ) ) {
61 return $wgCaptchaQuestions[ mt_rand( 0, count( $wgCaptchaQuestions ) - 1 ) ];
64 $question = array_rand( $wgCaptchaQuestions, 1 );
65 $answer = $wgCaptchaQuestions[ $question ];
66 return [
'question' => $question,
'answer' => $answer ];
77 "No questions found; set some in LocalSettings.php using the format from QuestyCaptcha.php."
82 'html' =>
"<p><label for=\"wpCaptchaWord\">{$captcha['question']}</label> " .
83 Html::element(
'input', [
84 'name' =>
'wpCaptchaWord',
85 'id' =>
'wpCaptchaWord',
86 'class' =>
'mw-ui-input',
88 'autocomplete' =>
'off',
90 'tabindex' => $tabIndex ] ) .
92 Xml::element(
'input', [
94 'name' =>
'wpCaptchaId',
95 'id' =>
'wpCaptchaId',
103 $wgOut->addWikiMsg(
'questycaptchahelp-text' );
105 $wgOut->addWikiMsg(
'captchahelp-cookies-needed' );
115 return $captchaData[
'question'];
125 array &$formDescriptor,
$action ) {
128 AuthenticationRequest::getRequestByClass( $requests,
129 CaptchaAuthenticationRequest::class,
true );
135 $formDescriptor[
'captchaInfo'][
'raw'] =
true;
136 $formDescriptor[
'captchaWord'][
'label-message'] =
null;
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static get()
Get somewhere to store captcha data that will persist between requests.
showHelp()
Show a page explaining what this wacky thing is.
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
getFormInformation( $tabIndex=1)
keyMatch( $answer, $info)
Validate a captcha response.
addCaptchaAPI(&$resultArr)
getCaptchaInfo( $captchaData, $id)
Demo CAPTCHA (not for production usage) and base class for real CAPTCHAs.
string $action
Used to select the right message.
storeCaptcha( $info)
Generate a captcha session ID and save the info in PHP's session storage.