2011-01-31 09:50:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2011-11-23 19:09:57 +00:00
|
|
|
* Captcha class using the reCAPTCHA widget.
|
|
|
|
* Stop Spam. Read Books.
|
2011-01-31 09:50:27 +00:00
|
|
|
*
|
|
|
|
* @addtogroup Extensions
|
|
|
|
* @author Mike Crawford <mike.crawford@gmail.com>
|
|
|
|
* @copyright Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
|
|
|
|
* @licence MIT/X11
|
|
|
|
*/
|
|
|
|
|
2011-10-14 23:09:19 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
2011-01-31 09:50:27 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2012-09-02 12:26:25 +00:00
|
|
|
$dir = __DIR__;
|
|
|
|
require_once $dir . '/ConfirmEdit.php';
|
2011-10-14 23:09:19 +00:00
|
|
|
$wgCaptchaClass = 'ReCaptcha';
|
|
|
|
|
2014-03-26 11:55:44 +00:00
|
|
|
$wgMessagesDirs['ReCaptcha'] = __DIR__ . '/i18n/re';
|
2012-01-11 23:24:21 +00:00
|
|
|
$wgExtensionMessagesFiles['ReCaptcha'] = $dir . '/ReCaptcha.i18n.php';
|
|
|
|
|
2012-01-12 08:58:40 +00:00
|
|
|
$wgAutoloadClasses['ReCaptcha'] = $dir . '/ReCaptcha.class.php';
|
2011-01-31 09:50:27 +00:00
|
|
|
|
|
|
|
require_once( 'recaptchalib.php' );
|
|
|
|
|
|
|
|
// Set these in LocalSettings.php
|
|
|
|
$wgReCaptchaPublicKey = '';
|
|
|
|
$wgReCaptchaPrivateKey = '';
|
|
|
|
// For backwards compatibility
|
|
|
|
$recaptcha_public_key = '';
|
|
|
|
$recaptcha_private_key = '';
|
|
|
|
|
2011-10-26 14:51:34 +00:00
|
|
|
/**
|
|
|
|
* Sets the theme for ReCaptcha
|
|
|
|
*
|
|
|
|
* See http://code.google.com/apis/recaptcha/docs/customization.html
|
|
|
|
*/
|
|
|
|
$wgReCaptchaTheme = 'red';
|
|
|
|
|
2011-01-31 09:50:27 +00:00
|
|
|
$wgExtensionFunctions[] = 'efReCaptcha';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure the keys are defined.
|
|
|
|
*/
|
|
|
|
function efReCaptcha() {
|
|
|
|
global $wgReCaptchaPublicKey, $wgReCaptchaPrivateKey;
|
|
|
|
global $recaptcha_public_key, $recaptcha_private_key;
|
|
|
|
global $wgServerName;
|
|
|
|
|
|
|
|
// Backwards compatibility
|
|
|
|
if ( $wgReCaptchaPublicKey == '' ) {
|
|
|
|
$wgReCaptchaPublicKey = $recaptcha_public_key;
|
|
|
|
}
|
|
|
|
if ( $wgReCaptchaPrivateKey == '' ) {
|
|
|
|
$wgReCaptchaPrivateKey = $recaptcha_private_key;
|
|
|
|
}
|
|
|
|
|
2012-01-12 08:58:40 +00:00
|
|
|
if ( $wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '' ) {
|
|
|
|
die ( 'You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' .
|
2012-01-11 23:24:21 +00:00
|
|
|
"use the reCAPTCHA plugin. You can sign up for a key <a href='" .
|
2012-01-12 08:58:40 +00:00
|
|
|
htmlentities( recaptcha_get_signup_url ( $wgServerName, "mediawiki" ) ) . "'>here</a>." );
|
2011-11-23 19:09:57 +00:00
|
|
|
}
|
2011-01-31 09:50:27 +00:00
|
|
|
}
|