Social Login WordPress Plugin – AccessPress Social Login Lite - Version 3.3.4

Version Description

  • Done some code cleanup and small issue with force_ssl_login resolved
Download this release

Release Info

Developer Access Keys
Plugin Icon 128x128 Social Login WordPress Plugin – AccessPress Social Login Lite
Version 3.3.4
Comparing to
See all releases

Code changes from version 3.3.3 to 3.3.4

accesspress-social-login-lite.php CHANGED
@@ -1,46 +1,48 @@
1
- <?php defined( 'ABSPATH' ) or die( "No script kiddies please!" );
 
 
2
  /*
3
  Plugin name: Social Login WordPress Plugin - AccessPress Social Login Lite
4
  Plugin URI: https://accesspressthemes.com/wordpress-plugins/accesspress-social-login-lite/
5
  Description: A plugin to add various social logins to a site.
6
- version: 3.3.3
7
  Author: AccessPress Themes
8
  Author URI: https://accesspressthemes.com/
9
  Text Domain: accesspress-social-login-lite
10
  Domain Path: /languages/
11
  License: GPLv2 or later
12
- */
13
  //Declearation of the necessary constants for plugin
14
- if( !defined( 'APSL_VERSION' ) ) {
15
- define( 'APSL_VERSION', '3.3.3' );
16
  }
17
 
18
- if( !defined( 'APSL_IMAGE_DIR' ) ) {
19
- define( 'APSL_IMAGE_DIR', plugin_dir_url( __FILE__ ) . 'images' );
20
  }
21
 
22
- if( !defined( 'APSL_JS_DIR' ) ) {
23
- define( 'APSL_JS_DIR', plugin_dir_url( __FILE__ ) . 'js' );
24
  }
25
 
26
- if( !defined( 'APSL_CSS_DIR' ) ) {
27
- define( 'APSL_CSS_DIR', plugin_dir_url( __FILE__ ) . 'css' );
28
  }
29
 
30
- if( !defined( 'APSL_LANG_DIR' ) ) {
31
- define( 'APSL_LANG_DIR', basename( dirname( __FILE__ ) ) . '/languages/' );
32
  }
33
 
34
- if( !defined( 'APSL_TEXT_DOMAIN' ) ) {
35
- define( 'APSL_TEXT_DOMAIN', 'accesspress-social-login-lite' );
36
  }
37
 
38
- if( !defined( 'APSL_SETTINGS' ) ) {
39
- define( 'APSL_SETTINGS', 'apsl-lite-settings' );
40
  }
41
 
42
- if( !defined( 'APSL_PLUGIN_DIR' ) ) {
43
- define( 'APSL_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
44
  }
45
  /**
46
  * Register a widget
@@ -48,163 +50,163 @@ if( !defined( 'APSL_PLUGIN_DIR' ) ) {
48
  */
49
  include_once( 'inc/backend/widget.php' );
50
 
51
- if (version_compare(get_bloginfo('version'), '4.3.1', '>=')){
52
- // Redefine user notification function
53
- if ( !function_exists('wp_new_user_notification') ) {
54
-
55
- function wp_new_user_notification( $user_id, $deprecated = null, $notify = 'both' ) {
56
- if ( $deprecated !== null ) {
57
- _deprecated_argument( __FUNCTION__, '4.3.1' );
58
- }
59
-
60
- global $wpdb, $wp_hasher;
61
- $user = get_userdata( $user_id );
62
- if ( empty ( $user ) )
63
- return;
64
-
65
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
66
- // we want to reverse this for the plain text arena of emails.
67
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
68
-
69
- $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
70
- $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
71
- $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
72
-
73
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
74
-
75
- if ( 'admin' === $notify || empty( $notify ) ) {
76
- return;
77
- }
78
-
79
- // Generate something random for a password reset key.
80
- $key = wp_generate_password( 20, false );
81
-
82
- /** This action is documented in wp-login.php */
83
- do_action( 'retrieve_password_key', $user->user_login, $key );
84
-
85
- // Now insert the key, hashed, into the DB.
86
- if ( empty( $wp_hasher ) ) {
87
- require_once ABSPATH . WPINC . '/class-phpass.php';
88
- $wp_hasher = new PasswordHash( 8, true );
89
- }
90
- $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
91
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
92
-
93
- $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
94
- $message .= __('To set your password, visit the following address:') . "\r\n\r\n";
95
- $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
96
-
97
- $message .= wp_login_url() . "\r\n\r\n";
98
- $message .= sprintf( __('If you have any problems, please contact us at %s.'), get_option('admin_email') ) . "\r\n\r\n";
99
- $message .= __('Adios!') . "\r\n\r\n";
100
-
101
- wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
102
- }
103
- }
104
- }else{
105
- // for wordpress version less than 4.3.1
106
  // Redefine user notification function
107
- if(!function_exists( 'wp_new_user_notification' )){
108
- function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
109
- $user = new WP_User($user_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
- $user_login = stripslashes($user->user_login);
112
- $user_email = stripslashes($user->user_email);
113
 
114
- $message = sprintf(__('New user registration on your site %s:'), get_option('blogname')) . "\r\n\r\n";
115
- $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
116
- $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
117
- $message .= __('Thanks!');
 
 
118
 
119
- $headers = 'From:'.get_option('blogname').' <'.get_option('admin_email').'>' . "\r\n";
120
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message, $headers);
 
 
 
 
 
 
 
 
121
 
122
- if ( empty($plaintext_pass) )
123
- return;
 
124
 
125
- $message = __('Hi there,') . "\r\n\r\n";
126
- $message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
127
- $message .= wp_login_url() . "\r\n";
128
- $message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
129
- $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n\r\n";
130
- $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\r\n\r\n";
131
- $message .= __('Thanks!');
132
 
133
- $headers = 'From:'.get_option('blogname').' <'.get_option('admin_email').'>' . "\r\n";
 
 
 
 
 
 
 
134
 
135
- wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message, $headers);
 
136
 
137
- }
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
 
142
  // Declaration of the class
143
- if( !class_exists( 'APSL_Lite_Class' ) ) {
144
-
145
  class APSL_Lite_Class {
146
-
147
  var $apsl_settings;
148
-
149
  function __construct() {
150
- $this->apsl_settings = get_option( APSL_SETTINGS );
151
- add_action( 'init', array($this, 'session_init') ); //start the session if not started yet.
152
- register_activation_hook( __FILE__, array($this, 'plugin_activation') ); //load the default setting for the plugin while activating
153
- add_action( 'init', array($this, 'plugin_text_domain') ); //load the plugin text domain
154
- add_action( 'admin_menu', array($this, 'add_apsl_menu') ); //register the plugin menu in backend
155
- add_action( 'admin_enqueue_scripts', array($this, 'register_admin_assets') ); //registers all the assets required for wp-admin
156
- add_action( 'wp_enqueue_scripts', array($this, 'register_frontend_assets') ); // registers all the assets required for the frontend
157
- add_action( 'admin_post_apsl_save_options', array($this, 'save_settings') ); //save settings of a plugin
158
-
159
- $options = get_option( APSL_SETTINGS );
160
- if( $options['apsl_enable_disable_plugin'] == 'yes' ) {
161
- if( in_array( "login_form", $options['apsl_display_options'] ) ) {
162
- add_action( 'login_form', array($this, 'add_social_login') ); // add the social logins to the login form
163
- add_action( 'woocommerce_login_form', array($this, 'add_social_login_form_to_comment') );
164
-
165
  }
166
-
167
- if( in_array( "register_form", $options['apsl_display_options'] ) ) {
168
- add_action( 'register_form', array($this, 'add_social_login') ); //add the social logins to the registration form
169
- add_action( 'after_signup_form', array($this, 'add_social_login') );
170
  }
171
-
172
- if( in_array( "comment_form", $options['apsl_display_options'] ) ) {
173
- add_action( 'comment_form_top', array($this, 'add_social_login_form_to_comment') ); //add the social logins to the comment form
174
- add_action( 'comment_form_must_log_in_after', array($this, 'add_social_login_form_to_comment') ); // add the social login buttons if “Users must be registered and logged in to comment” checked in the discussions settings.
175
-
176
  }
177
  }
178
-
179
- add_shortcode( 'apsl-login-lite', array($this, 'apsl_shortcode') ); //adds a shortcode
180
- add_action( 'init', array($this, 'login_check') ); //check for the social logins
181
- add_action( 'widgets_init', array($this, 'register_apsl_widget') ); //register the widget of a plugin
182
- add_action( 'login_enqueue_scripts', array($this, 'apsl_login_form_enqueue_style'), 10 );
183
- add_action( 'login_enqueue_scripts', array($this, 'apsl_login_form__enqueue_script'), 1 );
184
- add_action( 'admin_post_apsl_restore_default_settings', array($this, 'apsl_restore_default_settings') ); //restores default settings.
185
-
186
-
187
  /**
188
  * Hook to display custom avatars
189
  */
190
- add_filter( 'get_avatar', array($this, 'apsl_social_login_custom_avatar'), 10, 5 );
191
 
192
  //add delete action when user is deleted from wordpress backend.
193
- add_action( 'delete_user', array ($this, 'apsl_delete_user') );
194
  }
195
-
196
- function apsl_social_login_custom_avatar( $avatar, $mixed, $size, $default, $alt = '' ) {
197
- $options = get_option( APSL_SETTINGS );
198
  //Check if we have an user identifier
199
- if( is_numeric( $mixed ) AND $mixed > 0 ) {
200
  $user_id = $mixed;
201
  }
202
  //Check if we have an user email
203
- elseif( is_string( $mixed ) AND( $user = get_user_by( 'email', $mixed ) ) ) {
204
  $user_id = $user->ID;
205
  }
206
  //Check if we have an user object
207
- elseif( is_object( $mixed ) AND property_exists( $mixed, 'user_id' ) AND is_numeric( $mixed->user_id ) ) {
208
  $user_id = $mixed->user_id;
209
  }
210
  //None found
@@ -212,33 +214,35 @@ if( !class_exists( 'APSL_Lite_Class' ) ) {
212
  $user_id = null;
213
  }
214
  //User found?
215
- if( !empty( $user_id ) ) {
216
  //Override current avatar ?
217
  $override_avatar = true;
218
  //Read the avatar
219
- $user_meta_thumbnail = get_user_meta( $user_id, 'deuimage', true );
220
  //read user details
221
- $user_meta_name = get_user_meta( $user_id, 'first_name', true );
222
-
223
- if( $options['apsl_user_avatar_options'] == 'social' ) {
224
- $user_picture =( !empty( $user_meta_thumbnail ) ? $user_meta_thumbnail : '' );
225
  //Avatar found?
226
- if( $user_picture !== false AND strlen( trim( $user_picture ) ) > 0 ) {
227
  return '<img alt="' . $user_meta_name . '" src="' . $user_picture . '" class="avatar apsl-avatar-social-login avatar-' . $size . ' photo" height="' . $size . '" width="' . $size . '" />';
228
  }
229
  }
230
  }
231
  return $avatar;
232
  }
 
233
  //starts the session with the call of init hook
234
  function session_init() {
235
- if( !session_id() && !headers_sent() ) {
236
  session_start();
237
  }
238
  }
 
239
  //load the default settings of the plugin
240
  function plugin_activation() {
241
- if( !get_option( APSL_SETTINGS ) ) {
242
  include( 'inc/backend/activation.php' );
243
  }
244
  self:: apsl_database_install();
@@ -283,115 +287,124 @@ if( !class_exists( 'APSL_Lite_Class' ) ) {
283
  KEY user_id (user_id),
284
  KEY provider_name (provider_name)
285
  )";
286
- dbDelta( $sql );
287
  }
288
 
289
  //loads the text domain for translation
290
  function plugin_text_domain() {
291
- load_plugin_textdomain( 'accesspress-social-login-lite', false, APSL_LANG_DIR );
292
  }
 
293
  //register the plugin menu for backend.
294
  function add_apsl_menu() {
295
- add_menu_page( 'AccessPress Social Login Lite', 'AccessPress Social Login Lite', 'manage_options', 'accesspress-social-login-lite', array($this, 'main_page'), APSL_IMAGE_DIR . '/icon.png' );
296
  }
 
297
  //menu page
298
  function main_page() {
299
  include( 'inc/backend/main-page.php' );
300
  }
 
301
  //registration of the backend assets
302
  function register_admin_assets() {
303
- wp_enqueue_style( 'fontawsome-css', APSL_CSS_DIR .'/font-awesome/font-awesome.min.css', '', APSL_VERSION );
304
- if( isset( $_GET['page'] ) && $_GET['page'] == 'accesspress-social-login-lite' ) {
305
  //backend scripts
306
- wp_enqueue_script( 'jquery-ui-sortable' );
307
- wp_enqueue_script( 'apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION ); //registering plugin's admin js
308
  //register backend css
309
- wp_enqueue_style( 'apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION );
310
  }
311
  }
 
312
  //registration of the plugins frontend assets
313
  function register_frontend_assets() {
314
  //register frontend scripts
315
- wp_enqueue_script( 'apsl-frontend-js', APSL_JS_DIR . '/frontend.js', array('jquery'), APSL_VERSION );
316
-
317
  //register frontend css
318
  // wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
319
- wp_enqueue_style( 'fontawsome-css', APSL_CSS_DIR .'/font-awesome/font-awesome.min.css', '', APSL_VERSION );
320
 
321
- wp_enqueue_style( 'apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION );
322
  }
 
323
  //save the settings of a plugin
324
  function save_settings() {
325
- if( isset( $_POST['apsl_save_settings'] ) && $_POST['apsl_settings_action'] && wp_verify_nonce( $_POST['apsl_settings_action'], 'apsl_nonce_save_settings' ) ) {
326
  include( 'inc/backend/save-settings.php' );
327
- }
328
- else {
329
- die( 'No script kiddies please!' );
330
  }
331
  }
 
332
  //function to add the social login in the login and registration form.
333
  function add_social_login() {
334
- if( !is_user_logged_in() ) {
335
  include( 'inc/frontend/login_integration.php' );
336
  }
337
  }
 
338
  //function to add the social login in the comment form.
339
  function add_social_login_form_to_comment() {
340
- $options = get_option( APSL_SETTINGS );
341
  $login_text = $options['apsl_title_text_field'];
342
- if( !is_user_logged_in() ) {
343
- echo do_shortcode( "[apsl-login-lite login_text='{$login_text}']" );
344
  }
345
  }
 
346
  //function for adding shortcode of a plugin
347
- function apsl_shortcode( $attr ) {
348
  ob_start();
349
  include( 'inc/frontend/shortcode.php' );
350
  $html = ob_get_contents();
351
  ob_get_clean();
352
  return $html;
353
  }
 
354
  //checking of the login
355
  function login_check() {
356
  include( 'inc/frontend/login_check.php' );
357
  }
 
358
  //registration of the social login widget
359
  function register_apsl_widget() {
360
- register_widget( 'APSL_Lite_Widget' );
361
  }
362
-
363
  function apsl_login_form_enqueue_style() {
364
- wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
365
- wp_enqueue_style( 'apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION );
366
- wp_enqueue_style( 'apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION );
367
  }
368
-
369
  function apsl_login_form__enqueue_script() {
370
- wp_enqueue_script( 'apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION ); //registering plugin's admin js
371
-
372
  }
373
-
374
  function apsl_restore_default_settings() {
375
  $nonce = $_REQUEST['_wpnonce'];
376
- if( !empty( $_GET ) && wp_verify_nonce( $nonce, 'apsl-restore-default-settings-nonce' ) ) {
377
  //restore the default plugin activation settings from the activation page.
378
  include( 'inc/backend/activation.php' );
379
- $_SESSION['apsl_message'] = __( 'Settings restored Successfully.', 'accesspress-social-login-lite' );
380
- wp_redirect( admin_url() . 'admin.php?page=' . 'accesspress-social-login-lite' );
381
  exit;
382
- }
383
- else {
384
- die( 'No script kiddies please!' );
385
  }
386
  }
387
 
388
- function apsl_delete_user( $user_id ) {
389
  global $wpdb;
390
  $table_name = $apsl_userdetails = "{$wpdb->prefix}apsl_users_social_profile_details";
391
- $user_obj = get_userdata( $user_id );
392
- $result = $wpdb->delete( $table_name, array( 'user_id' => $user_id ) );
393
  }
394
- } //class termination
395
 
 
 
 
396
  }
397
  $apsl_object = new APSL_Lite_Class();
1
+ <?php
2
+
3
+ defined('ABSPATH') or die("No script kiddies please!");
4
  /*
5
  Plugin name: Social Login WordPress Plugin - AccessPress Social Login Lite
6
  Plugin URI: https://accesspressthemes.com/wordpress-plugins/accesspress-social-login-lite/
7
  Description: A plugin to add various social logins to a site.
8
+ version: 3.3.4
9
  Author: AccessPress Themes
10
  Author URI: https://accesspressthemes.com/
11
  Text Domain: accesspress-social-login-lite
12
  Domain Path: /languages/
13
  License: GPLv2 or later
14
+ */
15
  //Declearation of the necessary constants for plugin
16
+ if (!defined('APSL_VERSION')) {
17
+ define('APSL_VERSION', '3.3.4');
18
  }
19
 
20
+ if (!defined('APSL_IMAGE_DIR')) {
21
+ define('APSL_IMAGE_DIR', plugin_dir_url(__FILE__) . 'images');
22
  }
23
 
24
+ if (!defined('APSL_JS_DIR')) {
25
+ define('APSL_JS_DIR', plugin_dir_url(__FILE__) . 'js');
26
  }
27
 
28
+ if (!defined('APSL_CSS_DIR')) {
29
+ define('APSL_CSS_DIR', plugin_dir_url(__FILE__) . 'css');
30
  }
31
 
32
+ if (!defined('APSL_LANG_DIR')) {
33
+ define('APSL_LANG_DIR', basename(dirname(__FILE__)) . '/languages/');
34
  }
35
 
36
+ if (!defined('APSL_TEXT_DOMAIN')) {
37
+ define('APSL_TEXT_DOMAIN', 'accesspress-social-login-lite');
38
  }
39
 
40
+ if (!defined('APSL_SETTINGS')) {
41
+ define('APSL_SETTINGS', 'apsl-lite-settings');
42
  }
43
 
44
+ if (!defined('APSL_PLUGIN_DIR')) {
45
+ define('APSL_PLUGIN_DIR', plugin_dir_path(__FILE__));
46
  }
47
  /**
48
  * Register a widget
50
  */
51
  include_once( 'inc/backend/widget.php' );
52
 
53
+ if (version_compare(get_bloginfo('version'), '4.3.1', '>=')) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  // Redefine user notification function
55
+ if (!function_exists('wp_new_user_notification')) {
56
+
57
+ function wp_new_user_notification($user_id, $deprecated = null, $notify = 'both') {
58
+ if ($deprecated !== null) {
59
+ _deprecated_argument(__FUNCTION__, '4.3.1');
60
+ }
61
+
62
+ global $wpdb, $wp_hasher;
63
+ $user = get_userdata($user_id);
64
+ if (empty($user))
65
+ return;
66
+
67
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
68
+ // we want to reverse this for the plain text arena of emails.
69
+ $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
70
+
71
+ $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
72
+ $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
73
+ $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
74
 
75
+ @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
 
76
 
77
+ if ('admin' === $notify || empty($notify)) {
78
+ return;
79
+ }
80
+
81
+ // Generate something random for a password reset key.
82
+ $key = wp_generate_password(20, false);
83
 
84
+ /** This action is documented in wp-login.php */
85
+ do_action('retrieve_password_key', $user->user_login, $key);
86
+
87
+ // Now insert the key, hashed, into the DB.
88
+ if (empty($wp_hasher)) {
89
+ require_once ABSPATH . WPINC . '/class-phpass.php';
90
+ $wp_hasher = new PasswordHash(8, true);
91
+ }
92
+ $hashed = time() . ':' . $wp_hasher->HashPassword($key);
93
+ $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login));
94
 
95
+ $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
96
+ $message .= __('To set your password, visit the following address:') . "\r\n\r\n";
97
+ $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
98
 
99
+ $message .= wp_login_url() . "\r\n\r\n";
100
+ $message .= sprintf(__('If you have any problems, please contact us at %s.'), get_option('admin_email')) . "\r\n\r\n";
101
+ $message .= __('Adios!') . "\r\n\r\n";
 
 
 
 
102
 
103
+ wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
104
+ }
105
+
106
+ }
107
+ } else {
108
+ // for wordpress version less than 4.3.1
109
+ // Redefine user notification function
110
+ if (!function_exists('wp_new_user_notification')) {
111
 
112
+ function wp_new_user_notification($user_id, $plaintext_pass = '') {
113
+ $user = new WP_User($user_id);
114
 
115
+ $user_login = stripslashes($user->user_login);
116
+ $user_email = stripslashes($user->user_email);
117
+
118
+ $message = sprintf(__('New user registration on your site %s:'), get_option('blogname')) . "\r\n\r\n";
119
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
120
+ $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
121
+ $message .= __('Thanks!');
122
+
123
+ $headers = 'From:' . get_option('blogname') . ' <' . get_option('admin_email') . '>' . "\r\n";
124
+ @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message, $headers);
125
+
126
+ if (empty($plaintext_pass))
127
+ return;
128
+
129
+ $message = __('Hi there,') . "\r\n\r\n";
130
+ $message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
131
+ $message .= wp_login_url() . "\r\n";
132
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
133
+ $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n\r\n";
134
+ $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\r\n\r\n";
135
+ $message .= __('Thanks!');
136
+
137
+ $headers = 'From:' . get_option('blogname') . ' <' . get_option('admin_email') . '>' . "\r\n";
138
+
139
+ wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message, $headers);
140
+ }
141
+
142
+ }
143
  }
144
 
145
 
146
  // Declaration of the class
147
+ if (!class_exists('APSL_Lite_Class')) {
148
+
149
  class APSL_Lite_Class {
150
+
151
  var $apsl_settings;
152
+
153
  function __construct() {
154
+ $this->apsl_settings = get_option(APSL_SETTINGS);
155
+ add_action('init', array($this, 'session_init')); //start the session if not started yet.
156
+ register_activation_hook(__FILE__, array($this, 'plugin_activation')); //load the default setting for the plugin while activating
157
+ add_action('init', array($this, 'plugin_text_domain')); //load the plugin text domain
158
+ add_action('admin_menu', array($this, 'add_apsl_menu')); //register the plugin menu in backend
159
+ add_action('admin_enqueue_scripts', array($this, 'register_admin_assets')); //registers all the assets required for wp-admin
160
+ add_action('wp_enqueue_scripts', array($this, 'register_frontend_assets')); // registers all the assets required for the frontend
161
+ add_action('admin_post_apsl_save_options', array($this, 'save_settings')); //save settings of a plugin
162
+
163
+ $options = get_option(APSL_SETTINGS);
164
+ if ($options['apsl_enable_disable_plugin'] == 'yes') {
165
+ if (in_array("login_form", $options['apsl_display_options'])) {
166
+ add_action('login_form', array($this, 'add_social_login')); // add the social logins to the login form
167
+ add_action('woocommerce_login_form', array($this, 'add_social_login_form_to_comment'));
 
168
  }
169
+
170
+ if (in_array("register_form", $options['apsl_display_options'])) {
171
+ add_action('register_form', array($this, 'add_social_login')); //add the social logins to the registration form
172
+ add_action('after_signup_form', array($this, 'add_social_login'));
173
  }
174
+
175
+ if (in_array("comment_form", $options['apsl_display_options'])) {
176
+ add_action('comment_form_top', array($this, 'add_social_login_form_to_comment')); //add the social logins to the comment form
177
+ add_action('comment_form_must_log_in_after', array($this, 'add_social_login_form_to_comment')); // add the social login buttons if “Users must be registered and logged in to comment” checked in the discussions settings.
 
178
  }
179
  }
180
+
181
+ add_shortcode('apsl-login-lite', array($this, 'apsl_shortcode')); //adds a shortcode
182
+ add_action('init', array($this, 'login_check')); //check for the social logins
183
+ add_action('widgets_init', array($this, 'register_apsl_widget')); //register the widget of a plugin
184
+ add_action('login_enqueue_scripts', array($this, 'apsl_login_form_enqueue_style'), 10);
185
+ add_action('login_enqueue_scripts', array($this, 'apsl_login_form__enqueue_script'), 1);
186
+ add_action('admin_post_apsl_restore_default_settings', array($this, 'apsl_restore_default_settings')); //restores default settings.
187
+
188
+
189
  /**
190
  * Hook to display custom avatars
191
  */
192
+ add_filter('get_avatar', array($this, 'apsl_social_login_custom_avatar'), 10, 5);
193
 
194
  //add delete action when user is deleted from wordpress backend.
195
+ add_action('delete_user', array($this, 'apsl_delete_user'));
196
  }
197
+
198
+ function apsl_social_login_custom_avatar($avatar, $mixed, $size, $default, $alt = '') {
199
+ $options = get_option(APSL_SETTINGS);
200
  //Check if we have an user identifier
201
+ if (is_numeric($mixed) AND $mixed > 0) {
202
  $user_id = $mixed;
203
  }
204
  //Check if we have an user email
205
+ elseif (is_string($mixed) AND ( $user = get_user_by('email', $mixed) )) {
206
  $user_id = $user->ID;
207
  }
208
  //Check if we have an user object
209
+ elseif (is_object($mixed) AND property_exists($mixed, 'user_id') AND is_numeric($mixed->user_id)) {
210
  $user_id = $mixed->user_id;
211
  }
212
  //None found
214
  $user_id = null;
215
  }
216
  //User found?
217
+ if (!empty($user_id)) {
218
  //Override current avatar ?
219
  $override_avatar = true;
220
  //Read the avatar
221
+ $user_meta_thumbnail = get_user_meta($user_id, 'deuimage', true);
222
  //read user details
223
+ $user_meta_name = get_user_meta($user_id, 'first_name', true);
224
+
225
+ if ($options['apsl_user_avatar_options'] == 'social') {
226
+ $user_picture = (!empty($user_meta_thumbnail) ? $user_meta_thumbnail : '' );
227
  //Avatar found?
228
+ if ($user_picture !== false AND strlen(trim($user_picture)) > 0) {
229
  return '<img alt="' . $user_meta_name . '" src="' . $user_picture . '" class="avatar apsl-avatar-social-login avatar-' . $size . ' photo" height="' . $size . '" width="' . $size . '" />';
230
  }
231
  }
232
  }
233
  return $avatar;
234
  }
235
+
236
  //starts the session with the call of init hook
237
  function session_init() {
238
+ if (!session_id() && !headers_sent()) {
239
  session_start();
240
  }
241
  }
242
+
243
  //load the default settings of the plugin
244
  function plugin_activation() {
245
+ if (!get_option(APSL_SETTINGS)) {
246
  include( 'inc/backend/activation.php' );
247
  }
248
  self:: apsl_database_install();
287
  KEY user_id (user_id),
288
  KEY provider_name (provider_name)
289
  )";
290
+ dbDelta($sql);
291
  }
292
 
293
  //loads the text domain for translation
294
  function plugin_text_domain() {
295
+ load_plugin_textdomain('accesspress-social-login-lite', false, APSL_LANG_DIR);
296
  }
297
+
298
  //register the plugin menu for backend.
299
  function add_apsl_menu() {
300
+ add_menu_page('AccessPress Social Login Lite', 'AccessPress Social Login Lite', 'manage_options', 'accesspress-social-login-lite', array($this, 'main_page'), APSL_IMAGE_DIR . '/icon.png');
301
  }
302
+
303
  //menu page
304
  function main_page() {
305
  include( 'inc/backend/main-page.php' );
306
  }
307
+
308
  //registration of the backend assets
309
  function register_admin_assets() {
310
+ wp_enqueue_style('fontawsome-css', APSL_CSS_DIR . '/font-awesome/font-awesome.min.css', '', APSL_VERSION);
311
+ if (isset($_GET['page']) && $_GET['page'] == 'accesspress-social-login-lite') {
312
  //backend scripts
313
+ wp_enqueue_script('jquery-ui-sortable');
314
+ wp_enqueue_script('apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION); //registering plugin's admin js
315
  //register backend css
316
+ wp_enqueue_style('apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION);
317
  }
318
  }
319
+
320
  //registration of the plugins frontend assets
321
  function register_frontend_assets() {
322
  //register frontend scripts
323
+ wp_enqueue_script('apsl-frontend-js', APSL_JS_DIR . '/frontend.js', array('jquery'), APSL_VERSION);
324
+
325
  //register frontend css
326
  // wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
327
+ wp_enqueue_style('fontawsome-css', APSL_CSS_DIR . '/font-awesome/font-awesome.min.css', '', APSL_VERSION);
328
 
329
+ wp_enqueue_style('apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION);
330
  }
331
+
332
  //save the settings of a plugin
333
  function save_settings() {
334
+ if (isset($_POST['apsl_save_settings']) && $_POST['apsl_settings_action'] && wp_verify_nonce($_POST['apsl_settings_action'], 'apsl_nonce_save_settings')) {
335
  include( 'inc/backend/save-settings.php' );
336
+ } else {
337
+ die('No script kiddies please!');
 
338
  }
339
  }
340
+
341
  //function to add the social login in the login and registration form.
342
  function add_social_login() {
343
+ if (!is_user_logged_in()) {
344
  include( 'inc/frontend/login_integration.php' );
345
  }
346
  }
347
+
348
  //function to add the social login in the comment form.
349
  function add_social_login_form_to_comment() {
350
+ $options = get_option(APSL_SETTINGS);
351
  $login_text = $options['apsl_title_text_field'];
352
+ if (!is_user_logged_in()) {
353
+ echo do_shortcode("[apsl-login-lite login_text='{$login_text}']");
354
  }
355
  }
356
+
357
  //function for adding shortcode of a plugin
358
+ function apsl_shortcode($attr) {
359
  ob_start();
360
  include( 'inc/frontend/shortcode.php' );
361
  $html = ob_get_contents();
362
  ob_get_clean();
363
  return $html;
364
  }
365
+
366
  //checking of the login
367
  function login_check() {
368
  include( 'inc/frontend/login_check.php' );
369
  }
370
+
371
  //registration of the social login widget
372
  function register_apsl_widget() {
373
+ register_widget('APSL_Lite_Widget');
374
  }
375
+
376
  function apsl_login_form_enqueue_style() {
377
+ wp_enqueue_style('fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION);
378
+ wp_enqueue_style('apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION);
379
+ wp_enqueue_style('apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION);
380
  }
381
+
382
  function apsl_login_form__enqueue_script() {
383
+ wp_enqueue_script('apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION); //registering plugin's admin js
 
384
  }
385
+
386
  function apsl_restore_default_settings() {
387
  $nonce = $_REQUEST['_wpnonce'];
388
+ if (!empty($_GET) && wp_verify_nonce($nonce, 'apsl-restore-default-settings-nonce')) {
389
  //restore the default plugin activation settings from the activation page.
390
  include( 'inc/backend/activation.php' );
391
+ $_SESSION['apsl_message'] = __('Settings restored Successfully.', 'accesspress-social-login-lite');
392
+ wp_redirect(admin_url() . 'admin.php?page=' . 'accesspress-social-login-lite');
393
  exit;
394
+ } else {
395
+ die('No script kiddies please!');
 
396
  }
397
  }
398
 
399
+ function apsl_delete_user($user_id) {
400
  global $wpdb;
401
  $table_name = $apsl_userdetails = "{$wpdb->prefix}apsl_users_social_profile_details";
402
+ $user_obj = get_userdata($user_id);
403
+ $result = $wpdb->delete($table_name, array('user_id' => $user_id));
404
  }
 
405
 
406
+ }
407
+
408
+ //class termination
409
  }
410
  $apsl_object = new APSL_Lite_Class();
facebook/Exceptions/FacebookResumableUploadException.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
- namespace Facebook\Exceptions;
25
-
26
- /**
27
- * Class FacebookResumableUploadException
28
- *
29
- * @package Facebook
30
- */
31
- class FacebookResumableUploadException extends FacebookSDKException
32
- {
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook/FileUpload/FacebookResumableUploader.php DELETED
@@ -1,167 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
- namespace Facebook\FileUpload;
25
-
26
- use Facebook\Authentication\AccessToken;
27
- use Facebook\Exceptions\FacebookResponseException;
28
- use Facebook\Exceptions\FacebookResumableUploadException;
29
- use Facebook\Exceptions\FacebookSDKException;
30
- use Facebook\FacebookApp;
31
- use Facebook\FacebookClient;
32
- use Facebook\FacebookRequest;
33
-
34
- /**
35
- * Class FacebookResumableUploader
36
- *
37
- * @package Facebook
38
- */
39
- class FacebookResumableUploader
40
- {
41
- /**
42
- * @var FacebookApp
43
- */
44
- protected $app;
45
-
46
- /**
47
- * @var string
48
- */
49
- protected $accessToken;
50
-
51
- /**
52
- * @var FacebookClient The Facebook client service.
53
- */
54
- protected $client;
55
-
56
- /**
57
- * @var string Graph version to use for this request.
58
- */
59
- protected $graphVersion;
60
-
61
- /**
62
- * @param FacebookApp $app
63
- * @param FacebookClient $client
64
- * @param AccessToken|string|null $accessToken
65
- * @param string $graphVersion
66
- */
67
- public function __construct(FacebookApp $app, FacebookClient $client, $accessToken, $graphVersion)
68
- {
69
- $this->app = $app;
70
- $this->client = $client;
71
- $this->accessToken = $accessToken;
72
- $this->graphVersion = $graphVersion;
73
- }
74
-
75
- /**
76
- * Upload by chunks - start phase
77
- *
78
- * @param string $endpoint
79
- * @param FacebookFile $file
80
- *
81
- * @return FacebookTransferChunk
82
- *
83
- * @throws FacebookSDKException
84
- */
85
- public function start($endpoint, FacebookFile $file)
86
- {
87
- $params = [
88
- 'upload_phase' => 'start',
89
- 'file_size' => $file->getSize(),
90
- ];
91
- $response = $this->sendUploadRequest($endpoint, $params);
92
-
93
- return new FacebookTransferChunk($file, $response['upload_session_id'], $response['video_id'], $response['start_offset'], $response['end_offset']);
94
- }
95
-
96
- /**
97
- * Upload by chunks - transfer phase
98
- *
99
- * @param string $endpoint
100
- * @param FacebookTransferChunk $chunk
101
- * @param boolean $allowToThrow
102
- *
103
- * @return FacebookTransferChunk
104
- *
105
- * @throws FacebookResponseException
106
- */
107
- public function transfer($endpoint, FacebookTransferChunk $chunk, $allowToThrow = false)
108
- {
109
- $params = [
110
- 'upload_phase' => 'transfer',
111
- 'upload_session_id' => $chunk->getUploadSessionId(),
112
- 'start_offset' => $chunk->getStartOffset(),
113
- 'video_file_chunk' => $chunk->getPartialFile(),
114
- ];
115
-
116
- try {
117
- $response = $this->sendUploadRequest($endpoint, $params);
118
- } catch (FacebookResponseException $e) {
119
- $preException = $e->getPrevious();
120
- if ($allowToThrow || !$preException instanceof FacebookResumableUploadException) {
121
- throw $e;
122
- }
123
-
124
- // Return the same chunk entity so it can be retried.
125
- return $chunk;
126
- }
127
-
128
- return new FacebookTransferChunk($chunk->getFile(), $chunk->getUploadSessionId(), $chunk->getVideoId(), $response['start_offset'], $response['end_offset']);
129
- }
130
-
131
- /**
132
- * Upload by chunks - finish phase
133
- *
134
- * @param string $endpoint
135
- * @param string $uploadSessionId
136
- * @param array $metadata The metadata associated with the file.
137
- *
138
- * @return boolean
139
- *
140
- * @throws FacebookSDKException
141
- */
142
- public function finish($endpoint, $uploadSessionId, $metadata = [])
143
- {
144
- $params = array_merge($metadata, [
145
- 'upload_phase' => 'finish',
146
- 'upload_session_id' => $uploadSessionId,
147
- ]);
148
- $response = $this->sendUploadRequest($endpoint, $params);
149
-
150
- return $response['success'];
151
- }
152
-
153
- /**
154
- * Helper to make a FacebookRequest and send it.
155
- *
156
- * @param string $endpoint The endpoint to POST to.
157
- * @param array $params The params to send with the request.
158
- *
159
- * @return array
160
- */
161
- private function sendUploadRequest($endpoint, $params = [])
162
- {
163
- $request = new FacebookRequest($this->app, $this->accessToken, 'POST', $endpoint, $params, null, $this->graphVersion);
164
-
165
- return $this->client->sendRequest($request)->getDecodedBody();
166
- }
167
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook/FileUpload/FacebookTransferChunk.php DELETED
@@ -1,133 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
- namespace Facebook\FileUpload;
25
-
26
- /**
27
- * Class FacebookTransferChunk
28
- *
29
- * @package Facebook
30
- */
31
- class FacebookTransferChunk
32
- {
33
- /**
34
- * @var FacebookFile The file to chunk during upload.
35
- */
36
- private $file;
37
-
38
- /**
39
- * @var int The ID of the upload session.
40
- */
41
- private $uploadSessionId;
42
-
43
- /**
44
- * @var int Start byte position of the next file chunk.
45
- */
46
- private $startOffset;
47
-
48
- /**
49
- * @var int End byte position of the next file chunk.
50
- */
51
- private $endOffset;
52
-
53
- /**
54
- * @var int The ID of the video.
55
- */
56
- private $videoId;
57
-
58
- /**
59
- * @param FacebookFile $file
60
- * @param int $uploadSessionId
61
- * @param int $videoId
62
- * @param int $startOffset
63
- * @param int $endOffset
64
- */
65
- public function __construct(FacebookFile $file, $uploadSessionId, $videoId, $startOffset, $endOffset)
66
- {
67
- $this->file = $file;
68
- $this->uploadSessionId = $uploadSessionId;
69
- $this->videoId = $videoId;
70
- $this->startOffset = $startOffset;
71
- $this->endOffset = $endOffset;
72
- }
73
-
74
- /**
75
- * Return the file entity.
76
- *
77
- * @return FacebookFile
78
- */
79
- public function getFile()
80
- {
81
- return $this->file;
82
- }
83
-
84
- /**
85
- * Return a FacebookFile entity with partial content.
86
- *
87
- * @return FacebookFile
88
- */
89
- public function getPartialFile()
90
- {
91
- $maxLength = $this->endOffset - $this->startOffset;
92
-
93
- return new FacebookFile($this->file->getFilePath(), $maxLength, $this->startOffset);
94
- }
95
-
96
- /**
97
- * Return upload session Id
98
- *
99
- * @return int
100
- */
101
- public function getUploadSessionId()
102
- {
103
- return $this->uploadSessionId;
104
- }
105
-
106
- /**
107
- * Check whether is the last chunk
108
- *
109
- * @return bool
110
- */
111
- public function isLastChunk()
112
- {
113
- return $this->startOffset === $this->endOffset;
114
- }
115
-
116
- /**
117
- * @return int
118
- */
119
- public function getStartOffset()
120
- {
121
- return $this->startOffset;
122
- }
123
-
124
- /**
125
- * Get uploaded video Id
126
- *
127
- * @return int
128
- */
129
- public function getVideoId()
130
- {
131
- return $this->videoId;
132
- }
133
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook/GraphNodes/Birthday.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
- namespace Facebook\GraphNodes;
25
-
26
- use DateTime;
27
-
28
- /**
29
- * Birthday object to handle various Graph return formats
30
- *
31
- * @package Facebook
32
- */
33
- class Birthday extends DateTime
34
- {
35
- /**
36
- * @var bool
37
- */
38
- private $hasDate = false;
39
-
40
- /**
41
- * @var bool
42
- */
43
- private $hasYear = false;
44
-
45
- /**
46
- * Parses Graph birthday format to set indication flags, possible values:
47
- *
48
- * MM/DD/YYYY
49
- * MM/DD
50
- * YYYY
51
- *
52
- * @link https://developers.facebook.com/docs/graph-api/reference/user
53
- *
54
- * @param string $date
55
- */
56
- public function __construct($date)
57
- {
58
- $parts = explode('/', $date);
59
-
60
- $this->hasYear = count($parts) === 3 || count($parts) === 1;
61
- $this->hasDate = count($parts) === 3 || count($parts) === 2;
62
-
63
- parent::__construct($date);
64
- }
65
-
66
- /**
67
- * Returns whether date object contains birth day and month
68
- *
69
- * @return bool
70
- */
71
- public function hasDate()
72
- {
73
- return $this->hasDate;
74
- }
75
-
76
- /**
77
- * Returns whether date object contains birth year
78
- *
79
- * @return bool
80
- */
81
- public function hasYear()
82
- {
83
- return $this->hasYear;
84
- }
85
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook/HttpClients/HttpClientsFactory.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
- namespace Facebook\HttpClients;
25
-
26
- use GuzzleHttp\Client;
27
- use InvalidArgumentException;
28
- use Exception;
29
-
30
- class HttpClientsFactory
31
- {
32
- private function __construct()
33
- {
34
- // a factory constructor should never be invoked
35
- }
36
-
37
- /**
38
- * HTTP client generation.
39
- *
40
- * @param FacebookHttpClientInterface|Client|string|null $handler
41
- *
42
- * @throws Exception If the cURL extension or the Guzzle client aren't available (if required).
43
- * @throws InvalidArgumentException If the http client handler isn't "curl", "stream", "guzzle", or an instance of Facebook\HttpClients\FacebookHttpClientInterface.
44
- *
45
- * @return FacebookHttpClientInterface
46
- */
47
- public static function createHttpClient($handler)
48
- {
49
- if (!$handler) {
50
- return self::detectDefaultClient();
51
- }
52
-
53
- if ($handler instanceof FacebookHttpClientInterface) {
54
- return $handler;
55
- }
56
-
57
- if ('stream' === $handler) {
58
- return new FacebookStreamHttpClient();
59
- }
60
- if ('curl' === $handler) {
61
- if (!extension_loaded('curl')) {
62
- throw new Exception('The cURL extension must be loaded in order to use the "curl" handler.');
63
- }
64
-
65
- return new FacebookCurlHttpClient();
66
- }
67
-
68
- if ('guzzle' === $handler && !class_exists('GuzzleHttp\Client')) {
69
- throw new Exception('The Guzzle HTTP client must be included in order to use the "guzzle" handler.');
70
- }
71
-
72
- if ($handler instanceof Client) {
73
- return new FacebookGuzzleHttpClient($handler);
74
- }
75
- if ('guzzle' === $handler) {
76
- return new FacebookGuzzleHttpClient();
77
- }
78
-
79
- throw new InvalidArgumentException('The http client handler must be set to "curl", "stream", "guzzle", be an instance of GuzzleHttp\Client or an instance of Facebook\HttpClients\FacebookHttpClientInterface');
80
- }
81
-
82
- /**
83
- * Detect default HTTP client.
84
- *
85
- * @return FacebookHttpClientInterface
86
- */
87
- private static function detectDefaultClient()
88
- {
89
- if (extension_loaded('curl')) {
90
- return new FacebookCurlHttpClient();
91
- }
92
-
93
- if (class_exists('GuzzleHttp\Client')) {
94
- return new FacebookGuzzleHttpClient();
95
- }
96
-
97
- return new FacebookStreamHttpClient();
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook/PersistentData/PersistentDataFactory.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
- namespace Facebook\PersistentData;
25
-
26
- use InvalidArgumentException;
27
-
28
- class PersistentDataFactory
29
- {
30
- private function __construct()
31
- {
32
- // a factory constructor should never be invoked
33
- }
34
-
35
- /**
36
- * PersistentData generation.
37
- *
38
- * @param PersistentDataInterface|string|null $handler
39
- *
40
- * @throws InvalidArgumentException If the persistent data handler isn't "session", "memory", or an instance of Facebook\PersistentData\PersistentDataInterface.
41
- *
42
- * @return PersistentDataInterface
43
- */
44
- public static function createPersistentDataHandler($handler)
45
- {
46
- if (!$handler) {
47
- return session_status() === PHP_SESSION_ACTIVE
48
- ? new FacebookSessionPersistentDataHandler()
49
- : new FacebookMemoryPersistentDataHandler();
50
- }
51
-
52
- if ($handler instanceof PersistentDataInterface) {
53
- return $handler;
54
- }
55
-
56
- if ('session' === $handler) {
57
- return new FacebookSessionPersistentDataHandler();
58
- }
59
- if ('memory' === $handler) {
60
- return new FacebookMemoryPersistentDataHandler();
61
- }
62
-
63
- throw new InvalidArgumentException('The persistent data handler must be set to "session", "memory", or be an instance of Facebook\PersistentData\PersistentDataInterface');
64
- }
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook/PseudoRandomString/PseudoRandomStringGeneratorFactory.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
- namespace Facebook\PseudoRandomString;
25
-
26
- use Facebook\Exceptions\FacebookSDKException;
27
- use InvalidArgumentException;
28
-
29
- class PseudoRandomStringGeneratorFactory
30
- {
31
- private function __construct()
32
- {
33
- // a factory constructor should never be invoked
34
- }
35
-
36
- /**
37
- * Pseudo random string generator creation.
38
- *
39
- * @param PseudoRandomStringGeneratorInterface|string|null $generator
40
- *
41
- * @throws InvalidArgumentException If the pseudo random string generator must be set to "random_bytes", "mcrypt", "openssl", or "urandom", or be an instance of Facebook\PseudoRandomString\PseudoRandomStringGeneratorInterface.
42
- *
43
- * @return PseudoRandomStringGeneratorInterface
44
- */
45
- public static function createPseudoRandomStringGenerator($generator)
46
- {
47
- if (!$generator) {
48
- return self::detectDefaultPseudoRandomStringGenerator();
49
- }
50
-
51
- if ($generator instanceof PseudoRandomStringGeneratorInterface) {
52
- return $generator;
53
- }
54
-
55
- if ('random_bytes' === $generator) {
56
- return new RandomBytesPseudoRandomStringGenerator();
57
- }
58
- if ('mcrypt' === $generator) {
59
- return new McryptPseudoRandomStringGenerator();
60
- }
61
- if ('openssl' === $generator) {
62
- return new OpenSslPseudoRandomStringGenerator();
63
- }
64
- if ('urandom' === $generator) {
65
- return new UrandomPseudoRandomStringGenerator();
66
- }
67
-
68
- throw new InvalidArgumentException('The pseudo random string generator must be set to "random_bytes", "mcrypt", "openssl", or "urandom", or be an instance of Facebook\PseudoRandomString\PseudoRandomStringGeneratorInterface');
69
- }
70
-
71
- /**
72
- * Detects which pseudo-random string generator to use.
73
- *
74
- * @throws FacebookSDKException If unable to detect a cryptographically secure pseudo-random string generator.
75
- *
76
- * @return PseudoRandomStringGeneratorInterface
77
- */
78
- private static function detectDefaultPseudoRandomStringGenerator()
79
- {
80
- // Check for PHP 7's CSPRNG first to keep mcrypt deprecation messages from appearing in PHP 7.1.
81
- if (function_exists('random_bytes')) {
82
- return new RandomBytesPseudoRandomStringGenerator();
83
- }
84
-
85
- // Since openssl_random_pseudo_bytes() can sometimes return non-cryptographically
86
- // secure pseudo-random strings (in rare cases), we check for mcrypt_create_iv() next.
87
- if (function_exists('mcrypt_create_iv')) {
88
- return new McryptPseudoRandomStringGenerator();
89
- }
90
-
91
- if (function_exists('openssl_random_pseudo_bytes')) {
92
- return new OpenSslPseudoRandomStringGenerator();
93
- }
94
-
95
- if (!ini_get('open_basedir') && is_readable('/dev/urandom')) {
96
- return new UrandomPseudoRandomStringGenerator();
97
- }
98
-
99
- throw new FacebookSDKException('Unable to detect a cryptographically secure pseudo-random string generator.');
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook/PseudoRandomString/RandomBytesPseudoRandomStringGenerator.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
- namespace Facebook\PseudoRandomString;
25
-
26
- use Facebook\Exceptions\FacebookSDKException;
27
-
28
- class RandomBytesPseudoRandomStringGenerator implements PseudoRandomStringGeneratorInterface
29
- {
30
- use PseudoRandomStringGeneratorTrait;
31
-
32
- /**
33
- * @const string The error message when generating the string fails.
34
- */
35
- const ERROR_MESSAGE = 'Unable to generate a cryptographically secure pseudo-random string from random_bytes(). ';
36
-
37
- /**
38
- * @throws FacebookSDKException
39
- */
40
- public function __construct()
41
- {
42
- if (!function_exists('random_bytes')) {
43
- throw new FacebookSDKException(
44
- static::ERROR_MESSAGE .
45
- 'The function random_bytes() does not exist.'
46
- );
47
- }
48
- }
49
-
50
- /**
51
- * @inheritdoc
52
- */
53
- public function getPseudoRandomString($length)
54
- {
55
- $this->validateLength($length);
56
-
57
- return $this->binToHex(random_bytes($length), $length);
58
- }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook/polyfills.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2017 Facebook, Inc.
4
- *
5
- * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
- * use, copy, modify, and distribute this software in source code or binary
7
- * form for use in connection with the web services and APIs provided by
8
- * Facebook.
9
- *
10
- * As with any software that integrates with the Facebook platform, your use
11
- * of this software is subject to the Facebook Developer Principles and
12
- * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
- * shall be included in all copies or substantial portions of the software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- *
23
- */
24
-
25
- /**
26
- * @see https://github.com/sarciszewski/php-future/blob/master/src/Security.php#L37-L51
27
- */
28
- if (!function_exists('hash_equals')) {
29
- function hash_equals($knownString, $userString)
30
- {
31
- if (function_exists('mb_strlen')) {
32
- $kLen = mb_strlen($knownString, '8bit');
33
- $uLen = mb_strlen($userString, '8bit');
34
- } else {
35
- $kLen = strlen($knownString);
36
- $uLen = strlen($userString);
37
- }
38
- if ($kLen !== $uLen) {
39
- return false;
40
- }
41
- $result = 0;
42
- for ($i = 0; $i < $kLen; $i++) {
43
- $result |= (ord($knownString[$i]) ^ ord($userString[$i]));
44
- }
45
-
46
- // They are only identical strings if $result is exactly 0...
47
- return 0 === $result;
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/frontend/login_check.php CHANGED
@@ -1,99 +1,102 @@
1
  <?php
2
- defined( 'ABSPATH' ) or die( "No script kiddies please!" );
3
 
4
- if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
 
 
5
 
6
  class APSL_Lite_Login_Check_Class {
 
7
  //constructor
8
  function __construct() {
9
 
10
- if( isset( $_GET['apsl_login_id'] ) ) {
11
- if( isset( $_REQUEST['state'] ) ) {
12
- parse_str( base64_decode( $_REQUEST['state'] ), $state_vars );
13
 
14
- if( isset( $state_vars['redirect_to'] ) ) {
15
  $_GET['redirect_to'] = $_REQUEST['redirect_to'] = $state_vars['redirect_to'];
16
  }
17
  }
18
 
19
- $exploder = explode( '_', $_GET['apsl_login_id'] );
20
- switch( $exploder[0] ) {
21
  case 'facebook':
22
- if( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
23
- echo _e( 'The Facebook SDK requires PHP version 5.4 or higher. Please notify about this error to site admin.', 'accesspress-social-login-lite' );
24
  die();
25
  }
26
  $this->onFacebookLogin();
27
- break;
28
  case 'twitter':
29
- if( !class_exists( 'TwitterOAuth' ) ) {
30
  include( APSL_PLUGIN_DIR . 'twitter/OAuth.php' );
31
  include( APSL_PLUGIN_DIR . 'twitter/twitteroauth.php' );
32
  }
33
  $this->onTwitterLogin();
34
- break;
35
  case 'google':
36
- if( !class_exists( 'Google_Client' ) ) {
37
- include( APSL_PLUGIN_DIR . 'google/Client.php' );
38
- }
39
- if(!class_exists('Google_Service_Plus')){
40
- include( APSL_PLUGIN_DIR . 'google/Service/Plus.php' );
41
- }
42
  $this->onGoogleLogin();
43
- break;
44
  }
45
  }
46
  }
 
47
  //for facebook login
48
  function onFacebookLogin() {
49
  $response = new stdClass();
50
- $result = $this->facebookLogin( $response );
51
- if( isset( $result->status ) && $result->status == 'SUCCESS' ) {
52
  global $wpdb;
53
- $unique_verifier = sha1($result->deutype.$result->deuid);
54
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `provider_name` LIKE '$result->deutype' AND `identifier` LIKE '$result->deuid' AND `unique_verifier` LIKE '$unique_verifier'";
55
  $row = $wpdb->get_row($sql);
56
- if( !$row ) {
57
  //check if there is already a user with the email address provided from social login already
58
  $user_details_by_email = $this->getUserByMail($result->email);
59
- if( $user_details_by_email != false ){
60
  //user already there so log him in
61
  $id = $user_details_by_email->ID;
62
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `user_id` LIKE '$id'; ";
63
  $row = $wpdb->get_row($sql);
64
- if(!$row){
65
- self:: link_user($id, $result);
66
  }
67
- self:: loginUser( $id );
68
  die();
69
  }
70
- $_SESSION['user_details']= $result;
71
-
72
  // use FB id as username if sanitized username is empty
73
- $sanitized_user_name = sanitize_user( $result->username, true );
74
- if ( empty( $sanitized_user_name ) ) {
75
- $sanitized_user_name = $result->deuid;
76
  }
77
- $user_Id = self::creatUser( $sanitized_user_name, $result->email );
78
- $user_row = self:: getUserByMail( $result->email );
79
  $id = $user_row->ID;
80
  $result = $result;
81
  $role = 'subscriber';
82
- self:: UpdateUserMeta( $id, $result, $role );
83
- self:: loginUser( $id );
84
  exit();
85
- }else{
86
- if( ($row->provider_name == $result->deutype) && ($row->identifier == $result->deuid) ){
87
  //echo "user found in our database";
88
- self:: loginUser( $row->user_id );
89
  exit();
90
- }else{
91
  // user not found in our database
92
  // need to handle an exception
93
  }
94
  }
95
- }else{
96
- if(isset($_REQUEST['error'])){
97
  $_SESSION['apsl_login_error_flag'] = 1;
98
  $redirect_url = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();
99
  $this->redirect($redirect_url);
@@ -101,337 +104,322 @@ if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
101
  die();
102
  }
103
  }
104
-
105
  function facebookLogin() {
106
  $request = $_REQUEST;
107
  $site = $this->siteUrl();
108
  $callBackUrl = $this->callBackUrl();
109
  $response = new stdClass();
110
  $return_user_details = new stdClass();
111
- $exploder = explode( '_', $_GET['apsl_login_id'] );
112
  $action = $exploder[1];
113
- $options = get_option( APSL_SETTINGS );
114
- if(isset($options['apsl_facebook_settings']['apsl_profile_image_width'])){
115
- $width = $options['apsl_facebook_settings']['apsl_profile_image_width'];
116
- }else{
117
- $width = 150;
118
  }
119
 
120
- if(isset($options['apsl_facebook_settings']['apsl_profile_image_height'])){
121
  $height = $options['apsl_facebook_settings']['apsl_profile_image_height'];
122
- }else{
123
  $height = 150;
124
  }
125
 
126
- $config = array('app_id' => $options['apsl_facebook_settings']['apsl_facebook_app_id'], 'app_secret' => $options['apsl_facebook_settings']['apsl_facebook_app_secret'], 'default_graph_version' => 'v2.4', 'persistent_data_handler' => 'session' );
127
  include( APSL_PLUGIN_DIR . 'facebook/autoload.php' );
128
- $fb = new Facebook\Facebook( $config );
129
 
130
  $callback = $callBackUrl . 'apsl_login_id' . '=facebook_check';
131
 
132
- if( $action == 'login' ) {
133
  // Well looks like we are a fresh dude, login to Facebook!
134
  $helper = $fb->getRedirectLoginHelper();
135
  $permissions = array('email', 'public_profile'); // optional
136
- $loginUrl = $helper->getLoginUrl( $callback, $permissions );
137
 
138
- $encoded_url = isset( $_GET['redirect_to'] ) ? $_GET['redirect_to'] : '';
139
- if( isset( $encoded_url ) && $encoded_url != '' ) {
140
- setcookie("apsl_login_redirect_url", $encoded_url, time()+3600);
141
  // $callback = $callBackUrl . 'apsl_login_id' . '=facebook_check&redirect_to=' . $encoded_url;
142
  }
143
- $this->redirect( $loginUrl );
144
- }
145
- else {
146
- if( isset( $_REQUEST['error'] ) ) {
147
  $response->status = 'ERROR';
148
  $response->error_code = 2;
149
  $response->error_message = 'INVALID AUTHORIZATION';
150
  return $response;
151
  die();
152
  }
153
- if( isset( $_REQUEST['code'] ) ) {
154
  $helper = $fb->getRedirectLoginHelper();
155
  // Trick below will avoid "Cross-site request forgery validation failed. Required param "state" missing." from Facebook
156
  $_SESSION['FBRLH_state'] = $_REQUEST['state'];
157
  try {
158
  $accessToken = $helper->getAccessToken($callback);
159
- }
160
- catch( Facebook\Exceptions\FacebookResponseException $e ) {
161
  // When Graph returns an error
162
  echo 'Graph returned an error: ' . $e->getMessage();
163
  exit;
164
- }
165
- catch( Facebook\Exceptions\FacebookSDKException $e ) {
166
  // When validation fails or other local issues
167
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
168
  exit;
169
  }
170
-
171
- if( isset( $accessToken ) ) {
172
  // Logged in!
173
- $_SESSION['facebook_access_token'] = (string)$accessToken;
174
- $fb->setDefaultAccessToken( $accessToken );
175
 
176
  try {
177
- $response = $fb->get( '/me?fields=email,name, first_name, last_name, gender, link, about, birthday, education, hometown, is_verified, languages, location, website' );
178
  $userNode = $response->getGraphUser();
179
- }
180
- catch( Facebook\Exceptions\FacebookResponseException $e ) {
181
  // When Graph returns an error
182
  echo 'Graph returned an error: ' . $e->getMessage();
183
  exit;
184
- }
185
- catch( Facebook\Exceptions\FacebookSDKException $e ) {
186
  // When validation fails or other local issues
187
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
188
  exit;
189
  }
190
  // get the user profile details
191
- $user_profile = $this->accessProtected( $userNode, 'items' );
192
- if( $user_profile != null ) {
193
  $return_user_details->status = 'SUCCESS';
194
  $return_user_details->deuid = $user_profile['id'];
195
  $return_user_details->deutype = 'facebook';
196
  $return_user_details->first_name = $user_profile['first_name'];
197
  $return_user_details->last_name = $user_profile['last_name'];
198
- if(isset($user_profile['email']) || $user_profile['email'] != ''){
199
  $user_email = $user_profile['email'];
200
- }else{
201
- $user_email = $user_profile['id'].'@facebook.com';
202
  }
203
  $return_user_details->email = $user_email;
204
- $return_user_details->username = ($user_profile['first_name'] !='') ? strtolower( $user_profile['first_name'] ) : $user_email;
205
  $return_user_details->gender = isset($user_profile['gender']) ? $user_profile['gender'] : 'N/A';
206
  $return_user_details->url = $user_profile['link'];
207
  $return_user_details->about = ''; //facebook doesn't return user about details.
208
- $headers = get_headers( 'https://graph.facebook.com/' . $user_profile['id'] . '/picture?width='.$width.'&height='.$height, 1 );
209
  // just a precaution, check whether the header isset...
210
- if( isset( $headers['Location'] ) ) {
211
  $return_user_details->deuimage = $headers['Location']; // string
212
-
213
- }
214
- else {
215
  $return_user_details->deuimage = false; // nothing there? .. weird, but okay!
216
-
217
  }
218
  $return_user_details->error_message = '';
219
- }
220
- else {
221
  $return_user_details->status = 'ERROR';
222
  $return_user_details->error_code = 2;
223
  $return_user_details->error_message = 'INVALID AUTHORIZATION';
224
  }
225
  }
226
- }
227
- else {
228
  // Well looks like we are a fresh dude, login to Facebook!
229
  $helper = $fb->getRedirectLoginHelper();
230
  $permissions = array('email', 'public_profile'); // optional
231
- $loginUrl = $helper->getLoginUrl( $callback, $permissions );
232
- $this->redirect( $loginUrl );
233
  }
234
  }
235
  return $return_user_details;
236
  }
 
237
  //for twitter login
238
  function onTwitterLogin() {
239
  $result = $this->twitterLogin();
240
- if( isset( $result->status ) && $result->status == 'SUCCESS' ) {
241
  global $wpdb;
242
- $unique_verifier = sha1($result->deutype.$result->deuid);
243
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `provider_name` LIKE '$result->deutype' AND `identifier` LIKE '$result->deuid' AND `unique_verifier` LIKE '$unique_verifier'";
244
  $row = $wpdb->get_row($sql);
245
- if( !$row ) {
246
  //check if there is already a user with the email address provided from social login already
247
  $user_details_by_email = $this->getUserByMail($result->email);
248
- if( $user_details_by_email != false ){
249
  //user already there so log him in
250
  $id = $user_details_by_email->ID;
251
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `user_id` LIKE '$id'; ";
252
  $row = $wpdb->get_row($sql);
253
  // var_dump($row);
254
- if(!$row){
255
- self:: link_user($id, $result);
256
  }
257
- self:: loginUser( $id );
258
  die();
259
  }
260
- $_SESSION['user_details']= $result;
261
- self::creatUser( $result->username, $result->email );
262
- $user_row = self:: getUserByMail( $result->email );
263
  $id = $user_row->ID;
264
  $result = $result;
265
  $role = 'subscriber';
266
- self:: UpdateUserMeta( $id, $result, $role );
267
- self:: loginUser( $id );
268
  exit();
269
- }else{
270
- if( ($row->provider_name == $result->deutype) && ($row->identifier == $result->deuid) ){
271
  //echo "user found in our database";
272
- self:: loginUser( $row->user_id );
273
  exit();
274
- }else{
275
  // user not found in our database
276
  // need to handle an exception
277
  }
278
  }
279
- $_SESSION['apsl_login_error_flag'] = 1;
280
- }else{
281
- if(isset($_REQUEST['denied'])){
282
  $redirect_url = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();
283
  $this->redirect($redirect_url);
284
  }
285
  die();
286
  }
287
  }
288
-
289
  function twitterLogin() {
290
  $request = $_REQUEST;
291
  $site = $this->siteUrl();
292
  $callBackUrl = $this->callBackUrl();
293
  $response = new stdClass();
294
- $exploder = explode( '_', $_GET['apsl_login_id'] );
295
  $action = $exploder[1];
296
  @session_start();
297
- $options = get_option( APSL_SETTINGS );
298
- if( $action == 'login' ) {
299
  // Get identity from user and redirect browser to OpenID Server
300
- if( !isset( $request['oauth_token'] ) || $request['oauth_token'] == '' ) {
301
- $twitterObj = new TwitterOAuth( $options['apsl_twitter_settings']['apsl_twitter_api_key'], $options['apsl_twitter_settings']['apsl_twitter_api_secret'] );
302
- $encoded_url = isset( $_GET['redirect_to'] ) ? $_GET['redirect_to'] : '';
303
- if( isset( $encoded_url ) && $encoded_url != '' ) {
304
  $callback = $callBackUrl . 'apsl_login_id' . '=twitter_check&redirect_to=' . $encoded_url;
305
- }
306
- else {
307
  $callback = $callBackUrl . 'apsl_login_id' . '=twitter_check';
308
  }
309
-
310
- $request_token = $twitterObj->getRequestToken( $callback );
311
  $_SESSION['oauth_twitter'] = array();
312
  /* Save temporary credentials to session. */
313
  $_SESSION['oauth_twitter']['oauth_token'] = $token = $request_token['oauth_token'];
314
  $_SESSION['oauth_twitter']['oauth_token_secret'] = $request_token['oauth_token_secret'];
315
  /* If last connection failed don't display authorization link. */
316
- switch( $twitterObj->http_code ) {
317
  case 200:
318
  try {
319
- $url = $twitterObj->getAuthorizeUrl( $token );
320
- $this->redirect( $url );
321
- }
322
- catch( Exception $e ) {
323
  $response->status = 'ERROR';
324
  $response->error_code = 2;
325
  $response->error_message = 'Could not get AuthorizeUrl.';
326
  }
327
- break;
328
  default:
329
  $response->status = 'ERROR';
330
  $response->error_code = 2;
331
  $response->error_message = 'Could not connect to Twitter. Refresh the page or try again later.';
332
- break;
333
  }
334
- }
335
- else {
336
  $response->status = 'ERROR';
337
  $response->error_code = 2;
338
  $response->error_message = 'INVALID AUTHORIZATION';
339
  }
340
- }
341
- else if( isset( $request['oauth_token'] ) && isset( $request['oauth_verifier'] ) ) {
342
  /* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
343
- $twitterObj = new TwitterOAuth( $options['apsl_twitter_settings']['apsl_twitter_api_key'], $options['apsl_twitter_settings']['apsl_twitter_api_secret'], $_SESSION['oauth_twitter']['oauth_token'], $_SESSION['oauth_twitter']['oauth_token_secret'] );
344
  /* Remove no longer needed request tokens */
345
- unset( $_SESSION['oauth_twitter'] );
346
  try {
347
- $access_token = $twitterObj->getAccessToken( $request['oauth_verifier'] );
348
  /* If HTTP response is 200 continue otherwise send to connect page to retry */
349
- if( 200 == $twitterObj->http_code ) {
350
- $user_profile = $twitterObj->get( 'account/verify_credentials', array(
351
- 'screen_name' => $access_token['screen_name'],
352
- 'skip_status' => 'true',
353
- 'include_entities' => 'true',
354
- 'include_email' => 'true'
355
- )
356
- );
357
  /* Request access twitterObj from twitter */
358
  $response->status = 'SUCCESS';
359
  $response->deuid = $user_profile->id;
360
  $response->deutype = 'twitter';
361
- $response->name = explode( ' ', $user_profile->name, 2 );
362
  $response->first_name = $response->name[0];
363
- $response->last_name =( isset( $response->name[1] ) ) ? $response->name[1] : '';
364
  $response->deuimage = $user_profile->profile_image_url_https;
365
  $response->email = isset($user_profile->email) ? $user_profile->email : $user_profile->screen_name . '@twitter.com';
366
- $response->username = ($user_profile->screen_name !='') ? strtolower($user_profile->screen_name) : $user_email;
367
  $response->url = $user_profile->url;
368
  $response->about = isset($user_profile->description) ? $user_profile->description : '';
369
  $response->gender = isset($user_profile->gender) ? $user_profile->gender : 'N/A';
370
  $response->location = $user_profile->location;
371
  $response->error_message = '';
372
- }
373
- else {
374
  $response->status = 'ERROR';
375
  $response->error_code = 2;
376
  $response->error_message = 'Could not connect to Twitter. Refresh the page or try again later.';
377
  }
378
- }
379
- catch( Exception $e ) {
380
  $response->status = 'ERROR';
381
  $response->error_code = 2;
382
  $response->error_message = 'Could not get AccessToken.';
383
  }
384
- }
385
- else { // User Canceled your Request
386
  $response->status = 'ERROR';
387
  $response->error_code = 1;
388
  $response->error_message = "USER CANCELED REQUEST";
389
  }
390
  return $response;
391
  }
 
392
  //for google login
393
  function onGoogleLogin() {
394
  $result = $this->GoogleLogin();
395
- if( isset( $result->status ) && $result->status == 'SUCCESS' ) {
396
  global $wpdb;
397
- $unique_verifier = sha1($result->deutype.$result->deuid);
398
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `provider_name` LIKE '$result->deutype' AND `identifier` LIKE '$result->deuid' AND `unique_verifier` LIKE '$unique_verifier'";
399
  $row = $wpdb->get_row($sql);
400
- if( !$row ) {
401
  //check if there is already a user with the email address provided from social login already
402
  $user_details_by_email = $this->getUserByMail($result->email);
403
- if( $user_details_by_email != false ){
404
  //user already there so log him in
405
  $id = $user_details_by_email->ID;
406
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `user_id` LIKE '$id'; ";
407
  $row = $wpdb->get_row($sql);
408
- if(!$row){
409
- self:: link_user($id, $result);
410
  }
411
- self:: loginUser( $id );
412
  die();
413
  }
414
- $_SESSION['user_details']= $result;
415
- self::creatUser( $result->username, $result->email );
416
- $user_row = self:: getUserByMail( $result->email );
417
  $id = $user_row->ID;
418
  $result = $result;
419
  $role = 'subscriber';
420
- self:: UpdateUserMeta( $id, $result, $role );
421
- self:: loginUser( $id );
422
  exit();
423
- }else{
424
- if( ($row->provider_name == $result->deutype) && ($row->identifier == $result->deuid) ){
425
  //echo "user found in our database";
426
- self:: loginUser( $row->user_id );
427
  exit();
428
- }else{
429
  // user not found in our database
430
  // need to handle an exception
431
  }
432
  }
433
- }else{
434
- if(isset($_REQUEST['error'])){
435
  $_SESSION['apsl_login_error_flag'] = 1;
436
  $redirect_url = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();
437
  $this->redirect($redirect_url);
@@ -439,71 +427,67 @@ if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
439
  die();
440
  }
441
  }
442
-
443
  function GoogleLogin() {
444
  $post = $_POST;
445
  $get = $_GET;
446
  $request = $_REQUEST;
447
  $site = $this->siteUrl();
448
  $callBackUrl = $this->callBackUrl();
449
- $options = get_option( APSL_SETTINGS );
450
  $response = new stdClass();
451
- $a = explode( '_', $_GET['apsl_login_id'] );
452
  $action = $a[1];
453
  $client_id = $options['apsl_google_settings']['apsl_google_client_id'];
454
  $client_secret = $options['apsl_google_settings']['apsl_google_client_secret'];
455
-
456
  $site_url = site_url() . '/wp-admin';
457
- $encoded_url = isset( $_GET['redirect_to'] ) ? $_GET['redirect_to'] : $site_url;
458
  $callback = $callBackUrl . 'apsl_login_id' . '=google_check';
459
-
460
  $redirect_uri = $callback;
461
  $client = new Google_Client;
462
-
463
- $client->setClientId( $client_id );
464
- $client->setClientSecret( $client_secret );
465
- $client->setRedirectUri( $redirect_uri );
466
- $client->addScope( "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.profile.emails.read" );
467
- if( isset( $encoded_url ) && $encoded_url != '' ) {
468
- $client->setState( base64_encode( "redirect_to=$encoded_url" ) );
469
  }
470
-
471
- $service = new Google_Service_Plus( $client );
472
-
473
- if( $action == 'login' ) { // Get identity from user and redirect browser to OpenID Server
474
- unset($_SESSION['access_token']);
475
- if( !( isset( $_SESSION['access_token'] ) && $_SESSION['access_token'] ) ) {
476
  $authUrl = $client->createAuthUrl();
477
- $this->redirect( $authUrl );
478
  die();
479
- }
480
- else {
481
- $this->redirect( $redirect_uri . "&redirect_to=$encoded_url" );
482
  die();
483
  }
484
- }
485
- elseif( isset( $_GET['code'] ) ) { // Perform HTTP Request to OpenID server to validate key
486
- $client->authenticate( $_GET['code'] );
487
  $_SESSION['access_token'] = $client->getAccessToken();
488
- $this->redirect( $redirect_uri . "&redirect_to=$encoded_url" );
489
  die();
490
- }
491
- elseif( isset( $_SESSION['access_token'] ) && $_SESSION['access_token'] ) {
492
- $client->setAccessToken( $_SESSION['access_token'] );
493
-
494
  try {
495
- $user = $service->people->get( "me", array() );
496
- }
497
- catch( Exception $fault ) {
498
- unset( $_SESSION['access_token'] );
499
- $ref_object = $this->accessProtected( $fault, 'errors' );
500
  echo $ref_object[0]['message'] . " Please notify about this error to the Site Admin.";
501
  die();
502
  }
503
-
504
- if( !empty( $user ) ) {
505
- if( !empty( $user->emails ) ) {
506
-
507
  $response->email = $user->emails[0]->value;
508
  $response->username = ($user->name->givenName) ? strtolower($user->name->givenName) : $user_email;
509
  $response->first_name = $user->name->givenName;
@@ -517,26 +501,24 @@ if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
517
  $response->deutype = 'google';
518
  $response->status = 'SUCCESS';
519
  $response->error_message = '';
520
- }
521
- else {
522
  $response->status = 'ERROR';
523
  $response->error_code = 2;
524
  $response->error_message = "INVALID AUTHORIZATION";
525
  }
526
- }
527
- else { // Signature Verification Failed
528
  $response->status = 'ERROR';
529
  $response->error_code = 2;
530
  $response->error_message = "INVALID AUTHORIZATION";
531
  }
532
- }
533
- else { // User failed to login
534
  $response->status = 'ERROR';
535
  $response->error_code = 3;
536
  $response->error_message = "USER LOGIN FAIL";
537
  }
538
  return $response;
539
  }
 
540
  //other remaining methods
541
  function siteUrl() {
542
  return site_url();
@@ -545,277 +527,279 @@ if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
545
  function callBackUrl() {
546
  // $connection = !empty( $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
547
  $url = wp_login_url();
548
- if( strpos( $url, '?' ) === false ) {
549
- $url.= '?';
550
- }
551
- else {
552
- $url.= '&';
553
  }
554
  return $url;
555
  }
 
556
  //function to return json values from social media urls
557
- function get_json_values( $url ) {
558
- $response = wp_remote_get( $url );
559
- $json_response = wp_remote_retrieve_body( $response );
560
  return $json_response;
561
  }
562
 
563
- function redirect( $redirect ) {
564
- if( headers_sent() ) { // Use JavaScript to redirect if content has been previously sent (not recommended, but safe)
565
  echo '<script language="JavaScript" type="text/javascript">window.location=\'';
566
  echo $redirect;
567
  echo '\';</script>';
568
- }
569
- else { // Default Header Redirect
570
- header( 'Location: ' . $redirect );
571
  }
572
  exit;
573
  }
574
 
575
- static function get_username($user_name){
576
  $username = $user_name;
577
  $i = 1;
578
- while(username_exists( $username )){
579
- $username = $user_name.'_'.$i;
580
  $i++;
581
  }
582
  return $username;
583
  }
584
 
585
- function updateUser( $username, $email ) {
586
- $row = $this->getUserByUsername( $username );
587
- if( $row && $email != '' && $row->user_email != $email ) {
588
- $row = (array)$row;
589
  $row['user_email'] = $email;
590
- wp_update_user( $row );
591
  }
592
  }
593
 
594
- function getUserByMail( $email ) {
595
  global $wpdb;
596
- $row = $wpdb->get_row( "SELECT * FROM $wpdb->users WHERE user_email = '$email'" );
597
- if( $row ) {
598
  return $row;
599
  }
600
  return false;
601
  }
602
 
603
- function getUserByUsername( $username ) {
604
  global $wpdb;
605
- $row = $wpdb->get_row( "SELECT * FROM $wpdb->users WHERE user_login = '$username'" );
606
- if( $row ) {
607
  return $row;
608
  }
609
  return false;
610
  }
611
 
612
- function creatUser( $user_name, $user_email ) {
613
- $username = self:: get_username($user_name);
614
- $random_password = wp_generate_password( 12, false );
615
- $user_id = wp_create_user( $username, $random_password, $user_email );
616
- do_action( 'APSL_createUser', $user_id ); //hookable function to perform additional work after creation of user.
617
- $options = get_option( APSL_SETTINGS );
618
- if( $options['apsl_send_email_notification_options'] == 'yes' ) {
619
- if (version_compare(get_bloginfo('version'), '4.3.1', '>=')){
620
- wp_new_user_notification( $user_id, $deprecated = null, $notify = 'both' );
621
- }else{
622
- wp_new_user_notification( $user_id, $random_password );
623
  }
624
  }
625
  return $user_id;
626
  }
627
 
628
- function set_cookies( $user_id = 0, $remember = true ) {
629
- if( !function_exists( 'wp_set_auth_cookie' ) ) {
630
  return false;
631
  }
632
- if( !$user_id ) {
633
  return false;
634
  }
635
  wp_clear_auth_cookie();
636
- wp_set_auth_cookie( $user_id, $remember );
637
- wp_set_current_user( $user_id );
638
  return true;
639
  }
640
 
641
- function loginUser( $user_id ) {
642
  $current_url_an = get_permalink();
643
- $reauth = empty( $_REQUEST['reauth'] ) ? false : true;
644
- if( $reauth )wp_clear_auth_cookie();
645
-
646
- if( isset( $_REQUEST['redirect_to'] ) ) {
 
647
  $redirect_to = $_REQUEST['redirect_to'];
648
  // Redirect to https if user wants ssl
649
- if( isset( $secure_cookie ) && false !== strpos( $redirect_to, 'wp-admin' ) )$redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
 
650
  }
651
  else {
652
  $redirect_to = admin_url();
653
  }
654
- if( !isset( $secure_cookie ) && is_ssl() && !force_ssl_admin() &&( 0 !== strpos( $redirect_to, 'https' ) ) &&( 0 === strpos( $redirect_to, 'http' ) ) )$secure_cookie = false;
 
655
  // If cookies are disabled we can't log in even with a valid user+pass
656
- if( isset( $_POST['testcookie'] ) && empty( $_COOKIE[TEST_COOKIE] ) )$user = new WP_Error( 'test_cookie', __( "<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress." ) );
657
- else $user = wp_signon( '', isset( $secure_cookie ) );
 
 
658
 
659
- if( !$this->set_cookies( $user_id ) ) {
660
  return false;
661
  }
662
- $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : site_url();
663
- $user_login_url = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
664
 
665
- $options = get_option( APSL_SETTINGS );
666
- if( isset( $options['apsl_custom_login_redirect_options'] ) && $options['apsl_custom_login_redirect_options'] != '' ) {
667
- if( $options['apsl_custom_login_redirect_options'] == 'home' ) {
668
  $user_login_url = home_url();
669
- }
670
- else if( $options['apsl_custom_login_redirect_options'] == 'current_page' ) {
671
- if( isset( $_REQUEST['redirect_to'] ) ) {
672
  $redirect_to = $_REQUEST['redirect_to'];
673
  // Redirect to https if user wants ssl
674
- if( isset( $secure_cookie ) && false !== strpos( $redirect_to, 'wp-admin' ) )$user_login_url = preg_replace( '|^http://|', 'https://', $redirect_to );
 
675
  }
676
  else {
677
  $user_login_url = home_url();
678
  }
679
- }
680
- else if( $options['apsl_custom_login_redirect_options'] == 'custom_page' ) {
681
- if( $options['apsl_custom_login_redirect_link'] != '' ) {
682
  $login_page = $options['apsl_custom_login_redirect_link'];
683
  $user_login_url = $login_page;
684
- }
685
- else {
686
  $user_login_url = home_url();
687
  }
688
  }
689
- }
690
- else {
691
  $user_login_url = home_url();
692
  }
693
  $redirect_to = $user_login_url;
694
- $redirect_to = apply_filters( 'login_redirect', $redirect_to );
695
  $redirect_to = isset($_COOKIE["apsl_login_redirect_url"]) ? urldecode($_COOKIE["apsl_login_redirect_url"]) : $redirect_to;
696
  // echo "<script> window.close(); window.opener.location.href='$redirect_to'; </script>";
697
- wp_safe_redirect( $redirect_to );
698
  exit();
699
  }
 
700
  //returns the current page url
701
  public static function curPageURL() {
702
  $pageURL = 'http';
703
- if( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) {
704
- $pageURL.= "s";
705
  }
706
- $pageURL.= "://";
707
- if( $_SERVER["SERVER_PORT"] != "80" ) {
708
- $pageURL.= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
709
- }
710
- else {
711
- $pageURL.= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
712
  }
713
  return $pageURL;
714
  }
 
715
  //function to access the protected object properties
716
- function accessProtected( $obj, $prop ) {
717
- $reflection = new ReflectionClass( $obj );
718
- $property = $reflection->getProperty( $prop );
719
- $property->setAccessible( true );
720
- return $property->getValue( $obj );
721
  }
722
 
723
-
724
  //insert the user data into plugin's custom database
725
- static function link_user($id, $result){
726
  global $wpdb;
727
- $unique_verifier = sha1($result->deutype.$result->deuid);
728
  $apsl_userdetails = "{$wpdb->prefix}apsl_users_social_profile_details";
729
 
730
  $first_name = sanitize_text_field($result->first_name);
731
  $last_name = sanitize_text_field($result->last_name);
732
  $profile_url = sanitize_text_field($result->url);
733
- $photo_url = sanitize_text_field( $result->deuimage);
734
- $display_name = sanitize_text_field( $result->first_name . ' ' . $result->last_name);
735
  $description = sanitize_text_field($result->about);
736
 
737
- $table_name = $apsl_userdetails;
738
- $submit_array = array(
739
- "user_id" => $id,
740
- "provider_name" => $result->deutype,
741
- "identifier" => $result->deuid,
742
- "unique_verifier" => $unique_verifier,
743
- "email" => $result->email,
744
- "first_name" => $first_name,
745
- "last_name" => $last_name,
746
- "profile_url" =>$profile_url,
747
- "photo_url" =>$photo_url,
748
- "display_name" =>$display_name,
749
- "description" =>$description,
750
- "gender" =>$result->gender
751
- );
752
  $user_profile_details = $result;
753
- $wpdb->insert($table_name, $submit_array );
754
- if(!$result){
755
  echo "Data insertion failed";
756
  // die(mysql_error());
757
  }
758
  }
759
 
760
  //update the user meta data
761
- static function UpdateUserMeta( $id, $result, $role ) {
762
- update_user_meta( $id, 'email', $result->email );
763
- update_user_meta( $id, 'first_name', $result->first_name );
764
- update_user_meta( $id, 'last_name', $result->last_name );
765
- update_user_meta( $id, 'billing_first_name', $result->first_name );
766
- update_user_meta( $id, 'billing_last_name', $result->last_name );
767
- update_user_meta( $id, 'deuid', $result->deuid );
768
- update_user_meta( $id, 'deutype', $result->deutype );
769
- update_user_meta( $id, 'deuimage', $result->deuimage );
770
- update_user_meta( $id, 'description', $result->about );
771
- update_user_meta( $id, 'sex', $result->gender );
772
- wp_update_user( array(
773
  'ID' => $id,
774
  'display_name' => $result->first_name . ' ' . $result->last_name,
775
  // 'role' => $role,
776
  'user_url' => $result->url
777
- ) );
778
 
779
  global $wpdb;
780
- $unique_verifier = sha1($result->deutype.$result->deuid);
781
  $apsl_userdetails = "{$wpdb->prefix}apsl_users_social_profile_details";
782
 
783
  $first_name = sanitize_text_field($result->first_name);
784
  $last_name = sanitize_text_field($result->last_name);
785
  $profile_url = sanitize_text_field($result->url);
786
- $photo_url = sanitize_text_field( $result->deuimage);
787
- $display_name = sanitize_text_field( $result->first_name . ' ' . $result->last_name);
788
  $description = sanitize_text_field($result->about);
789
 
790
- $table_name = $apsl_userdetails;
791
- $submit_array = array(
792
- "user_id" => $id,
793
- "provider_name" => $result->deutype,
794
- "identifier" => $result->deuid,
795
- "unique_verifier" => $unique_verifier,
796
- "email" => $result->email,
797
- "first_name" => $first_name,
798
- "last_name" => $last_name,
799
- "profile_url" =>$profile_url,
800
- "photo_url" =>$photo_url,
801
- "display_name" =>$display_name,
802
- "description" =>$description,
803
- "gender" =>$result->gender
804
- );
805
  $user_profile_details = $result;
806
- $wpdb->insert($table_name, $submit_array );
807
 
808
  // if(function_exists('bp_has_profile')){
809
  // self:: apsl_buddypress_xprofile_mapping($id, $user_profile_details->deutype, $user_profile_details);
810
  // }
811
- if(!$result){
812
  echo "Data insertion failed";
813
  // die(mysql_error());
814
  }
815
  }
816
 
817
- } //termination of a class
818
 
 
819
  } //end of if statement
820
 
821
  $apsl_login_check = new APSL_Lite_Login_Check_Class();
1
  <?php
 
2
 
3
+ defined('ABSPATH') or die("No script kiddies please!");
4
+
5
+ if (!class_exists('APSL_Lite_Login_Check_Class')) {
6
 
7
  class APSL_Lite_Login_Check_Class {
8
+
9
  //constructor
10
  function __construct() {
11
 
12
+ if (isset($_GET['apsl_login_id'])) {
13
+ if (isset($_REQUEST['state'])) {
14
+ parse_str(base64_decode($_REQUEST['state']), $state_vars);
15
 
16
+ if (isset($state_vars['redirect_to'])) {
17
  $_GET['redirect_to'] = $_REQUEST['redirect_to'] = $state_vars['redirect_to'];
18
  }
19
  }
20
 
21
+ $exploder = explode('_', $_GET['apsl_login_id']);
22
+ switch ($exploder[0]) {
23
  case 'facebook':
24
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
25
+ echo _e('The Facebook SDK requires PHP version 5.4 or higher. Please notify about this error to site admin.', 'accesspress-social-login-lite');
26
  die();
27
  }
28
  $this->onFacebookLogin();
29
+ break;
30
  case 'twitter':
31
+ if (!class_exists('TwitterOAuth')) {
32
  include( APSL_PLUGIN_DIR . 'twitter/OAuth.php' );
33
  include( APSL_PLUGIN_DIR . 'twitter/twitteroauth.php' );
34
  }
35
  $this->onTwitterLogin();
36
+ break;
37
  case 'google':
38
+ if (!class_exists('Google_Client')) {
39
+ include( APSL_PLUGIN_DIR . 'google/Client.php' );
40
+ }
41
+ if (!class_exists('Google_Service_Plus')) {
42
+ include( APSL_PLUGIN_DIR . 'google/Service/Plus.php' );
43
+ }
44
  $this->onGoogleLogin();
45
+ break;
46
  }
47
  }
48
  }
49
+
50
  //for facebook login
51
  function onFacebookLogin() {
52
  $response = new stdClass();
53
+ $result = $this->facebookLogin($response);
54
+ if (isset($result->status) && $result->status == 'SUCCESS') {
55
  global $wpdb;
56
+ $unique_verifier = sha1($result->deutype . $result->deuid);
57
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `provider_name` LIKE '$result->deutype' AND `identifier` LIKE '$result->deuid' AND `unique_verifier` LIKE '$unique_verifier'";
58
  $row = $wpdb->get_row($sql);
59
+ if (!$row) {
60
  //check if there is already a user with the email address provided from social login already
61
  $user_details_by_email = $this->getUserByMail($result->email);
62
+ if ($user_details_by_email != false) {
63
  //user already there so log him in
64
  $id = $user_details_by_email->ID;
65
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `user_id` LIKE '$id'; ";
66
  $row = $wpdb->get_row($sql);
67
+ if (!$row) {
68
+ self:: link_user($id, $result);
69
  }
70
+ self:: loginUser($id);
71
  die();
72
  }
73
+ $_SESSION['user_details'] = $result;
74
+
75
  // use FB id as username if sanitized username is empty
76
+ $sanitized_user_name = sanitize_user($result->username, true);
77
+ if (empty($sanitized_user_name)) {
78
+ $sanitized_user_name = $result->deuid;
79
  }
80
+ $user_Id = self::creatUser($sanitized_user_name, $result->email);
81
+ $user_row = self:: getUserByMail($result->email);
82
  $id = $user_row->ID;
83
  $result = $result;
84
  $role = 'subscriber';
85
+ self:: UpdateUserMeta($id, $result, $role);
86
+ self:: loginUser($id);
87
  exit();
88
+ } else {
89
+ if (($row->provider_name == $result->deutype) && ($row->identifier == $result->deuid)) {
90
  //echo "user found in our database";
91
+ self:: loginUser($row->user_id);
92
  exit();
93
+ } else {
94
  // user not found in our database
95
  // need to handle an exception
96
  }
97
  }
98
+ } else {
99
+ if (isset($_REQUEST['error'])) {
100
  $_SESSION['apsl_login_error_flag'] = 1;
101
  $redirect_url = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();
102
  $this->redirect($redirect_url);
104
  die();
105
  }
106
  }
107
+
108
  function facebookLogin() {
109
  $request = $_REQUEST;
110
  $site = $this->siteUrl();
111
  $callBackUrl = $this->callBackUrl();
112
  $response = new stdClass();
113
  $return_user_details = new stdClass();
114
+ $exploder = explode('_', $_GET['apsl_login_id']);
115
  $action = $exploder[1];
116
+ $options = get_option(APSL_SETTINGS);
117
+ if (isset($options['apsl_facebook_settings']['apsl_profile_image_width'])) {
118
+ $width = $options['apsl_facebook_settings']['apsl_profile_image_width'];
119
+ } else {
120
+ $width = 150;
121
  }
122
 
123
+ if (isset($options['apsl_facebook_settings']['apsl_profile_image_height'])) {
124
  $height = $options['apsl_facebook_settings']['apsl_profile_image_height'];
125
+ } else {
126
  $height = 150;
127
  }
128
 
129
+ $config = array('app_id' => $options['apsl_facebook_settings']['apsl_facebook_app_id'], 'app_secret' => $options['apsl_facebook_settings']['apsl_facebook_app_secret'], 'default_graph_version' => 'v2.4', 'persistent_data_handler' => 'session');
130
  include( APSL_PLUGIN_DIR . 'facebook/autoload.php' );
131
+ $fb = new Facebook\Facebook($config);
132
 
133
  $callback = $callBackUrl . 'apsl_login_id' . '=facebook_check';
134
 
135
+ if ($action == 'login') {
136
  // Well looks like we are a fresh dude, login to Facebook!
137
  $helper = $fb->getRedirectLoginHelper();
138
  $permissions = array('email', 'public_profile'); // optional
139
+ $loginUrl = $helper->getLoginUrl($callback, $permissions);
140
 
141
+ $encoded_url = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : '';
142
+ if (isset($encoded_url) && $encoded_url != '') {
143
+ setcookie("apsl_login_redirect_url", $encoded_url, time() + 3600);
144
  // $callback = $callBackUrl . 'apsl_login_id' . '=facebook_check&redirect_to=' . $encoded_url;
145
  }
146
+ $this->redirect($loginUrl);
147
+ } else {
148
+ if (isset($_REQUEST['error'])) {
 
149
  $response->status = 'ERROR';
150
  $response->error_code = 2;
151
  $response->error_message = 'INVALID AUTHORIZATION';
152
  return $response;
153
  die();
154
  }
155
+ if (isset($_REQUEST['code'])) {
156
  $helper = $fb->getRedirectLoginHelper();
157
  // Trick below will avoid "Cross-site request forgery validation failed. Required param "state" missing." from Facebook
158
  $_SESSION['FBRLH_state'] = $_REQUEST['state'];
159
  try {
160
  $accessToken = $helper->getAccessToken($callback);
161
+ } catch (Facebook\Exceptions\FacebookResponseException $e) {
 
162
  // When Graph returns an error
163
  echo 'Graph returned an error: ' . $e->getMessage();
164
  exit;
165
+ } catch (Facebook\Exceptions\FacebookSDKException $e) {
 
166
  // When validation fails or other local issues
167
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
168
  exit;
169
  }
170
+
171
+ if (isset($accessToken)) {
172
  // Logged in!
173
+ $_SESSION['facebook_access_token'] = (string) $accessToken;
174
+ $fb->setDefaultAccessToken($accessToken);
175
 
176
  try {
177
+ $response = $fb->get('/me?fields=email,name, first_name, last_name, gender, link, about, birthday, education, hometown, is_verified, languages, location, website');
178
  $userNode = $response->getGraphUser();
179
+ } catch (Facebook\Exceptions\FacebookResponseException $e) {
 
180
  // When Graph returns an error
181
  echo 'Graph returned an error: ' . $e->getMessage();
182
  exit;
183
+ } catch (Facebook\Exceptions\FacebookSDKException $e) {
 
184
  // When validation fails or other local issues
185
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
186
  exit;
187
  }
188
  // get the user profile details
189
+ $user_profile = $this->accessProtected($userNode, 'items');
190
+ if ($user_profile != null) {
191
  $return_user_details->status = 'SUCCESS';
192
  $return_user_details->deuid = $user_profile['id'];
193
  $return_user_details->deutype = 'facebook';
194
  $return_user_details->first_name = $user_profile['first_name'];
195
  $return_user_details->last_name = $user_profile['last_name'];
196
+ if (isset($user_profile['email']) || $user_profile['email'] != '') {
197
  $user_email = $user_profile['email'];
198
+ } else {
199
+ $user_email = $user_profile['id'] . '@facebook.com';
200
  }
201
  $return_user_details->email = $user_email;
202
+ $return_user_details->username = ($user_profile['first_name'] != '') ? strtolower($user_profile['first_name']) : $user_email;
203
  $return_user_details->gender = isset($user_profile['gender']) ? $user_profile['gender'] : 'N/A';
204
  $return_user_details->url = $user_profile['link'];
205
  $return_user_details->about = ''; //facebook doesn't return user about details.
206
+ $headers = get_headers('https://graph.facebook.com/' . $user_profile['id'] . '/picture?width=' . $width . '&height=' . $height, 1);
207
  // just a precaution, check whether the header isset...
208
+ if (isset($headers['Location'])) {
209
  $return_user_details->deuimage = $headers['Location']; // string
210
+ } else {
 
 
211
  $return_user_details->deuimage = false; // nothing there? .. weird, but okay!
 
212
  }
213
  $return_user_details->error_message = '';
214
+ } else {
 
215
  $return_user_details->status = 'ERROR';
216
  $return_user_details->error_code = 2;
217
  $return_user_details->error_message = 'INVALID AUTHORIZATION';
218
  }
219
  }
220
+ } else {
 
221
  // Well looks like we are a fresh dude, login to Facebook!
222
  $helper = $fb->getRedirectLoginHelper();
223
  $permissions = array('email', 'public_profile'); // optional
224
+ $loginUrl = $helper->getLoginUrl($callback, $permissions);
225
+ $this->redirect($loginUrl);
226
  }
227
  }
228
  return $return_user_details;
229
  }
230
+
231
  //for twitter login
232
  function onTwitterLogin() {
233
  $result = $this->twitterLogin();
234
+ if (isset($result->status) && $result->status == 'SUCCESS') {
235
  global $wpdb;
236
+ $unique_verifier = sha1($result->deutype . $result->deuid);
237
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `provider_name` LIKE '$result->deutype' AND `identifier` LIKE '$result->deuid' AND `unique_verifier` LIKE '$unique_verifier'";
238
  $row = $wpdb->get_row($sql);
239
+ if (!$row) {
240
  //check if there is already a user with the email address provided from social login already
241
  $user_details_by_email = $this->getUserByMail($result->email);
242
+ if ($user_details_by_email != false) {
243
  //user already there so log him in
244
  $id = $user_details_by_email->ID;
245
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `user_id` LIKE '$id'; ";
246
  $row = $wpdb->get_row($sql);
247
  // var_dump($row);
248
+ if (!$row) {
249
+ self:: link_user($id, $result);
250
  }
251
+ self:: loginUser($id);
252
  die();
253
  }
254
+ $_SESSION['user_details'] = $result;
255
+ self::creatUser($result->username, $result->email);
256
+ $user_row = self:: getUserByMail($result->email);
257
  $id = $user_row->ID;
258
  $result = $result;
259
  $role = 'subscriber';
260
+ self:: UpdateUserMeta($id, $result, $role);
261
+ self:: loginUser($id);
262
  exit();
263
+ } else {
264
+ if (($row->provider_name == $result->deutype) && ($row->identifier == $result->deuid)) {
265
  //echo "user found in our database";
266
+ self:: loginUser($row->user_id);
267
  exit();
268
+ } else {
269
  // user not found in our database
270
  // need to handle an exception
271
  }
272
  }
273
+ $_SESSION['apsl_login_error_flag'] = 1;
274
+ } else {
275
+ if (isset($_REQUEST['denied'])) {
276
  $redirect_url = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();
277
  $this->redirect($redirect_url);
278
  }
279
  die();
280
  }
281
  }
282
+
283
  function twitterLogin() {
284
  $request = $_REQUEST;
285
  $site = $this->siteUrl();
286
  $callBackUrl = $this->callBackUrl();
287
  $response = new stdClass();
288
+ $exploder = explode('_', $_GET['apsl_login_id']);
289
  $action = $exploder[1];
290
  @session_start();
291
+ $options = get_option(APSL_SETTINGS);
292
+ if ($action == 'login') {
293
  // Get identity from user and redirect browser to OpenID Server
294
+ if (!isset($request['oauth_token']) || $request['oauth_token'] == '') {
295
+ $twitterObj = new TwitterOAuth($options['apsl_twitter_settings']['apsl_twitter_api_key'], $options['apsl_twitter_settings']['apsl_twitter_api_secret']);
296
+ $encoded_url = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : '';
297
+ if (isset($encoded_url) && $encoded_url != '') {
298
  $callback = $callBackUrl . 'apsl_login_id' . '=twitter_check&redirect_to=' . $encoded_url;
299
+ } else {
 
300
  $callback = $callBackUrl . 'apsl_login_id' . '=twitter_check';
301
  }
302
+
303
+ $request_token = $twitterObj->getRequestToken($callback);
304
  $_SESSION['oauth_twitter'] = array();
305
  /* Save temporary credentials to session. */
306
  $_SESSION['oauth_twitter']['oauth_token'] = $token = $request_token['oauth_token'];
307
  $_SESSION['oauth_twitter']['oauth_token_secret'] = $request_token['oauth_token_secret'];
308
  /* If last connection failed don't display authorization link. */
309
+ switch ($twitterObj->http_code) {
310
  case 200:
311
  try {
312
+ $url = $twitterObj->getAuthorizeUrl($token);
313
+ $this->redirect($url);
314
+ } catch (Exception $e) {
 
315
  $response->status = 'ERROR';
316
  $response->error_code = 2;
317
  $response->error_message = 'Could not get AuthorizeUrl.';
318
  }
319
+ break;
320
  default:
321
  $response->status = 'ERROR';
322
  $response->error_code = 2;
323
  $response->error_message = 'Could not connect to Twitter. Refresh the page or try again later.';
324
+ break;
325
  }
326
+ } else {
 
327
  $response->status = 'ERROR';
328
  $response->error_code = 2;
329
  $response->error_message = 'INVALID AUTHORIZATION';
330
  }
331
+ } else if (isset($request['oauth_token']) && isset($request['oauth_verifier'])) {
 
332
  /* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
333
+ $twitterObj = new TwitterOAuth($options['apsl_twitter_settings']['apsl_twitter_api_key'], $options['apsl_twitter_settings']['apsl_twitter_api_secret'], $_SESSION['oauth_twitter']['oauth_token'], $_SESSION['oauth_twitter']['oauth_token_secret']);
334
  /* Remove no longer needed request tokens */
335
+ unset($_SESSION['oauth_twitter']);
336
  try {
337
+ $access_token = $twitterObj->getAccessToken($request['oauth_verifier']);
338
  /* If HTTP response is 200 continue otherwise send to connect page to retry */
339
+ if (200 == $twitterObj->http_code) {
340
+ $user_profile = $twitterObj->get('account/verify_credentials', array(
341
+ 'screen_name' => $access_token['screen_name'],
342
+ 'skip_status' => 'true',
343
+ 'include_entities' => 'true',
344
+ 'include_email' => 'true'
345
+ )
346
+ );
347
  /* Request access twitterObj from twitter */
348
  $response->status = 'SUCCESS';
349
  $response->deuid = $user_profile->id;
350
  $response->deutype = 'twitter';
351
+ $response->name = explode(' ', $user_profile->name, 2);
352
  $response->first_name = $response->name[0];
353
+ $response->last_name = ( isset($response->name[1]) ) ? $response->name[1] : '';
354
  $response->deuimage = $user_profile->profile_image_url_https;
355
  $response->email = isset($user_profile->email) ? $user_profile->email : $user_profile->screen_name . '@twitter.com';
356
+ $response->username = ($user_profile->screen_name != '') ? strtolower($user_profile->screen_name) : $user_email;
357
  $response->url = $user_profile->url;
358
  $response->about = isset($user_profile->description) ? $user_profile->description : '';
359
  $response->gender = isset($user_profile->gender) ? $user_profile->gender : 'N/A';
360
  $response->location = $user_profile->location;
361
  $response->error_message = '';
362
+ } else {
 
363
  $response->status = 'ERROR';
364
  $response->error_code = 2;
365
  $response->error_message = 'Could not connect to Twitter. Refresh the page or try again later.';
366
  }
367
+ } catch (Exception $e) {
 
368
  $response->status = 'ERROR';
369
  $response->error_code = 2;
370
  $response->error_message = 'Could not get AccessToken.';
371
  }
372
+ } else { // User Canceled your Request
 
373
  $response->status = 'ERROR';
374
  $response->error_code = 1;
375
  $response->error_message = "USER CANCELED REQUEST";
376
  }
377
  return $response;
378
  }
379
+
380
  //for google login
381
  function onGoogleLogin() {
382
  $result = $this->GoogleLogin();
383
+ if (isset($result->status) && $result->status == 'SUCCESS') {
384
  global $wpdb;
385
+ $unique_verifier = sha1($result->deutype . $result->deuid);
386
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `provider_name` LIKE '$result->deutype' AND `identifier` LIKE '$result->deuid' AND `unique_verifier` LIKE '$unique_verifier'";
387
  $row = $wpdb->get_row($sql);
388
+ if (!$row) {
389
  //check if there is already a user with the email address provided from social login already
390
  $user_details_by_email = $this->getUserByMail($result->email);
391
+ if ($user_details_by_email != false) {
392
  //user already there so log him in
393
  $id = $user_details_by_email->ID;
394
  $sql = "SELECT * FROM `{$wpdb->prefix}apsl_users_social_profile_details` WHERE `user_id` LIKE '$id'; ";
395
  $row = $wpdb->get_row($sql);
396
+ if (!$row) {
397
+ self:: link_user($id, $result);
398
  }
399
+ self:: loginUser($id);
400
  die();
401
  }
402
+ $_SESSION['user_details'] = $result;
403
+ self::creatUser($result->username, $result->email);
404
+ $user_row = self:: getUserByMail($result->email);
405
  $id = $user_row->ID;
406
  $result = $result;
407
  $role = 'subscriber';
408
+ self:: UpdateUserMeta($id, $result, $role);
409
+ self:: loginUser($id);
410
  exit();
411
+ } else {
412
+ if (($row->provider_name == $result->deutype) && ($row->identifier == $result->deuid)) {
413
  //echo "user found in our database";
414
+ self:: loginUser($row->user_id);
415
  exit();
416
+ } else {
417
  // user not found in our database
418
  // need to handle an exception
419
  }
420
  }
421
+ } else {
422
+ if (isset($_REQUEST['error'])) {
423
  $_SESSION['apsl_login_error_flag'] = 1;
424
  $redirect_url = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();
425
  $this->redirect($redirect_url);
427
  die();
428
  }
429
  }
430
+
431
  function GoogleLogin() {
432
  $post = $_POST;
433
  $get = $_GET;
434
  $request = $_REQUEST;
435
  $site = $this->siteUrl();
436
  $callBackUrl = $this->callBackUrl();
437
+ $options = get_option(APSL_SETTINGS);
438
  $response = new stdClass();
439
+ $a = explode('_', $_GET['apsl_login_id']);
440
  $action = $a[1];
441
  $client_id = $options['apsl_google_settings']['apsl_google_client_id'];
442
  $client_secret = $options['apsl_google_settings']['apsl_google_client_secret'];
443
+
444
  $site_url = site_url() . '/wp-admin';
445
+ $encoded_url = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : $site_url;
446
  $callback = $callBackUrl . 'apsl_login_id' . '=google_check';
447
+
448
  $redirect_uri = $callback;
449
  $client = new Google_Client;
450
+
451
+ $client->setClientId($client_id);
452
+ $client->setClientSecret($client_secret);
453
+ $client->setRedirectUri($redirect_uri);
454
+ $client->addScope("https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.profile.emails.read");
455
+ if (isset($encoded_url) && $encoded_url != '') {
456
+ $client->setState(base64_encode("redirect_to=$encoded_url"));
457
  }
458
+
459
+ $service = new Google_Service_Plus($client);
460
+
461
+ if ($action == 'login') { // Get identity from user and redirect browser to OpenID Server
462
+ unset($_SESSION['access_token']);
463
+ if (!( isset($_SESSION['access_token']) && $_SESSION['access_token'] )) {
464
  $authUrl = $client->createAuthUrl();
465
+ $this->redirect($authUrl);
466
  die();
467
+ } else {
468
+ $this->redirect($redirect_uri . "&redirect_to=$encoded_url");
 
469
  die();
470
  }
471
+ } elseif (isset($_GET['code'])) { // Perform HTTP Request to OpenID server to validate key
472
+ $client->authenticate($_GET['code']);
 
473
  $_SESSION['access_token'] = $client->getAccessToken();
474
+ $this->redirect($redirect_uri . "&redirect_to=$encoded_url");
475
  die();
476
+ } elseif (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
477
+ $client->setAccessToken($_SESSION['access_token']);
478
+
 
479
  try {
480
+ $user = $service->people->get("me", array());
481
+ } catch (Exception $fault) {
482
+ unset($_SESSION['access_token']);
483
+ $ref_object = $this->accessProtected($fault, 'errors');
 
484
  echo $ref_object[0]['message'] . " Please notify about this error to the Site Admin.";
485
  die();
486
  }
487
+
488
+ if (!empty($user)) {
489
+ if (!empty($user->emails)) {
490
+
491
  $response->email = $user->emails[0]->value;
492
  $response->username = ($user->name->givenName) ? strtolower($user->name->givenName) : $user_email;
493
  $response->first_name = $user->name->givenName;
501
  $response->deutype = 'google';
502
  $response->status = 'SUCCESS';
503
  $response->error_message = '';
504
+ } else {
 
505
  $response->status = 'ERROR';
506
  $response->error_code = 2;
507
  $response->error_message = "INVALID AUTHORIZATION";
508
  }
509
+ } else { // Signature Verification Failed
 
510
  $response->status = 'ERROR';
511
  $response->error_code = 2;
512
  $response->error_message = "INVALID AUTHORIZATION";
513
  }
514
+ } else { // User failed to login
 
515
  $response->status = 'ERROR';
516
  $response->error_code = 3;
517
  $response->error_message = "USER LOGIN FAIL";
518
  }
519
  return $response;
520
  }
521
+
522
  //other remaining methods
523
  function siteUrl() {
524
  return site_url();
527
  function callBackUrl() {
528
  // $connection = !empty( $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
529
  $url = wp_login_url();
530
+ if (strpos($url, '?') === false) {
531
+ $url .= '?';
532
+ } else {
533
+ $url .= '&';
 
534
  }
535
  return $url;
536
  }
537
+
538
  //function to return json values from social media urls
539
+ function get_json_values($url) {
540
+ $response = wp_remote_get($url);
541
+ $json_response = wp_remote_retrieve_body($response);
542
  return $json_response;
543
  }
544
 
545
+ function redirect($redirect) {
546
+ if (headers_sent()) { // Use JavaScript to redirect if content has been previously sent (not recommended, but safe)
547
  echo '<script language="JavaScript" type="text/javascript">window.location=\'';
548
  echo $redirect;
549
  echo '\';</script>';
550
+ } else { // Default Header Redirect
551
+ header('Location: ' . $redirect);
 
552
  }
553
  exit;
554
  }
555
 
556
+ static function get_username($user_name) {
557
  $username = $user_name;
558
  $i = 1;
559
+ while (username_exists($username)) {
560
+ $username = $user_name . '_' . $i;
561
  $i++;
562
  }
563
  return $username;
564
  }
565
 
566
+ function updateUser($username, $email) {
567
+ $row = $this->getUserByUsername($username);
568
+ if ($row && $email != '' && $row->user_email != $email) {
569
+ $row = (array) $row;
570
  $row['user_email'] = $email;
571
+ wp_update_user($row);
572
  }
573
  }
574
 
575
+ function getUserByMail($email) {
576
  global $wpdb;
577
+ $row = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_email = '$email'");
578
+ if ($row) {
579
  return $row;
580
  }
581
  return false;
582
  }
583
 
584
+ function getUserByUsername($username) {
585
  global $wpdb;
586
+ $row = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$username'");
587
+ if ($row) {
588
  return $row;
589
  }
590
  return false;
591
  }
592
 
593
+ function creatUser($user_name, $user_email) {
594
+ $username = self:: get_username($user_name);
595
+ $random_password = wp_generate_password(12, false);
596
+ $user_id = wp_create_user($username, $random_password, $user_email);
597
+ do_action('APSL_createUser', $user_id); //hookable function to perform additional work after creation of user.
598
+ $options = get_option(APSL_SETTINGS);
599
+ if ($options['apsl_send_email_notification_options'] == 'yes') {
600
+ if (version_compare(get_bloginfo('version'), '4.3.1', '>=')) {
601
+ wp_new_user_notification($user_id, $deprecated = null, $notify = 'both');
602
+ } else {
603
+ wp_new_user_notification($user_id, $random_password);
604
  }
605
  }
606
  return $user_id;
607
  }
608
 
609
+ function set_cookies($user_id = 0, $remember = true) {
610
+ if (!function_exists('wp_set_auth_cookie')) {
611
  return false;
612
  }
613
+ if (!$user_id) {
614
  return false;
615
  }
616
  wp_clear_auth_cookie();
617
+ wp_set_auth_cookie($user_id, $remember);
618
+ wp_set_current_user($user_id);
619
  return true;
620
  }
621
 
622
+ function loginUser($user_id) {
623
  $current_url_an = get_permalink();
624
+ $reauth = empty($_REQUEST['reauth']) ? false : true;
625
+ if ($reauth)
626
+ wp_clear_auth_cookie();
627
+
628
+ if (isset($_REQUEST['redirect_to'])) {
629
  $redirect_to = $_REQUEST['redirect_to'];
630
  // Redirect to https if user wants ssl
631
+ if (isset($secure_cookie) && false !== strpos($redirect_to, 'wp-admin'))
632
+ $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
633
  }
634
  else {
635
  $redirect_to = admin_url();
636
  }
637
+ if (!isset($secure_cookie) && is_ssl() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ))
638
+ $secure_cookie = false;
639
  // If cookies are disabled we can't log in even with a valid user+pass
640
+ if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]))
641
+ $user = new WP_Error('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
642
+ else
643
+ $user = wp_signon('', isset($secure_cookie));
644
 
645
+ if (!$this->set_cookies($user_id)) {
646
  return false;
647
  }
648
+ $requested_redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();
649
+ $user_login_url = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
650
 
651
+ $options = get_option(APSL_SETTINGS);
652
+ if (isset($options['apsl_custom_login_redirect_options']) && $options['apsl_custom_login_redirect_options'] != '') {
653
+ if ($options['apsl_custom_login_redirect_options'] == 'home') {
654
  $user_login_url = home_url();
655
+ } else if ($options['apsl_custom_login_redirect_options'] == 'current_page') {
656
+ if (isset($_REQUEST['redirect_to'])) {
 
657
  $redirect_to = $_REQUEST['redirect_to'];
658
  // Redirect to https if user wants ssl
659
+ if (isset($secure_cookie) && false !== strpos($redirect_to, 'wp-admin'))
660
+ $user_login_url = preg_replace('|^http://|', 'https://', $redirect_to);
661
  }
662
  else {
663
  $user_login_url = home_url();
664
  }
665
+ } else if ($options['apsl_custom_login_redirect_options'] == 'custom_page') {
666
+ if ($options['apsl_custom_login_redirect_link'] != '') {
 
667
  $login_page = $options['apsl_custom_login_redirect_link'];
668
  $user_login_url = $login_page;
669
+ } else {
 
670
  $user_login_url = home_url();
671
  }
672
  }
673
+ } else {
 
674
  $user_login_url = home_url();
675
  }
676
  $redirect_to = $user_login_url;
677
+ $redirect_to = apply_filters('login_redirect', $redirect_to);
678
  $redirect_to = isset($_COOKIE["apsl_login_redirect_url"]) ? urldecode($_COOKIE["apsl_login_redirect_url"]) : $redirect_to;
679
  // echo "<script> window.close(); window.opener.location.href='$redirect_to'; </script>";
680
+ wp_safe_redirect($redirect_to);
681
  exit();
682
  }
683
+
684
  //returns the current page url
685
  public static function curPageURL() {
686
  $pageURL = 'http';
687
+ if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
688
+ $pageURL .= "s";
689
  }
690
+ $pageURL .= "://";
691
+ if ($_SERVER["SERVER_PORT"] != "80") {
692
+ $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
693
+ } else {
694
+ $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
 
695
  }
696
  return $pageURL;
697
  }
698
+
699
  //function to access the protected object properties
700
+ function accessProtected($obj, $prop) {
701
+ $reflection = new ReflectionClass($obj);
702
+ $property = $reflection->getProperty($prop);
703
+ $property->setAccessible(true);
704
+ return $property->getValue($obj);
705
  }
706
 
 
707
  //insert the user data into plugin's custom database
708
+ static function link_user($id, $result) {
709
  global $wpdb;
710
+ $unique_verifier = sha1($result->deutype . $result->deuid);
711
  $apsl_userdetails = "{$wpdb->prefix}apsl_users_social_profile_details";
712
 
713
  $first_name = sanitize_text_field($result->first_name);
714
  $last_name = sanitize_text_field($result->last_name);
715
  $profile_url = sanitize_text_field($result->url);
716
+ $photo_url = sanitize_text_field($result->deuimage);
717
+ $display_name = sanitize_text_field($result->first_name . ' ' . $result->last_name);
718
  $description = sanitize_text_field($result->about);
719
 
720
+ $table_name = $apsl_userdetails;
721
+ $submit_array = array(
722
+ "user_id" => $id,
723
+ "provider_name" => $result->deutype,
724
+ "identifier" => $result->deuid,
725
+ "unique_verifier" => $unique_verifier,
726
+ "email" => $result->email,
727
+ "first_name" => $first_name,
728
+ "last_name" => $last_name,
729
+ "profile_url" => $profile_url,
730
+ "photo_url" => $photo_url,
731
+ "display_name" => $display_name,
732
+ "description" => $description,
733
+ "gender" => $result->gender
734
+ );
735
  $user_profile_details = $result;
736
+ $wpdb->insert($table_name, $submit_array);
737
+ if (!$result) {
738
  echo "Data insertion failed";
739
  // die(mysql_error());
740
  }
741
  }
742
 
743
  //update the user meta data
744
+ static function UpdateUserMeta($id, $result, $role) {
745
+ update_user_meta($id, 'email', $result->email);
746
+ update_user_meta($id, 'first_name', $result->first_name);
747
+ update_user_meta($id, 'last_name', $result->last_name);
748
+ update_user_meta($id, 'billing_first_name', $result->first_name);
749
+ update_user_meta($id, 'billing_last_name', $result->last_name);
750
+ update_user_meta($id, 'deuid', $result->deuid);
751
+ update_user_meta($id, 'deutype', $result->deutype);
752
+ update_user_meta($id, 'deuimage', $result->deuimage);
753
+ update_user_meta($id, 'description', $result->about);
754
+ update_user_meta($id, 'sex', $result->gender);
755
+ wp_update_user(array(
756
  'ID' => $id,
757
  'display_name' => $result->first_name . ' ' . $result->last_name,
758
  // 'role' => $role,
759
  'user_url' => $result->url
760
+ ));
761
 
762
  global $wpdb;
763
+ $unique_verifier = sha1($result->deutype . $result->deuid);
764
  $apsl_userdetails = "{$wpdb->prefix}apsl_users_social_profile_details";
765
 
766
  $first_name = sanitize_text_field($result->first_name);
767
  $last_name = sanitize_text_field($result->last_name);
768
  $profile_url = sanitize_text_field($result->url);
769
+ $photo_url = sanitize_text_field($result->deuimage);
770
+ $display_name = sanitize_text_field($result->first_name . ' ' . $result->last_name);
771
  $description = sanitize_text_field($result->about);
772
 
773
+ $table_name = $apsl_userdetails;
774
+ $submit_array = array(
775
+ "user_id" => $id,
776
+ "provider_name" => $result->deutype,
777
+ "identifier" => $result->deuid,
778
+ "unique_verifier" => $unique_verifier,
779
+ "email" => $result->email,
780
+ "first_name" => $first_name,
781
+ "last_name" => $last_name,
782
+ "profile_url" => $profile_url,
783
+ "photo_url" => $photo_url,
784
+ "display_name" => $display_name,
785
+ "description" => $description,
786
+ "gender" => $result->gender
787
+ );
788
  $user_profile_details = $result;
789
+ $wpdb->insert($table_name, $submit_array);
790
 
791
  // if(function_exists('bp_has_profile')){
792
  // self:: apsl_buddypress_xprofile_mapping($id, $user_profile_details->deutype, $user_profile_details);
793
  // }
794
+ if (!$result) {
795
  echo "Data insertion failed";
796
  // die(mysql_error());
797
  }
798
  }
799
 
800
+ }
801
 
802
+ //termination of a class
803
  } //end of if statement
804
 
805
  $apsl_login_check = new APSL_Lite_Login_Check_Class();
readme.txt CHANGED
@@ -4,24 +4,26 @@ Tags: social, login, social login, facebook, twitter, google, social connect, s
4
  Donate link: http://accesspressthemes.com/donation/
5
  Requires at least: 3.8
6
  Tested up to: 4.9
7
- Stable tag: 3.3.3
 
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  No WordPress account and user credentials to remember, login using any of the most popular 3 social media accounts!
12
 
13
  == Description ==
 
14
  [Homepage](https://accesspressthemes.com/) | [Documentation](https://accesspressthemes.com/documentation/documentationplugin-instruction-accesspress-social-login-lite/) | [Support](https://accesspressthemes.com/support) | [Demo](http://demo.accesspressthemes.com/wordpress-plugins/accesspress-social-login-lite/) | [Premium Version](https://accesspressthemes.com/wordpress-plugins/accesspress-social-login/)
15
 
16
- AccessPress <strong>Social Login</strong> lite - is a perfect <strong>Free WordPress plugin</strong> to allow your website users to register/login to the website using one of their favorite social website accounts.
17
 
18
- As a website owner you can easily configure which social accounts to enable/disable for login, which areas of the website social login should be displayed (login, registration, comments). Also you can select the social login buttons/icons from 4 beautifully designed templates to fit them with your website's overall design/theme. Your website will fetch real data of the user's social profile!
19
 
20
- Your website visitors, can choose one of their favorite social accounts to login into your website. No need to fill up the long registration forms and remember many login credentials.
21
 
22
  Plugin setup is as easy as 1, 2, 3!
23
 
24
- <strong>Select from the most popular 3 social media</strong>
25
  configure which social media option to display at login area.
26
 
27
  <strong>Easy setup</strong>
@@ -30,8 +32,7 @@ Just put a few authorization details for each option you want to enable. Select
30
  <strong>Beautify your login page</strong>
31
  Select from 4 beautiful designs of social login buttons/icons.
32
 
33
-
34
- <strong>Your website visitors can now login using one of their favorite social account login. Easy, quick and convenient.</strong>
35
 
36
  <strong> This plugin requires PHP version 5.4 or Higher. </strong>
37
 
@@ -43,12 +44,12 @@ Select from 4 beautiful designs of social login buttons/icons.
43
  * Option to choose from 4 beautifully designed social login buttons/icons.
44
  * Option to configure the order of the social login buttons.
45
  * Use shortcode anywhere in the post/page to display social login.
46
- * Use widget to display social login.
47
  * Option to enable / disable social login (completely).
48
  * One click registration/login.
49
  * Ability to send the login details to the user's email.
50
- * Integrate with the wordpress users.
51
- * Nice and easy to use admin interface for site admin to manage, configure the plugin.
52
  * Translation ready.
53
  * <strong>Support</strong>
54
  - Dedicated email, forum support.
@@ -72,14 +73,14 @@ For more features upgrade to PRO version
72
  - VKontakte
73
  - Instagram
74
  - Foursquare
75
- - Wordpress
76
  - Buffer
77
 
78
  ★ 15 Beautiful design templates.
79
 
80
  ★ Works with Woocommerce.
81
 
82
- ★ Works with Buddypress.
83
 
84
  ★ High level of customization/configuration - admin can change the title
85
  attributes for social media icons, other texts, strings etc.
@@ -98,7 +99,7 @@ For premium upgrade please go [here](http://accesspressthemes.com/wordpress-plug
98
 
99
 
100
 
101
- For a easy installation guide checkout the Installation tab above.
102
 
103
  For complete information and documentation regarding plugin, please visit below links.
104
 
@@ -115,20 +116,20 @@ For complete information and documentation regarding plugin, please visit below
115
  1. Unzip accesspress-social-login-lite.zip
116
  2. Upload all the files to the /wp-content/plugins/accesspress-social-login-lite
117
  3. Activate the plugin through the 'Plugins' menu in WordPress.
118
- 4. For customizing the plugin's settings, click on AccessPress Social login lite menu in Wordpress left admin menu.
119
 
120
  == Frequently Asked Questions ==
121
  = What does this plugin do? =
122
- This plugin provides the ability to allow anyone to login into your site using major social media (Facebook, Twitter, google) by the use of the latest APIs on your website!
123
 
124
- = Will it effect my site's speed? =
125
  No, because we have integrated the plugin with the minimal codes to do the social login.
126
 
127
  = Do I need to design the icons again? =
128
- No , you won't need to get any trouble regarding design and layout of the icons since we have provided inbuilt 4 beautiful icon themes.You can choose any as per your requirement.
129
 
130
  = Can I use AccessPress social Login lite where ever I want? =
131
- Yes. You can use the AccessPress social login lite anywhere by using shortcode in your templates files or in posts and pages content. Also you can use login widget in sidebar.
132
 
133
  == Screenshots ==
134
  1. Backend Display of Social Login.
@@ -137,12 +138,15 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
137
  4. Backend Other settings Section.
138
 
139
  == Changelog ==
 
 
 
140
  = 3.3.3 =
141
  * Done small bug fixings in the backend settings.
142
 
143
  = 3.3.2 =
144
  * Done the bug fixings for the login redirect issue occurring for the google login.
145
- * Added the note section for the twitter login issue occurring for "Callback locking" issue.
146
 
147
  = 3.3.1 =
148
  * Done the update of the Facebook SDK to latest.
@@ -153,28 +157,28 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
153
  * Updated the information for the creation of facebook app for social login in note section.
154
 
155
  = 3.2.9 =
156
- * Done the plugin compactibility tests with wordpress version 4.8
157
- * Removal of unncessary commented codes from the plugin.
158
 
159
  = 3.2.8 =
160
- * Done the checking if there already exist the google oauth class as it's creating error if other plugin already included it.
161
 
162
  = 3.2.7 =
163
  * Done the update of the font-awesome icons to version 4.7.0 in the plugin.
164
 
165
  = 3.2.6 =
166
- * Done the modification of the callBackUrl function to work with custom login url.
167
  * Fixed the issue appearing for the database insert error due to gender input field.
168
 
169
  = 3.2.5 =
170
- * Fixed the display of the error message when user deny the authorization of the app for login.
171
 
172
  = 3.2.4 =
173
  * Now our plugin can fetch the twitter user's email address while doing social login using twitter(applicable for new user login only).
174
- * Fixed the google login issue if the user don't have google+ account.
175
 
176
  = 3.2.3 =
177
- * Added the check for the username and if username is empty user email address will be used as username.
178
 
179
  = 3.2.2 =
180
  * Done the code formatting and removal of unnecessary codes.
@@ -183,10 +187,10 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
183
  * Fixed the input field size for the image size settings for the facebook.
184
 
185
  = 3.2.0 =
186
- * Tested the plugin compactibility with wordpress version 4.7
187
 
188
  = 3.1.9 =
189
- * Done the removal of unnuecessary codes from the login check functions.
190
  * Done the link fixings for the social media links in about page.
191
  * Done some strings translation ready in the shortcode.php file.
192
 
@@ -194,7 +198,7 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
194
  * Done the addition of the notice for the google+ login info.
195
 
196
  = 3.1.7 =
197
- * Done the removal of the 'bio' field from the facebook login to make the plugin compactible with the Facebook API version 2.8.
198
 
199
  = 3.1.6 =
200
  * Done the addition of the documentation link to how to use section.
@@ -203,23 +207,23 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
203
  * Added More WordPress Resources link.
204
 
205
  = 3.1.4 =
206
- * Fixed the error appearing for the buddypress.
207
 
208
  = 3.1.3 =
209
- * Frontend and backend css optimization by removing unnecessary codes.
210
 
211
  = 3.1.2 =
212
- * Done the bug fixing for the facebook login if user don't allow to access email address.
213
 
214
  = 3.1.1 =
215
  * Done small bug fixings for twitter user fields.
216
  * Addition of the social login in the woocommerce login form.
217
- * Done the bug fixings regarding the user login issue when user change email address.
218
 
219
  = 3.1.0 =
220
  * Done the bug fixings for the google login.
221
- * Done the bug fixings for the username repeate issue.
222
- * Done the modification of the wp_new_user_notification function to match with wordpress version less than 4.3.1
223
 
224
  = 3.0.9 =
225
  * Done the bug fixing for the facebook login.
@@ -228,7 +232,7 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
228
  * Modified facebook app creation note section.
229
 
230
  = 3.0.7 =
231
- * Done the modification of plugin to set the username to firstname.
232
 
233
  = 3.0.6 =
234
  * Done the text modifications in the about section.
@@ -238,7 +242,7 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
238
  * Removed unnecessary commented code from plugins settings pages.
239
 
240
  = 3.0.4 =
241
- * Done the addition of option for the profile image dimension settings for facebook.
242
 
243
  = 3.0.3 =
244
  * Done the modifications for the google app creation note section.
@@ -248,7 +252,7 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
248
 
249
  = 3.0.1 =
250
  * Done the modifications of the note sections for the google settings.
251
- * Done bug fixing for the email notifications for admin with blank user details after doing upgrade of the notification function.
252
  * Done the addition of a hook to display the social login buttons when "Users must be registered and logged in to comment" checked in the discussions settings.
253
  * Done the addition of login redirect filter.
254
 
@@ -256,10 +260,10 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
256
  * Done the update of the user notification function to latest.
257
 
258
  = 2.0.9 =
259
- * Done the bug fixing for the facebook login with the newer api version v2.5.
260
 
261
  = 2.0.8 =
262
- * Done the bug fixing for the email notifications for the admin with the blank user details when user deny the app for login.
263
 
264
  = 2.0.7 =
265
  * Addition of the header_sent method checking in the plugin's main class for the session start.
@@ -269,7 +273,7 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
269
 
270
  = 2.0.5 =
271
  * Text domain changed to match the plugin folder name.
272
- * Done the backend css modifications.
273
 
274
  = 2.0.4 =
275
  * Sanitization of the text fields for the plugin's backend settings.
@@ -290,15 +294,15 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
290
  * Code optimization for the login check class.
291
 
292
  = 1.0.9 =
293
- * Fixed the issues google redirect issues for after social login to current page.
294
- * Demo link url change.
295
 
296
  = 1.0.8 =
297
  * Code optimization for activation and save settings page and login_check page.
298
 
299
  = 1.0.7 =
300
- * Bug fixing for the social login issues with facebook.
301
- * Implemented the new version of the facebook php sdk v5.0
302
 
303
  = 1.0.6 =
304
  * Code formatting and optimization for backend save settings.
@@ -320,10 +324,10 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
320
 
321
  = 1.0.1 =
322
  * Change of the theme 4 for the social login icons with text.
323
- * Additon of the necessary css for the theme 4.
324
 
325
  = 1.0.0 =
326
  * Plugin submitted to http://wordpress.org for review and approval
327
 
328
  == Upgrade Notice ==
329
- There is an update available for the AccessPress Social Login lite Plugin. Please update to recieve new updates and bug fixes.
4
  Donate link: http://accesspressthemes.com/donation/
5
  Requires at least: 3.8
6
  Tested up to: 4.9
7
+ Stable tag: 3.3.4
8
+ Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
  No WordPress account and user credentials to remember, login using any of the most popular 3 social media accounts!
13
 
14
  == Description ==
15
+
16
  [Homepage](https://accesspressthemes.com/) | [Documentation](https://accesspressthemes.com/documentation/documentationplugin-instruction-accesspress-social-login-lite/) | [Support](https://accesspressthemes.com/support) | [Demo](http://demo.accesspressthemes.com/wordpress-plugins/accesspress-social-login-lite/) | [Premium Version](https://accesspressthemes.com/wordpress-plugins/accesspress-social-login/)
17
 
18
+ AccessPress Social Login lite - is a perfect <strong>Free WordPress plugin</strong> to allow your website users to register/login to the website using one of their favorite social website accounts.
19
 
20
+ As a website owner, you can easily configure which social accounts to enable/disable for login, which areas of the website social login should be displayed (login, registration, comments). Also, you can select the social login buttons/icons from 4 beautifully designed templates to fit them with your website's overall design/theme. Your website will fetch real data from the user's social profile!
21
 
22
+ Your website visitors can choose one of their favorite social accounts to login to your website. No need to fill up the long registration forms and remember many login credentials.
23
 
24
  Plugin setup is as easy as 1, 2, 3!
25
 
26
+ <strong>Select from the most popular 3 social media</strong>
27
  configure which social media option to display at login area.
28
 
29
  <strong>Easy setup</strong>
32
  <strong>Beautify your login page</strong>
33
  Select from 4 beautiful designs of social login buttons/icons.
34
 
35
+ <strong>Your website visitors can now login using one of their favorite social account login. Easy, quick and convenient.</strong>
 
36
 
37
  <strong> This plugin requires PHP version 5.4 or Higher. </strong>
38
 
44
  * Option to choose from 4 beautifully designed social login buttons/icons.
45
  * Option to configure the order of the social login buttons.
46
  * Use shortcode anywhere in the post/page to display social login.
47
+ * Use the widget to display social login.
48
  * Option to enable / disable social login (completely).
49
  * One click registration/login.
50
  * Ability to send the login details to the user's email.
51
+ * Integrate with the WordPress users.
52
+ * Nice and easy to use admin interface for the site admin to manage, configure the plugin.
53
  * Translation ready.
54
  * <strong>Support</strong>
55
  - Dedicated email, forum support.
73
  - VKontakte
74
  - Instagram
75
  - Foursquare
76
+ - WordPress
77
  - Buffer
78
 
79
  ★ 15 Beautiful design templates.
80
 
81
  ★ Works with Woocommerce.
82
 
83
+ ★ Works with BuddyPress.
84
 
85
  ★ High level of customization/configuration - admin can change the title
86
  attributes for social media icons, other texts, strings etc.
99
 
100
 
101
 
102
+ For an easy installation guide checkout the Installation tab above.
103
 
104
  For complete information and documentation regarding plugin, please visit below links.
105
 
116
  1. Unzip accesspress-social-login-lite.zip
117
  2. Upload all the files to the /wp-content/plugins/accesspress-social-login-lite
118
  3. Activate the plugin through the 'Plugins' menu in WordPress.
119
+ 4. For customizing the plugin's settings, click on AccessPress Social login lite menu in WordPress left admin menu.
120
 
121
  == Frequently Asked Questions ==
122
  = What does this plugin do? =
123
+ This plugin provides the ability to allow anyone to login to your site using major social media (Facebook, Twitter, Google) by the use of the latest APIs on your website!
124
 
125
+ = Will it affect my site's speed? =
126
  No, because we have integrated the plugin with the minimal codes to do the social login.
127
 
128
  = Do I need to design the icons again? =
129
+ No, you won't need to get any trouble regarding design and layout of the icons since we have provided inbuilt 4 beautiful icon themes. You can choose any as per your requirement.
130
 
131
  = Can I use AccessPress social Login lite where ever I want? =
132
+ Yes. You can use the AccessPress social login lite anywhere by using the shortcode in your templates files or in posts and pages content. Also, you can use login widget in the sidebar.
133
 
134
  == Screenshots ==
135
  1. Backend Display of Social Login.
138
  4. Backend Other settings Section.
139
 
140
  == Changelog ==
141
+ = 3.3.4 =
142
+ * Done some code cleanup and small issue with force_ssl_login resolved
143
+
144
  = 3.3.3 =
145
  * Done small bug fixings in the backend settings.
146
 
147
  = 3.3.2 =
148
  * Done the bug fixings for the login redirect issue occurring for the google login.
149
+ * Added the note section for the Twitter login issue occurring for "Callback locking" issue.
150
 
151
  = 3.3.1 =
152
  * Done the update of the Facebook SDK to latest.
157
  * Updated the information for the creation of facebook app for social login in note section.
158
 
159
  = 3.2.9 =
160
+ * Done the plugin compatibility tests with Wordpress version 4.8
161
+ * Removal of unnecessary commented codes from the plugin.
162
 
163
  = 3.2.8 =
164
+ * Done the checking if there already exist the Google OAuth class as it's creating an error if another plugin already included it.
165
 
166
  = 3.2.7 =
167
  * Done the update of the font-awesome icons to version 4.7.0 in the plugin.
168
 
169
  = 3.2.6 =
170
+ * Done the modification of the callback URL function to work with custom login URL.
171
  * Fixed the issue appearing for the database insert error due to gender input field.
172
 
173
  = 3.2.5 =
174
+ * Fixed the display of the error message when the user denies the authorization of the app for login.
175
 
176
  = 3.2.4 =
177
  * Now our plugin can fetch the twitter user's email address while doing social login using twitter(applicable for new user login only).
178
+ * Fixed the google login issue if the user doesn't have Google+ account.
179
 
180
  = 3.2.3 =
181
+ * Added the check for the username and if the username is empty user email address will be used as the username.
182
 
183
  = 3.2.2 =
184
  * Done the code formatting and removal of unnecessary codes.
187
  * Fixed the input field size for the image size settings for the facebook.
188
 
189
  = 3.2.0 =
190
+ * Tested the plugin compatibility with Wordpress version 4.7
191
 
192
  = 3.1.9 =
193
+ * Done the removal of unnecessary codes from the login check functions.
194
  * Done the link fixings for the social media links in about page.
195
  * Done some strings translation ready in the shortcode.php file.
196
 
198
  * Done the addition of the notice for the google+ login info.
199
 
200
  = 3.1.7 =
201
+ * Done the removal of the 'bio' field from the facebook login to make the plugin compatible with the Facebook API version 2.8.
202
 
203
  = 3.1.6 =
204
  * Done the addition of the documentation link to how to use section.
207
  * Added More WordPress Resources link.
208
 
209
  = 3.1.4 =
210
+ * Fixed the error appearing for the BuddyPress.
211
 
212
  = 3.1.3 =
213
+ * Frontend and backend CSS optimization by removing unnecessary codes.
214
 
215
  = 3.1.2 =
216
+ * Done the bug fixing for the facebook login if the user doesn't allow to access email address.
217
 
218
  = 3.1.1 =
219
  * Done small bug fixings for twitter user fields.
220
  * Addition of the social login in the woocommerce login form.
221
+ * Done the bug fixings regarding the user login issue when a user changes the email address.
222
 
223
  = 3.1.0 =
224
  * Done the bug fixings for the google login.
225
+ * Done the bug fixings for the username repeat issue.
226
+ * Done the modification of the wp_new_user_notification function to match with WordPress version less than 4.3.1
227
 
228
  = 3.0.9 =
229
  * Done the bug fixing for the facebook login.
232
  * Modified facebook app creation note section.
233
 
234
  = 3.0.7 =
235
+ * Done the modification of plugin to set the username to first name.
236
 
237
  = 3.0.6 =
238
  * Done the text modifications in the about section.
242
  * Removed unnecessary commented code from plugins settings pages.
243
 
244
  = 3.0.4 =
245
+ * Done the addition of an option for the profile image dimension settings for Facebook.
246
 
247
  = 3.0.3 =
248
  * Done the modifications for the google app creation note section.
252
 
253
  = 3.0.1 =
254
  * Done the modifications of the note sections for the google settings.
255
+ * Done bug fixing for the email notifications for admin with blank user details after doing the upgrade of the notification function.
256
  * Done the addition of a hook to display the social login buttons when "Users must be registered and logged in to comment" checked in the discussions settings.
257
  * Done the addition of login redirect filter.
258
 
260
  * Done the update of the user notification function to latest.
261
 
262
  = 2.0.9 =
263
+ * Done the bug fixing for the facebook login with the newer API version v2.5.
264
 
265
  = 2.0.8 =
266
+ * Done the bug fixing for the email notifications for the admin with the blank user details when user denies the app for login.
267
 
268
  = 2.0.7 =
269
  * Addition of the header_sent method checking in the plugin's main class for the session start.
273
 
274
  = 2.0.5 =
275
  * Text domain changed to match the plugin folder name.
276
+ * Done the backend CSS modifications.
277
 
278
  = 2.0.4 =
279
  * Sanitization of the text fields for the plugin's backend settings.
294
  * Code optimization for the login check class.
295
 
296
  = 1.0.9 =
297
+ * Fixed the issues google redirect issues for after social login to the current page.
298
+ * Demo link URL change.
299
 
300
  = 1.0.8 =
301
  * Code optimization for activation and save settings page and login_check page.
302
 
303
  = 1.0.7 =
304
+ * Bug fixing for the social login issues with Facebook.
305
+ * Implemented the new version of the Facebook PHP SDK v5.0
306
 
307
  = 1.0.6 =
308
  * Code formatting and optimization for backend save settings.
324
 
325
  = 1.0.1 =
326
  * Change of the theme 4 for the social login icons with text.
327
+ * Addition of the necessary CSS for the theme 4.
328
 
329
  = 1.0.0 =
330
  * Plugin submitted to http://wordpress.org for review and approval
331
 
332
  == Upgrade Notice ==
333
+ There is an update available for the AccessPress Social Login lite Plugin. Please update to receive new updates and bug fixes.