MediaWiki  1.33.0
FancyCaptcha Class Reference

FancyCaptcha for displaying captchas precomputed by captcha.py. More...

Inheritance diagram for FancyCaptcha:
Collaboration diagram for FancyCaptcha:

Public Member Functions

 describeCaptchaType ()
 
 estimateCaptchaCount ()
 
 getBackend ()
 
 getCaptcha ()
 Returns an array with 'salt' and 'hash' keys. More...
 
 getCaptchaCount ()
 
 getCaptchaInfo ( $captchaData, $id)
 
 getFormInformation ( $tabIndex=1)
 
 hashFromImageName ( $basename)
 
 imagePath ( $salt, $hash)
 
 onAuthChangeFormFields (array $requests, array $fieldInfo, array &$formDescriptor, $action)
 
 showImage ()
 
- Public Member Functions inherited from SimpleCaptcha
 addFormInformationToOutput (OutputPage $out, array $formInformation)
 Processes the given $formInformation array and adds the options (see getFormInformation()) to the given OutputPage object. More...
 
 addFormToOutput (OutputPage $out, $tabIndex=1)
 Uses getFormInformation() to get the CAPTCHA form and adds it to the given OutputPage object. More...
 
 apiGetAllowedParams (&$module, &$params, $flags)
 
 canSkipCaptcha ( $user, Config $config)
 Check whether the user provided / IP making the request is allowed to skip captchas. More...
 
 captchaTriggers ( $title, $action)
 
 clearCaptcha ( $index)
 Clear out existing captcha info from the session, to ensure it can't be reused. More...
 
 confirmEditMerged ( $context, $content, $status, $summary, $user, $minorEdit)
 An efficient edit filter callback based on the text after section merging. More...
 
 confirmEmailUser ( $from, $to, $subject, $text, &$error)
 Check the captcha on Special:EmailUser. More...
 
 createAuthenticationRequest ()
 
 editShowCaptcha ( $editPage)
 Insert the captcha prompt into an edit form. More...
 
 getError ()
 Return the error from the last passCaptcha* call. More...
 
 getMessage ( $action)
 Show a message asking the user to enter a captcha on edit The result will be treated as wiki text. More...
 
 increaseBadLoginCounter ( $username)
 Increase bad login counter after a failed login. More...
 
 injectEmailUser (&$form)
 Inject whazawhoo @fixme if multiple thingies insert a header, could break. More...
 
 isBadLoginPerUserTriggered ( $u)
 Is the per-user captcha triggered? More...
 
 isBadLoginTriggered ()
 Check if a bad login has already been registered for this IP address. More...
 
 needCreateAccountCaptcha (User $creatingUser=null)
 Logic to check if we need to pass a captcha for the current user to create a new account, or not. More...
 
 passCaptchaFromRequest (WebRequest $request, User $user)
 Given a required captcha run, test form input for correct input on the open session. More...
 
 passCaptchaLimited ( $index, $word, User $user)
 Checks, if the user reached the amount of false CAPTCHAs and give him some vacation or run self::passCaptcha() and clear counter if correct. More...
 
 passCaptchaLimitedFromRequest (WebRequest $request, User $user)
 Checks, if the user reached the amount of false CAPTCHAs and give him some vacation or run self::passCaptcha() and clear counter if correct. More...
 
 resetBadLoginCounter ( $username)
 Reset bad login counter after a successful login. More...
 
 retrieveCaptcha ( $index)
 Fetch this session's captcha info. More...
 
 setAction ( $action)
 
 setTrigger ( $trigger)
 
 shouldCheck (WikiPage $page, $content, $section, $context, $oldtext=null)
 
 showEditFormFields (&$editPage, &$out)
 Show error message for missing or incorrect captcha on EditPage. More...
 
 showHelp ()
 Show a page explaining what this wacky thing is. More...
 
 storeCaptcha ( $info)
 Generate a captcha session ID and save the info in PHP's session storage. More...
 
 triggersCaptcha ( $action, $title=null)
 Checks, whether the passed action should trigger a CAPTCHA. More...
 

Protected Member Functions

 addCaptchaAPI (&$resultArr)
 
 keyMatch ( $answer, $info)
 Check if the submitted form matches the captcha session data provided by the plugin when the form was generated. More...
 
 passCaptcha ( $index, $word)
 Delete a solved captcha image, if $wgCaptchaDeleteOnSolve is true. More...
 
 pickImage ()
 Select a previously generated captcha image from the queue. More...
 
 pickImageDir ( $directory, $levels, &$lockouts)
 
 pickImageFromDir ( $directory, &$lockouts)
 
 pickImageFromList ( $directory, array $files, &$lockouts)
 
- Protected Member Functions inherited from SimpleCaptcha
 getCaptchaParamsFromRequest (WebRequest $request)
 
 isAPICaptchaModule ( $module)
 
 log ( $message)
 Log the status and any triggering info for debugging or statistics. More...
 

Static Protected Attributes

static $messagePrefix = 'fancycaptcha-'
 
- Static Protected Attributes inherited from SimpleCaptcha
static $messagePrefix = 'captcha-'
 

Additional Inherited Members

- Protected Attributes inherited from SimpleCaptcha
string $action
 Used to select the right message. More...
 
string $trigger
 Used in log messages. More...
 

Detailed Description

FancyCaptcha for displaying captchas precomputed by captcha.py.

Definition at line 9 of file FancyCaptcha.php.

Member Function Documentation

◆ addCaptchaAPI()

FancyCaptcha::addCaptchaAPI ( $resultArr)
protected
Parameters
array&$resultArr

Reimplemented from SimpleCaptcha.

Definition at line 86 of file FancyCaptcha.php.

References $title, describeCaptchaType(), SpecialPage\getTitleFor(), pickImage(), and SimpleCaptcha\storeCaptcha().

◆ describeCaptchaType()

FancyCaptcha::describeCaptchaType ( )
Returns
array

Reimplemented from SimpleCaptcha.

Definition at line 102 of file FancyCaptcha.php.

Referenced by addCaptchaAPI().

◆ estimateCaptchaCount()

FancyCaptcha::estimateCaptchaCount ( )
Deprecated:
Use getCaptchaCount instead for an accurate figure
Returns
int Number of captcha files

Definition at line 43 of file FancyCaptcha.php.

References getCaptchaCount(), and wfDeprecated().

◆ getBackend()

FancyCaptcha::getBackend ( )

◆ getCaptcha()

FancyCaptcha::getCaptcha ( )

Returns an array with 'salt' and 'hash' keys.

Hash is md5( $wgCaptchaSecret . $salt . $answer . $wgCaptchaSecret . $salt )[0..15]

Returns
array
Exceptions
ExceptionWhen a captcha image cannot be produced.

Reimplemented from SimpleCaptcha.

Definition at line 443 of file FancyCaptcha.php.

References pickImage().

Referenced by getFormInformation().

◆ getCaptchaCount()

FancyCaptcha::getCaptchaCount ( )
Returns
int Number of captcha files

Definition at line 51 of file FancyCaptcha.php.

References getBackend().

Referenced by estimateCaptchaCount().

◆ getCaptchaInfo()

FancyCaptcha::getCaptchaInfo (   $captchaData,
  $id 
)
Parameters
array$captchaData
string$id
Returns
string

Reimplemented from SimpleCaptcha.

Definition at line 456 of file FancyCaptcha.php.

References $title, and SpecialPage\getTitleFor().

Referenced by onAuthChangeFormFields().

◆ getFormInformation()

FancyCaptcha::getFormInformation (   $tabIndex = 1)
Parameters
int$tabIndex
Returns
array

Reimplemented from SimpleCaptcha.

Definition at line 113 of file FancyCaptcha.php.

References $modules, $title, captcha-old\action, getCaptcha(), SpecialPage\getTitleFor(), SimpleCaptcha\storeCaptcha(), text, and wfMessage().

◆ hashFromImageName()

FancyCaptcha::hashFromImageName (   $basename)
Parameters
string$basename
Returns
array (salt, hash)
Exceptions
Exception

Definition at line 409 of file FancyCaptcha.php.

References $matches.

◆ imagePath()

FancyCaptcha::imagePath (   $salt,
  $hash 
)
Parameters
string$salt
string$hash
Returns
string

Definition at line 392 of file FancyCaptcha.php.

References $file, and getBackend().

Referenced by passCaptcha(), and showImage().

◆ keyMatch()

FancyCaptcha::keyMatch (   $answer,
  $info 
)
protected

Check if the submitted form matches the captcha session data provided by the plugin when the form was generated.

Parameters
string$answer
array$info
Returns
bool

Reimplemented from SimpleCaptcha.

Definition at line 68 of file FancyCaptcha.php.

References wfDebug().

◆ onAuthChangeFormFields()

FancyCaptcha::onAuthChangeFormFields ( array  $requests,
array  $fieldInfo,
array $formDescriptor,
  $action 
)
Parameters
array$requests
array$fieldInfo
array&$formDescriptor
string$action

Reimplemented from SimpleCaptcha.

Definition at line 467 of file FancyCaptcha.php.

References SimpleCaptcha\$action, $formDescriptor, $req, $requests, captcha-old\action, class, getCaptchaInfo(), and SimpleCaptcha\getMessage().

◆ passCaptcha()

FancyCaptcha::passCaptcha (   $index,
  $word 
)
protected

Delete a solved captcha image, if $wgCaptchaDeleteOnSolve is true.

@inheritDoc

Reimplemented from SimpleCaptcha.

Definition at line 421 of file FancyCaptcha.php.

References getBackend(), imagePath(), and SimpleCaptcha\retrieveCaptcha().

◆ pickImage()

FancyCaptcha::pickImage ( )
protected

Select a previously generated captcha image from the queue.

Returns
mixed tuple of (salt key, text hash) or false if no image to find

Definition at line 189 of file FancyCaptcha.php.

References getBackend(), and pickImageDir().

Referenced by addCaptchaAPI(), and getCaptcha().

◆ pickImageDir()

FancyCaptcha::pickImageDir (   $directory,
  $levels,
$lockouts 
)
protected
Parameters
string$directory
int$levels
int&$lockouts
Returns
array|bool

Definition at line 204 of file FancyCaptcha.php.

References $dirs, $wgMemc, as, captcha-old\count, getBackend(), pickImageFromDir(), and wfDebug().

Referenced by pickImage().

◆ pickImageFromDir()

FancyCaptcha::pickImageFromDir (   $directory,
$lockouts 
)
protected
Parameters
string$directory
int&$lockouts
Returns
array|bool

Definition at line 265 of file FancyCaptcha.php.

References $wgMemc, as, captcha-old\count, getBackend(), pickImageFromList(), and wfDebug().

Referenced by pickImageDir().

◆ pickImageFromList()

FancyCaptcha::pickImageFromList (   $directory,
array  $files,
$lockouts 
)
protected
Parameters
string$directory
array$files
int&$lockouts
Returns
array|bool

Definition at line 312 of file FancyCaptcha.php.

References $matches, $wgMemc, add, captcha-old\count, and getBackend().

Referenced by pickImageFromDir().

◆ showImage()

FancyCaptcha::showImage ( )

Member Data Documentation

◆ $messagePrefix

FancyCaptcha::$messagePrefix = 'fancycaptcha-'
staticprotected

Definition at line 12 of file FancyCaptcha.php.


The documentation for this class was generated from the following file: