[Mediawiki-l] Possible to block users from using a specific email service?
Jim Laurino
wycan.y.jimlaur at dfgh.net
Thu Dec 9 21:27:15 UTC 2010
On 12/09/2010 01:49:56 PM, Clayton - ccornell at openoffice.org wrote:
[snip]
> >>> Is there any practical way of blocking new users from using specific
> >>> services like Mailinator? Is there a better way of dealing with
> >>> situations like this?
[snip]
> Ok, this is the exact code I've added to the end of the
> LocalSettings.php file:
>
> ###################
> $wgHooks['AbortNewAccount'][] = 'noMailinator';
>
> function noMailinator( $user, $message ) {
> if( !preg_match( '/@(mailinator|binkmail).com$/', $user->getEmail() )) {
> $message = 'One-time-use email services are forbidden on the
> OpenOffice.org Wiki';
> return false;
> }
> return true;
> }
> ###################
>
> I created a test account using mailinator as the authentication email
> address, and it went through and accepted the account creation. So...
> is there any way to trap or see what's happening at this stage? I can't
> see any reason the function doesn't work (now that I've got the right
> number of parenthesis). Given my (weak) knowledge of php, it seems to
> follow what's documented.
[snip]
Try replacing the test with this:
if( preg_match( '/@(mailinator|binkmail)\.com/i', .....
preg_match() returns the number of matches, it will be zero (false) if there are none. [1]
In addition the pattern is now case insensitive and the period is meant literally.
The "end of string" specification ($) seems superfluous and could cause trouble.
[1] http://www.php.net/manual/en/function.preg-match.php
Hope that helps.
Jim
More information about the MediaWiki-l
mailing list