vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Limit only users to single email domain. (https://vborg.vbsupport.ru/showthread.php?t=78244)

bmpwe 03-17-2005 03:08 AM

Limit only users to single email domain.
 
Is there any way to allow only users with a foo.com email addresse to register?

Jolten 03-17-2005 03:41 AM

wow.. that would be quite limiting.

bmpwe 03-17-2005 04:16 AM

Quote:

Originally Posted by Jolten
wow.. that would be quite limiting.

I'm devolping a college community website... liniting the addresse is the best method I've thought of to keep not students from joining.

BTW, our uni gives away email addresses to all students.

Jolten 03-17-2005 05:04 AM

but... if all your students have an @school.org email, you'd be limiting registration to 1 student.

Marco van Herwaarden 03-17-2005 05:28 AM

Quote:

Originally Posted by Jolten
but... if all your students have an @school.org email, you'd be limiting registration to 1 student.

You wold be limiting to the @school.org domain. this will still mean that both joe@school.org and jill@school.org could signup

Jolten 03-17-2005 06:04 AM

guess I read it wrong :) sorry.

Brad 03-17-2005 06:14 AM

Heres a simple way to do it, but you'll lose the ability to ban domains (which should'nt matter because you are only allowing certain domains anyway). What I am basicly going to do is take the Banned Email Addresses list and turn it into the Allowed Email Addresses list.

Open functions_register.php in a code editor, and find this block of code:

PHP Code:

// ###################### Start checkbannedemail #######################
function is_banned_email($email)
{
    global 
$vboptions$datastore;

    if (
$vboptions['enablebanning'] AND !empty($datastore['banemail']))
    {
        
$bannedemails preg_split('/\s+/'$datastore['banemail'], -1PREG_SPLIT_NO_EMPTY);

        foreach (
$bannedemails AS $bannedemail)
        {
            if (
is_valid_email($bannedemail))
            {
                
$regex '^' preg_quote($bannedemail'#') . '$';
            }
            else
            {
                
$regex preg_quote($bannedemail'#');
            }

            if (
preg_match("#$regex#i"$email))
            {
                return 
1;
            }
        }
    }

    return 
0;


Simple function, if a email address is on the list it returns 1, otherwise 0. Depending on what it returns an error is thrown letting the user know the email address they entered has been banned. So basicly by swaping the 0 and 1 you will reverse what triggers the error, which in this case would be a email address that is not on the list.

So our block of code becomes:

PHP Code:

// ###################### Start checkbannedemail #######################
function is_banned_email($email)
{
    global 
$vboptions$datastore;

    if (
$vboptions['enablebanning'] AND !empty($datastore['banemail']))
    {
        
$bannedemails preg_split('/\s+/'$datastore['banemail'], -1PREG_SPLIT_NO_EMPTY);

        foreach (
$bannedemails AS $bannedemail)
        {
            if (
is_valid_email($bannedemail))
            {
                
$regex '^' preg_quote($bannedemail'#') . '$';
            }
            else
            {
                
$regex preg_quote($bannedemail'#');
            }

            if (
preg_match("#$regex#i"$email))
            {
                return 
0;
            }
        }
    }

    return 
1;


Now navigate to vB admin cp -> vBulletin Options -> User banning options -> Banned Email Addresses and enter "@foo.com" (without quotes) in the textarea and anybody that registers will have to use an email address on the @foo.com domain.

This best thing about this approch is that it supports multiple domains, and its easy to add and modify them.

bmpwe 03-17-2005 02:25 PM

Thank you very much.

Is there any way I can let moderators and administers have a non foo.com domain? I'm hoping to expand this... if I did, I won't have access to other schoools email addresses.

Where exactly is this file? There is a file in includes/ that has the exact file name you mentioned.... but the code you quoted is nowhere to be found. This is all the file includes:
PHP Code:

<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 3.0.3 - Licence Number *removed*
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000?2004 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

error_reporting(E_ALL & ~E_NOTICE);

define('REGOPTION_ADMINEMAIL'1);
define('REGOPTION_INVISIBLEMODE'2);
define('REGOPTION_RECEIVEEMAIL'4);
define('REGOPTION_ENABLEPM'8);
define('REGOPTION_EMAILONPM'16);
define('REGOPTION_PMPOPUP'32);
define('REGOPTION_VBCODE_NONE'64);
define('REGOPTION_VBCODE_STANDARD'128);
define('REGOPTION_VBCODE_ENHANCED'256);
define('REGOPTION_SUBSCRIBE_NONE'512);
define('REGOPTION_SUBSCRIBE_NONOTIFY'1024);
define('REGOPTION_SUBSCRIBE_INSTANT'2048);
define('REGOPTION_SUBSCRIBE_DAILY'4096);
define('REGOPTION_SUBSCRIBE_WEEKLY'8192);
define('REGOPTION_VCARD'16384);
define('REGOPTION_SIGNATURE'32768);
define('REGOPTION_AVATAR'65536);
define('REGOPTION_IMAGE'131072);
define('REGOPTION_THREAD_LINEAR_OLDEST'262144);
define('REGOPTION_THREAD_LINEAR_NEWEST'524288);
define('REGOPTION_THREAD_THREADED'1048576);
define('REGOPTION_THREAD_HYBRID'2097152);
define('REGOPTION_SHOWREPUTATION'4194304);
define('REGOPTION_REQBIRTHDAY'8388608);

/*======================================================================*\
|| ####################################################################
|| # Downloaded: 13:29, Sat Jul 31st 2004
|| # CVS: $RCSfile: functions_register.php,v $ - $Revision: 1.2 $
|| ####################################################################
\*======================================================================*/
?>


Aylwin 04-05-2005 08:58 AM

The code to be changed is in functions_user.php.

cheesegrits 07-30-2006 12:43 AM

Brad - thanks for this suggestion. I needed to restrict our users to a certain set of domains (we're an ISP, providing forums for just our users), and turning the "banned domains" into "allowed domains" was exactly what I needed.

One note for anyone else needing to do this. Enforcing specific domains for the email during registration is half the solution. The other half is preventing them from changing their email once they have signed up. To do this, you can either edit the 'modifypassword' template accordingly, or you can edit profile.php to force $show{edit_email_field} to always be FALSE.

-- hugh


All times are GMT. The time now is 09:21 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02388 seconds
  • Memory Usage 1,776KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete