X-Git-Url: https://git.toastfreeware.priv.at/toast/cookiecaptcha.git/blobdiff_plain/3db4c19909babfcc38a5219a98f6c849306df4a1..c7b30198527052bc7db36acd3ee9e826bc1029db:/FancyCaptcha.class.php diff --git a/FancyCaptcha.class.php b/FancyCaptcha.class.php index 0d74116..26227aa 100644 --- a/FancyCaptcha.class.php +++ b/FancyCaptcha.class.php @@ -44,7 +44,7 @@ class FancyCaptcha extends SimpleCaptcha { 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. @@ -69,9 +69,10 @@ class FancyCaptcha extends SimpleCaptcha { 'id' => 'wpCaptchaId', 'value' => $index ) ) . "
" . - Xml::element( 'input', array( + Html::element( 'input', array( 'name' => 'wpCaptchaWord', 'id' => 'wpCaptchaWord', + 'required', 'tabindex' => 1 ) ) . // tab in before the edit textarea "
\n"; } @@ -166,7 +167,7 @@ class FancyCaptcha extends SimpleCaptcha { } function showImage() { - global $wgOut, $wgRequest; + global $wgOut; $wgOut->disable(); @@ -227,4 +228,23 @@ class FancyCaptcha extends SimpleCaptcha { # 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; + } }