return;
}
$index = $this->storeCaptcha( $info );
- $title = Title::makeTitle( NS_SPECIAL, 'Captcha/image' );
+ $title = SpecialPage::getTitleFor( 'Captcha', 'image' );
$resultArr['captcha']['type'] = 'image';
$resultArr['captcha']['mime'] = 'image/png';
$resultArr['captcha']['id'] = $index;
function getForm() {
$info = $this->pickImage();
if ( !$info ) {
- die( "out of captcha images; this shouldn't happen" );
+ throw new MWException( "Ran out of captcha images" );
}
// Generate a random key for use of this captcha image in this session.
wfDebug( "Captcha id $index using hash ${info['hash']}, salt ${info['salt']}.\n" );
- $title = Title::makeTitle( NS_SPECIAL, 'Captcha/image' );
+ $title = SpecialPage::getTitleFor( 'Captcha', 'image' );
return "<p>" .
Xml::element( 'img', array(
'id' => 'wpCaptchaId',
'value' => $index ) ) .
"<p>" .
- Xml::element( 'input', array(
+ Html::element( 'input', array(
'name' => 'wpCaptchaWord',
'id' => 'wpCaptchaWord',
+ 'required',
'tabindex' => 1 ) ) . // tab in before the edit textarea
"</p>\n";
}
}
function showImage() {
- global $wgOut, $wgRequest;
+ global $wgOut;
$wgOut->disable();
# the default for edits
return wfEmptyMsg( $name, $text ) ? wfMsg( 'fancycaptcha-edit' ) : $text;
}
+
+ /**
+ * Delete a solved captcha image, if $wgCaptchaDeleteOnSolve is true.
+ */
+ function passCaptcha() {
+ global $wgCaptchaDeleteOnSolve;
+
+ $info = $this->retrieveCaptcha(); // get the captcha info before it gets deleted
+ $pass = parent::passCaptcha();
+
+ if ( $pass && $wgCaptchaDeleteOnSolve ) {
+ $filename = $this->imagePath( $info['salt'], $info['hash'] );
+ if ( file_exists( $filename ) ) {
+ unlink( $filename );
+ }
+ }
+
+ return $pass;
+ }
}