[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/extensions/ConfirmEdit/ -> ReCaptcha.php (source)

   1  <?php
   2  
   3  /**
   4   * Captcha class using the reCAPTCHA widget.
   5   * Stop Spam. Read Books.
   6   *
   7   * @addtogroup Extensions
   8   * @author Mike Crawford <[email protected]>
   9   * @copyright Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
  10   * @licence MIT/X11
  11   */
  12  
  13  if ( !defined( 'MEDIAWIKI' ) ) {
  14      exit;
  15  }
  16  
  17  $dir = __DIR__;
  18  require_once $dir . '/ConfirmEdit.php';
  19  $wgCaptchaClass = 'ReCaptcha';
  20  
  21  $wgMessagesDirs['ReCaptcha'] = __DIR__ . '/i18n/re';
  22  $wgExtensionMessagesFiles['ReCaptcha'] = $dir . '/ReCaptcha.i18n.php';
  23  
  24  $wgAutoloadClasses['ReCaptcha'] = $dir . '/ReCaptcha.class.php';
  25  
  26  require_once ( 'recaptchalib.php' );
  27  
  28  // Set these in LocalSettings.php
  29  $wgReCaptchaPublicKey = '';
  30  $wgReCaptchaPrivateKey = '';
  31  // For backwards compatibility
  32  $recaptcha_public_key = '';
  33  $recaptcha_private_key = '';
  34  
  35  /**
  36   * Sets the theme for ReCaptcha
  37   *
  38   * See http://code.google.com/apis/recaptcha/docs/customization.html
  39   */
  40  $wgReCaptchaTheme = 'red';
  41  
  42  $wgExtensionFunctions[] = 'efReCaptcha';
  43  
  44  /**
  45   * Make sure the keys are defined.
  46   */
  47  function efReCaptcha() {
  48      global $wgReCaptchaPublicKey, $wgReCaptchaPrivateKey;
  49      global $recaptcha_public_key, $recaptcha_private_key;
  50      global $wgServerName;
  51  
  52      // Backwards compatibility
  53      if ( $wgReCaptchaPublicKey == '' ) {
  54          $wgReCaptchaPublicKey = $recaptcha_public_key;
  55      }
  56      if ( $wgReCaptchaPrivateKey == '' ) {
  57          $wgReCaptchaPrivateKey = $recaptcha_private_key;
  58      }
  59  
  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>." );
  64      }
  65  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1