Index: trunk/extensions/ConfirmEdit/QuestyCaptcha.i18n.php |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | 'questycaptcha-createaccount' => 'To help protect against automated account creation, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
18 | 18 | 'questycaptcha-create' => 'To create the page, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
19 | 19 | 'questycaptcha-edit' => 'To edit this page, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
| 20 | + 'questycaptcha-sendemail' => 'To help protect against automated spamming, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
20 | 21 | 'questycaptchahelp-text' => "Web sites that accept contributions from the public, like this wiki, are often abused by spammers who use automated tools to add their links to many sites. |
21 | 22 | While these spam links can be removed, they are a significant nuisance. |
22 | 23 | |
Index: trunk/extensions/ConfirmEdit/ConfirmEdit_body.php |
— | — | @@ -46,6 +46,14 @@ |
47 | 47 | static function confirmUserLogin( $u, $pass, &$retval ) { |
48 | 48 | return self::getInstance()->confirmUserLogin( $u, $pass, $retval ); |
49 | 49 | } |
| 50 | + |
| 51 | + static function injectEmailUser( &$form ) { |
| 52 | + return self::getInstance()->injectEmailUser( $form ); |
| 53 | + } |
| 54 | + |
| 55 | + static function confirmEmailUser( $from, $to, $subject, $text, &$error ) { |
| 56 | + return self::getInstance()->confirmEmailUser( $from, $to, $subject, $text, $error ); |
| 57 | + } |
50 | 58 | } |
51 | 59 | |
52 | 60 | class CaptchaSpecialPage extends UnlistedSpecialPage { |
— | — | @@ -141,6 +149,28 @@ |
142 | 150 | /** |
143 | 151 | * Inject whazawhoo |
144 | 152 | * @fixme if multiple thingies insert a header, could break |
| 153 | + * @param HTMLForm |
| 154 | + * @return bool true to keep running callbacks |
| 155 | + */ |
| 156 | + function injectEmailUser( &$form ) { |
| 157 | + global $wgCaptchaTriggers, $wgOut, $wgUser; |
| 158 | + if ( $wgCaptchaTriggers['sendemail'] ) { |
| 159 | + if ( $wgUser->isAllowed( 'skipcaptcha' ) ) { |
| 160 | + wfDebug( "ConfirmEdit: user group allows skipping captcha on email sending\n" ); |
| 161 | + return true; |
| 162 | + } |
| 163 | + $form->addFooterText( |
| 164 | + "<div class='captcha'>" . |
| 165 | + $wgOut->parse( $this->getMessage( 'sendemail' ) ) . |
| 166 | + $this->getForm() . |
| 167 | + "</div>\n" ); |
| 168 | + } |
| 169 | + return true; |
| 170 | + } |
| 171 | + |
| 172 | + /** |
| 173 | + * Inject whazawhoo |
| 174 | + * @fixme if multiple thingies insert a header, could break |
145 | 175 | * @param SimpleTemplate $template |
146 | 176 | * @return bool true to keep running callbacks |
147 | 177 | */ |
— | — | @@ -565,6 +595,40 @@ |
566 | 596 | } |
567 | 597 | |
568 | 598 | /** |
| 599 | + * Check the captcha on Special:EmailUser |
| 600 | + * @param $from MailAddress |
| 601 | + * @param $to MailAddress |
| 602 | + * @param $subject String |
| 603 | + * @param $text String |
| 604 | + * @param $error String reference |
| 605 | + * @return Bool true to continue saving, false to abort and show a captcha form |
| 606 | + */ |
| 607 | + function confirmEmailUser( $from, $to, $subject, $text, &$error ) { |
| 608 | + global $wgCaptchaTriggers, $wgUser; |
| 609 | + if ( $wgCaptchaTriggers['sendemail'] ) { |
| 610 | + if ( $wgUser->isAllowed( 'skipcaptcha' ) ) { |
| 611 | + wfDebug( "ConfirmEdit: user group allows skipping captcha on email sending\n" ); |
| 612 | + return true; |
| 613 | + } |
| 614 | + if ( $this->isIPWhitelisted() ) |
| 615 | + return true; |
| 616 | + |
| 617 | + if ( defined( 'MW_API' ) ) { |
| 618 | + # API mode |
| 619 | + # Asking for captchas in the API is really silly |
| 620 | + $error = wfMsg( 'captcha-disabledinapi' ); |
| 621 | + return false; |
| 622 | + } |
| 623 | + $this->trigger = "{$wgUser->getName()} sending email"; |
| 624 | + if ( !$this->passCaptcha() ) { |
| 625 | + $error = wfMsg( 'captcha-sendemail-fail' ); |
| 626 | + return false; |
| 627 | + } |
| 628 | + } |
| 629 | + return true; |
| 630 | + } |
| 631 | + |
| 632 | + /** |
569 | 633 | * Given a required captcha run, test form input for correct |
570 | 634 | * input on the open session. |
571 | 635 | * @return bool if passed, false if failed or new session |
Index: trunk/extensions/ConfirmEdit/ConfirmEdit.i18n.php |
— | — | @@ -16,6 +16,9 @@ |
17 | 17 | 'captcha-createaccount' => 'To help protect against automated account creation, please solve the simple sum below and enter the answer in the box ([[Special:Captcha/help|more info]]):', |
18 | 18 | 'captcha-createaccount-fail' => "Incorrect or missing confirmation code.", |
19 | 19 | 'captcha-create' => 'To create the page, please solve the simple sum below and enter the answer in the box ([[Special:Captcha/help|more info]]):', |
| 20 | + 'captcha-sendemail' => 'To help protect against automated spamming, please solve the simple sum below and enter the answer in the box ([[Special:Captcha/help|more info]]):', |
| 21 | + 'captcha-sendemail-fail' => 'Incorrect or missing confirmation code.', |
| 22 | + 'captcha-disabledinapi' => 'This action requires a captcha, so it cannot be performed through the API.', |
20 | 23 | 'captchahelp-title' => 'Captcha help', |
21 | 24 | 'captchahelp-cookies-needed' => "You will need to have cookies enabled in your browser for this to work.", |
22 | 25 | 'captchahelp-text' => "Web sites that accept postings from the public, like this wiki, are often abused by spammers who use automated tools to post their links to many sites. |
Index: trunk/extensions/ConfirmEdit/FancyCaptcha.i18n.php |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | 'fancycaptcha-createaccount' => 'To help protect against automated account creation, please enter the words that appear below in the box ([[Special:Captcha/help|more info]]):', |
18 | 18 | 'fancycaptcha-create' => 'To create the page, please enter the words that appear below in the box ([[Special:Captcha/help|more info]]):', |
19 | 19 | 'fancycaptcha-edit' => 'To edit this page, please enter the words that appear below in the box ([[Special:Captcha/help|more info]]):', |
| 20 | + 'fancycaptcha-sendemail' => 'To help protect against automated spamming, please enter the words that appear below in the box ([[Special:Captcha/help|more info]]):', |
20 | 21 | ); |
21 | 22 | |
22 | 23 | /** Message documentation (Message documentation) |
Index: trunk/extensions/ConfirmEdit/ConfirmEdit.php |
— | — | @@ -88,6 +88,7 @@ |
89 | 89 | $wgCaptchaTriggers = array(); |
90 | 90 | $wgCaptchaTriggers['edit'] = false; // Would check on every edit |
91 | 91 | $wgCaptchaTriggers['create'] = false; // Check on page creation. |
| 92 | +$wgCaptchaTriggers['sendemail'] = false; // Special:Emailuser |
92 | 93 | $wgCaptchaTriggers['addurl'] = true; // Check on edits that add URLs |
93 | 94 | $wgCaptchaTriggers['createaccount'] = true; // Special:Userlogin&type=signup |
94 | 95 | $wgCaptchaTriggers['badlogin'] = true; // Special:Userlogin after failure |
— | — | @@ -190,6 +191,8 @@ |
191 | 192 | $wgHooks['LoginAuthenticateAudit'][] = 'ConfirmEditHooks::triggerUserLogin'; |
192 | 193 | $wgHooks['UserLoginForm'][] = 'ConfirmEditHooks::injectUserLogin'; |
193 | 194 | $wgHooks['AbortLogin'][] = 'ConfirmEditHooks::confirmUserLogin'; |
| 195 | +$wgHooks['EmailUserForm'][] = 'ConfirmEditHooks::injectEmailUser'; |
| 196 | +$wgHooks['EmailUser'][] = 'ConfirmEditHooks::confirmEmailUser'; |
194 | 197 | # Register API hook |
195 | 198 | $wgHooks['APIEditBeforeSave'][] = 'ConfirmEditHooks::confirmEditAPI'; |
196 | 199 | |