Ejemplo n.º 1
0
function wp_check_bind_user($username, $password)
{
    if (empty($password)) {
        return __('<strong>ERROR</strong>: The password field is empty.');
    }
    $userdata = get_userdatabylogin($username);
    if (!$userdata) {
        return sprintf(__('<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login'));
    }
    if (is_multisite()) {
        // Is user marked as spam?
        if (1 == $userdata->spam) {
            return __('<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 __('Site Suspended.');
            }
        }
    }
    $userdata = apply_filters('wp_authenticate_user', $userdata, $password);
    if (is_wp_error($userdata)) {
        return;
    }
    if (!wp_check_password($password, $userdata->user_pass, $userdata->ID)) {
        return 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, site_url('wp-login.php?action=lostpassword', 'login'));
    }
}
Ejemplo n.º 2
0
/**
 * Checks whether the given username exists.
 *
 * @since 2.0.0
 *
 * @param string $username Username.
 * @return null|int The user's ID on success, and null on failure.
 */
function username_exists( $username ) {
	if ( $user = get_userdatabylogin( $username ) ) {
		return $user->ID;
	} else {
		return null;
	}
}
function msum_maybe_add_roles($user_login)
{
    $userdata = get_userdatabylogin($user_login);
    if ($userdata != false && get_user_meta($userdata->ID, 'msum_has_caps', true) != 'true') {
        msum_add_roles($userdata->ID);
    }
}
Ejemplo n.º 4
0
function php_exec_process($phpexec_text)
{
    $phpexec_userdata = get_userdatabylogin(the_author('login', false));
    if ($phpexec_userdata->user_level >= php_exec_getuserlevel()) {
        $phpexec_doeval = true;
    }
    $phpexec_textarr = preg_split("/(<phpcode>.*<\\/phpcode>)/Us", $phpexec_text, -1, PREG_SPLIT_DELIM_CAPTURE);
    // capture the tags as well as in between
    $phpexec_stop = count($phpexec_textarr);
    // loop stuff
    for ($phpexec_i = 0; $phpexec_i < $phpexec_stop; $phpexec_i++) {
        $phpexec_content = $phpexec_textarr[$phpexec_i];
        if (preg_match("/^<phpcode>(.*)<\\/phpcode>/Us", $phpexec_content, $phpexec_code)) {
            // If it's a phpcode
            $phpexec_php = $phpexec_code[1];
            if ($phpexec_doeval) {
                ob_start();
                eval("?>" . $phpexec_php . "<?php ");
                $phpexec_output .= ob_get_clean();
            } else {
                $phpexec_output .= htmlspecialchars($phpexec_php);
            }
        } else {
            $phpexec_output .= $phpexec_content;
        }
    }
    return $phpexec_output;
}
Ejemplo n.º 5
0
function wp_authenticate_username_password($user, $username, $password)
{
    if (is_a($user, 'WP_User')) {
        return $user;
    }
    if (empty($username) || empty($password)) {
        $error = new WP_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_userdatabylogin($username);
    if (!$userdata || $userdata->user_login != $username) {
        return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.'));
    }
    $userdata = apply_filters('wp_authenticate_user', $userdata, $password);
    if (is_wp_error($userdata)) {
        return $userdata;
    }
    if (!wp_check_password($password, $userdata->user_pass, $userdata->ID)) {
        return new WP_Error('incorrect_password', __('<strong>ERROR</strong>: Incorrect password.'));
    }
    $user = new WP_User($userdata->ID);
    return $user;
}
Ejemplo n.º 6
0
function widget_author_info_card($args)
{
    if (get_query_var('author_name')) {
        $curauth = get_userdatabylogin(get_query_var('author_name'));
    } else {
        $curauth = get_userdata(get_query_var('author'));
    }
    extract($args);
    echo $before_widget . $before_title;
    // If its the author page.
    if (get_option('sa_add_to_author_page') == 'yes' && is_author()) {
        $title = $curauth->display_name;
        echo $title . $after_title;
        echo sa_author_info_card($curauth);
    } else {
        $title = "List of Authors";
        echo $title . $after_title;
        ob_start();
        wp_list_authors('show_fullname=1&optioncount=1');
        $author_list = ob_get_contents();
        ob_end_clean();
        echo "<ul>{$author_list}</ul>";
    }
    echo $after_widget;
}
Ejemplo n.º 7
0
/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    $allow = apply_filters('allow_password_reset', true, $user_data->ID);
    if (!$allow) {
        return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
    } else {
        if (is_wp_error($allow)) {
            return $allow;
        }
    }
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_login = %s", $user_login));
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
    $message .= site_url() . '/?ptype=affiliate' . "\r\n";
    $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    if ($message && !wp_mail($user_email, $title, $message)) {
        die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
    }
    return true;
}
function get_currentuserinfo()
{
    // a bit like get_userdata(), on steroids
    global $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5, $cookiehash, $xoopsUser;
    // *** retrieving user's data from cookies and db - no spoofing
    /*
    	$user_login = $_COOKIE['wordpressuser_'.$cookiehash];
    	$userdata = get_userdatabylogin($user_login);
    	$user_level = $userdata->user_level;
    	$user_ID = $userdata->ID;
    	$user_nickname = $userdata->user_nickname;
    	$user_email = $userdata->user_email;
    	$user_url = $userdata->user_url;
    	$user_pass_md5 = md5($userdata->user_pass);
    */
    if ($xoopsUser) {
        $user_login = $xoopsUser->uname();
        $userdata = get_userdatabylogin($user_login);
        $user_level = $userdata->user_level;
        $user_ID = $userdata->ID;
        $user_nickname = $userdata->user_nickname;
        $user_email = $userdata->user_email;
        $user_url = $userdata->user_url;
        //		$user_pass_md5 = md5($userdata->user_pass);
        $user_pass_md5 = $xoopsUser->pass();
    }
}
function comber_login_guest()
{
    if (isset($_POST['comber_user_login']) && wp_verify_nonce($_POST['comber_login_nonce'], 'comber-login-nonce')) {
        // this returns the user ID and other info from the user name
        $user = get_userdatabylogin($_POST['comber_user_login']);
        if (!$user) {
            // if the user name doesn't exist
            comber_errors()->add('empty_username', __('Invalid username'));
        }
        if (!isset($_POST['comber_user_pass']) || $_POST['comber_user_pass'] == '') {
            // if no password was entered
            comber_errors()->add('empty_password', __('Please enter a password'));
        }
        // check the user's login with their password
        if (!wp_check_password($_POST['comber_user_pass'], $user->user_pass, $user->ID)) {
            // if the password is incorrect for the specified user
            comber_errors()->add('empty_password', __('Incorrect password'));
        }
        // retrieve all error messages
        $errors = comber_errors()->get_error_messages();
        // only log the user in if there are no errors
        if (empty($errors)) {
            wp_setcookie($_POST['comber_user_login'], $_POST['comber_user_pass'], true);
            wp_set_current_user($user->ID, $_POST['comber_user_login']);
            do_action('wp_login', $_POST['comber_user_login']);
            wp_redirect(home_url($_POST['current_page']));
            exit;
        } else {
            wp_redirect(home_url($_POST['current_page'] . '/?login=true&fail=true'));
            exit;
        }
    }
}
Ejemplo n.º 10
0
function wp_authenticate_username_password($user, $username, $password)
{
    if (is_a($user, 'WP_User')) {
        return $user;
    }
    if (empty($username) || empty($password)) {
        $error = new WP_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_userdatabylogin($username);
    if (!$userdata) {
        return new WP_Error('invalid_username', sprintf(__('<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login')));
    }
    $userdata = apply_filters('wp_authenticate_user', $userdata, $password);
    if (is_wp_error($userdata)) {
        return $userdata;
    }
    if (!wp_check_password($password, $userdata->user_pass, $userdata->ID)) {
        return new WP_Error('incorrect_password', sprintf(__('<strong>ERROR</strong>: Incorrect password. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login')));
    }
    $user = new WP_User($userdata->ID);
    return $user;
}
Ejemplo n.º 11
0
/**
 * hm_parse_user function.
 *
 * @access public
 * @param mixed $user. (default: null)
 * @return void
 */
function hm_parse_user($user = null)
{
    // We're we passed an object with ID
    if (is_object($user) && is_numeric($user->ID)) {
        return get_userdata($user->ID);
    }
    // We're we passed an object with user_id
    if (is_object($user) && is_numeric($user->user_id)) {
        return get_userdata($user->user_id);
    }
    // We're we passed an array
    if (is_array($user) && is_numeric($user['ID'])) {
        return get_userdata($user['ID']);
    }
    // ID
    if (is_numeric($user)) {
        return get_userdata($user);
    }
    // username
    if (is_string($user)) {
        return get_userdatabylogin($user);
    }
    // null
    global $current_user;
    return get_userdata($current_user->ID);
}
Ejemplo n.º 12
0
/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'templatic'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'templatic'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'templatic'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_login like \"{$user_login}\" or user_email like \"{$user_login}\"");
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key', 'templatic'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = '<p><b>Your login Information :</b></p>';
    $message .= '<p>' . sprintf(__('Username: %s', 'templatic'), $user->user_login) . "</p>";
    $message .= '<p>' . sprintf(__('Password: %s', 'templatic'), $new_pass) . "</p>";
    $message .= '<p>You can login to : <a href="' . site_url() . '/?ptype=login' . "\">Login</a> or the URL is :  " . site_url() . "/?ptype=login</p>";
    $message .= '<p>Thank You,<br> ' . get_option('blogname') . '</p>';
    $user_email = $user_data->user_email;
    $user_name = $user_data->user_nicename;
    $fromEmail = get_site_emailId();
    $fromEmailName = get_site_emailName();
    $title = sprintf(__('[%s] Your new password', 'templatic'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    if (get_option('pttthemes_send_mail') == 'Enable' || get_option('pttthemes_send_mail') == '') {
        templ_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '');
        ///forgot password email
    }
    return true;
}
function username_exists( $username ) {
	global $wpdb;
	$username = sanitize_user( $username );
	$user = get_userdatabylogin($username);
	if ( $user )
		return $user->ID;

	return null;
}
Ejemplo n.º 14
0
function user_pass_ok($user_login,$user_pass) {
	global $cache_userdata;
	if ( empty($cache_userdata[$user_login]) ) {
		$userdata = get_userdatabylogin($user_login);
	} else {
		$userdata = $cache_userdata[$user_login];
	}
	return (md5($user_pass) == $userdata->user_pass);
}
Ejemplo n.º 15
0
 function synlogin($get, $post)
 {
     !API_SYNLOGIN && exit(API_RETURN_FORBIDDEN);
     $user = get_userdatabylogin($get['username']);
     if ($user) {
         header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
         wp_set_auth_cookie($user->ID, false, '');
     }
     exit(API_RETURN_SUCCEED);
 }
Ejemplo n.º 16
0
function wpi_get_current_author()
{
    global $author, $author_name;
    if (is_get('author_name')) {
        $user = get_userdatabylogin($author_name);
    } else {
        $user = get_userdata(intval($author));
    }
    return $user;
}
Ejemplo n.º 17
0
/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb, $General, $Cart, $Product;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    //do_action('retreive_password', $user_login);  // Misspelled and deprecated
    //do_action('retrieve_password', $user_login);
    //$allow = apply_filters('allow_password_reset', true, $user_data->ID);
    ////////////////////////////////////
    //forget pw changed on 1st april 2010 start//
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_login = \"{$user_login}\" or user_email = \"{$user_login}\"");
    $new_pass = wp_generate_password(12, false);
    wp_set_password($new_pass, $user->ID);
    if ($General->is_send_forgot_pw_email()) {
        $message = '<p>' . sprintf(__('Username: %s'), $user_data->user_login) . '</p>';
        $message .= '<p>' . sprintf(__('Password: %s'), $new_pass) . "</p>";
        $message .= '<p>You can <a href="' . $General->get_url_login(site_url('/?ptype=login')) . '">Login</a> now</p>';
        $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
        $user_email = $user_data->user_email;
        $user_login = $user_data->user_login;
        $title = apply_filters('password_reset_title', $title);
        $message = apply_filters('password_reset_message', $message, $new_pass);
        //forget pw changed on 1st april 2010 end//
        global $General;
        $fromEmail = $General->get_site_emailId();
        $fromEmailName = $General->get_site_emailName();
        $General->sendEmail($fromEmail, $fromEmailName, $user_email, $user_login, $title, $message, $extra = '');
        ///To clidne email
    }
    return true;
}
/**
 * The 'wpmu_activate_user', 'wpmu_new_user' & 'wpmu_activate_blog' actions can only be 
 * hooked if the plugin is in the mu-plugins folder, which is a PITA. 
 * 
 * This function calls @see msum_add_roles from the 'wp_login' action.  
 */
function msum_maybe_add_roles($user_login)
{
    if (function_exists('get_user_by')) {
        $userdata = get_user_by('login', $user_login);
    } else {
        $userdata = get_userdatabylogin($user_login);
    }
    if ($userdata != false && get_user_meta($userdata->ID, 'msum_has_caps', true) != 'true') {
        msum_add_roles($userdata->ID);
    }
}
Ejemplo n.º 19
0
function retrieve_password() {
	global $wpdb;

	$errors = new WP_Error();

	if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
		$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));

	if ( strstr($_POST['user_login'], '@') ) {
		$user_data = get_user_by_email(trim($_POST['user_login']));
		if ( empty($user_data) )
			$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
	} else {
		$login = trim($_POST['user_login']);
		$user_data = get_userdatabylogin($login);
	}

	do_action('lostpassword_post');

	if ( $errors->get_error_code() )
		return $errors;

	if ( !$user_data ) {
		$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
		return $errors;
	}

	// redefining user_login ensures we return the right case in the email
	$user_login = $user_data->user_login;
	$user_email = $user_data->user_email;

	do_action('retreive_password', $user_login);  // Misspelled and deprecated
	do_action('retrieve_password', $user_login);

	$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
	if ( empty($key) ) {
		// Generate something random for a key...
		$key = wp_generate_password();
		do_action('retrieve_password_key', $user_login, $key);
		// Now insert the new md5 key into the db
		$wpdb->query($wpdb->prepare("UPDATE $wpdb->users SET user_activation_key = %s WHERE user_login = %s", $key, $user_login));
	}
	$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
	$message .= get_option('siteurl') . "\r\n\r\n";
	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
	$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
	$message .= get_option('siteurl') . "/wp-login.php?action=rp&key=$key\r\n";

	if ( !wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message) )
		die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');

	return true;
}
Ejemplo n.º 20
0
 public function wordpress_login($user_login)
 {
     //$user_login = '******';
     $user = get_userdatabylogin($user_login);
     //print_r($user);
     //exit;
     $user_id = $user->ID;
     wp_set_current_user($user_id, $user_login);
     wp_set_auth_cookie($user_id);
     do_action('wp_login', $user_login);
     //return $this->redirect()->toUrl('http://blog.ovessence.loc/wp-admin/');
 }
Ejemplo n.º 21
0
/**
 * Alerts user when someone comments on their forum topic
 *
 * @Param: the id of the topic
 *
 * @author: Joe Hoyle
 * @version 1.0
 **/
function nm_alert_user_wrote_forum_reply($replyID)
{
    $userInfo = wp_get_current_user();
    $post = bb_get_post($replyID);
    $topicAuthor = get_topic_author($post->topic_id);
    $topicAuthor = get_userdatabylogin($topicAuthor);
    if ($post->poster_id != $topicAuthor->ID) {
        $alert = array();
        $alert['content'] = '<a href="' . getProfileLink($post->poster_id) . '" title="View ' . nm_user_public_name($post->poster_id) . 's profile">' . nm_user_public_name($post->poster_id) . '</a> has replied to your forum topic: <a href="' . get_post_link($replyID) . '" title="View ' . get_topic_title($topic_id) . '">' . get_topic_title($topic_id) . '</a>.';
        $alert['type'] = 'forum';
        nm_add_alert($topicAuthor->ID, $alert);
    }
    return $topicID;
}
Ejemplo n.º 22
0
 public function authenticate($username)
 {
     if (!$this->glueCodeFound) {
         return;
     }
     $userdata = get_userdatabylogin($username);
     global $AJXP_GLUE_GLOBALS;
     $AJXP_GLUE_GLOBALS = array();
     //$plugInAction, $login, $result, $secret, $autoCreate;
     $AJXP_GLUE_GLOBALS["secret"] = $this->secret;
     $AJXP_GLUE_GLOBALS["autoCreate"] = $this->autoCreate;
     $AJXP_GLUE_GLOBALS["plugInAction"] = "login";
     $AJXP_GLUE_GLOBALS["login"] = array("name" => $username, "password" => $userdata->user_pass, "roles" => $userdata->roles);
     include $this->glueCode;
 }
Ejemplo n.º 23
0
 function set_user($u)
 {
     // defaults
     $this->user = NULL;
     $this->user_ID = NULL;
     // $u may be a numeric id or an object
     $user = is_object($u) ? $u : (is_numeric($u) ? get_userdata($u) : get_userdatabylogin($u));
     if ($user) {
         $this->user = $user;
         $this->user_ID = (int) $user->ID;
         $this->profile = $user->race_profile;
         $this->full_name = $user->first_name . ' ' . $user->last_name;
         $this->nonce_key = "race-warrior-{$this->user_ID}-{$this->type}";
         $this->donor_url = get_option('home') . '/warrior/' . $user->user_nicename . '/';
     }
 }
Ejemplo n.º 24
0
function ldap_authenticate($user, $username, $password)
{
    if (is_a($user, 'WP_User')) {
        return $user;
    }
    //  Uncomment to only allow users to authenticate with LDAP and not against the default WP U/P
    //remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
    if (empty($username)) {
        return new WP_Error('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
    }
    if (empty($password)) {
        return new WP_Error('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
    }
    // VU LDAP Credentials
    $ldapSettings = array();
    $ldapSettings['ldapHost'] = 'ldaps://123.123.123.123';
    $ldapSettings['ldapPort'] = 637;
    $ldapSettings['ldapUser'] = '******';
    $ldapSettings['ldapPass'] = '******';
    $ldapSettings['searchbase'] = 'DC=valpo,DC=edu';
    $ldapSettings['filter'] = '(sAMAccountName=' . $username . ')';
    $ds = ldap_connect($ldapSettings['ldapHost'], $ldapSettings['ldapPort']) or die("There was a problem connecting to LDAP Server - " . $ldapSettings['ldapHost']);
    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
    $r = ldap_bind($ds, $ldapSettings['ldapUser'], $ldapSettings['ldapPass']);
    $sr = ldap_search($ds, $ldapSettings['searchbase'], $ldapSettings['filter']);
    $userInfo = ldap_get_entries($ds, $sr);
    if (isset($userInfo[0]['dn'])) {
        $userdn = $userInfo[0]['dn'];
        $dsVerify = ldap_connect($ldapSettings['ldapHost'], $ldapSettings['ldapPort']) or die("There was a problem connecting to LDAP Server - " . $ldapSettings['ldapHost']);
        $rVerify = @ldap_bind($dsVerify, $userdn, stripslashes($password));
    } else {
        return new WP_Error('invalid_username', __('<strong>Login Error</strong>: LDAP user not found.'));
    }
    if (!$rVerify) {
        return new WP_Error('invalid_password', __('<strong>Login Error</strong>: Password incorrect.'));
    } else {
        $user = get_userdatabylogin($username);
        if (!$user || strtolower($user->user_login) != strtolower($username)) {
            return new WP_Error('invalid_username', __('<strong>Login Error</strong>: LDAP credentials are correct but not added to Wordpress. Contact IMC to be properly setup.'));
        } else {
            return new WP_User($user->ID);
        }
    }
}
Ejemplo n.º 25
0
 function show_profiles()
 {
     global $wp_rewrite, $wp_query;
     if (get_query_var("showprofiles")) {
         if (get_query_var("person")) {
             $user = get_userdatabylogin(get_query_var('person'));
             if (get_usermeta($user->ID, 'warp_up_public') == 1) {
                 require 'person.php';
             } else {
                 $wp_query->is_404 = true;
                 return;
             }
         } else {
             require 'people.php';
         }
         exit;
     }
 }
Ejemplo n.º 26
0
 function add_link($args)
 {
     extract($args);
     $params['link_url'] = esc_html($url);
     $params['link_url'] = esc_url($params['link_url']);
     $params['link_name'] = esc_html($name);
     $params['link_id'] = '';
     $params['link_description'] = $description;
     $params['link_target'] = $link_target;
     $params['link_category'] = array();
     //Add Link category
     if (is_array($link_category) && !empty($link_category)) {
         $terms = get_terms('link_category', array('hide_empty' => 0));
         if ($terms) {
             foreach ($terms as $term) {
                 if (in_array($term->name, $link_category)) {
                     $params['link_category'][] = $term->term_id;
                     $link_category = $this->remove_element($link_category, $term->name);
                 }
             }
         }
         if (!empty($link_category)) {
             foreach ($link_category as $linkkey => $linkval) {
                 if (!empty($linkval)) {
                     $link = wp_insert_term($linkval, 'link_category');
                     if (isset($link['term_id']) && !empty($link['term_id'])) {
                         $params['link_category'][] = $link['term_id'];
                     }
                 }
             }
         }
     }
     //Add Link Owner
     $user_obj = get_userdatabylogin($user);
     if ($user_obj && $user_obj->ID) {
         $params['link_owner'] = $user_obj->ID;
     }
     if (!function_exists('wp_insert_link')) {
         include_once ABSPATH . 'wp-admin/includes/bookmark.php';
     }
     $is_success = wp_insert_link($params);
     return $is_success ? true : array('error' => 'Failed to add link.', 'error_code' => 'failed_to_add_link');
 }
 function bpcs_get_user_id($user_id = "-1")
 {
     global $bp;
     if ($user_id == "-1") {
         $user_id = $bp->loggedin_user->userdata->ID;
     }
     if (!is_numeric($user_id)) {
         $user = get_userdatabylogin($user_id);
         if ($user == false) {
             $user_id = $bp->loggedin_user->userdata->ID;
         } else {
             $user_id = $user->ID;
         }
     }
     $user = get_userdata($user_id);
     if ($user == false) {
         $user_id = $bp->loggedin_user->userdata->ID;
     }
     return $user_id;
 }
 function get_user_id_param($user_id)
 {
     if ($user_id and !empty($user_id) and !is_numeric($user_id)) {
         if ($user_id == 'current') {
             global $user_ID;
             $user_id = $user_ID;
         } else {
             if (function_exists('get_user_by')) {
                 $user = get_user_by('login', $user_id);
             } else {
                 $user = get_userdatabylogin($user_id);
             }
             if ($user) {
                 $user_id = $user->ID;
             }
             unset($user);
         }
     }
     return $user_id;
 }
Ejemplo n.º 29
0
function get_usermeta_author_page()
{
    global $wpdb, $custom_usermeta_db_table_name;
    $return_str = '';
    $paten_str = '<div class="{#CSS#}"> {#TITLE#} - {#VALUE#}</div>';
    global $current_user;
    if (isset($_GET['author_name'])) {
        $curauth = get_userdatabylogin($author_name);
    } else {
        $curauth = get_userdata(intval($_GET['author']));
    }
    $uid = $curauth->ID;
    if ($curauth->user_description) {
        $return_str = '<p>' . $curauth->user_description . '</p>';
    }
    $sql = "select * from {$custom_usermeta_db_table_name} where is_active=1 and show_on_detail=1 ";
    if ($fields_name) {
        $fields_name = '"' . str_replace(',', '","', $fields_name) . '"';
        $sql .= " and htmlvar_name in ({$fields_name}) ";
    }
    $sql .= " order by sort_order asc";
    $post_meta_info = $wpdb->get_results($sql);
    $search_arr = array('{#TITLE#}', '{#VALUE#}', '{#CSS#}');
    $replace_arr = array();
    if ($post_meta_info) {
        foreach ($post_meta_info as $post_meta_info_obj) {
            if ($post_meta_info_obj->site_title) {
                $replace_arr[] = $post_meta_info_obj->site_title;
            }
            $htmlvar = $post_meta_info_obj->htmlvar_name;
            if ($htmlvar) {
                $replace_arr = array($post_meta_info_obj->site_title, $curauth->{$htmlvar}, $post_meta_info_obj->htmlvar_name);
                if ($curauth->{$htmlvar}) {
                    $return_str .= str_replace($search_arr, $replace_arr, $paten_str);
                }
            }
        }
    }
    echo $return_str;
}
Ejemplo n.º 30
0
	function wp_login($username, $password, $already_md5 = false) {
		global $wpdb, $error;


		if(is_object($GLOBALS["xoopsModule"]) && WP_BLOG_DIRNAME == $GLOBALS["xoopsModule"]->getVar("dirname")){
			if(!is_object($GLOBALS["xoopsUser"])){
				wp_clearcookie();
				return false;
			}
		}			

		$username = sanitize_user($username);

		if ( '' == $username )
			return false;

		if ( '' == $password ) {
			$error = __('<strong>ERROR</strong>: The password field is empty.');
			return false;
		}

		$login = get_userdatabylogin($username);
		//$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '******'");

		if (!$login) {
			$error = __('<strong>ERROR</strong>: Invalid username.');
			return false;
		} else {
			if ($login->user_login == $username) {
					if ($login->user_pass == $password) return true;
					if ($login->user_pass == md5($password)) return true;
			}

			$error = __('<strong>ERROR</strong>: Incorrect password.');
			$pwd = '';
			return false;
		}
	}