<?php
class CookieCaptcha extends SimpleCaptcha {
- /**
- * Check if the submitted form matches the captcha session data provided
- * by the plugin when the form was generated.
- *
- * @param string $answer
- * @param array $info
- * @return bool
- */
- function keyMatch( $answer, $info ) {
+ // Check whether the cookie is present
+ function keyMatch($answer, $info) {
global $wgCaptchaCookieName;
if (isset($_COOKIE[$wgCaptchaCookieName])) {
wfDebug( "CookieCaptcha: Found cookie\n" );
- return true;
+ return parent::keyMatch($answer, $info);
} else {
wfDebug( "CookieCaptcha: Didn't find cookie...\n" );
return false;
}
}
- function retrieveCaptcha() {
- return true;
- }
-
- /*
- function addCaptchaAPI( &$resultArr ) {
- $info = $this->pickImage();
- if ( !$info ) {
- $resultArr['captcha']['error'] = 'Out of images';
- return;
- }
- $index = $this->storeCaptcha( $info );
- $title = SpecialPage::getTitleFor( 'Captcha', 'image' );
- $resultArr['captcha']['type'] = 'image';
- $resultArr['captcha']['mime'] = 'image/png';
- $resultArr['captcha']['id'] = $index;
- $resultArr['captcha']['url'] = $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) );
- }
- */
- /**
- * Insert the captcha prompt into the edit form.
- */
function getForm() {
global $wgCaptchaCookieName, $wgCaptchaCookieImage, $wgCaptchaCookieAlt, $wgCaptchaCookieStyle;
- return "<p>" .
+ return parent::getForm() . "<p>" .
Html::element( 'img', array(
'src' => $wgCaptchaCookieImage,
'alt' => $wgCaptchaCookieAlt,
"</p>\n";
}
- /**
- * Show a message asking the user to enter a captcha on edit
- * The result will be treated as wiki text
- *
- * @param $action string Action being performed
- * @return string
- */
- /*
- function getMessage( $action ) {
- $name = 'fancycaptcha-' . $action;
- $text = wfMessage( $name )->text();
- # Obtain a more tailored message, if possible, otherwise, fall back to
- # the default for edits
- return wfMessage( $name, $text )->isDisabled() ?
- wfMessage( 'fancycaptcha-edit' )->text() : $text;
- }
- */
-
}