Forum

Mod: Block Email Do...
 
Notifications
Clear all

Mod: Block Email Domains From Registering

HPFanFicArchive.Com
(@hpfanficarchive-com)
Eminent Member

This mod will block entire domains from registering and not individual email addresses.  I find this useful to block free email sites that spammers use.


in user/editbio.php

At around line 51 find:

if(!empty($_POST['submit'])) {

Add under:

$blocked_email_list = array('autobestpreis.eu','next.org','and_so_on.net');
$blocked_domain = substr(strrchr($_POST['email'], "@"), 1); //extract domain name from email

if(in_array($blocked_domain, $blocked_email_list)){

$Banned_ip = $_SERVER['REMOTE_ADDR'];
$Banned_host = gethostbyaddr($Banned_ip);

$Banned_penname = $_POST['newpenname'];
$Banned_email = $_POST['email'];

$Banned_to      = 'YOUR EMAIL ADDRESS HERE';
$Banned_subject = 'Banned Registration Attempt';
$Banned_message = "PenName: $Banned_penname" . "rn" . "Email: $Banned_email" . "IP: $Banned_ip" . "rn" . "Host: $Banned_host";
$Banned_headers = 'From: YOUR EMAIL ADDRESS HERE' . "rn" . 'Reply-To: YOUR EMAIL ADDRESS HERE' . "rn" . 'X-Mailer: PHP/' . phpversion();

mail($Banned_to, $Banned_subject, $Banned_message, $Banned_headers);

// Change the HTML below to suit your site.
exit("<font color=white><B>This email domain has been banned.</B></font>");

}

Save & upload

  • $blocked_email_list is where you add to the blocked list
  • YOUR EMAIL ADDRESS HERE - Needs to be changed 3 times to your email address
  • You can change the HTML in the exit call to suit your needs.

You will receive an email with any attempt that is blocked so you can see what is going on.

Thanks,
Chad

http://www.FicSavers.Com
http://www.HPFanFicArchive.Com
http://www.FavoritesTracker.Org

Quote
Topic starter Posted : 19/08/2016 8:48 pm
LD-MTT
(@ladama)
Trusted Member

I installed this on our test archive last night and it looks like it works.

However I got to thinking that it's probably futile to try to add all the spam domains out there, so I'm wondering if maybe it would be better to kind of do the reverse of this mod and set it up to only allow emails from certain domains to register. On our site, if only gmail, hotmail, yahoo and aol addresses were allowed that already covers about 2/3rd of our members and we can easily add other common service providers. Is this possible?

ReplyQuote
Posted : 24/04/2017 5:49 am
Share: