From 6dbbdee2ef5770f792ad9d4aee0f9f339383d9f2 Mon Sep 17 00:00:00 2001 From: donncha Date: Fri, 15 Dec 2006 11:54:03 +0000 Subject: is_blog_user() is now blog_id aware (Matt) Move email domain check into it's own function Another check email on signup git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@825 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/wpmu-functions.php | 43 ++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'wp-includes/wpmu-functions.php') diff --git a/wp-includes/wpmu-functions.php b/wp-includes/wpmu-functions.php index ec9746c..1ab66da 100644 --- a/wp-includes/wpmu-functions.php +++ b/wp-includes/wpmu-functions.php @@ -795,10 +795,13 @@ function wpmu_admin_redirect_url() { } } -function is_blog_user() { +function is_blog_user( $blog_id = 0 ) { global $current_user, $wpdb, $wpmuBaseTablePrefix; - $cap_key = $wpmuBaseTablePrefix . $wpdb->blogid . '_capabilities'; + if ( !$blog_id ) + $blog_id = $wpdb->blogid; + + $cap_key = $wpmuBaseTablePrefix . $blog_id . '_capabilities'; if ( is_array($current_user->$cap_key) && in_array(1, $current_user->$cap_key) ) return true; @@ -824,6 +827,24 @@ function validate_email( $email, $check_domain = true) { return false; } +function is_email_address_unsafe( $user_email ) { + $banned_names = get_site_option( "banned_email_domains" ); + if ( is_array( $banned_names ) && empty( $banned_names ) == false ) { + $email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) ); + foreach( $banned_names as $banned_domain ) { + if ( + strstr( $email_domain, $banned_domain ) || + ( + strstr( $banned_domain, '/' ) && + preg_match( $banned_domain, $email_domain ) + ) + ) + return true; + } + } + return false; +} + function wpmu_validate_user_signup($user_name, $user_email) { global $wpdb, $current_site; @@ -849,20 +870,8 @@ function wpmu_validate_user_signup($user_name, $user_email) { $errors->add('user_name', __("That username is not allowed")); } - $banned_names = get_site_option( "banned_email_domains" ); - if ( is_array( $banned_names ) && empty( $banned_names ) == false ) { - $email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) ); - foreach( $banned_names as $banned_domain ) { - if ( - strstr( $email_domain, $banned_domain ) || - ( - strstr( $banned_domain, '/' ) && - preg_match( $banned_domain, $email_domain ) - ) - ) - $errors->add('user_email', __("You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.")); - } - } + if( is_email_address_unsafe( $user_email ) ) + $errors->add('user_email', __("You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.")); if( strlen( $user_name ) < 4 ) { $errors->add('user_name', __("Username must be at least 4 characters")); @@ -910,6 +919,8 @@ function wpmu_validate_user_signup($user_name, $user_email) { } else { $errors->add('user_name', __("That username is currently reserved but may be available in a couple of days.")); } + if( $signup->active == 0 && $signup->user_email == $user_email ) + $errors->add('user_email_used', __("username and email used")); } $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE user_email = '$user_email'"); -- cgit