On 12/09/2010 10:27 PM, Jim Laurino wrote:
On 12/09/2010 01:49:56 PM, Clayton - ccornell@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.
I was wondering about escaping the dot... I also removed $ and added /i for case insensitive as suggested... tested creating a new account using mailinator as the authentication email and it still allows it through.
Hmmm time to do some more reading I think :-P This looks like it should work... Would it make a difference if I converted this to a custom extension instead of dropping it direct into LocalSettings? I can't see how it'd make a difference, but...
C.