예제 #1
0
파일: user.php 프로젝트: nxtclass/NXTClass
function nxt_authenticate_username_password($user, $username, $password)
{
    if (is_a($user, 'nxt_User')) {
        return $user;
    }
    if (empty($username) || empty($password)) {
        $error = new nxt_Error();
        if (empty($username)) {
            $error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
        }
        if (empty($password)) {
            $error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
        }
        return $error;
    }
    $userdata = get_user_by('login', $username);
    if (!$userdata) {
        return new nxt_Error('invalid_username', sprintf(__('<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), nxt_lostpassword_url()));
    }
    if (is_multisite()) {
        // Is user marked as spam?
        if (1 == $userdata->spam) {
            return new nxt_Error('invalid_username', __('<strong>ERROR</strong>: Your account has been marked as a spammer.'));
        }
        // Is a user's blog marked as spam?
        if (!is_super_admin($userdata->ID) && isset($userdata->primary_blog)) {
            $details = get_blog_details($userdata->primary_blog);
            if (is_object($details) && $details->spam == 1) {
                return new nxt_Error('blog_suspended', __('Site Suspended.'));
            }
        }
    }
    $userdata = apply_filters('nxt_authenticate_user', $userdata, $password);
    if (is_nxt_error($userdata)) {
        return $userdata;
    }
    if (!nxt_check_password($password, $userdata->user_pass, $userdata->ID)) {
        return new nxt_Error('incorrect_password', sprintf(__('<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?'), $username, nxt_lostpassword_url()));
    }
    $user = new nxt_User($userdata->ID);
    return $user;
}
예제 #2
0
    $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
    $result = nxtmu_activate_signup($key);
    if (is_nxt_error($result)) {
        if ('already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code()) {
            $signup = $result->get_error_data();
            ?>
				<h2><?php 
            _e('Your account is now active!');
            ?>
</h2>
				<?php 
            echo '<p class="lead-in">';
            if ($signup->domain . $signup->path == '') {
                printf(__('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;.  Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), network_site_url('nxt-login.php', 'login'), $signup->user_login, $signup->user_email, nxt_lostpassword_url());
            } else {
                printf(__('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;.  Please check your email inbox at %4$s for your password and login instructions.  If you do not receive an email, please check your junk or spam folder.  If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, nxt_lostpassword_url());
            }
            echo '</p>';
        } else {
            ?>
				<h2><?php 
            _e('An error occurred during the activation');
            ?>
</h2>
				<?php 
            echo '<p>' . $result->get_error_message() . '</p>';
        }
    } else {
        extract($result);
        $url = get_blogaddress_by_id((int) $blog_id);
        $user = new nxt_User((int) $user_id);