1
bubuche93
How to only allow selected email domain at registration
  • 2007/12/17 16:20

  • bubuche93

  • Just popping in

  • Posts: 25

  • Since: 2006/11/19


Hello !
I am using XOOPS to manage a large student website (3 schools represented)

We would like to protect our content from non-students by allowing only 3 email domains at registration: @school1.edu @school2.edu...

After searching a bit on internet i found a little clue.
In register.php there is the following code:

foreach ($xoopsConfigUser['bad_emails'] as $be) {
    if (!empty(
$be) && preg_match("/".$be."/i"$email)) {
        
$stop .= _US_INVALIDMAIL.'';
        break;
    }
}


If i change "preg_match" to "!preg_match" it should work, but it isn't. Well, it works when i specify only one domain name in the "bad emails" area on the "email preference" administration page, not 3.

I think i got it wrong with the regex on the email preference page.
what should i write in the field ?

@school1.edu | @school2.edu | @school3.edu
or maybe @school1.edu$ | .. ?

Thanks for your help !!

Franck

2
wingrider101
Re: How to only allow selected email domain at registration

Actually, you can set e-mail addresses/domains you don't want users to be able to use/register in the Admin/System/Preferences/User Info Settings

In the field marked "Enter emails that should not be used in user profile" you can add domains seperated by a | (pipe). This will let you "black-list" domains, but XOOPS does not have a default "white-list" or "gray-list feature", and you would need to modify the source to add one, or hard code in the fields.

I'm not much of a PHP guy, so maybe one of the PHP Gurus here can help you out, but you might try to think of a clever way to use the existing feature first before all of that coding...

Hope this helps...

BAM
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Byron McKay
wingrider101 at gmail dot com
http://byron.homelinux.com
http://www.xoopstyro.com
-------------------------------------
Xoops CMS Intranet sites for Business
-------------------------------------

3
bubuche93
Re: How to only allow selected email domain at registration
  • 2007/12/18 1:37

  • bubuche93

  • Just popping in

  • Posts: 25

  • Since: 2006/11/19


Hmm thank you for your answer but i already know this feature. I wanted to use it the other way but modifying the code in register.php

I can't blacklist all the domains in the world excepted 3 ;)

The topic is still open !

Franck

4
hackbrill
Re: How to only allow selected email domain at registration
  • 2007/12/18 3:25

  • hackbrill

  • Friend of XOOPS

  • Posts: 283

  • Since: 2005/7/14


277  function checkEmail($email,$antispam false)
 
278  {
 
279      if (!$email || !preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+([.][a-z0-9-]+)+$/i",$email)){
 
280          return false;
 
281      }
 
282      if ($antispam) {
 
283          $email str_replace("@"" at "$email);
 
284          $email str_replace("."" dot "$email);
 
285      }
 
286      return $email;


This is just a thought but maybe you could go the other way and define what email accounts are valid by changing the above code snippet from include/function.php.

5
bubuche93
Re: How to only allow selected email domain at registration
  • 2007/12/21 11:34

  • bubuche93

  • Just popping in

  • Posts: 25

  • Since: 2006/11/19


Hello Hackbrill, thank you for your answer.

I cuold change the regex here too, but the one i tried did not work (I have read several docs about regex but I am still not sure about the right one to use)

I would prefer use the method i cited above, so that the admins will be able to change the allowed domains to their convenience in the XOOPS admin panel (new admins are appointed every year or so).


Thanks !
Franck

6
Peekay
Re: How to only allow selected email domain at registration
  • 2007/12/21 12:34

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


There is a solution for a single mail suffix in this post May give you something to work on.

HTH
A thread is for life. Not just for Christmas.

7
bubuche93
Re: How to only allow selected email domain at registration
  • 2007/12/23 19:33

  • bubuche93

  • Just popping in

  • Posts: 25

  • Since: 2006/11/19


I have already read this post, this is the first one i found while searching for answers :)

The proposed solution in that post works perfectly for one domain, but when i write @domain1.com | @domain2.com | domain3.com in the XOOPS "bad emails" field, it doesn't work anymore.

I think there's a mistake in the way i enter the list of domains @domains1.com | ...

Franck

Login

Who's Online

334 user(s) are online (274 user(s) are browsing Support Forums)


Members: 0


Guests: 334


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits