WordPress Social Share, Social Login and Social Comments Plugin – Super Socializer - Version 7.13.13

Version Description

[9 February 2021] = [Bugfix] Social Login was not working in some cases because of PHP sessions

Download this release

Release Info

Developer the_champ
Plugin Icon 128x128 WordPress Social Share, Social Login and Social Comments Plugin – Super Socializer
Version 7.13.13
Comparing to
See all releases

Code changes from version 7.13.12 to 7.13.13

Files changed (2) hide show
  1. readme.txt +10 -4
  2. super_socializer.php +190 -327
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === WordPress Social Share, Social Login and Social Comments Plugin - Super Socializer ===
2
  Contributors: Heateor, farhan8heateor, jatin8heateor, the_champ, Hungarian Translator: László Tavaszi http://kerekmese.hu, Chinese Translator: CalmSmile calmsmile.org, Portuguese Translator: Paulo Purkyt https://www.linkedin.com/in/ppurkyt, Italian Translator: FG3D (Freedom's Gate) https://fg3d.net, Spanish translator: Ignacio Iglesias http://trespies.com, Arabic Translator: http://www.ArabsSM.com, Russian/Ukrainian Translator: Nicholas Lagunov
3
  Donate link: https://www.heateor.com/donate?action=Super+Socializer
4
  Tags: social login, social share, line login, social commenting, social comments, social plugin, profile data, social analytics, online identity, social profile storage, single sign-on, social media follow, facebook login, twitter login, linkedin login, google login, vkontakte login, Windows Live Login, Microsoft Login, Wordpress login, Yahoo login, Spotify login, Dribbble login, Kakao login, Github login, Twitch login, Instagram login, dropbox login, foursquare login, disqus login, reddit login
5
  Requires at least: 2.5.0
6
- Tested up to: 5.6
7
- Stable tag: 7.13.12
8
  License: GPLv2 or later
9
 
10
  The unique Social Plugin to let you integrate Social Login, Social Share, Social Comments and Social Media follow at your website
@@ -212,6 +212,9 @@ Yes, we can help you with it. Just drop an email at support[ at ]heateor[ dot ]c
212
  8. **Social Commenting**: Disqus Commenting selected
213
 
214
  == Changelog ==
 
 
 
215
  = 7.13.12 [27 January 2021] =
216
  [New] Added Dropbox, Foursquare, Disqus and Reddit in the Social Login networks
217
  [Improvement] Google login doesn't depend on any 3rd party library anymore
@@ -2216,4 +2219,7 @@ Yes, we can help you with it. Just drop an email at support[ at ]heateor[ dot ]c
2216
  [New] Added Dropbox, Foursquare, Disqus and Reddit in the Social Login networks
2217
  [Improvement] Google login doesn't depend on any 3rd party library anymore
2218
  [Bugfix] Social Avatar saved from Facebook login was appearing broken. Users need to login at least once via their Facebook account after this plugin-update to fix the broken social avatar
2219
- <a href="https://blog.heateor.com/super-socializer-supports-dropbox-reddit-foursquare-disqus-social-login" target="_blank">More details on What's new</a>
 
 
 
1
+ === Social Share, Social Login and Social Comments Plugin - Super Socializer ===
2
  Contributors: Heateor, farhan8heateor, jatin8heateor, the_champ, Hungarian Translator: László Tavaszi http://kerekmese.hu, Chinese Translator: CalmSmile calmsmile.org, Portuguese Translator: Paulo Purkyt https://www.linkedin.com/in/ppurkyt, Italian Translator: FG3D (Freedom's Gate) https://fg3d.net, Spanish translator: Ignacio Iglesias http://trespies.com, Arabic Translator: http://www.ArabsSM.com, Russian/Ukrainian Translator: Nicholas Lagunov
3
  Donate link: https://www.heateor.com/donate?action=Super+Socializer
4
  Tags: social login, social share, line login, social commenting, social comments, social plugin, profile data, social analytics, online identity, social profile storage, single sign-on, social media follow, facebook login, twitter login, linkedin login, google login, vkontakte login, Windows Live Login, Microsoft Login, Wordpress login, Yahoo login, Spotify login, Dribbble login, Kakao login, Github login, Twitch login, Instagram login, dropbox login, foursquare login, disqus login, reddit login
5
  Requires at least: 2.5.0
6
+ Tested up to: 5.6.1
7
+ Stable tag: 7.13.13
8
  License: GPLv2 or later
9
 
10
  The unique Social Plugin to let you integrate Social Login, Social Share, Social Comments and Social Media follow at your website
212
  8. **Social Commenting**: Disqus Commenting selected
213
 
214
  == Changelog ==
215
+ = 7.13.13 [9 February 2021] =
216
+ [Bugfix] Social Login was not working in some cases because of PHP sessions
217
+
218
  = 7.13.12 [27 January 2021] =
219
  [New] Added Dropbox, Foursquare, Disqus and Reddit in the Social Login networks
220
  [Improvement] Google login doesn't depend on any 3rd party library anymore
2219
  [New] Added Dropbox, Foursquare, Disqus and Reddit in the Social Login networks
2220
  [Improvement] Google login doesn't depend on any 3rd party library anymore
2221
  [Bugfix] Social Avatar saved from Facebook login was appearing broken. Users need to login at least once via their Facebook account after this plugin-update to fix the broken social avatar
2222
+ <a href="https://blog.heateor.com/super-socializer-supports-dropbox-reddit-foursquare-disqus-social-login" target="_blank">More details on What's new</a>
2223
+
2224
+ = 7.13.13 [9 February 2021] =
2225
+ [Bugfix] Social Login was not working in some cases because of PHP sessions
super_socializer.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Super Socializer
4
  Plugin URI: https://super-socializer-wordpress.heateor.com
5
  Description: A complete 360 degree solution to provide all the social features like Social Login, Social Commenting, Social Sharing, Social Media follow and more
6
- Version: 7.13.12
7
  Author: Team Heateor
8
  Author URI: https://www.heateor.com
9
  Text Domain: super-socializer
@@ -11,7 +11,7 @@ Domain Path: /languages
11
  License: GPL2+
12
  */
13
  defined('ABSPATH') or die("Cheating........Uh!!");
14
- define('THE_CHAMP_SS_VERSION', '7.13.12');
15
 
16
  require 'helper.php';
17
 
@@ -152,24 +152,15 @@ function the_champ_connect(){
152
  // Instagram
153
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Instagram')){
154
  if(isset($theChampLoginOptions['providers']) && in_array('instagram', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['insta_id']) && $theChampLoginOptions['insta_id'] != '' && isset($theChampLoginOptions['insta_app_secret']) && $theChampLoginOptions['insta_app_secret'] != ''){
155
- if(function_exists('session_start')){
156
- if(session_status() == PHP_SESSION_NONE){
157
- session_start();
158
- }
159
- }
160
  // save referrer url in state
161
- $_SESSION['super_socializer_instagram_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
162
- wp_redirect("https://api.instagram.com/oauth/authorize?client_id=".$theChampLoginOptions['insta_id']."&scope=user_profile,user_media&response_type=code&language=en-us&redirect_uri=".urlencode(home_url()."/SuperSocializerAuth/Instagram"));
163
  die;
164
  }
165
  }
166
 
167
- if(isset($_GET['code']) && remove_query_arg(array('code'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Instagram'){
168
- if(function_exists('session_start')){
169
- if(session_status() == PHP_SESSION_NONE){
170
- session_start();
171
- }
172
- }
173
  $postData = array(
174
  'client_id' => $theChampLoginOptions['insta_id'],
175
  'client_secret' => $theChampLoginOptions['insta_app_secret'],
@@ -200,12 +191,13 @@ function the_champ_connect(){
200
 
201
  if(is_object($profileData) && isset($profileData->id)){
202
  $profileData = the_champ_sanitize_profile_data($profileData, 'instagram');
203
- $instagramRedirectUrl = isset($_SESSION['super_socializer_instagram_redirect']) && $_SESSION['super_socializer_instagram_redirect'] ? esc_url(trim($_SESSION['super_socializer_instagram_redirect'])) : home_url();
204
- unset($_SESSION['super_socializer_instagram_redirect']);
205
  $response = the_champ_user_auth($profileData, 'instagram', $instagramRedirectUrl);
206
  if($response == 'show form'){
207
  return;
208
  }
 
209
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
210
  $redirectTo = the_champ_get_login_redirection_url($instagramRedirectUrl, true);
211
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
@@ -263,7 +255,8 @@ function the_champ_connect(){
263
  if(isset($theChampLoginOptions['li_key']) && $theChampLoginOptions['li_key'] != '' && isset($theChampLoginOptions['li_secret']) && $theChampLoginOptions['li_secret'] != ''){
264
  if(!isset($_GET['code']) && !isset($_GET['state'])){
265
  $linkedinAuthState = mt_rand();
266
- update_user_meta($linkedinAuthState, 'heateor_ss_linkedin_auth_state', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
 
267
  if(isset($_GET['heateorMSEnabled'])){
268
  update_user_meta($linkedinAuthState, 'heateor_ss_linkedin_mc_sub', 1);
269
  }
@@ -271,8 +264,7 @@ function the_champ_connect(){
271
  wp_redirect('https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id='.$theChampLoginOptions['li_key'].'&redirect_uri='.urlencode(home_url().'/?SuperSocializerAuth=Linkedin').'&state='. $linkedinAuthState .'&scope='.$linkedinScope);
272
  die;
273
  }
274
- if(isset($_GET['code']) && isset($_GET['state']) && ($linkedinRedirectUrl = get_user_meta(esc_attr(trim($_GET['state'])), 'heateor_ss_linkedin_auth_state', true))){
275
- delete_user_meta(esc_attr(trim($_GET['state'])), 'heateor_ss_linkedin_auth_state');
276
  $url = 'https://www.linkedin.com/oauth/v2/accessToken';
277
  $data_access_token = array(
278
  'grant_type' => 'authorization_code',
@@ -328,10 +320,12 @@ function the_champ_connect(){
328
  );
329
 
330
  $profileData = the_champ_sanitize_profile_data($user, 'linkedin');
331
- if(get_user_meta(esc_attr(trim($_GET['state'])), 'heateor_ss_linkedin_mc_sub', true)){
 
332
  $profileData['mc_subscribe'] = 1;
333
  delete_user_meta($linkedinAuthState, 'heateor_ss_linkedin_mc_sub');
334
  }
 
335
  $response = the_champ_user_auth($profileData, 'linkedin', $linkedinRedirectUrl);
336
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
337
  $redirectTo = the_champ_get_login_redirection_url($linkedinRedirectUrl, true);
@@ -395,11 +389,11 @@ function the_champ_connect(){
395
  if(is_object($profileData) && isset($profileData->userId)){
396
  $profileData = the_champ_sanitize_profile_data($profileData, 'line');
397
  $lineRedirectUrl = isset($_SESSION['super_socializer_line_redirect']) && $_SESSION['super_socializer_line_redirect'] ? esc_url(trim($_SESSION['super_socializer_line_redirect'])) : home_url();
398
- unset($_SESSION['super_socializer_line_redirect']);
399
  $response = the_champ_user_auth($profileData, 'line', $lineRedirectUrl);
400
  if($response == 'show form'){
401
  return;
402
  }
 
403
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
404
  $redirectTo = the_champ_get_login_redirection_url($lineRedirectUrl, true);
405
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
@@ -420,26 +414,16 @@ function the_champ_connect(){
420
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Yahoo')){
421
  if(isset($theChampLoginOptions['providers']) && in_array('yahoo', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['yahoo_channel_id']) && $theChampLoginOptions['yahoo_channel_id'] != '' && isset($theChampLoginOptions['yahoo_channel_secret']) && $theChampLoginOptions['yahoo_channel_secret'] != ''){
422
  if(!isset($_GET['code'])){
423
- if(function_exists('session_start')){
424
- if(session_status() == PHP_SESSION_NONE){
425
- session_start();
426
- }
427
- }
428
  // save referrer url in state
429
- $_SESSION['super_socializer_yahoo_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
430
  }
431
- wp_redirect("https://api.login.yahoo.com/oauth2/request_auth?client_id=".$theChampLoginOptions['yahoo_channel_id']."&response_type=code&language=en-us&redirect_uri=".home_url()."/SuperSocializerAuth/Yahoo");
432
  die;
433
  }
434
  }
435
 
436
- if(isset($_GET['code']) && remove_query_arg(array('code'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Yahoo'){
437
- if(function_exists('session_start')){
438
- if(session_status() == PHP_SESSION_NONE){
439
- session_start();
440
- }
441
- }
442
-
443
  $postData = array(
444
  'grant_type' => 'authorization_code',
445
  'code' => esc_attr(trim($_GET['code'])),
@@ -469,12 +453,13 @@ function the_champ_connect(){
469
 
470
  if(is_object($profileData) && isset($profileData->sub)){
471
  $profileData = the_champ_sanitize_profile_data($profileData, 'yahoo');
472
- $yahooRedirectUrl = isset($_SESSION['super_socializer_yahoo_redirect']) && $_SESSION['super_socializer_yahoo_redirect'] ? esc_url(trim($_SESSION['super_socializer_yahoo_redirect'])) : home_url();
473
- unset($_SESSION['super_socializer_yahoo_redirect']);
474
  $response = the_champ_user_auth($profileData, 'yahoo', $yahooRedirectUrl);
475
  if($response == 'show form'){
476
  return;
477
  }
 
478
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
479
  $redirectTo = the_champ_get_login_redirection_url($yahooRedirectUrl, true);
480
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
@@ -497,25 +482,15 @@ function the_champ_connect(){
497
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Wordpress')){
498
  if(isset($theChampLoginOptions['providers']) && in_array('wordpress', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['wordpress_client_id']) && $theChampLoginOptions['wordpress_client_id'] != '' && isset($theChampLoginOptions['wordpress_client_secret']) && $theChampLoginOptions['wordpress_client_secret'] != ''){
499
  if(!isset($_GET['code'])){
500
- if(function_exists('session_start')){
501
- if(session_status() == PHP_SESSION_NONE){
502
- session_start();
503
- }
504
- }
505
  // save referrer url in state
506
- $_SESSION['super_socializer_wordpress_redirect'] = isset($_GET['super_socializer_wordpress_redirect_to']) ? esc_url(trim($_GET['super_socializer_wordpress_redirect_to'])) : home_url();
507
  }
508
- wp_redirect("https://public-api.wordpress.com/oauth2/authorize?client_id=".$theChampLoginOptions['wordpress_client_id']."&scope=auth&response_type=code&redirect_uri=".home_url()."/SuperSocializerAuth/Wordpress");
509
  die;
510
  }
511
  }
512
- if(isset($_GET['code']) && remove_query_arg(array('code','state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Wordpress'){
513
- if(function_exists('session_start')){
514
- if(session_status() == PHP_SESSION_NONE){
515
- session_start();
516
- }
517
- }
518
-
519
  $postData = array(
520
  'grant_type' => 'authorization_code',
521
  'code' => esc_attr(trim($_GET['code'])),
@@ -545,12 +520,13 @@ function the_champ_connect(){
545
 
546
  if(is_object($profileData) && isset($profileData->ID)){
547
  $profileData = the_champ_sanitize_profile_data($profileData, 'wordpress');
548
- $wordpressRedirectUrl = isset($_SESSION['super_socializer_wordpress_redirect']) && $_SESSION['super_socializer_wordpress_redirect'] ? esc_url(trim($_SESSION['super_socializer_wordpress_redirect'])) : home_url();
549
- unset($_SESSION['super_socializer_wordpress_redirect']);
550
  $response = the_champ_user_auth($profileData, 'wordpress', $wordpressRedirectUrl);
551
  if($response == 'show form'){
552
  return;
553
  }
 
554
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
555
  $redirectTo = the_champ_get_login_redirection_url($wordpressRedirectUrl, true);
556
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
@@ -572,24 +548,14 @@ function the_champ_connect(){
572
  // windows live
573
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Live')){
574
  if(isset($theChampLoginOptions['providers']) && in_array('microsoft', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['live_channel_id']) && $theChampLoginOptions['live_channel_id'] != '' && isset($theChampLoginOptions['live_channel_secret']) && $theChampLoginOptions['live_channel_secret'] != ''){
575
- if(function_exists('session_start')){
576
- if(session_status() == PHP_SESSION_NONE){
577
- session_start();
578
- }
579
- }
580
  // save referrer url in state
581
- $_SESSION['super_socializer_live_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
582
- wp_redirect("https://login.live.com/oauth20_authorize.srf?client_id=".$theChampLoginOptions['live_channel_id']."&scope=wl.emails,wl.basic&response_type=code&redirect_uri=".home_url()."/SuperSocializerAuth/Live");
583
  die;
584
  }
585
  }
586
- if(isset($_GET['code']) && remove_query_arg(array('code'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Live'){
587
- if(function_exists('session_start')){
588
- if(session_status() == PHP_SESSION_NONE){
589
- session_start();
590
- }
591
- }
592
-
593
  $postData = array(
594
  'grant_type' => 'authorization_code',
595
  'code' => esc_attr(trim($_GET['code'])),
@@ -617,12 +583,13 @@ function the_champ_connect(){
617
 
618
  if(is_object($profileData) && isset($profileData->id)){
619
  $profileData = the_champ_sanitize_profile_data($profileData, 'microsoft');
620
- $liveRedirectUrl = isset($_SESSION['super_socializer_live_redirect']) && $_SESSION['super_socializer_live_redirect'] ? esc_url(trim($_SESSION['super_socializer_live_redirect'])) : home_url();
621
- unset($_SESSION['super_socializer_live_redirect']);
622
  $response = the_champ_user_auth($profileData, 'microsoft', $liveRedirectUrl);
623
  if($response == 'show form'){
624
  return;
625
  }
 
626
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
627
  $redirectTo = the_champ_get_login_redirection_url($liveRedirectUrl, true);
628
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
@@ -641,30 +608,20 @@ function the_champ_connect(){
641
  }
642
  }
643
 
644
- //twitch
645
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Twitch')){
646
  if(isset($theChampLoginOptions['providers']) && in_array('twitch', $theChampLoginOptions['providers']) && $theChampLoginOptions['twitch_client_id'] && $theChampLoginOptions['twitch_client_secret']){
647
  if(!isset($_GET['code'])){
648
- if(function_exists('session_start')){
649
- if(session_status() == PHP_SESSION_NONE){
650
- session_start();
651
- }
652
- }
653
  // save referrer url in state
654
- $_SESSION['super_socializer_twitch_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
655
  }
656
- wp_redirect("https://id.twitch.tv/oauth2/authorize?client_id=".$theChampLoginOptions['twitch_client_id']."&scope=user_read&response_type=code&redirect_uri=".urlencode(home_url()."/SuperSocializerAuth/Twitch"));
657
  die;
658
  }
659
  }
660
 
661
- if(isset($_GET['code']) && remove_query_arg(array('code','scope'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Twitch'){
662
- if(function_exists('session_start')){
663
- if(session_status() == PHP_SESSION_NONE){
664
- session_start();
665
- }
666
- }
667
-
668
  $postData = array(
669
  'grant_type' => 'authorization_code',
670
  'code' => esc_attr(trim($_GET['code'])),
@@ -694,12 +651,13 @@ function the_champ_connect(){
694
 
695
  if(is_object($profileData) && isset($profileData->_id)){
696
  $profileData = the_champ_sanitize_profile_data($profileData, 'twitch');
697
- $twitchRedirectUrl = isset($_SESSION['super_socializer_twitch_redirect']) && $_SESSION['super_socializer_twitch_redirect'] ? esc_url(trim($_SESSION['super_socializer_twitch_redirect'])) : home_url();
698
- unset($_SESSION['super_socializer_twitch_redirect']);
699
  $response = the_champ_user_auth($profileData, 'twitch', $twitchRedirectUrl);
700
  if($response == 'show form'){
701
  return;
702
  }
 
703
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
704
  $redirectTo = the_champ_get_login_redirection_url($twitchRedirectUrl, true);
705
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
@@ -720,32 +678,19 @@ function the_champ_connect(){
720
  // reddit
721
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Reddit')){
722
  if(isset($theChampLoginOptions['providers']) && in_array('reddit', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['reddit_client_id']) && $theChampLoginOptions['reddit_client_id'] != '' && isset($theChampLoginOptions['reddit_client_secret']) && $theChampLoginOptions['reddit_client_secret'] != ''){
723
- if(function_exists('session_start')){
724
- if(session_status() == PHP_SESSION_NONE){
725
- session_start();
726
- }
727
- }
728
- // save referrer url in state
729
- $_SESSION['super_socializer_disqus_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
730
- $_SESSION['super_socializer_reddit_state'] = mt_rand();
731
- wp_redirect("https://ssl.reddit.com/api/v1/authorize?client_id=" . $theChampLoginOptions['reddit_client_id'] . "&scope=identity&state=" . $_SESSION['super_socializer_reddit_state'] . "&duration=temporary&response_type=code&redirect_uri=" . home_url() . "/SuperSocializerAuth/Reddit");
732
  die;
733
  }
734
  }
735
- if(isset($_GET['code']) && remove_query_arg(array(
736
  'code',
737
  'state',
738
  'scope'
739
  ), html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))) == home_url() . '/SuperSocializerAuth/Reddit'){
740
- if(function_exists('session_start')){
741
- if(session_status() == PHP_SESSION_NONE){
742
- session_start();
743
- }
744
- }
745
- if(esc_attr(trim($_GET['state'])) != $_SESSION['super_socializer_reddit_state']){
746
- return;
747
- }
748
- $post_data = array(
749
  'grant_type' => 'authorization_code',
750
  'code' => esc_attr(trim($_GET['code'])),
751
  'redirect_uri' => home_url() . "/SuperSocializerAuth/Reddit",
@@ -761,7 +706,7 @@ function the_champ_connect(){
761
  'Content-Type' => 'application/x-www-form-urlencoded',
762
  'Authorization' => 'Basic ' . base64_encode($theChampLoginOptions['reddit_client_id'] . ':' . $theChampLoginOptions['reddit_client_secret'])
763
  ),
764
- 'body' => http_build_query($post_data)
765
  ));
766
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
767
  $body = json_decode(wp_remote_retrieve_body($response));
@@ -775,24 +720,24 @@ function the_champ_connect(){
775
  $profileData = json_decode(wp_remote_retrieve_body($response));
776
  if(is_object($profileData) && isset($profileData->id) && isset($profileData->verified) && $profileData->verified == 1){
777
  $profileData = the_champ_sanitize_profile_data($profileData, 'reddit');
778
- $reddit_redirect_url = isset($_SESSION['super_socializer_disqus_redirect']) && $_SESSION['super_socializer_disqus_redirect'] ? esc_url(trim($_SESSION['super_socializer_disqus_redirect'])) : home_url();
779
- unset($_SESSION['super_socializer_disqus_redirect']);
780
- $response = the_champ_user_auth($profileData, 'reddit', $reddit_redirect_url);
781
  if($response == 'show form'){
782
  return;
783
  }
784
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
785
- $redirect_to = the_champ_get_login_redirection_url($reddit_redirect_url, true);
786
  } elseif(isset($response['message']) && $response['message'] == 'linked'){
787
- $redirect_to = $reddit_redirect_url . (strpos($reddit_redirect_url, '?') !== false ? '&' : '?') . 'linked=1';
788
  } elseif(isset($response['message']) && $response['message'] == 'not linked'){
789
- $redirect_to = $reddit_redirect_url . (strpos($reddit_redirect_url, '?') !== false ? '&' : '?') . 'linked=0';
790
  } elseif(isset($response['url']) && $response['url'] != ''){
791
- $redirect_to = $response['url'];
792
  } else {
793
- $redirect_to = the_champ_get_login_redirection_url($reddit_redirect_url);
794
  }
795
- the_champ_close_login_popup($redirect_to);
796
  }
797
  }
798
  }
@@ -801,27 +746,19 @@ function the_champ_connect(){
801
  //disqus
802
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Disqus')){
803
  if(isset($theChampLoginOptions['providers']) && in_array('disqus', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['disqus_public_key']) && $theChampLoginOptions['disqus_public_key'] != '' && isset($theChampLoginOptions['disqus_secret_key']) && $theChampLoginOptions['disqus_secret_key'] != ''){
804
- if(function_exists('session_start')){
805
- if(session_status() == PHP_SESSION_NONE){
806
- session_start();
807
- }
808
- }
809
- // save referrer url in state
810
- $_SESSION['super_socializer_disqus_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
811
- wp_redirect("https://disqus.com/api/oauth/2.0/authorize/?client_id=" . $theChampLoginOptions['disqus_public_key'] . "&scope=read,email&response_type=code&redirect_uri=" . home_url() . "/SuperSocializerAuth/Disqus");
812
  die;
813
  }
814
  }
815
- if(isset($_GET['code']) && remove_query_arg(array(
816
  'code',
817
- 'scope'
 
818
  ), html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))) == home_url() . '/SuperSocializerAuth/Disqus'){
819
- if(function_exists('session_start')){
820
- if(session_status() == PHP_SESSION_NONE){
821
- session_start();
822
- }
823
- }
824
- $post_data = array(
825
  'grant_type' => 'authorization_code',
826
  'code' => esc_attr(trim($_GET['code'])),
827
  'redirect_uri' => home_url() . "/SuperSocializerAuth/Disqus",
@@ -837,7 +774,7 @@ function the_champ_connect(){
837
  'Content-Type' => 'application/x-www-form-urlencoded',
838
  'Authorization' => 'Basic ' . base64_encode($theChampLoginOptions['disqus_public_key'] . ':' . $theChampLoginOptions['disqus_secret_key'])
839
  ),
840
- 'body' => http_build_query($post_data)
841
  ));
842
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
843
  $body = json_decode(wp_remote_retrieve_body($response));
@@ -851,24 +788,25 @@ function the_champ_connect(){
851
  $profileData = json_decode(wp_remote_retrieve_body($response));
852
  if(is_object($profileData) && isset($profileData->response->id)){
853
  $profileData = the_champ_sanitize_profile_data($profileData, 'disqus');
854
- $disqus_redirect_url = isset($_SESSION['super_socializer_disqus_redirect']) && $_SESSION['super_socializer_disqus_redirect'] ? esc_url(trim($_SESSION['super_socializer_disqus_redirect'])) : home_url();
855
- unset($_SESSION['super_socializer_disqus_redirect']);
856
- $response = the_champ_user_auth($profileData, 'disqus', $disqus_redirect_url);
857
  if($response == 'show form'){
858
  return;
859
  }
 
860
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
861
- $redirect_to = the_champ_get_login_redirection_url($disqus_redirect_url, true);
862
  } elseif(isset($response['message']) && $response['message'] == 'linked'){
863
- $redirect_to = $disqus_redirect_url . (strpos($disqus_redirect_url, '?') !== false ? '&' : '?') . 'linked=1';
864
  } elseif(isset($response['message']) && $response['message'] == 'not linked'){
865
- $redirect_to = $disqus_redirect_url . (strpos($disqus_redirect_url, '?') !== false ? '&' : '?') . 'linked=0';
866
  } elseif(isset($response['url']) && $response['url'] != ''){
867
- $redirect_to = $response['url'];
868
  } else {
869
- $redirect_to = the_champ_get_login_redirection_url($disqus_redirect_url);
870
  }
871
- the_champ_close_login_popup($redirect_to);
872
  }
873
  }
874
  }
@@ -877,32 +815,19 @@ function the_champ_connect(){
877
  //dropbox
878
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Dropbox')){
879
  if(isset($theChampLoginOptions['providers']) && in_array('dropbox', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['dropbox_app_key']) && $theChampLoginOptions['dropbox_app_key'] != '' && isset($theChampLoginOptions['dropbox_app_secret']) && $theChampLoginOptions['dropbox_app_secret'] != ''){
880
- if(function_exists('session_start')){
881
- if(session_status() == PHP_SESSION_NONE){
882
- session_start();
883
- }
884
- }
885
- // save referrer url in state
886
- $_SESSION['super_socializer_dropbox_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
887
- $_SESSION['super_socializer_dropbox_state'] = mt_rand();
888
- wp_redirect("https://www.dropbox.com/1/oauth2/authorize?client_id=" . $theChampLoginOptions['dropbox_app_key'] . "&scope=account_info.read&state=" . $_SESSION['super_socializer_dropbox_state'] . "&response_type=code&redirect_uri=" . home_url() . "/SuperSocializerAuth/Dropbox");
889
  die;
890
  }
891
  }
892
- if(isset($_GET['code']) && remove_query_arg(array(
893
  'code',
894
  'scope',
895
  'state'
896
  ), html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))) == home_url() . '/SuperSocializerAuth/Dropbox'){
897
- if(function_exists('session_start')){
898
- if(session_status() == PHP_SESSION_NONE){
899
- session_start();
900
- }
901
- }
902
- if(esc_attr(trim($_GET['state'])) != $_SESSION['super_socializer_dropbox_state']){
903
- return;
904
- }
905
- $post_data = array(
906
  'grant_type' => 'authorization_code',
907
  'code' => esc_attr(trim($_GET['code'])),
908
  'redirect_uri' => home_url() . "/SuperSocializerAuth/Dropbox"
@@ -917,7 +842,7 @@ function the_champ_connect(){
917
  'Content-Type' => 'application/x-www-form-urlencoded',
918
  'Authorization' => 'Basic ' . base64_encode($theChampLoginOptions['dropbox_app_key'] . ':' . $theChampLoginOptions['dropbox_app_secret'])
919
  ),
920
- 'body' => http_build_query($post_data)
921
  ));
922
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
923
  $body = json_decode(wp_remote_retrieve_body($response));
@@ -932,25 +857,26 @@ function the_champ_connect(){
932
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
933
  $profileData = json_decode(wp_remote_retrieve_body($response));
934
  if(is_object($profileData) && isset($profileData->account_id)){
935
- $profileData = the_champ_sanitize_profile_data($profileData, 'dropbox');
936
- $dropbox_redirect_url = isset($_SESSION['super_socializer_dropbox_redirect']) && $_SESSION['super_socializer_dropbox_redirect'] ? esc_url(trim($_SESSION['super_socializer_dropbox_redirect'])) : home_url();
937
- unset($_SESSION['super_socializer_dropbox_redirect']);
938
- $response = the_champ_user_auth($profileData, 'dropbox', $dropbox_redirect_url);
939
  if($response == 'show form'){
940
  return;
941
  }
 
942
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
943
- $redirect_to = the_champ_get_login_redirection_url($dropbox_redirect_url, true);
944
  } elseif(isset($response['message']) && $response['message'] == 'linked'){
945
- $redirect_to = $dropbox_redirect_url . (strpos($dropbox_redirect_url, '?') !== false ? '&' : '?') . 'linked=1';
946
  } elseif(isset($response['message']) && $response['message'] == 'not linked'){
947
- $redirect_to = $dropbox_redirect_url . (strpos($dropbox_redirect_url, '?') !== false ? '&' : '?') . 'linked=0';
948
  } elseif(isset($response['url']) && $response['url'] != ''){
949
- $redirect_to = $response['url'];
950
  } else {
951
- $redirect_to = the_champ_get_login_redirection_url($dropbox_redirect_url);
952
  }
953
- the_champ_close_login_popup($redirect_to);
954
  }
955
  }
956
  }
@@ -959,26 +885,17 @@ function the_champ_connect(){
959
  // foursquare
960
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Foursquare')){
961
  if(isset($theChampLoginOptions['providers']) && in_array('foursquare', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['foursquare_client_id']) && $theChampLoginOptions['foursquare_client_id'] != '' && isset($theChampLoginOptions['foursquare_client_secret']) && $theChampLoginOptions['foursquare_client_secret'] != ''){
962
- if(function_exists('session_start')){
963
- if(session_status() == PHP_SESSION_NONE){
964
- session_start();
965
- }
966
- }
967
- // save referrer url in state
968
- $_SESSION['super_socializer_foursquare_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
969
- wp_redirect("https://foursquare.com/oauth2/authenticate/?client_id=" . $theChampLoginOptions['foursquare_client_id'] . "&response_type=code&redirect_uri=" . home_url() . "/SuperSocializerAuth/Foursquare");
970
  die;
971
  }
972
  }
973
- if(isset($_GET['code']) && remove_query_arg(array(
974
- 'code'
975
  ), html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))) == home_url() . '/SuperSocializerAuth/Foursquare'){
976
- if(function_exists('session_start')){
977
- if(session_status() == PHP_SESSION_NONE){
978
- session_start();
979
- }
980
- }
981
- $post_data = array(
982
  'grant_type' => 'authorization_code',
983
  'code' => esc_attr(trim($_GET['code'])),
984
  'redirect_uri' => home_url() . "/SuperSocializerAuth/Foursquare",
@@ -994,7 +911,7 @@ function the_champ_connect(){
994
  'Content-Type' => 'application/x-www-form-urlencoded',
995
  'Authorization' => 'Basic ' . base64_encode($theChampLoginOptions['foursquare_client_id'] . ':' . $theChampLoginOptions['foursquare_client_secret'])
996
  ),
997
- 'body' => http_build_query($post_data)
998
  ));
999
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1000
  $body = json_decode(wp_remote_retrieve_body($response));
@@ -1005,27 +922,27 @@ function the_champ_connect(){
1005
  )
1006
  ));
1007
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1008
- $profile_data = json_decode(wp_remote_retrieve_body($response));
1009
- if(is_object($profile_data) && isset($profile_data->response->user->id)){
1010
- $profile_data = the_champ_sanitize_profile_data($profile_data, 'foursquare');
1011
- $foursquare_redirect_url = isset($_SESSION['super_socializer_foursquare_redirect']) && $_SESSION['super_socializer_foursquare_redirect'] ? esc_url(trim($_SESSION['super_socializer_foursquare_redirect'])) : home_url();
1012
- unset($_SESSION['super_socializer_foursquare_redirect']);
1013
- $response = the_champ_user_auth($profile_data, 'foursquare', $foursquare_redirect_url);
1014
  if($response == 'show form'){
1015
  return;
1016
  }
1017
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
1018
- $redirect_to = the_champ_get_login_redirection_url($foursquare_redirect_url, true);
1019
  } elseif(isset($response['message']) && $response['message'] == 'linked'){
1020
- $redirect_to = $foursquare_redirect_url . (strpos($foursquare_redirect_url, '?') !== false ? '&' : '?') . 'linked=1';
1021
  } elseif(isset($response['message']) && $response['message'] == 'not linked'){
1022
- $redirect_to = $foursquare_redirect_url . (strpos($foursquare_redirect_url, '?') !== false ? '&' : '?') . 'linked=0';
1023
  } elseif(isset($response['url']) && $response['url'] != ''){
1024
- $redirect_to = $response['url'];
1025
  } else {
1026
- $redirect_to = the_champ_get_login_redirection_url($foursquare_redirect_url);
1027
  }
1028
- the_champ_close_login_popup($redirect_to);
1029
  }
1030
  }
1031
  }
@@ -1035,26 +952,16 @@ function the_champ_connect(){
1035
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Dribbble')){
1036
  if(isset($theChampLoginOptions['providers']) && in_array('dribbble', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['dribbble_client_id']) && $theChampLoginOptions['dribbble_client_id'] != '' && isset($theChampLoginOptions['dribbble_client_secret']) && $theChampLoginOptions['dribbble_client_secret'] != ''){
1037
  if(!isset($_GET['code'])){
1038
- if(function_exists('session_start')){
1039
- if(session_status() == PHP_SESSION_NONE){
1040
- session_start();
1041
- }
1042
- }
1043
  // save referrer url in state
1044
- $_SESSION['super_socializer_dribbble_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
1045
  }
1046
- wp_redirect("https://dribbble.com/oauth/authorize?client_id=".$theChampLoginOptions['dribbble_client_id']."&scope=public&redirect_uri=".urlencode(home_url()."/SuperSocializerAuth/Dribbble"));
1047
  die;
1048
  }
1049
  }
1050
 
1051
- if(isset($_GET['code']) && remove_query_arg(array('code','scope'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Dribbble'){
1052
- if(function_exists('session_start')){
1053
- if(session_status() == PHP_SESSION_NONE){
1054
- session_start();
1055
- }
1056
- }
1057
-
1058
  $postData = array(
1059
  'grant_type' => 'authorization_code',
1060
  'code' => esc_attr(trim($_GET['code'])),
@@ -1080,13 +987,12 @@ function the_champ_connect(){
1080
  $response = wp_remote_get("https://api.dribbble.com/v2/user?access_token", array('timeout' => 15, 'headers' => array('Accept' => 'application/json' , 'Authorization' => $authorization )));
1081
 
1082
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1083
- $profileData = json_decode(wp_remote_retrieve_body( $response ));
1084
-
1085
- if(is_object($profileData) && isset($profileData->id)){
1086
- $profileData = the_champ_sanitize_profile_data($profileData, 'dribbble');
1087
- $yahooRedirectUrl = isset($_SESSION['super_socializer_dribbble_redirect']) && $_SESSION['super_socializer_dribbble_redirect'] ? esc_url(trim($_SESSION['super_socializer_dribbble_redirect'])) : home_url();
1088
- unset($_SESSION['super_socializer_dribbble_redirect']);
1089
- $response = the_champ_user_auth($profileData, 'dribbble', $yahooRedirectUrl);
1090
  if($response == 'show form'){
1091
  return;
1092
  }
@@ -1111,24 +1017,15 @@ function the_champ_connect(){
1111
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Spotify')){
1112
  if(isset($theChampLoginOptions['providers']) && in_array('spotify', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['spotify_client_id']) && $theChampLoginOptions['spotify_client_id'] != '' && isset($theChampLoginOptions['spotify_client_secret']) && $theChampLoginOptions['spotify_client_secret'] != ''){
1113
  if(!isset($_GET['code'])){
1114
- if(function_exists('session_start')){
1115
- if(session_status() == PHP_SESSION_NONE){
1116
- session_start();
1117
- }
1118
- }
1119
  // save referrer url in state
1120
- $_SESSION['super_socializer_spotify_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
1121
  }
1122
- wp_redirect("https://accounts.spotify.com/authorize?client_id=".$theChampLoginOptions['spotify_client_id']."&scope=user-read-email&response_type=code&redirect_uri=".home_url()."/SuperSocializerAuth/Spotify");
1123
  die;
1124
  }
1125
  }
1126
- if(isset($_GET['code']) && remove_query_arg(array('code'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Spotify'){
1127
- if(function_exists('session_start')){
1128
- if(session_status() == PHP_SESSION_NONE){
1129
- session_start();
1130
- }
1131
- }
1132
  $postData = array(
1133
  'grant_type' => 'authorization_code',
1134
  'code' => esc_attr(trim($_GET['code'])),
@@ -1155,9 +1052,9 @@ function the_champ_connect(){
1155
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1156
  $profileData = json_decode(wp_remote_retrieve_body( $response ));
1157
  if(is_object($profileData) && isset($profileData->id)){
1158
- $profileData = the_champ_sanitize_profile_data($profileData, 'spotify');
1159
- $spotifyRedirectUrl = isset($_SESSION['super_socializer_spotify_redirect']) && $_SESSION['super_socializer_spotify_redirect'] ? esc_url(trim($_SESSION['super_socializer_spotify_redirect'])) : home_url();
1160
- unset($_SESSION['super_socializer_spotify_redirect']);
1161
  $response = the_champ_user_auth($profileData, 'spotify', $spotifyRedirectUrl);
1162
  if($response == 'show form'){
1163
  return;
@@ -1184,25 +1081,15 @@ function the_champ_connect(){
1184
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Kakao')){
1185
  if(isset($theChampLoginOptions['providers']) && in_array('kakao', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['kakao_client_id']) && $theChampLoginOptions['kakao_client_id'] != '' && isset($theChampLoginOptions['kakao_client_secret']) && $theChampLoginOptions['kakao_client_secret'] != ''){
1186
  if(!isset($_GET['code'])){
1187
- if(function_exists('session_start')){
1188
- if(session_status() == PHP_SESSION_NONE){
1189
- session_start();
1190
- }
1191
- }
1192
  // save referrer url in state
1193
- $_SESSION['super_socializer_kakao_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
1194
  }
1195
- wp_redirect("https://kauth.kakao.com/oauth/authorize?client_id=".$theChampLoginOptions['kakao_client_id']."&state=state&response_type=code&redirect_uri=".home_url()."/SuperSocializerAuth/Kakao");
1196
  die;
1197
  }
1198
  }
1199
- if(isset($_GET['code']) && remove_query_arg(array('code','state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Kakao'){
1200
- if(function_exists('session_start')){
1201
- if(session_status() == PHP_SESSION_NONE){
1202
- session_start();
1203
- }
1204
- }
1205
-
1206
  $postData = array(
1207
  'grant_type' => 'authorization_code',
1208
  'code' => esc_attr(trim($_GET['code'])),
@@ -1229,15 +1116,15 @@ function the_champ_connect(){
1229
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1230
  $profileData = json_decode(wp_remote_retrieve_body( $response ));
1231
  if(is_object($profileData) && isset($profileData->id)){
1232
- $profileData = the_champ_sanitize_profile_data($profileData, 'kakao');
1233
- $kakaoRedirectUrl = isset($_SESSION['super_socializer_kakao_redirect']) && $_SESSION['super_socializer_kakao_redirect'] ? esc_url(trim($_SESSION['super_socializer_kakao_redirect'])) : home_url();
1234
- unset($_SESSION['super_socializer_kakao_redirect']);
1235
  $response = the_champ_user_auth($profileData, 'kakao', $kakaoRedirectUrl);
1236
  if($response == 'show form'){
1237
  return;
1238
  }
1239
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
1240
- $redirectTo = the_champ_get_login_redirection_url($liveRedirectUrl, true);
1241
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
1242
  $redirectTo = $kakaoRedirectUrl . ( strpos( $kakaoRedirectUrl, '?' ) !== false ? '&' : '?' ) . 'linked=1';
1243
  }elseif(isset($response['message']) && $response['message'] == 'not linked'){
@@ -1258,24 +1145,15 @@ function the_champ_connect(){
1258
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Github')){
1259
  if(isset($theChampLoginOptions['providers']) && in_array('github', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['github_client_id']) && $theChampLoginOptions['github_client_id'] != '' && isset($theChampLoginOptions['github_client_secret']) && $theChampLoginOptions['github_client_secret'] != ''){
1260
  if(!isset($_GET['code'])){
1261
- if(function_exists('session_start')){
1262
- if(session_status() == PHP_SESSION_NONE){
1263
- session_start();
1264
- }
1265
- }
1266
  // save referrer url in state
1267
- $_SESSION['super_socializer_github_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
1268
  }
1269
- wp_redirect("https://github.com/login/oauth/authorize?client_id=".$theChampLoginOptions['github_client_id']."&scope=read:user user:email&state=state&response_type=code&redirect_uri=".home_url()."/SuperSocializerAuth/Github");
1270
  die;
1271
  }
1272
  }
1273
- if(isset($_GET['code']) && remove_query_arg(array('code','state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Github'){
1274
- if(function_exists('session_start')){
1275
- if(session_status() == PHP_SESSION_NONE){
1276
- session_start();
1277
- }
1278
- }
1279
  $postData = array(
1280
  'state' => 'state',
1281
  'code' => esc_attr(trim($_GET['code'])),
@@ -1318,15 +1196,15 @@ function the_champ_connect(){
1318
  }
1319
  }
1320
  }
1321
- $profileData = the_champ_sanitize_profile_data($profileData, 'github');
1322
- $githubRedirectUrl = isset($_SESSION['super_socializer_github_redirect']) && $_SESSION['super_socializer_github_redirect'] ? esc_url(trim($_SESSION['super_socializer_github_redirect'])) : home_url();
1323
- unset($_SESSION['super_socializer_github_redirect']);
1324
  $response = the_champ_user_auth($profileData, 'github', $githubRedirectUrl);
1325
  if($response == 'show form'){
1326
  return;
1327
  }
1328
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
1329
- $redirectTo = the_champ_get_login_redirection_url($liveRedirectUrl, true);
1330
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
1331
  $redirectTo = $githubRedirectUrl . ( strpos( $githubRedirectUrl, '?' ) !== false ? '&' : '?' ) . 'linked=1';
1332
  }elseif(isset($response['message']) && $response['message'] == 'not linked'){
@@ -1347,19 +1225,14 @@ function the_champ_connect(){
1347
  // Facebook
1348
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Facebook')){
1349
  if(isset($theChampLoginOptions['providers']) && in_array('facebook', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['fb_key']) && $theChampLoginOptions['fb_key'] != '' && isset($theChampLoginOptions['fb_secret']) && $theChampLoginOptions['fb_secret'] != ''){
1350
- if(function_exists('session_start')){
1351
- if(session_status() == PHP_SESSION_NONE){
1352
- session_start();
1353
- }
1354
- }
1355
  if(!isset($_GET['code'])){
 
1356
  // save referrer url in state
1357
- $_SESSION['super_socializer_facebook_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
1358
- $_SESSION['super_socializer_facebook_state'] = mt_rand();
1359
- wp_redirect("https://www.facebook.com/v9.0/dialog/oauth?scope=email&client_id=" . $theChampLoginOptions['fb_key'] . "&state=" . $_SESSION['super_socializer_facebook_state'] . "&redirect_uri=" . home_url() . "/?SuperSocializerAuth=Facebook");
1360
  die;
1361
- }elseif(isset($_GET['code']) && isset($_GET['state']) && esc_attr(trim($_GET['state'])) == $_SESSION['super_socializer_facebook_state']){
1362
- $post_data = array(
1363
  'code' => esc_attr(trim($_GET['code'])),
1364
  'redirect_uri' => home_url() . "/?SuperSocializerAuth=Facebook",
1365
  'client_id' => $theChampLoginOptions['fb_key'],
@@ -1374,7 +1247,7 @@ function the_champ_connect(){
1374
  'headers' => array(
1375
  'Content-Type' => 'application/x-www-form-urlencoded'
1376
  ),
1377
- 'body' => http_build_query($post_data)
1378
  ));
1379
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1380
  $body = json_decode(wp_remote_retrieve_body($response));
@@ -1386,24 +1259,25 @@ function the_champ_connect(){
1386
  $profileData = json_decode(wp_remote_retrieve_body($response));
1387
  if(is_object($profileData) && isset($profileData->id)){
1388
  $profileData = the_champ_sanitize_profile_data($profileData, 'facebook');
1389
- $facebook_redirect_url = isset($_SESSION['super_socializer_facebook_redirect']) && $_SESSION['super_socializer_facebook_redirect'] ? esc_url(trim($_SESSION['super_socializer_facebook_redirect'])) : home_url();
1390
- unset($_SESSION['super_socializer_facebook_redirect']);
 
1391
  $response = the_champ_user_auth($profileData, 'faceboook', $facebook_redirect_url);
1392
  if($response == 'show form'){
1393
  return;
1394
  }
1395
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
1396
- $redirect_to = the_champ_get_login_redirection_url($facebook_redirect_url, true);
1397
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
1398
- $redirect_to = $facebook_redirect_url . (strpos($facebook_redirect_url, '?') !== false ? '&' : '?') . 'linked=1';
1399
  }elseif(isset($response['message']) && $response['message'] == 'not linked'){
1400
- $redirect_to = $facebook_redirect_url . (strpos($facebook_redirect_url, '?') !== false ? '&' : '?') . 'linked=0';
1401
  }elseif(isset($response['url']) && $response['url'] != ''){
1402
- $redirect_to = $response['url'];
1403
  }else{
1404
- $redirect_to = the_champ_get_login_redirection_url($facebook_redirect_url);
1405
  }
1406
- the_champ_close_login_popup($redirect_to);
1407
  }
1408
  }
1409
  }
@@ -1415,26 +1289,16 @@ function the_champ_connect(){
1415
  // Google
1416
  if(isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Google') {
1417
  if(isset($theChampLoginOptions['providers']) && in_array('google', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['google_key']) && $theChampLoginOptions['google_key'] != '' && isset($theChampLoginOptions['google_secret']) && $theChampLoginOptions['google_secret'] != '') {
1418
- if(function_exists('session_start')) {
1419
- if(session_status() == PHP_SESSION_NONE) {
1420
- session_start();
1421
- }
1422
- }
1423
- // save referrer url in state
1424
- $_SESSION['super_socializer_google_redirect'] = isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url();
1425
- $_SESSION['super_socializer_google_state'] = mt_rand();
1426
- wp_redirect("https://accounts.google.com/o/oauth2/auth?client_id=" . $theChampLoginOptions['google_key'] . "&scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile&state=" . $_SESSION['super_socializer_google_state'] . "&response_type=code&redirect_uri=" . home_url());
1427
  die;
1428
  }
1429
  }
1430
- if(isset($_GET['code']) && isset($_GET['state'])) {
1431
- if(function_exists('session_start')) {
1432
- if(session_status() == PHP_SESSION_NONE) {
1433
- session_start();
1434
- }
1435
- }
1436
- if(isset($_SESSION['super_socializer_google_state']) && esc_attr(trim($_GET['state'])) == $_SESSION['super_socializer_google_state']) {
1437
- $post_data = array(
1438
  'grant_type' => 'authorization_code',
1439
  'code' => esc_attr(trim($_GET['code'])),
1440
  'redirect_uri' => home_url(),
@@ -1450,7 +1314,7 @@ function the_champ_connect(){
1450
  'headers' => array(
1451
  'Content-Type' => 'application/x-www-form-urlencoded'
1452
  ),
1453
- 'body' => http_build_query($post_data)
1454
  ));
1455
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']) {
1456
  $body = json_decode(wp_remote_retrieve_body($response));
@@ -1464,28 +1328,27 @@ function the_champ_connect(){
1464
  )
1465
  ));
1466
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']) {
1467
- $profile_data = json_decode(wp_remote_retrieve_body($response));
1468
- if(is_object($profile_data) && isset($profile_data->sub)) {
1469
- $profile_data = the_champ_sanitize_profile_data($profile_data, 'google');
1470
- $google_redirect_url = isset($_SESSION['super_socializer_google_redirect']) && $_SESSION['super_socializer_google_redirect'] ? esc_url(trim($_SESSION['super_socializer_google_redirect'])) : home_url();
1471
- unset($_SESSION['super_socializer_google_redirect']);
1472
- unset($_SESSION['super_socializer_google_state']);
1473
- $response = the_champ_user_auth($profile_data, 'google', $google_redirect_url);
1474
  if($response == 'show form') {
1475
  return;
1476
  }
1477
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')) {
1478
- $redirect_to = the_champ_get_login_redirection_url($google_redirect_url, true);
1479
  } elseif(isset($response['message']) && $response['message'] == 'linked') {
1480
- $redirect_to = $google_redirect_url . (strpos($google_redirect_url, '?') !== false ? '&' : '?') . 'linked=1';
1481
  } elseif(isset($response['message']) && $response['message'] == 'not linked') {
1482
- $redirect_to = $google_redirect_url . (strpos($google_redirect_url, '?') !== false ? '&' : '?') . 'linked=0';
1483
  } elseif(isset($response['url']) && $response['url'] != '') {
1484
- $redirect_to = $response['url'];
1485
  } else {
1486
- $redirect_to = the_champ_get_login_redirection_url($google_redirect_url);
1487
  }
1488
- the_champ_close_login_popup($redirect_to);
1489
  }
1490
  }
1491
  }
@@ -1698,11 +1561,11 @@ function the_champ_get_valid_url($url){
1698
  if(html_entity_decode(esc_url(remove_query_arg(array('ss_message', 'SuperSocializerVerified', 'SuperSocializerUnverified', 'wp_lang', 'loggedout'), $decodedUrl))) == wp_login_url() || $decodedUrl == home_url().'/wp-login.php?action=register'){
1699
  $url = esc_url(home_url()).'/';
1700
  }elseif(isset($_GET['redirect_to'])){
1701
- $redirect_to = esc_url($_GET['redirect_to']);
1702
- if(urldecode($redirect_to) == admin_url()){
1703
  $url = esc_url(home_url()).'/';
1704
- }elseif(the_champ_validate_url(urldecode($redirect_to)) && (strpos(urldecode($redirect_to), 'http://') !== false || strpos(urldecode($redirect_to), 'https://') !== false)){
1705
- $url = $redirect_to;
1706
  }else{
1707
  $url = esc_url(home_url()).'/';
1708
  }
3
  Plugin Name: Super Socializer
4
  Plugin URI: https://super-socializer-wordpress.heateor.com
5
  Description: A complete 360 degree solution to provide all the social features like Social Login, Social Commenting, Social Sharing, Social Media follow and more
6
+ Version: 7.13.13
7
  Author: Team Heateor
8
  Author URI: https://www.heateor.com
9
  Text Domain: super-socializer
11
  License: GPL2+
12
  */
13
  defined('ABSPATH') or die("Cheating........Uh!!");
14
+ define('THE_CHAMP_SS_VERSION', '7.13.13');
15
 
16
  require 'helper.php';
17
 
152
  // Instagram
153
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Instagram')){
154
  if(isset($theChampLoginOptions['providers']) && in_array('instagram', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['insta_id']) && $theChampLoginOptions['insta_id'] != '' && isset($theChampLoginOptions['insta_app_secret']) && $theChampLoginOptions['insta_app_secret'] != ''){
155
+ $instagramLoginState = mt_rand();
 
 
 
 
156
  // save referrer url in state
157
+ update_user_meta( $instagramLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url() );
158
+ wp_redirect("https://api.instagram.com/oauth/authorize?client_id=".$theChampLoginOptions['insta_id']."&scope=user_profile,user_media&response_type=code&language=en-us&state=".$instagramLoginState."&redirect_uri=".urlencode(home_url()."/SuperSocializerAuth/Instagram"));
159
  die;
160
  }
161
  }
162
 
163
+ if(isset($_GET['code']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false && remove_query_arg(array('code', 'state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Instagram'){
 
 
 
 
 
164
  $postData = array(
165
  'client_id' => $theChampLoginOptions['insta_id'],
166
  'client_secret' => $theChampLoginOptions['insta_app_secret'],
191
 
192
  if(is_object($profileData) && isset($profileData->id)){
193
  $profileData = the_champ_sanitize_profile_data($profileData, 'instagram');
194
+ $instagramLoginState = esc_attr(trim($_GET['state']));
195
+ $instagramRedirectUrl = get_user_meta($instagramLoginState, 'super_socializer_redirect_to', true);
196
  $response = the_champ_user_auth($profileData, 'instagram', $instagramRedirectUrl);
197
  if($response == 'show form'){
198
  return;
199
  }
200
+ delete_user_meta($instagramLoginState, 'super_socializer_redirect_to', true);
201
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
202
  $redirectTo = the_champ_get_login_redirection_url($instagramRedirectUrl, true);
203
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
255
  if(isset($theChampLoginOptions['li_key']) && $theChampLoginOptions['li_key'] != '' && isset($theChampLoginOptions['li_secret']) && $theChampLoginOptions['li_secret'] != ''){
256
  if(!isset($_GET['code']) && !isset($_GET['state'])){
257
  $linkedinAuthState = mt_rand();
258
+ // save referrer url in state
259
+ update_user_meta( $linkedinAuthState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url() );
260
  if(isset($_GET['heateorMSEnabled'])){
261
  update_user_meta($linkedinAuthState, 'heateor_ss_linkedin_mc_sub', 1);
262
  }
264
  wp_redirect('https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id='.$theChampLoginOptions['li_key'].'&redirect_uri='.urlencode(home_url().'/?SuperSocializerAuth=Linkedin').'&state='. $linkedinAuthState .'&scope='.$linkedinScope);
265
  die;
266
  }
267
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false){
 
268
  $url = 'https://www.linkedin.com/oauth/v2/accessToken';
269
  $data_access_token = array(
270
  'grant_type' => 'authorization_code',
320
  );
321
 
322
  $profileData = the_champ_sanitize_profile_data($user, 'linkedin');
323
+ $linkedinAuthState = esc_attr(trim($_GET['state']));
324
+ if(get_user_meta($linkedinAuthState, 'heateor_ss_linkedin_mc_sub', true)){
325
  $profileData['mc_subscribe'] = 1;
326
  delete_user_meta($linkedinAuthState, 'heateor_ss_linkedin_mc_sub');
327
  }
328
+ $linkedinRedirectUrl = get_user_meta($linkedinAuthState, 'super_socializer_redirect_to', true);
329
  $response = the_champ_user_auth($profileData, 'linkedin', $linkedinRedirectUrl);
330
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
331
  $redirectTo = the_champ_get_login_redirection_url($linkedinRedirectUrl, true);
389
  if(is_object($profileData) && isset($profileData->userId)){
390
  $profileData = the_champ_sanitize_profile_data($profileData, 'line');
391
  $lineRedirectUrl = isset($_SESSION['super_socializer_line_redirect']) && $_SESSION['super_socializer_line_redirect'] ? esc_url(trim($_SESSION['super_socializer_line_redirect'])) : home_url();
 
392
  $response = the_champ_user_auth($profileData, 'line', $lineRedirectUrl);
393
  if($response == 'show form'){
394
  return;
395
  }
396
+ unset($_SESSION['super_socializer_line_redirect']);
397
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
398
  $redirectTo = the_champ_get_login_redirection_url($lineRedirectUrl, true);
399
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
414
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Yahoo')){
415
  if(isset($theChampLoginOptions['providers']) && in_array('yahoo', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['yahoo_channel_id']) && $theChampLoginOptions['yahoo_channel_id'] != '' && isset($theChampLoginOptions['yahoo_channel_secret']) && $theChampLoginOptions['yahoo_channel_secret'] != ''){
416
  if(!isset($_GET['code'])){
417
+ $yahooLoginState = mt_rand();
 
 
 
 
418
  // save referrer url in state
419
+ update_user_meta($yahooLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
420
  }
421
+ wp_redirect("https://api.login.yahoo.com/oauth2/request_auth?client_id=".$theChampLoginOptions['yahoo_channel_id']."&response_type=code&language=en-us&state=".$yahooLoginState."&redirect_uri=".home_url()."/SuperSocializerAuth/Yahoo");
422
  die;
423
  }
424
  }
425
 
426
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false && remove_query_arg(array('code', 'state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Yahoo'){
 
 
 
 
 
 
427
  $postData = array(
428
  'grant_type' => 'authorization_code',
429
  'code' => esc_attr(trim($_GET['code'])),
453
 
454
  if(is_object($profileData) && isset($profileData->sub)){
455
  $profileData = the_champ_sanitize_profile_data($profileData, 'yahoo');
456
+ $yahooLoginState = esc_attr(trim($_GET['state']));
457
+ $yahooRedirectUrl = get_user_meta($yahooLoginState, 'super_socializer_redirect_to', true);
458
  $response = the_champ_user_auth($profileData, 'yahoo', $yahooRedirectUrl);
459
  if($response == 'show form'){
460
  return;
461
  }
462
+ delete_user_meta($yahooLoginState, 'super_socializer_redirect_to', true);
463
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
464
  $redirectTo = the_champ_get_login_redirection_url($yahooRedirectUrl, true);
465
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
482
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Wordpress')){
483
  if(isset($theChampLoginOptions['providers']) && in_array('wordpress', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['wordpress_client_id']) && $theChampLoginOptions['wordpress_client_id'] != '' && isset($theChampLoginOptions['wordpress_client_secret']) && $theChampLoginOptions['wordpress_client_secret'] != ''){
484
  if(!isset($_GET['code'])){
485
+ $wordpressLoginState = mt_rand();
 
 
 
 
486
  // save referrer url in state
487
+ update_user_meta($wordpressLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
488
  }
489
+ wp_redirect("https://public-api.wordpress.com/oauth2/authorize?client_id=".$theChampLoginOptions['wordpress_client_id']."&scope=auth&response_type=code&state=".$wordpressLoginState."&redirect_uri=".home_url()."/SuperSocializerAuth/Wordpress");
490
  die;
491
  }
492
  }
493
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false && remove_query_arg(array('code','state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Wordpress'){
 
 
 
 
 
 
494
  $postData = array(
495
  'grant_type' => 'authorization_code',
496
  'code' => esc_attr(trim($_GET['code'])),
520
 
521
  if(is_object($profileData) && isset($profileData->ID)){
522
  $profileData = the_champ_sanitize_profile_data($profileData, 'wordpress');
523
+ $wordpressLoginState = esc_attr(trim($_GET['state']));
524
+ $wordpressRedirectUrl = get_user_meta($wordpressLoginState, 'super_socializer_redirect_to', true);
525
  $response = the_champ_user_auth($profileData, 'wordpress', $wordpressRedirectUrl);
526
  if($response == 'show form'){
527
  return;
528
  }
529
+ delete_user_meta($wordpressLoginState, 'super_socializer_redirect_to', true);
530
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
531
  $redirectTo = the_champ_get_login_redirection_url($wordpressRedirectUrl, true);
532
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
548
  // windows live
549
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Live')){
550
  if(isset($theChampLoginOptions['providers']) && in_array('microsoft', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['live_channel_id']) && $theChampLoginOptions['live_channel_id'] != '' && isset($theChampLoginOptions['live_channel_secret']) && $theChampLoginOptions['live_channel_secret'] != ''){
551
+ $liveLoginState = mt_rand();
 
 
 
 
552
  // save referrer url in state
553
+ update_user_meta($liveLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
554
+ wp_redirect("https://login.live.com/oauth20_authorize.srf?client_id=".$theChampLoginOptions['live_channel_id']."&scope=wl.emails,wl.basic&response_type=code&state=".$liveLoginState."&redirect_uri=".home_url()."/SuperSocializerAuth/Live");
555
  die;
556
  }
557
  }
558
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false && remove_query_arg(array('code', 'state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Live'){
 
 
 
 
 
 
559
  $postData = array(
560
  'grant_type' => 'authorization_code',
561
  'code' => esc_attr(trim($_GET['code'])),
583
 
584
  if(is_object($profileData) && isset($profileData->id)){
585
  $profileData = the_champ_sanitize_profile_data($profileData, 'microsoft');
586
+ $liveLoginState = esc_attr(trim($_GET['state']));
587
+ $liveRedirectUrl = get_user_meta($liveLoginState, 'super_socializer_redirect_to', true);
588
  $response = the_champ_user_auth($profileData, 'microsoft', $liveRedirectUrl);
589
  if($response == 'show form'){
590
  return;
591
  }
592
+ delete_user_meta($liveLoginState, 'super_socializer_redirect_to');
593
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
594
  $redirectTo = the_champ_get_login_redirection_url($liveRedirectUrl, true);
595
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
608
  }
609
  }
610
 
611
+ // twitch
612
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Twitch')){
613
  if(isset($theChampLoginOptions['providers']) && in_array('twitch', $theChampLoginOptions['providers']) && $theChampLoginOptions['twitch_client_id'] && $theChampLoginOptions['twitch_client_secret']){
614
  if(!isset($_GET['code'])){
615
+ $twitchLoginState = mt_rand();
 
 
 
 
616
  // save referrer url in state
617
+ update_user_meta($twitchLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
618
  }
619
+ wp_redirect("https://id.twitch.tv/oauth2/authorize?client_id=".$theChampLoginOptions['twitch_client_id']."&scope=user_read&response_type=code&state=".$twitchLoginState."&redirect_uri=".urlencode(home_url()."/SuperSocializerAuth/Twitch"));
620
  die;
621
  }
622
  }
623
 
624
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false && remove_query_arg(array('code', 'scope', 'state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Twitch'){
 
 
 
 
 
 
625
  $postData = array(
626
  'grant_type' => 'authorization_code',
627
  'code' => esc_attr(trim($_GET['code'])),
651
 
652
  if(is_object($profileData) && isset($profileData->_id)){
653
  $profileData = the_champ_sanitize_profile_data($profileData, 'twitch');
654
+ $twitchLoginState = esc_attr(trim($_GET['state']));
655
+ $twitchRedirectUrl = get_user_meta($twitchLoginState, 'super_socializer_redirect_to', true);
656
  $response = the_champ_user_auth($profileData, 'twitch', $twitchRedirectUrl);
657
  if($response == 'show form'){
658
  return;
659
  }
660
+ delete_user_meta($twitchLoginState, 'super_socializer_redirect_to', true);
661
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
662
  $redirectTo = the_champ_get_login_redirection_url($twitchRedirectUrl, true);
663
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
678
  // reddit
679
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Reddit')){
680
  if(isset($theChampLoginOptions['providers']) && in_array('reddit', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['reddit_client_id']) && $theChampLoginOptions['reddit_client_id'] != '' && isset($theChampLoginOptions['reddit_client_secret']) && $theChampLoginOptions['reddit_client_secret'] != ''){
681
+ $redditLoginState = mt_rand();
682
+ // save referrer url in state
683
+ update_user_meta($redditLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
684
+ wp_redirect("https://ssl.reddit.com/api/v1/authorize?client_id=" . $theChampLoginOptions['reddit_client_id'] . "&scope=identity&state=" . $redditLoginState . "&duration=temporary&response_type=code&redirect_uri=" . home_url() . "/SuperSocializerAuth/Reddit");
 
 
 
 
 
685
  die;
686
  }
687
  }
688
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false && remove_query_arg(array(
689
  'code',
690
  'state',
691
  'scope'
692
  ), html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))) == home_url() . '/SuperSocializerAuth/Reddit'){
693
+ $postData = array(
 
 
 
 
 
 
 
 
694
  'grant_type' => 'authorization_code',
695
  'code' => esc_attr(trim($_GET['code'])),
696
  'redirect_uri' => home_url() . "/SuperSocializerAuth/Reddit",
706
  'Content-Type' => 'application/x-www-form-urlencoded',
707
  'Authorization' => 'Basic ' . base64_encode($theChampLoginOptions['reddit_client_id'] . ':' . $theChampLoginOptions['reddit_client_secret'])
708
  ),
709
+ 'body' => http_build_query($postData)
710
  ));
711
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
712
  $body = json_decode(wp_remote_retrieve_body($response));
720
  $profileData = json_decode(wp_remote_retrieve_body($response));
721
  if(is_object($profileData) && isset($profileData->id) && isset($profileData->verified) && $profileData->verified == 1){
722
  $profileData = the_champ_sanitize_profile_data($profileData, 'reddit');
723
+ $redditLoginState = esc_attr(trim($_GET['state']));
724
+ $redditRedirectUrl = get_user_meta($redditLoginState, 'super_socializer_redirect_to', true);
725
+ $response = the_champ_user_auth($profileData, 'reddit', $redditRedirectUrl);
726
  if($response == 'show form'){
727
  return;
728
  }
729
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
730
+ $redirectTo = the_champ_get_login_redirection_url($redditRedirectUrl, true);
731
  } elseif(isset($response['message']) && $response['message'] == 'linked'){
732
+ $redirectTo = $redditRedirectUrl . (strpos($redditRedirectUrl, '?') !== false ? '&' : '?') . 'linked=1';
733
  } elseif(isset($response['message']) && $response['message'] == 'not linked'){
734
+ $redirectTo = $redditRedirectUrl . (strpos($redditRedirectUrl, '?') !== false ? '&' : '?') . 'linked=0';
735
  } elseif(isset($response['url']) && $response['url'] != ''){
736
+ $redirectTo = $response['url'];
737
  } else {
738
+ $redirectTo = the_champ_get_login_redirection_url($redditRedirectUrl);
739
  }
740
+ the_champ_close_login_popup($redirectTo);
741
  }
742
  }
743
  }
746
  //disqus
747
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Disqus')){
748
  if(isset($theChampLoginOptions['providers']) && in_array('disqus', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['disqus_public_key']) && $theChampLoginOptions['disqus_public_key'] != '' && isset($theChampLoginOptions['disqus_secret_key']) && $theChampLoginOptions['disqus_secret_key'] != ''){
749
+ $disqusLoginState = mt_rand();
750
+ // save referrer url in state
751
+ update_user_meta($disqusLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
752
+ wp_redirect("https://disqus.com/api/oauth/2.0/authorize/?client_id=" . $theChampLoginOptions['disqus_public_key'] . "&scope=read,email&response_type=code&state=". $disqusLoginState ."&redirect_uri=" . home_url() . "/SuperSocializerAuth/Disqus");
 
 
 
 
753
  die;
754
  }
755
  }
756
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false && remove_query_arg(array(
757
  'code',
758
+ 'scope',
759
+ 'state'
760
  ), html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))) == home_url() . '/SuperSocializerAuth/Disqus'){
761
+ $postData = array(
 
 
 
 
 
762
  'grant_type' => 'authorization_code',
763
  'code' => esc_attr(trim($_GET['code'])),
764
  'redirect_uri' => home_url() . "/SuperSocializerAuth/Disqus",
774
  'Content-Type' => 'application/x-www-form-urlencoded',
775
  'Authorization' => 'Basic ' . base64_encode($theChampLoginOptions['disqus_public_key'] . ':' . $theChampLoginOptions['disqus_secret_key'])
776
  ),
777
+ 'body' => http_build_query($postData)
778
  ));
779
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
780
  $body = json_decode(wp_remote_retrieve_body($response));
788
  $profileData = json_decode(wp_remote_retrieve_body($response));
789
  if(is_object($profileData) && isset($profileData->response->id)){
790
  $profileData = the_champ_sanitize_profile_data($profileData, 'disqus');
791
+ $disqusLoginState = esc_attr(trim($_GET['state']));
792
+ $disqusRedirectUrl = get_user_meta($disqusLoginState, 'super_socializer_redirect_to', true);
793
+ $response = the_champ_user_auth($profileData, 'disqus', $disqusRedirectUrl);
794
  if($response == 'show form'){
795
  return;
796
  }
797
+ delete_user_meta($disqusLoginState, 'super_socializer_redirect_to', true);
798
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
799
+ $redirectTo = the_champ_get_login_redirection_url($disqusRedirectUrl, true);
800
  } elseif(isset($response['message']) && $response['message'] == 'linked'){
801
+ $redirectTo = $disqusRedirectUrl . (strpos($disqusRedirectUrl, '?') !== false ? '&' : '?') . 'linked=1';
802
  } elseif(isset($response['message']) && $response['message'] == 'not linked'){
803
+ $redirectTo = $disqusRedirectUrl . (strpos($disqusRedirectUrl, '?') !== false ? '&' : '?') . 'linked=0';
804
  } elseif(isset($response['url']) && $response['url'] != ''){
805
+ $redirectTo = $response['url'];
806
  } else {
807
+ $redirectTo = the_champ_get_login_redirection_url($disqusRedirectUrl);
808
  }
809
+ the_champ_close_login_popup($redirectTo);
810
  }
811
  }
812
  }
815
  //dropbox
816
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Dropbox')){
817
  if(isset($theChampLoginOptions['providers']) && in_array('dropbox', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['dropbox_app_key']) && $theChampLoginOptions['dropbox_app_key'] != '' && isset($theChampLoginOptions['dropbox_app_secret']) && $theChampLoginOptions['dropbox_app_secret'] != ''){
818
+ $dropboxLoginState = mt_rand();
819
+ // save referrer url in state
820
+ update_user_meta($dropboxLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
821
+ wp_redirect("https://www.dropbox.com/1/oauth2/authorize?client_id=" . $theChampLoginOptions['dropbox_app_key'] . "&scope=account_info.read&state=" . $dropboxLoginState . "&response_type=code&redirect_uri=" . home_url() . "/SuperSocializerAuth/Dropbox");
 
 
 
 
 
822
  die;
823
  }
824
  }
825
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false && remove_query_arg(array(
826
  'code',
827
  'scope',
828
  'state'
829
  ), html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))) == home_url() . '/SuperSocializerAuth/Dropbox'){
830
+ $postData = array(
 
 
 
 
 
 
 
 
831
  'grant_type' => 'authorization_code',
832
  'code' => esc_attr(trim($_GET['code'])),
833
  'redirect_uri' => home_url() . "/SuperSocializerAuth/Dropbox"
842
  'Content-Type' => 'application/x-www-form-urlencoded',
843
  'Authorization' => 'Basic ' . base64_encode($theChampLoginOptions['dropbox_app_key'] . ':' . $theChampLoginOptions['dropbox_app_secret'])
844
  ),
845
+ 'body' => http_build_query($postData)
846
  ));
847
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
848
  $body = json_decode(wp_remote_retrieve_body($response));
857
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
858
  $profileData = json_decode(wp_remote_retrieve_body($response));
859
  if(is_object($profileData) && isset($profileData->account_id)){
860
+ $profileData = the_champ_sanitize_profile_data($profileData, 'dropbox');
861
+ $dropboxLoginState = esc_attr(trim($_GET['state']));
862
+ $dropboxRedirectUrl = get_user_meta($dropboxLoginState, 'super_socializer_redirect_to', true);
863
+ $response = the_champ_user_auth($profileData, 'dropbox', $dropboxRedirectUrl);
864
  if($response == 'show form'){
865
  return;
866
  }
867
+ delete_user_meta($dropboxLoginState, 'super_socializer_redirect_to', true);
868
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
869
+ $redirectTo = the_champ_get_login_redirection_url($dropboxRedirectUrl, true);
870
  } elseif(isset($response['message']) && $response['message'] == 'linked'){
871
+ $redirectTo = $dropboxRedirectUrl . (strpos($dropboxRedirectUrl, '?') !== false ? '&' : '?') . 'linked=1';
872
  } elseif(isset($response['message']) && $response['message'] == 'not linked'){
873
+ $redirectTo = $dropboxRedirectUrl . (strpos($dropboxRedirectUrl, '?') !== false ? '&' : '?') . 'linked=0';
874
  } elseif(isset($response['url']) && $response['url'] != ''){
875
+ $redirectTo = $response['url'];
876
  } else {
877
+ $redirectTo = the_champ_get_login_redirection_url($dropboxRedirectUrl);
878
  }
879
+ the_champ_close_login_popup($redirectTo);
880
  }
881
  }
882
  }
885
  // foursquare
886
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Foursquare')){
887
  if(isset($theChampLoginOptions['providers']) && in_array('foursquare', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['foursquare_client_id']) && $theChampLoginOptions['foursquare_client_id'] != '' && isset($theChampLoginOptions['foursquare_client_secret']) && $theChampLoginOptions['foursquare_client_secret'] != ''){
888
+ $foursquareLoginState = mt_rand();
889
+ // save referrer url in state
890
+ update_user_meta($foursquareLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
891
+ wp_redirect("https://foursquare.com/oauth2/authenticate/?client_id=" . $theChampLoginOptions['foursquare_client_id'] . "&response_type=code&state=". $foursquareLoginState ."&redirect_uri=" . home_url() . "/SuperSocializerAuth/Foursquare");
 
 
 
 
892
  die;
893
  }
894
  }
895
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) && remove_query_arg(array(
896
+ 'code', 'state'
897
  ), html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))) == home_url() . '/SuperSocializerAuth/Foursquare'){
898
+ $postData = array(
 
 
 
 
 
899
  'grant_type' => 'authorization_code',
900
  'code' => esc_attr(trim($_GET['code'])),
901
  'redirect_uri' => home_url() . "/SuperSocializerAuth/Foursquare",
911
  'Content-Type' => 'application/x-www-form-urlencoded',
912
  'Authorization' => 'Basic ' . base64_encode($theChampLoginOptions['foursquare_client_id'] . ':' . $theChampLoginOptions['foursquare_client_secret'])
913
  ),
914
+ 'body' => http_build_query($postData)
915
  ));
916
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
917
  $body = json_decode(wp_remote_retrieve_body($response));
922
  )
923
  ));
924
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
925
+ $profileData = json_decode(wp_remote_retrieve_body($response));
926
+ if(is_object($profileData) && isset($profileData->response->user->id)){
927
+ $profileData = the_champ_sanitize_profile_data($profileData, 'foursquare');
928
+ $foursquareLoginState = esc_attr(trim($_GET['state']));
929
+ $foursquareRedirectUrl = get_user_meta($foursquareLoginState, 'super_socializer_redirect_to', true);
930
+ $response = the_champ_user_auth($profileData, 'foursquare', $foursquareRedirectUrl);
931
  if($response == 'show form'){
932
  return;
933
  }
934
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
935
+ $redirectTo = the_champ_get_login_redirection_url($foursquareRedirectUrl, true);
936
  } elseif(isset($response['message']) && $response['message'] == 'linked'){
937
+ $redirectTo = $foursquareRedirectUrl . (strpos($foursquareRedirectUrl, '?') !== false ? '&' : '?') . 'linked=1';
938
  } elseif(isset($response['message']) && $response['message'] == 'not linked'){
939
+ $redirectTo = $foursquareRedirectUrl . (strpos($foursquareRedirectUrl, '?') !== false ? '&' : '?') . 'linked=0';
940
  } elseif(isset($response['url']) && $response['url'] != ''){
941
+ $redirectTo = $response['url'];
942
  } else {
943
+ $redirectTo = the_champ_get_login_redirection_url($foursquareRedirectUrl);
944
  }
945
+ the_champ_close_login_popup($redirectTo);
946
  }
947
  }
948
  }
952
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Dribbble')){
953
  if(isset($theChampLoginOptions['providers']) && in_array('dribbble', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['dribbble_client_id']) && $theChampLoginOptions['dribbble_client_id'] != '' && isset($theChampLoginOptions['dribbble_client_secret']) && $theChampLoginOptions['dribbble_client_secret'] != ''){
954
  if(!isset($_GET['code'])){
955
+ $dribbbleLoginState = mt_rand();
 
 
 
 
956
  // save referrer url in state
957
+ update_user_meta($dribbbleLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
958
  }
959
+ wp_redirect("https://dribbble.com/oauth/authorize?client_id=".$theChampLoginOptions['dribbble_client_id']."&scope=public&state=". $dribbbleLoginState ."&redirect_uri=".urlencode(home_url()."/SuperSocializerAuth/Dribbble"));
960
  die;
961
  }
962
  }
963
 
964
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) && remove_query_arg(array('code','scope', 'state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Dribbble'){
 
 
 
 
 
 
965
  $postData = array(
966
  'grant_type' => 'authorization_code',
967
  'code' => esc_attr(trim($_GET['code'])),
987
  $response = wp_remote_get("https://api.dribbble.com/v2/user?access_token", array('timeout' => 15, 'headers' => array('Accept' => 'application/json' , 'Authorization' => $authorization )));
988
 
989
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
990
+ $profileData = json_decode(wp_remote_retrieve_body($response));
991
+ if(is_object($profileData) && isset($profileData->id)){
992
+ $profileData = the_champ_sanitize_profile_data($profileData, 'dribbble');
993
+ $dribbbleLoginState = esc_attr(trim($_GET['state']));
994
+ $dribbbleRedirectUrl = get_user_meta($dribbbleLoginState, 'super_socializer_redirect_to', true);
995
+ $response = the_champ_user_auth($profileData, 'dribbble', $dribbbleRedirectUrl);
 
996
  if($response == 'show form'){
997
  return;
998
  }
1017
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Spotify')){
1018
  if(isset($theChampLoginOptions['providers']) && in_array('spotify', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['spotify_client_id']) && $theChampLoginOptions['spotify_client_id'] != '' && isset($theChampLoginOptions['spotify_client_secret']) && $theChampLoginOptions['spotify_client_secret'] != ''){
1019
  if(!isset($_GET['code'])){
1020
+ $spotifyLoginState = mt_rand();
 
 
 
 
1021
  // save referrer url in state
1022
+ update_user_meta($spotifyLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
1023
  }
1024
+ wp_redirect("https://accounts.spotify.com/authorize?client_id=".$theChampLoginOptions['spotify_client_id']."&scope=user-read-email&response_type=code&state=". $spotifyLoginState ."&redirect_uri=".home_url()."/SuperSocializerAuth/Spotify");
1025
  die;
1026
  }
1027
  }
1028
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) && remove_query_arg(array('code', 'state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Spotify'){
 
 
 
 
 
1029
  $postData = array(
1030
  'grant_type' => 'authorization_code',
1031
  'code' => esc_attr(trim($_GET['code'])),
1052
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1053
  $profileData = json_decode(wp_remote_retrieve_body( $response ));
1054
  if(is_object($profileData) && isset($profileData->id)){
1055
+ $profileData = the_champ_sanitize_profile_data($profileData, 'spotify');
1056
+ $spotifyLoginState = esc_attr(trim($_GET['state']));
1057
+ $spotifyRedirectUrl = get_user_meta($spotifyLoginState, 'super_socializer_redirect_to', true);
1058
  $response = the_champ_user_auth($profileData, 'spotify', $spotifyRedirectUrl);
1059
  if($response == 'show form'){
1060
  return;
1081
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Kakao')){
1082
  if(isset($theChampLoginOptions['providers']) && in_array('kakao', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['kakao_client_id']) && $theChampLoginOptions['kakao_client_id'] != '' && isset($theChampLoginOptions['kakao_client_secret']) && $theChampLoginOptions['kakao_client_secret'] != ''){
1083
  if(!isset($_GET['code'])){
1084
+ $kakaoLoginState = mt_rand();
 
 
 
 
1085
  // save referrer url in state
1086
+ update_user_meta($kakaoLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
1087
  }
1088
+ wp_redirect("https://kauth.kakao.com/oauth/authorize?client_id=".$theChampLoginOptions['kakao_client_id']."&state=state&response_type=code&state=". $kakaoLoginState ."&redirect_uri=".home_url()."/SuperSocializerAuth/Kakao");
1089
  die;
1090
  }
1091
  }
1092
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) && remove_query_arg(array('code','state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Kakao'){
 
 
 
 
 
 
1093
  $postData = array(
1094
  'grant_type' => 'authorization_code',
1095
  'code' => esc_attr(trim($_GET['code'])),
1116
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1117
  $profileData = json_decode(wp_remote_retrieve_body( $response ));
1118
  if(is_object($profileData) && isset($profileData->id)){
1119
+ $profileData = the_champ_sanitize_profile_data($profileData, 'kakao');
1120
+ $kakaoLoginState = esc_attr(trim($_GET['state']));
1121
+ $kakaoRedirectUrl = get_user_meta($kakaoLoginState, 'super_socializer_redirect_to', true);
1122
  $response = the_champ_user_auth($profileData, 'kakao', $kakaoRedirectUrl);
1123
  if($response == 'show form'){
1124
  return;
1125
  }
1126
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
1127
+ $redirectTo = the_champ_get_login_redirection_url($kakaoRedirectUrl, true);
1128
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
1129
  $redirectTo = $kakaoRedirectUrl . ( strpos( $kakaoRedirectUrl, '?' ) !== false ? '&' : '?' ) . 'linked=1';
1130
  }elseif(isset($response['message']) && $response['message'] == 'not linked'){
1145
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Github')){
1146
  if(isset($theChampLoginOptions['providers']) && in_array('github', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['github_client_id']) && $theChampLoginOptions['github_client_id'] != '' && isset($theChampLoginOptions['github_client_secret']) && $theChampLoginOptions['github_client_secret'] != ''){
1147
  if(!isset($_GET['code'])){
1148
+ $githubLoginState = mt_rand();
 
 
 
 
1149
  // save referrer url in state
1150
+ update_user_meta($githubLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
1151
  }
1152
+ wp_redirect("https://github.com/login/oauth/authorize?client_id=".$theChampLoginOptions['github_client_id']."&scope=read:user user:email&state=". $githubLoginState ."&response_type=code&redirect_uri=".home_url()."/SuperSocializerAuth/Github");
1153
  die;
1154
  }
1155
  }
1156
+ if(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) && remove_query_arg(array('code','state'), html_entity_decode(esc_url(the_champ_get_http().$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]))) == home_url().'/SuperSocializerAuth/Github'){
 
 
 
 
 
1157
  $postData = array(
1158
  'state' => 'state',
1159
  'code' => esc_attr(trim($_GET['code'])),
1196
  }
1197
  }
1198
  }
1199
+ $profileData = the_champ_sanitize_profile_data($profileData, 'github');
1200
+ $githubLoginState = esc_attr(trim($_GET['state']));
1201
+ $githubRedirectUrl = get_user_meta($githubLoginState, 'super_socializer_redirect_to', true);
1202
  $response = the_champ_user_auth($profileData, 'github', $githubRedirectUrl);
1203
  if($response == 'show form'){
1204
  return;
1205
  }
1206
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
1207
+ $redirectTo = the_champ_get_login_redirection_url($githubRedirectUrl, true);
1208
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
1209
  $redirectTo = $githubRedirectUrl . ( strpos( $githubRedirectUrl, '?' ) !== false ? '&' : '?' ) . 'linked=1';
1210
  }elseif(isset($response['message']) && $response['message'] == 'not linked'){
1225
  // Facebook
1226
  if((isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Facebook')){
1227
  if(isset($theChampLoginOptions['providers']) && in_array('facebook', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['fb_key']) && $theChampLoginOptions['fb_key'] != '' && isset($theChampLoginOptions['fb_secret']) && $theChampLoginOptions['fb_secret'] != ''){
 
 
 
 
 
1228
  if(!isset($_GET['code'])){
1229
+ $facebookLoginState = mt_rand();
1230
  // save referrer url in state
1231
+ update_user_meta($facebookLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
1232
+ wp_redirect("https://www.facebook.com/v9.0/dialog/oauth?scope=email&client_id=" . $theChampLoginOptions['fb_key'] . "&state=" . $facebookLoginState . "&redirect_uri=" . home_url() . "/?SuperSocializerAuth=Facebook");
 
1233
  die;
1234
+ }elseif(isset($_GET['code']) && isset($_GET['state']) && get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false){
1235
+ $postData = array(
1236
  'code' => esc_attr(trim($_GET['code'])),
1237
  'redirect_uri' => home_url() . "/?SuperSocializerAuth=Facebook",
1238
  'client_id' => $theChampLoginOptions['fb_key'],
1247
  'headers' => array(
1248
  'Content-Type' => 'application/x-www-form-urlencoded'
1249
  ),
1250
+ 'body' => http_build_query($postData)
1251
  ));
1252
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
1253
  $body = json_decode(wp_remote_retrieve_body($response));
1259
  $profileData = json_decode(wp_remote_retrieve_body($response));
1260
  if(is_object($profileData) && isset($profileData->id)){
1261
  $profileData = the_champ_sanitize_profile_data($profileData, 'facebook');
1262
+ $facebookLoginState = esc_attr(trim($_GET['state']));
1263
+ $facebook_redirect_url = get_user_meta($facebookLoginState, 'super_socializer_redirect_to', true);
1264
+ delete_user_meta($facebookLoginState, 'super_socializer_redirect_to');
1265
  $response = the_champ_user_auth($profileData, 'faceboook', $facebook_redirect_url);
1266
  if($response == 'show form'){
1267
  return;
1268
  }
1269
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
1270
+ $redirectTo = the_champ_get_login_redirection_url($facebook_redirect_url, true);
1271
  }elseif(isset($response['message']) && $response['message'] == 'linked'){
1272
+ $redirectTo = $facebook_redirect_url . (strpos($facebook_redirect_url, '?') !== false ? '&' : '?') . 'linked=1';
1273
  }elseif(isset($response['message']) && $response['message'] == 'not linked'){
1274
+ $redirectTo = $facebook_redirect_url . (strpos($facebook_redirect_url, '?') !== false ? '&' : '?') . 'linked=0';
1275
  }elseif(isset($response['url']) && $response['url'] != ''){
1276
+ $redirectTo = $response['url'];
1277
  }else{
1278
+ $redirectTo = the_champ_get_login_redirection_url($facebook_redirect_url);
1279
  }
1280
+ the_champ_close_login_popup($redirectTo);
1281
  }
1282
  }
1283
  }
1289
  // Google
1290
  if(isset($_GET['SuperSocializerAuth']) && sanitize_text_field($_GET['SuperSocializerAuth']) == 'Google') {
1291
  if(isset($theChampLoginOptions['providers']) && in_array('google', $theChampLoginOptions['providers']) && isset($theChampLoginOptions['google_key']) && $theChampLoginOptions['google_key'] != '' && isset($theChampLoginOptions['google_secret']) && $theChampLoginOptions['google_secret'] != '') {
1292
+ $googleLoginState = mt_rand();
1293
+ // save referrer url in state
1294
+ update_user_meta($googleLoginState, 'super_socializer_redirect_to', isset($_GET['super_socializer_redirect_to']) ? esc_url(trim($_GET['super_socializer_redirect_to'])) : home_url());
1295
+ wp_redirect("https://accounts.google.com/o/oauth2/auth?client_id=" . $theChampLoginOptions['google_key'] . "&scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile&state=". $googleLoginState ."&response_type=code&redirect_uri=" . home_url());
 
 
 
 
 
1296
  die;
1297
  }
1298
  }
1299
+ if(isset($_GET['code']) && isset($_GET['state'])){
1300
+ if(get_user_meta(esc_attr(trim($_GET['state'])), 'super_socializer_redirect_to', true) !== false){
1301
+ $postData = array(
 
 
 
 
 
1302
  'grant_type' => 'authorization_code',
1303
  'code' => esc_attr(trim($_GET['code'])),
1304
  'redirect_uri' => home_url(),
1314
  'headers' => array(
1315
  'Content-Type' => 'application/x-www-form-urlencoded'
1316
  ),
1317
+ 'body' => http_build_query($postData)
1318
  ));
1319
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']) {
1320
  $body = json_decode(wp_remote_retrieve_body($response));
1328
  )
1329
  ));
1330
  if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']) {
1331
+ $profileData = json_decode(wp_remote_retrieve_body($response));
1332
+ if(is_object($profileData) && isset($profileData->sub)) {
1333
+ $profileData = the_champ_sanitize_profile_data($profileData, 'google');
1334
+ $googleLoginState = esc_attr(trim($_GET['state']));
1335
+ $googleRedirectUrl = get_user_meta($googleLoginState, 'super_socializer_redirect_to', true);
1336
+ $response = the_champ_user_auth($profileData, 'google', $googleRedirectUrl);
 
1337
  if($response == 'show form') {
1338
  return;
1339
  }
1340
  if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')) {
1341
+ $redirectTo = the_champ_get_login_redirection_url($googleRedirectUrl, true);
1342
  } elseif(isset($response['message']) && $response['message'] == 'linked') {
1343
+ $redirectTo = $googleRedirectUrl . (strpos($googleRedirectUrl, '?') !== false ? '&' : '?') . 'linked=1';
1344
  } elseif(isset($response['message']) && $response['message'] == 'not linked') {
1345
+ $redirectTo = $googleRedirectUrl . (strpos($googleRedirectUrl, '?') !== false ? '&' : '?') . 'linked=0';
1346
  } elseif(isset($response['url']) && $response['url'] != '') {
1347
+ $redirectTo = $response['url'];
1348
  } else {
1349
+ $redirectTo = the_champ_get_login_redirection_url($googleRedirectUrl);
1350
  }
1351
+ the_champ_close_login_popup($redirectTo);
1352
  }
1353
  }
1354
  }
1561
  if(html_entity_decode(esc_url(remove_query_arg(array('ss_message', 'SuperSocializerVerified', 'SuperSocializerUnverified', 'wp_lang', 'loggedout'), $decodedUrl))) == wp_login_url() || $decodedUrl == home_url().'/wp-login.php?action=register'){
1562
  $url = esc_url(home_url()).'/';
1563
  }elseif(isset($_GET['redirect_to'])){
1564
+ $redirectTo = esc_url($_GET['redirect_to']);
1565
+ if(urldecode($redirectTo) == admin_url()){
1566
  $url = esc_url(home_url()).'/';
1567
+ }elseif(the_champ_validate_url(urldecode($redirectTo)) && (strpos(urldecode($redirectTo), 'http://') !== false || strpos(urldecode($redirectTo), 'https://') !== false)){
1568
+ $url = $redirectTo;
1569
  }else{
1570
  $url = esc_url(home_url()).'/';
1571
  }