Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-17-2005, 03:08 AM
bmpwe bmpwe is offline
 
Join Date: Jul 2004
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Limit only users to single email domain.

Is there any way to allow only users with a foo.com email addresse to register?
Reply With Quote
  #2  
Old 03-17-2005, 03:41 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wow.. that would be quite limiting.
Reply With Quote
  #3  
Old 03-17-2005, 04:16 AM
bmpwe bmpwe is offline
 
Join Date: Jul 2004
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 03-17-2005, 05:04 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

but... if all your students have an @school.org email, you'd be limiting registration to 1 student.
Reply With Quote
  #5  
Old 03-17-2005, 05:28 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 03-17-2005, 06:04 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

guess I read it wrong sorry.
Reply With Quote
  #7  
Old 03-17-2005, 06:14 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 03-17-2005, 02:25 PM
bmpwe bmpwe is offline
 
Join Date: Jul 2004
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 $
|| ####################################################################
\*======================================================================*/
?>
Reply With Quote
  #9  
Old 04-05-2005, 08:58 AM
Aylwin Aylwin is offline
 
Join Date: Mar 2005
Location: Finland
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The code to be changed is in functions_user.php.
Reply With Quote
  #10  
Old 07-30-2006, 12:43 AM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:50 PM.


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.04664 seconds
  • Memory Usage 2,287KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete