coppermine-gallery.com/forum

No Support => Modifications/Add-Ons/Hacks => Mods: Emails/Notifications => Topic started by: Anne on April 11, 2005, 12:39:55 AM

Title: Banning free email providers
Post by: Anne on April 11, 2005, 12:39:55 AM
Is there any way to prevent people from registering using a free email provider (ie. Hotmail, Yahoo, etc.)?
Title: Re: Banning free email providers
Post by: Nibbler on April 11, 2005, 12:55:24 AM
Yes. You need to edit your register.php

find:

if (!eregi("^[_\.0-9a-z\-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,6}$", $email)) $error .= '<li>' . $lang_register_php['err_invalid_email'];

and add after it:

$banned = array(
'hotmail',
'yahoo',
'msn',
'gmail'
);

foreach($banned as $ban){
if (strpos(strtolower($email), "@$ban.")){
$error .= '<li>' . 'Registration not permitted from free email providers.';
break;
}
}


You can change the array of banned providers and the rejection message as required. You could also change the message to use $lang_register_php['err_invalid_email'] to give a general message of 'invalid email' in the user's language if you prefer.

This will not work for bridged installs.
Title: Re: Banning free email providers
Post by: brandoncolorado on April 14, 2005, 03:11:52 PM
what about the opposite?  Is there any way I could only allow certain users (i.e. with email addresses from my school) to register?
Title: Re: Banning free email providers
Post by: Joachim Müller on April 14, 2005, 03:52:06 PM
http://forum.coppermine-gallery.net/index.php?topic=16615.0
Title: Re: Banning free email providers
Post by: brandoncolorado on April 14, 2005, 04:21:18 PM
LOL *Blushes and never asks question again*
Title: Re: Banning free email providers
Post by: Leny on December 20, 2006, 08:54:20 PM
Hi folks.
I have CPG 1.4.10 & BBH 2.0.21 bridged working fine.

Im looking for something that keep out certain domains (like 10minutemail.com or mailinator.com) from registering.

Reading this post and another one (Makc666's) I can't see solution for me but I think should be nice have an editable "blacklist", or something like that, in next releases of CPG (or some plugin).

Im just writing ideas, no solutions, i know.  :-\

Going back... anyone knows how can I ban domains having bridged system?  ??? Thanks.



Title: Re: Banning free email providers
Post by: Nibbler on December 20, 2006, 09:15:54 PM
You need to do that in your forum.
Title: Re: Banning free email providers
Post by: Leny on December 20, 2006, 10:20:31 PM
Thank you very much Nibbler!
Title: Re: Banning free email providers
Post by: wuurp on February 13, 2007, 06:50:59 PM
What about blocking certain tlds, like .info or .biz?

Could this be made more general by doing for example:

$banned = array(
'@hotmail.',
'@yahoo.',
'@msn.',
'@gmail.',
'.info$',
'.biz$'
);

foreach($banned as $ban){
if (strpos(strtolower($email), "$ban")){
$error .= '<li>' . 'Registration not permitted from free email providers.';
break;
}
}


Title: Re: Banning free email providers
Post by: Nibbler on February 13, 2007, 06:57:07 PM
Try


if (preg_match('/\.(info|biz)$/', $email)){
if (strpos(strtolower($email), "$ban")){
$error .= '<li>' . 'Registration not permitted from this tld.';
break;
}
}
Title: Re: Banning free email providers
Post by: wuurp on February 13, 2007, 08:15:02 PM
oops.

Of course. My brain was still thinking about the eregi from the previous line, not strpos.

Thanks.
Title: Re: Banning free email providers
Post by: wuurp on February 26, 2007, 04:26:33 PM
Quote from: Nibbler on February 13, 2007, 06:57:07 PM
Try


if (preg_match('/\.(info|biz)$/', $email)){
if (strpos(strtolower($email), "$ban")){
$error .= '<li>' . 'Registration not permitted from this tld.';
break;
}
}


Should this actually be more like

if (preg_match('/\.(info|biz)$/', $email)) $error .= '<li>' . 'Registration not permitted from this tld.';

since it's no longer in that foreach loop?
Title: Re: Banning free email providers
Post by: Nibbler on February 26, 2007, 04:35:13 PM
Yeah. I copied too much code.
Title: Re: Banning free email providers
Post by: Mimer on December 18, 2011, 01:06:49 AM
Any chance I can use this code in CPG 1.5.16?
If so, where do I put it?

Quote from: Nibbler on April 11, 2005, 12:55:24 AM
$banned = array(
'hotmail',
'yahoo',
'msn',
'gmail'
);

foreach($banned as $ban){
if (strpos(strtolower($email), "@$ban.")){
$error .= '<li>' . 'Registration not permitted from free email providers.';
break;
}
}