Index: trunk/extensions/ConfirmEdit/ReCaptcha.php |
— | — | @@ -86,29 +86,31 @@ |
87 | 87 | * |
88 | 88 | */ |
89 | 89 | function passCaptcha() { |
90 | | - global $wgReCaptchaPrivateKey; |
91 | | - global $wgRequest; |
| 90 | + global $wgReCaptchaPrivateKey, $wgRequest; |
92 | 91 | |
93 | 92 | //API is hardwired to return wpCaptchaId and wpCaptchaWord, so use that if the standard two are empty |
94 | | - $challenge = $wgRequest->getVal('recaptcha_challenge_field',$wgRequest->getVal('wpCaptchaId')); |
95 | | - $response = $wgRequest->getVal('recaptcha_response_field',$wgRequest->getVal('wpCaptchaWord')); |
| 93 | + $challenge = $wgRequest->getVal( 'recaptcha_challenge_field', $wgRequest->getVal( 'wpCaptchaId' ) ); |
| 94 | + $response = $wgRequest->getVal( 'recaptcha_response_field', $wgRequest->getVal( 'wpCaptchaWord' ) ); |
| 95 | + |
96 | 96 | if ( $response === null ) { |
97 | 97 | //new captcha session |
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
| 101 | + $recaptcha_response = recaptcha_check_answer( |
| 102 | + $wgReCaptchaPrivateKey, |
| 103 | + $wgRequest->getIP(), |
| 104 | + $challenge, |
| 105 | + $response |
| 106 | + ); |
101 | 107 | |
102 | | - recaptcha_check_answer ( |
103 | | - $wgReCaptchaPrivateKey, |
104 | | - $wgRequest->getIP(), |
105 | | - $challenge, |
106 | | - $response |
107 | | - ); |
108 | 108 | if (!$recaptcha_response->is_valid) { |
109 | 109 | $this->recaptcha_error = $recaptcha_response->error; |
110 | 110 | return false; |
111 | 111 | } |
| 112 | + |
112 | 113 | $recaptcha_error = null; |
| 114 | + |
113 | 115 | return true; |
114 | 116 | |
115 | 117 | } |