mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-24 00:04:15 +00:00
Move ReCaptcha to it's own place
Bug: T88047 Change-Id: I6cdb9ac1d21c84fc9b01cd90b9cba4aa3db1eccc
This commit is contained in:
parent
cad5bc9200
commit
dc727507ea
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This is a backwards-compatibility shim, generated by:
|
||||
* https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
|
||||
*
|
||||
* Beginning with MediaWiki 1.23, translation strings are stored in json files,
|
||||
* and the EXTENSION.i18n.php file only exists to provide compatibility with
|
||||
* older releases of MediaWiki. For more information about this migration, see:
|
||||
* https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
|
||||
*
|
||||
* This shim maintains compatibility back to MediaWiki 1.17.
|
||||
*/
|
||||
$messages = array();
|
||||
if ( !function_exists( 'wfJsonI18nShim74b2af1eb76d9704' ) ) {
|
||||
function wfJsonI18nShim74b2af1eb76d9704( $cache, $code, &$cachedData ) {
|
||||
$codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] );
|
||||
foreach ( $codeSequence as $csCode ) {
|
||||
$fileName = dirname( __FILE__ ) . "/i18n/re/$csCode.json";
|
||||
if ( is_readable( $fileName ) ) {
|
||||
$data = FormatJson::decode( file_get_contents( $fileName ), true );
|
||||
foreach ( array_keys( $data ) as $key ) {
|
||||
if ( $key === '' || $key[0] === '@' ) {
|
||||
unset( $data[$key] );
|
||||
}
|
||||
}
|
||||
$cachedData['messages'] = array_merge( $data, $cachedData['messages'] );
|
||||
}
|
||||
|
||||
$cachedData['deps'][] = new FileDependency( $fileName );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShim74b2af1eb76d9704';
|
||||
}
|
|
@ -1,64 +1,2 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Captcha class using the reCAPTCHA widget.
|
||||
* Stop Spam. Read Books.
|
||||
*
|
||||
* @addtogroup Extensions
|
||||
* @author Mike Crawford <mike.crawford@gmail.com>
|
||||
* @copyright Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
|
||||
* @licence MIT/X11
|
||||
*/
|
||||
|
||||
if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/ConfirmEdit.php';
|
||||
$wgCaptchaClass = 'ReCaptcha';
|
||||
|
||||
$wgMessagesDirs['ReCaptcha'] = __DIR__ . '/ReCaptcha/i18n';
|
||||
$wgExtensionMessagesFiles['ReCaptcha'] = __DIR__ . '/ReCaptcha.i18n.php';
|
||||
|
||||
$wgAutoloadClasses['ReCaptcha'] = __DIR__ . '/ReCaptcha.class.php';
|
||||
|
||||
require_once( 'recaptchalib.php' );
|
||||
|
||||
// Set these in LocalSettings.php
|
||||
$wgReCaptchaPublicKey = '';
|
||||
$wgReCaptchaPrivateKey = '';
|
||||
// For backwards compatibility
|
||||
$recaptcha_public_key = '';
|
||||
$recaptcha_private_key = '';
|
||||
|
||||
/**
|
||||
* Sets the theme for ReCaptcha
|
||||
*
|
||||
* See http://code.google.com/apis/recaptcha/docs/customization.html
|
||||
*/
|
||||
$wgReCaptchaTheme = 'red';
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
if ( $wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '' ) {
|
||||
die ( 'You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' .
|
||||
"use the reCAPTCHA plugin. You can sign up for a key <a href='" .
|
||||
htmlentities( recaptcha_get_signup_url ( $wgServerName, "mediawiki" ) ) . "'>here</a>." );
|
||||
}
|
||||
}
|
||||
require_once __DIR__ . "/ReCaptcha/ReCaptcha.php";
|
||||
|
|
63
ReCaptcha/ReCaptcha.php
Normal file
63
ReCaptcha/ReCaptcha.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Captcha class using the reCAPTCHA widget.
|
||||
* Stop Spam. Read Books.
|
||||
*
|
||||
* @addtogroup Extensions
|
||||
* @author Mike Crawford <mike.crawford@gmail.com>
|
||||
* @copyright Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
|
||||
* @licence MIT/X11
|
||||
*/
|
||||
|
||||
if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once dirname( __DIR__ ) . '/ConfirmEdit.php';
|
||||
$wgCaptchaClass = 'ReCaptcha';
|
||||
|
||||
$wgMessagesDirs['ReCaptcha'] = __DIR__ . '/i18n';
|
||||
|
||||
$wgAutoloadClasses['ReCaptcha'] = __DIR__ . '/ReCaptcha.class.php';
|
||||
|
||||
require_once( 'recaptchalib.php' );
|
||||
|
||||
// Set these in LocalSettings.php
|
||||
$wgReCaptchaPublicKey = '';
|
||||
$wgReCaptchaPrivateKey = '';
|
||||
// For backwards compatibility
|
||||
$recaptcha_public_key = '';
|
||||
$recaptcha_private_key = '';
|
||||
|
||||
/**
|
||||
* Sets the theme for ReCaptcha
|
||||
*
|
||||
* See http://code.google.com/apis/recaptcha/docs/customization.html
|
||||
*/
|
||||
$wgReCaptchaTheme = 'red';
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
if ( $wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '' ) {
|
||||
die ( 'You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' .
|
||||
"use the reCAPTCHA plugin. You can sign up for a key <a href='" .
|
||||
htmlentities( recaptcha_get_signup_url ( $wgServerName, "mediawiki" ) ) . "'>here</a>." );
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue