Exemplo n.º 1
0
 function estate_open_id_login($get_vars)
 {
     require get_template_directory() . '/libs/resources/openid.php';
     $openid = new LightOpenID(wpestate_get_domain_openid());
     $allowed_html = array();
     if ($openid->validate()) {
         $dashboard_url = wpestate_get_dashboard_profile_link();
         $openid_identity = wp_kses($get_vars['openid_identity'], $allowed_html);
         $openid_identity_check = wp_kses($get_vars['openid_identity'], $allowed_html);
         if (strrpos($openid_identity_check, 'google')) {
             $email = wp_kses($get_vars['openid_ext1_value_contact_email'], $allowed_html);
             $last_name = wp_kses($get_vars['openid_ext1_value_namePerson_last'], $allowed_html);
             $first_name = wp_kses($get_vars['openid_ext1_value_namePerson_first'], $allowed_html);
             $full_name = $first_name . $last_name;
             $openid_identity_pos = strrpos($openid_identity, 'id?id=');
             $openid_identity = str_split($openid_identity, $openid_identity_pos + 6);
             $openid_identity_code = $openid_identity[1];
         }
         if (strrpos($openid_identity_check, 'yahoo')) {
             $email = wp_kses($get_vars['openid_ax_value_email'], $allowed_html);
             $full_name = wp_kses(str_replace(' ', '.', $get_vars['openid_ax_value_fullname']), $allowed_html);
             $openid_identity_pos = strrpos($openid_identity, '/a/.');
             $openid_identity = str_split($openid_identity, $openid_identity_pos + 4);
             $openid_identity_code = $openid_identity[1];
         }
         wpestate_register_user_via_google($email, $full_name, $openid_identity_code);
         $info = array();
         $info['user_login'] = $full_name;
         $info['user_password'] = $openid_identity_code;
         $info['remember'] = true;
         $user_signon = wp_signon($info, false);
         if (is_wp_error($user_signon)) {
             wp_redirect(esc_url(home_url()));
         } else {
             wpestate_update_old_users($user_signon->ID);
             wp_redirect($dashboard_url);
         }
     }
 }
Exemplo n.º 2
0
 function wpestate_ajax_loginx_form()
 {
     if (is_user_logged_in()) {
         echo json_encode(array('loggedin' => true, 'message' => esc_html__('You are already logged in! redirecting...', 'wpestate')));
         exit;
     }
     if (!check_ajax_referer('login_ajax_nonce', 'security-login', false) == 1) {
         check_ajax_referer('login_ajax_nonce', 'security-login-mobile');
     }
     $allowed_html = array();
     $login_user = wp_kses($_POST['login_user'], $allowed_html);
     $login_pwd = wp_kses($_POST['login_pwd'], $allowed_html);
     $ispop = intval($_POST['ispop']);
     $propid = intval($_POST['propid']);
     $redirect_url = '';
     if ($login_user == '' || $login_pwd == '') {
         echo json_encode(array('loggedin' => false, 'message' => esc_html__('Username and/or Password field is empty!', 'wpestate')));
         exit;
     }
     wp_clear_auth_cookie();
     $info = array();
     $info['user_login'] = $login_user;
     $info['user_password'] = $login_pwd;
     $info['remember'] = true;
     $user_signon = wp_signon($info, true);
     if (is_wp_error($user_signon)) {
         echo json_encode(array('loggedin' => false, 'message' => esc_html__('Wrong username or password!', 'wpestate')));
     } else {
         global $current_user;
         wp_set_current_user($user_signon->ID);
         if ($propid != 0) {
             $redirect_url = wpestate_new_list_to_user($propid, $user_signon->ID);
         }
         do_action('set_current_user');
         $current_user = wp_get_current_user();
         echo json_encode(array('loggedin' => true, 'ispop' => $ispop, 'newuser' => $user_signon->ID, 'newlink' => html_entity_decode($redirect_url), 'message' => esc_html__('Login successful, redirecting...', 'wpestate')));
         wpestate_update_old_users($user_signon->ID);
     }
     die;
 }