Beispiel #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);
         }
     }
 }
 function wpestate_ajax_google_login()
 {
     require get_template_directory() . '/libs/resources/openid.php';
     $allowed_html = array();
     $dash_profile = wpestate_get_dashboard_profile_link();
     $login_type = wp_kses($_POST['login_type'], $allowed_html);
     if (isset($_POST['propid'])) {
         $propid = intval($_POST['propid']);
     } else {
         $propid = 0;
     }
     try {
         $openid = new LightOpenID(wpestate_get_domain_openid());
         if (!$openid->mode) {
             if ($login_type == 'google') {
                 $openid->identity = 'https://www.google.com/accounts/o8/id';
                 $openid->identity = 'https://www.googleapis.com/plus/v1/people/me/openIdConnect';
             } else {
                 if ($login_type == 'yahoo') {
                     $openid->identity = 'https://me.yahoo.com';
                 } else {
                     if ($login_type == 'aol') {
                         $openid->identity = 'http://openid.aol.com/';
                     }
                 }
             }
             $openid->required = array('namePerson', 'namePerson/first', 'namePerson/last', 'contact/email');
             $openid->optional = array('namePerson', 'namePerson/friendly');
             $openid->returnUrl = $dash_profile;
             $openid->propid = $propid;
             print $openid->authUrl();
             exit;
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
     }
 }