Social Login - Version 5.5.2

Version Description

  • Compatibility with International characters.
Download this release

Release Info

Developer cyberlord92
Plugin Icon 128x128 Social Login
Version 5.5.2
Comparing to
See all releases

Code changes from version 5.5.1 to 5.5.2

class-mo-openid-login-widget.php CHANGED
@@ -975,6 +975,7 @@ class mo_openid_sharing_ver_wid extends WP_Widget {
975
  $decrypted_user_name = isset($_POST['username']) ? mo_openid_decrypt_sanitize($_POST['username']): '';
976
  $decrypted_user_picture = isset($_POST['profilePic']) ? mo_openid_decrypt_sanitize($_POST['profilePic']): '';
977
  $decrypted_user_url = isset($_POST['profileUrl']) ? mo_openid_decrypt_sanitize($_POST['profileUrl']): '';
 
978
  $decrypted_first_name = isset($_POST['firstName']) ? mo_openid_decrypt_sanitize($_POST['firstName']): '';
979
  $decrypted_last_name = isset($_POST['lastName']) ? mo_openid_decrypt_sanitize($_POST['lastName']): '';
980
  $decrypted_app_name = isset($_POST['appName']) ? mo_openid_decrypt_sanitize($_POST['appName']): '';
@@ -1008,151 +1009,151 @@ class mo_openid_sharing_ver_wid extends WP_Widget {
1008
 
1009
  //if email or username not returned from app
1010
  if ( empty($decrypted_email) || empty($decrypted_user_name) )
1011
- {
1012
 
1013
  if( empty($decrypted_app_name) || empty($decrypted_user_id)){
1014
  wp_die('There was an error during login. Please try to login manually.');
1015
  }
1016
  else
1017
  {
1018
- //check if provider + identifier group exists
1019
- global $wpdb;
1020
- $id_returning_user = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where provider = %s AND identifier = %s",$decrypted_app_name,$decrypted_user_id));
1021
-
1022
- mo_openid_start_session();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1023
 
1024
- // if returning user whose appname + identifier exists, log him in
1025
- if(isset($id_returning_user))
1026
- {
1027
- $user = get_user_by('id', $id_returning_user );
1028
- if(get_option('moopenid_social_login_avatar') && isset($user_picture))
1029
- update_user_meta($id_returning_user, 'moopenid_user_avatar', $user_picture);
1030
- $_SESSION['mo_login'] = true;
1031
- do_action( 'miniorange_collect_attributes_for_authenticated_user', $user, mo_openid_get_redirect_url());
1032
- do_action( 'wp_login', $user->user_login, $user );
1033
- wp_set_auth_cookie( $id_returning_user, true );
1034
- }
1035
- // if new user and profile completion is enabled
1036
- elseif (get_option('mo_openid_enable_profile_completion')){
1037
 
1038
- $path = site_url();
1039
- $path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
1040
- echo mo_openid_profile_completion_form($path, $last_name, $first_name, $user_full_name, $user_url, $user_picture, $decrypted_user_name, $decrypted_email, $decrypted_app_name, $decrypted_user_id);
1041
- exit;
1042
- }
1043
- // if new user and profile completion is disabled, auto create dummy data and register user
1044
- else
1045
- {
1046
- // auto registration is enabled
1047
- if(get_option('mo_openid_auto_register_enable')) {
1048
-
1049
- if(!empty($decrypted_email))
1050
- {
1051
- $split_email = array();
1052
- $split_email = explode('@',$decrypted_email);
1053
- $username = $split_email[0];
1054
- $user_email = $decrypted_email;
1055
- }
1056
- else if(!empty($decrypted_user_name))
1057
- {
1058
- $split_app_name = array();
1059
- $split_app_name = explode('_',$decrypted_app_name);
1060
- $username = $decrypted_user_name;
1061
- $user_email = $decrypted_user_name.'@'.$split_app_name[0].'.com';
1062
- }
1063
- else
1064
- {
1065
- $split_app_name = array();
1066
- $split_app_name = explode('_',$decrypted_app_name);
1067
- $username = 'user_'.get_option('mo_openid_user_count');
1068
- $user_email = 'user_'.get_option('mo_openid_user_count').'@'.$split_app_name[0].'.com';
1069
- //update_option('mo_openid_user_count',get_option('mo_openid_user_count')+1); update only if user is successfully created
1070
- }
1071
-
1072
-
1073
- $random_password = wp_generate_password( 10, false );
1074
-
1075
- $userdata = array(
1076
- 'user_login' => $username,
1077
- 'user_email' => $user_email,
1078
- 'user_pass' => $random_password,
1079
- 'display_name' => $user_full_name,
1080
- 'first_name' => $first_name,
1081
- 'last_name' => $last_name,
1082
- 'user_url' => $user_url,
1083
- );
1084
-
1085
-
1086
- $user_id = wp_insert_user( $userdata);
1087
-
1088
- if(is_wp_error( $user_id )) {
1089
- //print_r($user_id);
1090
- wp_die('There was an error in registration. Please contact your administrator.');
1091
- }
1092
 
1093
- update_option('mo_openid_user_count',get_option('mo_openid_user_count')+1);
1094
- // run the query to add provider and identifier for the user
1095
- $table_name = $wpdb->prefix . 'users';
1096
-
1097
- $provider_column = 'provider';
1098
- $identifier_column = 'identifier';
1099
-
1100
- $row = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ".$table_name." AND column_name = ".$provider_column);
1101
- if(empty($row)){
1102
- $wpdb->query("ALTER TABLE ".$table_name." ADD ".$provider_column." VARCHAR(20) NOT NULL ");
1103
- }
1104
-
1105
- $row = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ".$table_name." AND column_name = ".$identifier_column);
1106
- if(empty($row)){
1107
- $wpdb->query("ALTER TABLE ".$table_name." ADD ".$identifier_column." VARCHAR(100) NOT NULL ");
1108
- }
1109
-
1110
- $result = $wpdb->update(
1111
- $table_name,
1112
- array(
1113
- 'provider' => $decrypted_app_name, // string
1114
- 'identifier' => $decrypted_user_id // string
1115
- ),
1116
- array( 'ID' => $user_id ),
1117
- array(
1118
- '%s', // value1
1119
- '%s' // value2
1120
- ),
1121
- array( '%d' )
1122
- );
1123
-
1124
- if($result === false)
1125
- {
1126
- //$wpdb->show_errors();
1127
- //$wpdb->print_error();
1128
- //exit;
1129
- wp_die('Error in update query');
1130
- }
1131
 
1132
- $user = get_user_by('email', $user_email );
1133
- if(get_option('mo_openid_login_role_mapping') && mo_openid_is_customer_valid()){
1134
- $user->set_role( get_option('mo_openid_login_role_mapping') );
1135
- }
1136
- if(get_option('moopenid_social_login_avatar') && isset($user_picture)){
1137
- update_user_meta($user_id, 'moopenid_user_avatar', $user_picture);
1138
- }
1139
- $_SESSION['mo_login'] = true;
1140
-
1141
- //registration hook
1142
- do_action( 'mo_user_register', $user_id);
1143
- //login hook
1144
- do_action( 'miniorange_collect_attributes_for_authenticated_user', $user, mo_openid_get_redirect_url());
1145
- do_action( 'wp_login', $user->user_login, $user );
1146
- wp_set_auth_cookie( $user_id, true );
1147
- }
 
 
 
1148
 
1149
- $redirect_url = mo_openid_get_redirect_url();
1150
- wp_redirect($redirect_url);
1151
- exit;
1152
 
1153
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1155
  }
 
 
 
 
 
 
 
 
1156
 
1157
 
1158
  }
@@ -1637,5 +1638,81 @@ add_action( 'init', 'mo_openid_login_validate' );
1637
  //add_action( 'init', 'mo_openid_start_session' );
1638
  //add_action( 'wp_logout', 'mo_openid_end_session' );
1639
  add_action( 'wp_login', 'mo_openid_login_redirect', 9, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1640
  }
1641
  ?>
975
  $decrypted_user_name = isset($_POST['username']) ? mo_openid_decrypt_sanitize($_POST['username']): '';
976
  $decrypted_user_picture = isset($_POST['profilePic']) ? mo_openid_decrypt_sanitize($_POST['profilePic']): '';
977
  $decrypted_user_url = isset($_POST['profileUrl']) ? mo_openid_decrypt_sanitize($_POST['profileUrl']): '';
978
+ $decrypted_user_url = urldecode($decrypted_user_url);
979
  $decrypted_first_name = isset($_POST['firstName']) ? mo_openid_decrypt_sanitize($_POST['firstName']): '';
980
  $decrypted_last_name = isset($_POST['lastName']) ? mo_openid_decrypt_sanitize($_POST['lastName']): '';
981
  $decrypted_app_name = isset($_POST['appName']) ? mo_openid_decrypt_sanitize($_POST['appName']): '';
1009
 
1010
  //if email or username not returned from app
1011
  if ( empty($decrypted_email) || empty($decrypted_user_name) )
1012
+ {
1013
 
1014
  if( empty($decrypted_app_name) || empty($decrypted_user_id)){
1015
  wp_die('There was an error during login. Please try to login manually.');
1016
  }
1017
  else
1018
  {
1019
+ //check if provider + identifier group exists
1020
+ global $wpdb;
1021
+ $id_returning_user = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where provider = %s AND identifier = %s",$decrypted_app_name,$decrypted_user_id));
1022
+
1023
+ mo_openid_start_session();
1024
+
1025
+ // if returning user whose appname + identifier exists, log him in
1026
+ if(isset($id_returning_user))
1027
+ {
1028
+ $user = get_user_by('id', $id_returning_user );
1029
+ if(get_option('moopenid_social_login_avatar') && isset($user_picture))
1030
+ update_user_meta($id_returning_user, 'moopenid_user_avatar', $user_picture);
1031
+ $_SESSION['mo_login'] = true;
1032
+ do_action( 'miniorange_collect_attributes_for_authenticated_user', $user, mo_openid_get_redirect_url());
1033
+ do_action( 'wp_login', $user->user_login, $user );
1034
+ wp_set_auth_cookie( $id_returning_user, true );
1035
+ }
1036
+ // if new user and profile completion is enabled
1037
+ elseif (get_option('mo_openid_enable_profile_completion')){
1038
 
1039
+ $path = site_url();
1040
+ $path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
1041
+ echo mo_openid_profile_completion_form($path, $last_name, $first_name, $user_full_name, $user_url, $user_picture, $decrypted_user_name, $decrypted_email, $decrypted_app_name, $decrypted_user_id);
1042
+ exit;
1043
+ }
1044
+ // if new user and profile completion is disabled, auto create dummy data and register user
1045
+ else
1046
+ {
1047
+ // auto registration is enabled
1048
+ if(get_option('mo_openid_auto_register_enable')) {
 
 
 
1049
 
1050
+ if(!empty($decrypted_email))
1051
+ {
1052
+ $split_email = array();
1053
+ $split_email = explode('@',$decrypted_email);
1054
+ $username = $split_email[0];
1055
+ $user_email = $decrypted_email;
1056
+ }
1057
+ else if(!empty($decrypted_user_name))
1058
+ {
1059
+ $split_app_name = array();
1060
+ $split_app_name = explode('_',$decrypted_app_name);
1061
+ $username = $decrypted_user_name;
1062
+ $user_email = $decrypted_user_name.'@'.$split_app_name[0].'.com';
1063
+ }
1064
+ else
1065
+ {
1066
+ $split_app_name = array();
1067
+ $split_app_name = explode('_',$decrypted_app_name);
1068
+ $username = 'user_'.get_option('mo_openid_user_count');
1069
+ $user_email = 'user_'.get_option('mo_openid_user_count').'@'.$split_app_name[0].'.com';
1070
+ //update_option('mo_openid_user_count',get_option('mo_openid_user_count')+1); update only if user is successfully created
1071
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1072
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1073
 
1074
+ $random_password = wp_generate_password( 10, false );
1075
+
1076
+ $userdata = array(
1077
+ 'user_login' => $username,
1078
+ 'user_email' => $user_email,
1079
+ 'user_pass' => $random_password,
1080
+ 'display_name' => $user_full_name,
1081
+ 'first_name' => $first_name,
1082
+ 'last_name' => $last_name,
1083
+ 'user_url' => $user_url,
1084
+ );
1085
+
1086
+
1087
+ $user_id = wp_insert_user( $userdata);
1088
+
1089
+ if(is_wp_error( $user_id )) {
1090
+ //print_r($user_id);
1091
+ wp_die('There was an error in registration. Please contact your administrator.');
1092
+ }
1093
 
1094
+ update_option('mo_openid_user_count',get_option('mo_openid_user_count')+1);
1095
+ // run the query to add provider and identifier for the user
1096
+ $table_name = $wpdb->prefix . 'users';
1097
 
1098
+ $provider_column = 'provider';
1099
+ $identifier_column = 'identifier';
1100
+
1101
+ $row = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ".$table_name." AND column_name = ".$provider_column);
1102
+ if(empty($row)){
1103
+ $wpdb->query("ALTER TABLE ".$table_name." ADD ".$provider_column." VARCHAR(20) NOT NULL ");
1104
+ }
1105
+
1106
+ $row = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ".$table_name." AND column_name = ".$identifier_column);
1107
+ if(empty($row)){
1108
+ $wpdb->query("ALTER TABLE ".$table_name." ADD ".$identifier_column." VARCHAR(100) NOT NULL ");
1109
+ }
1110
+
1111
+ $result = $wpdb->update(
1112
+ $table_name,
1113
+ array(
1114
+ 'provider' => $decrypted_app_name, // string
1115
+ 'identifier' => $decrypted_user_id // string
1116
+ ),
1117
+ array( 'ID' => $user_id ),
1118
+ array(
1119
+ '%s', // value1
1120
+ '%s' // value2
1121
+ ),
1122
+ array( '%d' )
1123
+ );
1124
 
1125
+ if($result === false)
1126
+ {
1127
+ //$wpdb->show_errors();
1128
+ //$wpdb->print_error();
1129
+ //exit;
1130
+ wp_die('Error in update query');
1131
+ }
1132
+
1133
+ $user = get_user_by('email', $user_email );
1134
+ if(get_option('mo_openid_login_role_mapping') && mo_openid_is_customer_valid()){
1135
+ $user->set_role( get_option('mo_openid_login_role_mapping') );
1136
+ }
1137
+ if(get_option('moopenid_social_login_avatar') && isset($user_picture)){
1138
+ update_user_meta($user_id, 'moopenid_user_avatar', $user_picture);
1139
+ }
1140
+ $_SESSION['mo_login'] = true;
1141
+
1142
+ //registration hook
1143
+ do_action( 'mo_user_register', $user_id);
1144
+ //login hook
1145
+ do_action( 'miniorange_collect_attributes_for_authenticated_user', $user, mo_openid_get_redirect_url());
1146
+ do_action( 'wp_login', $user->user_login, $user );
1147
+ wp_set_auth_cookie( $user_id, true );
1148
  }
1149
+
1150
+ $redirect_url = mo_openid_get_redirect_url();
1151
+ wp_redirect($redirect_url);
1152
+ exit;
1153
+
1154
+ }
1155
+
1156
+ }
1157
 
1158
 
1159
  }
1638
  //add_action( 'init', 'mo_openid_start_session' );
1639
  //add_action( 'wp_logout', 'mo_openid_end_session' );
1640
  add_action( 'wp_login', 'mo_openid_login_redirect', 9, 2);
1641
+ add_filter('sanitize_user', 'mo_openid_sanitize_user', 10, 3);
1642
+ remove_filter('sanitize_title','sanitize_title_with_dashes', 10);
1643
+ add_filter( 'sanitize_title', 'mo_openid_sanitize_title_with_dashes', 10, 3 );
1644
+
1645
+ function mo_openid_sanitize_user($username, $raw_username, $strict) {
1646
+
1647
+ $username = wp_strip_all_tags( $raw_username );
1648
+ $username = remove_accents( $username );
1649
+ // Kill octets
1650
+ $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
1651
+ $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities
1652
+ // If strict, reduce to ASCII and Cyrillic characters for max portability.
1653
+ if ( $strict )
1654
+ $username = preg_replace( '|[^a-zあ-ん\p{Han}а-я0-9ㅂㅈㄷㄱ쇼ㅕㅑㅐㅔㅁㄴㅇㄹ호ㅓㅏㅣㅋㅌㅊ퓨ㅜㅡㅃㅉㄸㄲ썌ㅖ _.\-@]|iu', '', $username );
1655
+ $username = trim( $username );
1656
+ // Consolidate contiguous whitespace
1657
+ $username = preg_replace( '|\s+|', ' ', $username );
1658
+ return $username;
1659
+ }
1660
+
1661
+ function mo_openid_sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) {
1662
+
1663
+ $title = strip_tags($raw_title);
1664
+ // Preserve escaped octets.
1665
+ $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
1666
+ // Remove percent signs that are not part of an octet.
1667
+ $title = str_replace('%', '', $title);
1668
+ // Restore octets.
1669
+ $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
1670
+ if (seems_utf8($title)) {
1671
+ if (function_exists('mb_strtolower')) {
1672
+ $title = mb_strtolower($title, 'UTF-8');
1673
+ }
1674
+ }
1675
+
1676
+ $title = strtolower($title);
1677
+
1678
+ if ( 'save' == $context ) {
1679
+ // Convert nbsp, ndash and mdash to hyphens
1680
+ $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
1681
+ // Convert nbsp, ndash and mdash HTML entities to hyphens
1682
+ $title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title );
1683
+ // Convert forward slash to hyphen
1684
+ $title = str_replace( '/', '-', $title );
1685
+
1686
+ // Strip these characters entirely
1687
+ $title = str_replace( array(
1688
+ // iexcl and iquest
1689
+ '%c2%a1', '%c2%bf',
1690
+ // angle quotes
1691
+ '%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba',
1692
+ // curly quotes
1693
+ '%e2%80%98', '%e2%80%99', '%e2%80%9c', '%e2%80%9d',
1694
+ '%e2%80%9a', '%e2%80%9b', '%e2%80%9e', '%e2%80%9f',
1695
+ // copy, reg, deg, hellip and trade
1696
+ '%c2%a9', '%c2%ae', '%c2%b0', '%e2%80%a6', '%e2%84%a2',
1697
+ // acute accents
1698
+ '%c2%b4', '%cb%8a', '%cc%81', '%cd%81',
1699
+ // grave accent, macron, caron
1700
+ '%cc%80', '%cc%84', '%cc%8c',
1701
+ ), '', $title );
1702
+ // Convert times to x
1703
+ $title = str_replace( '%c3%97', 'x', $title );
1704
+ }
1705
+
1706
+ $title = preg_replace('/&.+?;/', '', $title); // kill entities
1707
+ $title = str_replace('.', '-', $title);
1708
+
1709
+ //$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
1710
+ $title = preg_replace( '|[^a-zあ-ん\p{Han}а-я0-9ㅂㅈㄷㄱ쇼ㅕㅑㅐㅔㅁㄴㅇㄹ호ㅓㅏㅣㅋㅌㅊ퓨ㅜㅡㅃㅉㄸㄲ썌ㅖ _.\-@]|iu', '', $title );
1711
+ $title = preg_replace('/\s+/', '-', $title);
1712
+ $title = preg_replace('|-+|', '-', $title);
1713
+ $title = trim($title, '-');
1714
+
1715
+ return $title;
1716
+ }
1717
  }
1718
  ?>
miniorange_openid_sso_settings.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Social Login, Social Sharing by miniOrange
5
  * Plugin URI: http://miniorange.com
6
  * Description: Allow your users to login, comment and share with Facebook, Google, Twitter, LinkedIn etc using customizable buttons.
7
- * Version: 5.5.1
8
  * Author: miniOrange
9
  * Author URI: http://miniorange.com
10
  * License: GPL2
4
  * Plugin Name: Social Login, Social Sharing by miniOrange
5
  * Plugin URI: http://miniorange.com
6
  * Description: Allow your users to login, comment and share with Facebook, Google, Twitter, LinkedIn etc using customizable buttons.
7
+ * Version: 5.5.2
8
  * Author: miniOrange
9
  * Author URI: http://miniorange.com
10
  * License: GPL2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://miniorange.com
4
  Tags: social login, social, facebook, twitter, login
5
  Requires at least: 2.0.2
6
  Tested up to: 4.9
7
- Stable tag: 5.5.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -144,6 +144,9 @@ Please email us at info@miniorange.com. You can also submit your query from the
144
 
145
 
146
  == Changelog ==
 
 
 
147
  = 5.5.1 =
148
  * Major Security Fix in login flow. Mandatory Update is required.
149
 
@@ -410,6 +413,9 @@ Please email us at info@miniorange.com. You can also submit your query from the
410
  * First version of Social Login, Social Sharing plugin.
411
 
412
  == Upgrade Notice ==
 
 
 
413
  = 5.5.1 =
414
  * Major Security Fix in login flow. Mandatory Update is required.
415
 
4
  Tags: social login, social, facebook, twitter, login
5
  Requires at least: 2.0.2
6
  Tested up to: 4.9
7
+ Stable tag: 5.5.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
144
 
145
 
146
  == Changelog ==
147
+ = 5.5.2 =
148
+ * Compatibility with International characters.
149
+
150
  = 5.5.1 =
151
  * Major Security Fix in login flow. Mandatory Update is required.
152
 
413
  * First version of Social Login, Social Sharing plugin.
414
 
415
  == Upgrade Notice ==
416
+ = 5.5.2 =
417
+ * Compatibility with International characters.
418
+
419
  = 5.5.1 =
420
  * Major Security Fix in login flow. Mandatory Update is required.
421