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' ) ) {
17 require_once dirname( __FILE__ ) . '/ConfirmEdit.php';
18 $wgCaptchaClass = 'ReCaptcha';
20 $dir = dirname( __FILE__ );
22 $wgExtensionMessagesFiles['ReCaptcha'] = $dir . '/ReCaptcha.i18n.php';
24 $wgAutoloadClasses['ReCaptcha'] = $dir . '/ReCaptcha.class.php';
26 require_once( 'recaptchalib.php' );
28 // Set these in LocalSettings.php
29 $wgReCaptchaPublicKey = '';
30 $wgReCaptchaPrivateKey = '';
31 // For backwards compatibility
32 $recaptcha_public_key = '';
33 $recaptcha_private_key = '';
36 * Sets the theme for ReCaptcha
38 * See http://code.google.com/apis/recaptcha/docs/customization.html
40 $wgReCaptchaTheme = 'red';
42 $wgExtensionFunctions[] = 'efReCaptcha';
45 * Make sure the keys are defined.
47 function efReCaptcha() {
48 global $wgReCaptchaPublicKey, $wgReCaptchaPrivateKey;
49 global $recaptcha_public_key, $recaptcha_private_key;
52 // Backwards compatibility
53 if ( $wgReCaptchaPublicKey == '' ) {
54 $wgReCaptchaPublicKey = $recaptcha_public_key;
56 if ( $wgReCaptchaPrivateKey == '' ) {
57 $wgReCaptchaPrivateKey = $recaptcha_private_key;
60 if ( $wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '' ) {
61 die ( 'You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' .
62 "use the reCAPTCHA plugin. You can sign up for a key <a href='" .
63 htmlentities( recaptcha_get_signup_url ( $wgServerName, "mediawiki" ) ) . "'>here</a>." );