function efFancyCaptchaMessages() {
return array(
-
+
/* English */
'en' => array(
'fancycaptcha-edit' => 'Your edit includes new external links. To help protect against automated
'fancycaptcha-createaccount' => 'Comme protection contre les créations de compte abusives, veuillez entrer les mots
ci-dessous dans la boîte ([[Special:Captcha/help|plus d’informations]]) :',
),
-
+
/* Indonesian */
'id' => array(
'fancycaptcha-edit' => 'Suntingan Anda mencantumkan pranala luar baru. Untuk perlindungan terhadap spam otomatis, harap masukkan kata di bawah ini ke dalam kotak yang tersedia ([[Special:Captcha/help|info tambahan]]):',
*/
function keyMatch( $request, $info ) {
global $wgCaptchaSecret;
-
+
$answer = $request->getVal( 'wpCaptchaWord' );
$digest = $wgCaptchaSecret . $info['salt'] . $answer . $wgCaptchaSecret . $info['salt'];
$answerHash = substr( md5( $digest ), 0, 16 );
-
+
if( $answerHash == $info['hash'] ) {
wfDebug( "FancyCaptcha: answer hash matches expected {$info['hash']}\n" );
return true;
return false;
}
}
-
+
/**
* Insert the captcha prompt into the edit form.
*/
if( !$info ) {
die( "out of captcha images; this shouldn't happen" );
}
-
+
// Generate a random key for use of this captcha image in this session.
// This is needed so multiple edits in separate tabs or windows can
// go through without extra pain.
$index = $this->storeCaptcha( $info );
-
+
wfDebug( "Captcha id $index using hash ${info['hash']}, salt ${info['salt']}.\n" );
-
+
$title = Title::makeTitle( NS_SPECIAL, 'Captcha/image' );
-
- return "<p>" .
+
+ return "<p>" .
wfElement( 'img', array(
'src' => $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) ),
'width' => $info['width'],
'tabindex' => 1 ) ) . // tab in before the edit textarea
"</p>\n";
}
-
+
/**
* Select a previously generated captcha image from the queue.
* @fixme subject to race conditions if lots of files vanish
global $wgCaptchaDirectory;
$n = mt_rand( 0, $this->countFiles( $wgCaptchaDirectory ) );
$dir = opendir( $wgCaptchaDirectory );
-
+
$count = 0;
-
+
$entry = readdir( $dir );
$pick = false;
while( false !== $entry ) {
closedir( $dir );
return $pick;
}
-
+
/**
* Count the number of files in a directory.
* @return int
closedir( $dir );
return $count;
}
-
+
function showImage() {
global $wgOut, $wgRequest;
global $wgCaptchaDirectory;
-
+
$wgOut->disable();
-
+
$info = $this->retrieveCaptcha();
if( $info ) {
if( $info['viewed'] ) {
wfHttpError( 403, 'Access Forbidden', "Can't view captcha image a second time." );
return false;
}
-
+
$info['viewed'] = wfTimestamp();
$this->storeCaptcha( $info );
-
+
$salt = $info['salt'];
$hash = $info['hash'];
$file = $wgCaptchaDirectory . DIRECTORY_SEPARATOR . "image_{$salt}_{$hash}.png";
-
+
if( file_exists( $file ) ) {
header( 'Content-type: image/png' );
readfile( $file );
wfHttpError( 500, 'Internal Error', 'Requested bogus captcha image' );
return false;
}
-
+
/**
* Show a message asking the user to enter a captcha on edit
* The result will be treated as wiki text
# the default for edits
return wfEmptyMsg( $name, $text ) ? wfMsg( 'fancycaptcha-edit' ) : $text;
}
-
+
}
} # End invocation guard