/**
 * Validates security question
 *
 * @global type $bp
 * @global boolean $wangguard_bp_validated
 */
function wangguard_signup_validate_bp11()
{
    global $bp;
    global $wangguard_bp_validated;
    $wangguard_bp_validated = true;
    $signup_email = $_POST['signup_email'];
    $wggstopcheck = false;
    do_action('pre_wangguard_validate_signup_form_wordpress_no_multisite', $signup_email);
    $wggstopcheck = apply_filters('pre_wangguard_validate_signup_form_wordpress_no_multisite', $wggstopcheck);
    if (!$wggstopcheck) {
        if (!wangguard_validate_hfields($signup_email)) {
            $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__('<strong>ERROR</strong>: Banned by WangGuard <a href="http://www.wangguard.com/faq" target="_new">Is it an error?</a> Perhaps you tried to register many times.', 'wangguard'));
            return;
        }
        $answerOK = wangguard_question_repliedOK();
        //If at least a question exists on the questions table, then check the provided answer
        if (!$answerOK) {
            $bp->signup->errors['wangguardquestansw'] = wangguard_fix_bp_slashes_maybe(__('<strong>ERROR</strong>: The answer to the security question is invalid.', 'wangguard'));
        } else {
            //check domain against the list of selected blocked domains
            $blocked = wangguard_is_domain_blocked($signup_email);
            if ($blocked) {
                $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__("<strong>ERROR</strong>: Domain not allowed.", 'wangguard'));
            } else {
                $reported = wangguard_is_email_reported_as_sp($signup_email, wangguard_getRemoteIP(), wangguard_getRemoteProxyIP());
                if ($reported) {
                    $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__('<strong>ERROR</strong>: Banned by WangGuard <a href="http://www.wangguard.com/faq" target="_new">Is it an error?</a> Perhaps you tried to register many times.', 'wangguard'));
                } else {
                    if (wangguard_email_aliases_exists($signup_email)) {
                        $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__('<strong>ERROR</strong>: Duplicate alias email found by WangGuard.', 'wangguard'));
                    } else {
                        if (!wangguard_mx_record_is_ok($signup_email)) {
                            $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__("<strong>ERROR</strong>: WangGuard couldn't find an MX record associated with your email domain.", 'wangguard'));
                        }
                    }
                }
            }
        }
        if (isset($bp->signup->errors['signup_email'])) {
            $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe($bp->signup->errors['signup_email']);
        }
    }
}
/**
 * Validates security question
 * 
 * @global type $bp
 * @global boolean $wangguard_bp_validated
 */
function wangguard_signup_validate_bp11()
{
    global $bp;
    global $wangguard_bp_validated;
    $wangguard_bp_validated = true;
    if (!wangguard_validate_hfields($_POST['signup_email'])) {
        $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__('<strong>ERROR</strong>: Banned by WangGuard <a href="http://www.wangguard.com/faq" target="_new">Is a mistake?</a>.', 'wangguard'));
        return;
    }
    $answerOK = wangguard_question_repliedOK();
    //If at least a question exists on the questions table, then check the provided answer
    if (!$answerOK) {
        $bp->signup->errors['wangguardquestansw'] = wangguard_fix_bp_slashes_maybe(__('<strong>ERROR</strong>: The answer to the security question is invalid.', 'wangguard'));
    } else {
        //check domain against the list of selected blocked domains
        $blocked = wangguard_is_domain_blocked($_REQUEST['signup_email']);
        if ($blocked) {
            $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__("<strong>ERROR</strong>: Domain not allowed.", 'wangguard'));
        } else {
            $reported = wangguard_is_email_reported_as_sp($_REQUEST['signup_email'], wangguard_getRemoteIP(), wangguard_getRemoteProxyIP());
            if ($reported) {
                $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__('<strong>ERROR</strong>: Banned by WangGuard <a href="http://www.wangguard.com/faq" target="_new">Is a mistake?</a>.', 'wangguard'));
            } else {
                if (wangguard_email_aliases_exists($_REQUEST['signup_email'])) {
                    $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__('<strong>ERROR</strong>: Duplicate alias email found by WangGuard.', 'wangguard'));
                } else {
                    if (!wangguard_mx_record_is_ok($_REQUEST['signup_email'])) {
                        $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe(__("<strong>ERROR</strong>: WangGuard couldn't find an MX record associated with your email domain.", 'wangguard'));
                    }
                }
            }
        }
    }
    if (isset($bp->signup->errors['signup_email'])) {
        $bp->signup->errors['signup_email'] = wangguard_fix_bp_slashes_maybe($bp->signup->errors['signup_email']);
    }
}