Index: trunk/extensions/ConfirmEdit/ReCaptcha.php |
— | — | @@ -55,8 +55,8 @@ |
56 | 56 | |
57 | 57 | if ($wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '') { |
58 | 58 | die ('You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' . |
59 | | - "use the reCAPTCHA plugin. You can sign up for a key <a href='" . |
60 | | - htmlentities(recaptcha_get_signup_url ($wgServerName, "mediawiki")) . "'>here</a>."); |
| 59 | + "use the reCAPTCHA plugin. You can sign up for a key <a href='" . |
| 60 | + htmlentities(recaptcha_get_signup_url ($wgServerName, "mediawiki")) . "'>here</a>."); |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
— | — | @@ -68,9 +68,9 @@ |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Displays the reCAPTCHA widget. |
72 | | - * If $this->recaptcha_error is set, it will display an error in the widget. |
| 72 | + * If $this->recaptcha_error is set, it will display an error in the widget. |
73 | 73 | * |
74 | | - */ |
| 74 | + */ |
75 | 75 | function getForm() { |
76 | 76 | global $wgReCaptchaPublicKey, $wgReCaptchaTheme; |
77 | 77 | $useHttps = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ); |
— | — | @@ -82,21 +82,24 @@ |
83 | 83 | /** |
84 | 84 | * Calls the library function recaptcha_check_answer to verify the users input. |
85 | 85 | * Sets $this->recaptcha_error if the user is incorrect. |
86 | | - * @return boolean |
87 | | - * |
88 | | - */ |
| 86 | + * @return boolean |
| 87 | + * |
| 88 | + */ |
89 | 89 | function passCaptcha() { |
90 | 90 | global $wgReCaptchaPrivateKey; |
91 | | - $recaptcha_response = recaptcha_check_answer ($wgReCaptchaPrivateKey, |
92 | | - wfGetIP (), |
93 | | - $_POST['recaptcha_challenge_field'], |
94 | | - $_POST['recaptcha_response_field']); |
95 | | - if (!$recaptcha_response->is_valid) { |
| 91 | + $recaptcha_response = |
| 92 | + recaptcha_check_answer ( |
| 93 | + $wgReCaptchaPrivateKey, |
| 94 | + wfGetIP (), |
| 95 | + $_POST['recaptcha_challenge_field'], |
| 96 | + $_POST['recaptcha_response_field'] |
| 97 | + ); |
| 98 | + if (!$recaptcha_response->is_valid) { |
96 | 99 | $this->recaptcha_error = $recaptcha_response->error; |
97 | 100 | return false; |
98 | | - } |
| 101 | + } |
99 | 102 | $recaptcha_error = null; |
100 | | - return true; |
| 103 | + return true; |
101 | 104 | |
102 | 105 | } |
103 | 106 | |
— | — | @@ -108,17 +111,17 @@ |
109 | 112 | if( $this->shouldCheck( $editPage, $newtext, $section ) ) { |
110 | 113 | |
111 | 114 | if (!isset($_POST['recaptcha_response_field'])) { |
112 | | - //User has not yet been presented with Captcha, show the widget. |
113 | | - $editPage->showEditForm( array( &$this, 'editCallback' ) ); |
114 | | - return false; |
| 115 | + //User has not yet been presented with Captcha, show the widget. |
| 116 | + $editPage->showEditForm( array( &$this, 'editCallback' ) ); |
| 117 | + return false; |
115 | 118 | } |
116 | 119 | |
117 | 120 | if( $this->passCaptcha() ) { |
118 | | - return true; |
| 121 | + return true; |
119 | 122 | } else { |
120 | | - //Try again - show the widget |
121 | | - $editPage->showEditForm( array( &$this, 'editCallback' ) ); |
122 | | - return false; |
| 123 | + //Try again - show the widget |
| 124 | + $editPage->showEditForm( array( &$this, 'editCallback' ) ); |
| 125 | + return false; |
123 | 126 | } |
124 | 127 | |
125 | 128 | } else { |