Don't check badlogin attempts in memcached if we are not configured to show captchas...
[toast/cookiecaptcha.git] / ConfirmEditHooks.php
1 <?php
2
3 class ConfirmEditHooks {
4
5         /**
6          * Get the global Captcha instance
7          *
8          * @return Captcha|SimpleCaptcha
9          */
10         static function getInstance() {
11                 global $wgCaptcha, $wgCaptchaClass;
12                 static $done = false;
13                 if ( !$done ) {
14                         $done = true;
15                         $wgCaptcha = new $wgCaptchaClass;
16                 }
17                 return $wgCaptcha;
18         }
19
20         static function confirmEditMerged( $editPage, $newtext ) {
21                 return self::getInstance()->confirmEditMerged( $editPage, $newtext );
22         }
23
24         static function confirmEditAPI( $editPage, $newtext, &$resultArr ) {
25                 return self::getInstance()->confirmEditAPI( $editPage, $newtext, $resultArr );
26         }
27
28         static function injectUserCreate( &$template ) {
29                 return self::getInstance()->injectUserCreate( $template );
30         }
31
32         static function confirmUserCreate( $u, &$message ) {
33                 return self::getInstance()->confirmUserCreate( $u, $message );
34         }
35
36         static function triggerUserLogin( $user, $password, $retval ) {
37                 return self::getInstance()->triggerUserLogin( $user, $password, $retval );
38         }
39
40         static function injectUserLogin( &$template ) {
41                 return self::getInstance()->injectUserLogin( $template );
42         }
43
44         static function confirmUserLogin( $u, $pass, &$retval ) {
45                 return self::getInstance()->confirmUserLogin( $u, $pass, $retval );
46         }
47
48         static function injectEmailUser( &$form ) {
49                 return self::getInstance()->injectEmailUser( $form );
50         }
51
52         static function confirmEmailUser( $from, $to, $subject, $text, &$error ) {
53                 return self::getInstance()->confirmEmailUser( $from, $to, $subject, $text, $error );
54         }
55
56         public static function APIGetAllowedParams( &$module, &$params ) {
57                 return self::getInstance()->APIGetAllowedParams( $module, $params );
58         }
59
60         public static function APIGetParamDescription( &$module, &$desc ) {
61                 return self::getInstance()->APIGetParamDescription( $module, $desc );
62         }
63 }
64
65 class CaptchaSpecialPage extends UnlistedSpecialPage {
66         public function __construct(){
67                 parent::__construct( 'Captcha' );
68         }
69         function execute( $par ) {
70                 $this->setHeaders();
71                 $instance = ConfirmEditHooks::getInstance();
72                 switch( $par ) {
73                 case "image":
74                         if ( method_exists( $instance, 'showImage' ) )
75                                 return $instance->showImage();
76                 case "help":
77                 default:
78                         return $instance->showHelp();
79                 }
80         }
81 }
82