3 class CookieCaptcha extends SimpleCaptcha {
5 * Check if the submitted form matches the captcha session data provided
6 * by the plugin when the form was generated.
8 * @param string $answer
12 function keyMatch( $answer, $info ) {
13 if (isset($_COOKIE['cookiecaptcha'])) {
14 wfDebug( "CookieCaptcha: Found cookie\n" );
17 wfDebug( "CookieCaptcha: Didn't find cookie...\n" );
22 function retrieveCaptcha() {
27 function addCaptchaAPI( &$resultArr ) {
28 $info = $this->pickImage();
30 $resultArr['captcha']['error'] = 'Out of images';
33 $index = $this->storeCaptcha( $info );
34 $title = SpecialPage::getTitleFor( 'Captcha', 'image' );
35 $resultArr['captcha']['type'] = 'image';
36 $resultArr['captcha']['mime'] = 'image/png';
37 $resultArr['captcha']['id'] = $index;
38 $resultArr['captcha']['url'] = $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) );
43 * Insert the captcha prompt into the edit form.
48 Html::element( 'img', array(
55 * Show a message asking the user to enter a captcha on edit
56 * The result will be treated as wiki text
58 * @param $action string Action being performed
62 function getMessage( $action ) {
63 $name = 'fancycaptcha-' . $action;
64 $text = wfMessage( $name )->text();
65 # Obtain a more tailored message, if possible, otherwise, fall back to
66 # the default for edits
67 return wfMessage( $name, $text )->isDisabled() ?
68 wfMessage( 'fancycaptcha-edit' )->text() : $text;