miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | 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;
}
}

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

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, 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
 Share Topic's Link

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


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Check out the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑