News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Allow only one domain to register

Started by Kerrick, September 05, 2008, 02:24:56 AM

Previous topic - Next topic

Kerrick

Hi there. I want to set up a forum for our college, but I want to require email validation -- and not just from any email. I would like to figure out how to modify the SMF code if necessary, so that when a user registers, it requires an email address to be one and only one domain (in this case, [email protected]), and if they try to register with something else, give them an error, and allow them to go back and try again.


I did find something similar here:
Quote from: [Unknown] on August 28, 2004, 04:37:09 PM
Sources/Register.php, find:

if (empty($_POST['email']) || preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]+@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', stripslashes($_POST['email'])) == 0)
fatal_error(sprintf($txt[500], $_POST['user']), false);


Add below:
if (preg_match('~@(hotmail\.com|aol\.com|yahoo\.com|gmail\.com|engineer\.com|mail\.com|otherwebmailsite\.org)$~', $_POST['email']))
fatal_error('Sorry, but you cannot register here with a webmail/free email account.  Please choose a different email address, and remember that you can choose to keep your email hidden.', false);


This doesn't fix it everywhere, but it's better than nothing, no? (I'd put this in and then KEEP the ban... see?)

-[Unknown]
But that doesn't do what I'm looking for. That blocks certain email domains, whereas I want to block all but a certain one. I know nearly nothing about PHP, so how could I modify this snippet to only allow registration from [email protected] addresses?


P.S. I think it's something to do with the preg_match thing, but that may be my n00bishness speaking. :P

Please do not PM me for mod support, I do check the support threads.

My mod: Externalize Links

Nathaniel

You may be able to use or modify the mod below, so that it works only for certain domains. ;)
http://custom.simplemachines.org/mods/index.php?mod=1353
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

[SiNaN]

It just checks if the domain is valid or not LHVWB.

Although I don't know anything about regex patterns, I think this will work:

../Sources/Subs-Members.php

Find:

fatal_error(sprintf($txt[500], $regOptions['username']), false);

Replace:

fatal_error(sprintf($txt[500], $regOptions['username']), false);

   if (!preg_match('~@(semo\.edu|)$~', $_POST['email']))
      fatal_error('Sorry, but you cannot register here with a webmail/free email account.  Please choose a different email address, and remember that you can choose to keep your email hidden.', false);
Former SMF Core Developer | My Mods | SimplePortal

Kerrick

Quote from: [SiNaN] on September 05, 2008, 02:51:50 AM
It just checks if the domain is valid or not LHVWB.

Although I don't know anything about regex patterns, I think this will work:

../Sources/Subs-Members.php

Find:

fatal_error(sprintf($txt[500], $regOptions['username']), false);

Replace:

fatal_error(sprintf($txt[500], $regOptions['username']), false);

   if (!preg_match('~@(semo\.edu|)$~', $_POST['email']))
      fatal_error('Sorry, but you cannot register here with a webmail/free email account.  Please choose a different email address, and remember that you can choose to keep your email hidden.', false);

That worked perfectly! Thank you so much! I greatly appreciate it!

Please do not PM me for mod support, I do check the support threads.

My mod: Externalize Links

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

SpelingMistakes

I have one question

I lead one restricted forum and I want to do next – I will love that new members use its real e- mails which mean not use fake or public e-mails for registering on forum

Is it possible?

For instance – if I come from Russia and my ip is also from Russia, than my e-mail also must be from Russia – how to solve this?

Maybe that is kind of complication, but I have need for this kind of feature

I lead one specialized forum and I want not only e-mail verification but also to suppress using of public e-mails and I will try to use this - http://custom.simplemachines.org/mods/index.php?mod=1493 , but I need little more effort because I don't understand is it this suggested solution above (like an answer from Blue Dream) is also solution for all my needs – I think that is not, but I will rather ask than answer on this question. - Is this only works for some specific domain or ....

I think I need kind of ip checking and resolving from where that is and checking e-mail regarding that results – Is it possible?


Thanks in advance

Spel
There is a huge difference between living and being alive!

[SiNaN]

I don't think you can find out where the e-mail address is from. Even if you find it, not sure how accurate it would be.

Most used method is MX record checks. See this mod:

http://custom.simplemachines.org/mods/index.php?mod=1353
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: