miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /   

Blocking registration emails filtered by domain, or some other criteria

Author Paul
Lead Developer
#1 | Posted: 4 Aug 2015 19:09 
Referencing to the topic named "Blocking registration emails filtered by domain", and all the suggestions and the codes mentioned, I have built the united solution for disabling registration or profile's updating processes, if the email put meets some criteria.

Put this code under bb_plugins.php, possibly at the top part of it:

/* Registration - disabled some email accounts */
if($action=='register' or $action=='editprefs'){

if(!function_exists('dotsInEmail')){
function dotsInEmail($chkEmail){
$dotsLimit=2;

$spl=explode('@', $chkEmail);
$un=$spl[0];
$dots=0;
for($i=0; $i<strlen($un); $i++){
if($un[$i]=='.') $dots++;
}
if($dots>=$dotsLimit) return TRUE;
else return FALSE;

}
}

if(!function_exists('disallowedEmailDomain')){
function disallowedEmailDomain($chkEmail) {
$disallowed_domains=array(
'spambuster.com',
'mail.ru',
'gmail.com'
);
$dis=FALSE;
foreach($disallowed_domains as $dd){
if(substr_count($chkEmail, '@'.$dd)>0){
$dis=TRUE;
break;
}
}
return $dis;
}
}

$chkEmail=strtolower(trim($_POST['email']));

if(substr_count($chkEmail, '@')==1){
if(substr($chkEmail, -9)=='gmail.com' and dotsInEmail($chkEmail)) $correct=7;
elseif(disallowedEmailDomain($chkEmail)) $correct=7;
}

}
/* --Registration - disabled some email accounts */

Under your language pack lang/eng.php or another, you should add this variable:

/* Forbidden email */
$l_userErrors[7]='You couldn\'t use this email address for registration! Try another one.';

EXPLANATION:

This code for bb_plugins.php consists of two parts.

The function named dotsInEmail checks gmail.com email addresses for the number of dots put in. I've noticed, that spammers often use automated emails containing multiple dots, like:

a.b.ck.e.yb.oy@gmail.com
ab.ck.e.y.bo.y@gmail.com
abc.k.e.yboy@gmail.com

etc. But usually, if a dot is used in the email address, it should be just one, separating name/surname. Considering this, the function will disallow to register any gmail.com address, if it's first part containing more than one dot. The number of dots could be changed in the function itself, here:

$dotsLimit=2;

The function disallowedEmailDomain is about filtering out any email, which contains any domain specified under $disallowed_domains - they should be specified in lowercase.

It's possible to disable this or that function, or include both (now they are included both). For example, if you would like to enable just a gmail.com dots filtering, change code to this:

if(substr($chkEmail, -9)=='gmail.com' and dotsInEmail($chkEmail)) $correct=7;
//elseif(disallowedEmailDomain($chkEmail)) $correct=7;

or in the case of enabling just domain-filtering, put this:

//if(substr($chkEmail, -9)=='gmail.com' and dotsInEmail($chkEmail)) $correct=7;
if(disallowedEmailDomain($chkEmail)) $correct=7;

You're welcome to put further comments here, 'cause I will close the older thread.

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications / Blocking registration emails filtered by domain, or some other criteria Top

Your Reply Click this icon to move up to the quoted message

 Short link for this topic:

 ?
You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB