4 * Captcha class using the reCAPTCHA widget.
5 * Stop Spam. Read Books.
7 * @addtogroup Extensions
8 * @author Mike Crawford <mike.crawford@gmail.com>
9 * @copyright Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
13 if ( !defined( 'MEDIAWIKI' ) ) {
18 require_once $dir . '/ConfirmEdit.php';
19 $wgCaptchaClass = 'ReCaptcha';
21 $wgExtensionMessagesFiles['ReCaptcha'] = $dir . '/ReCaptcha.i18n.php';
23 $wgAutoloadClasses['ReCaptcha'] = $dir . '/ReCaptcha.class.php';
25 require_once( 'recaptchalib.php' );
27 // Set these in LocalSettings.php
28 $wgReCaptchaPublicKey = '';
29 $wgReCaptchaPrivateKey = '';
30 // For backwards compatibility
31 $recaptcha_public_key = '';
32 $recaptcha_private_key = '';
35 * Sets the theme for ReCaptcha
37 * See http://code.google.com/apis/recaptcha/docs/customization.html
39 $wgReCaptchaTheme = 'red';
41 $wgExtensionFunctions[] = 'efReCaptcha';
44 * Make sure the keys are defined.
46 function efReCaptcha() {
47 global $wgReCaptchaPublicKey, $wgReCaptchaPrivateKey;
48 global $recaptcha_public_key, $recaptcha_private_key;
51 // Backwards compatibility
52 if ( $wgReCaptchaPublicKey == '' ) {
53 $wgReCaptchaPublicKey = $recaptcha_public_key;
55 if ( $wgReCaptchaPrivateKey == '' ) {
56 $wgReCaptchaPrivateKey = $recaptcha_private_key;
59 if ( $wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '' ) {
60 die ( 'You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' .
61 "use the reCAPTCHA plugin. You can sign up for a key <a href='" .
62 htmlentities( recaptcha_get_signup_url ( $wgServerName, "mediawiki" ) ) . "'>here</a>." );