Skip to content

Commit

Permalink
indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoprimo committed Jan 26, 2014
1 parent f72d6a1 commit 6874f19
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 166 deletions.
77 changes: 38 additions & 39 deletions google/connect.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
<?php

require_once(dirname(dirname(__FILE__)) . '/openid/openid.php');
require_once(dirname(dirname(__FILE__)) . '/utils.php' );

try {
if(!isset($_GET['openid_mode']) || $_GET['openid_mode'] == 'cancel') {
$openid = new LightOpenID;
$openid->identity = 'https://www.google.com/accounts/o8/id';
$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email');
header('Location: ' . $openid->authUrl());
} else {
$openid = new LightOpenID;
if($openid->validate()) {
$google_id = $openid->identity;
$attributes = $openid->getAttributes();
$email = $attributes['contact/email'];
$first_name = $attributes['namePerson/first'];
$last_name = $attributes['namePerson/last'];
$signature = social_connect_generate_signature($google_id);
do_action( 'social_connect_before_register_google', $google_id, $signature );
?>
<html>
<head>
<script>
function init() {
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'google',
'social_connect_openid_identity' : '<?php echo $google_id ?>',
'social_connect_signature' : '<?php echo $signature ?>',
'social_connect_email' : '<?php echo $email ?>',
'social_connect_first_name' : '<?php echo $first_name ?>',
'social_connect_last_name' : '<?php echo $last_name ?>'});

window.close();
}
</script>
</head>
<body onload="init();">
</body>
</html>
<?php
}
}
if (!isset($_GET['openid_mode']) || $_GET['openid_mode'] == 'cancel') {
$openid = new LightOpenID;
$openid->identity = 'https://www.google.com/accounts/o8/id';
$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email');
header('Location: ' . $openid->authUrl());
} else {
$openid = new LightOpenID;
if ($openid->validate()) {
$google_id = $openid->identity;
$attributes = $openid->getAttributes();
$email = $attributes['contact/email'];
$first_name = $attributes['namePerson/first'];
$last_name = $attributes['namePerson/last'];
$signature = social_connect_generate_signature($google_id);
do_action( 'social_connect_before_register_google', $google_id, $signature );
?>
<html>
<head>
<script>
function init() {
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'google',
'social_connect_openid_identity' : '<?php echo $google_id ?>',
'social_connect_signature' : '<?php echo $signature ?>',
'social_connect_email' : '<?php echo $email ?>',
'social_connect_first_name' : '<?php echo $first_name ?>',
'social_connect_last_name' : '<?php echo $last_name ?>'});

window.close();
}
</script>
</head>
<body onload="init();"></body>
</html>
<?php
}
}
} catch(ErrorException $e) {
echo $e->getMessage();
echo $e->getMessage();
}
?>
58 changes: 25 additions & 33 deletions twitter/callback.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/wp-load.php');
require_once(dirname(dirname(__FILE__)) . '/utils.php' );

Expand All @@ -10,20 +11,13 @@
}

/**
* @file
* Take the user when they return from Twitter. Get access tokens.
* Verify credentials and redirect to based on response from Twitter.
*/

/* Start session and load lib */
require_once('twitteroauth/twitteroauth.php');

/* If the oauth_token is old redirect to the connect page. */
/*if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) {
$_SESSION['oauth_status'] = 'oldtoken';
header('Location: ./clearsessions.php');
}*/

/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);

Expand All @@ -39,38 +33,36 @@

/* If HTTP response is 200 continue otherwise send to connect page to retry */
if (200 == $connection->http_code) {
/* The user has been verified and the access tokens can be saved for future use */
$_SESSION['status'] = 'verified';
/* The user has been verified and the access tokens can be saved for future use */
$_SESSION['status'] = 'verified';

$user = $connection->get('account/verify_credentials');
$name = $user->name;
$screen_name = $user->screen_name;
$twitter_id = $user->id;
$signature = social_connect_generate_signature($twitter_id);
?>
?>

<html>
<head>
<script>
function init() {
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'twitter',
'social_connect_signature' : '<?php echo $signature ?>',
'social_connect_twitter_identity' : '<?php echo $twitter_id ?>',
'social_connect_screen_name' : '<?php echo $screen_name ?>',
'social_connect_name' : '<?php echo $name ?>'});

<html>
<head>
<script>
function init() {
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'twitter',
'social_connect_signature' : '<?php echo $signature ?>',
'social_connect_twitter_identity' : '<?php echo $twitter_id ?>',
'social_connect_screen_name' : '<?php echo $screen_name ?>',
'social_connect_name' : '<?php echo $name ?>'});

window.close();
}
</script>
</head>
<body onload="init();">
</body>
</html>

<?php
//header('Location: ./index.php');
window.close();
}
</script>
</head>
<body onload="init();">
</body>
</html>

<?php
} else {
/* Save HTTP status for error dialog on connnect page.*/
//header('Location: ./clearsessions.php');
echo 'Login error';
/* Save HTTP status for error dialog on connnect page.*/
echo 'Login error';
}
33 changes: 16 additions & 17 deletions twitter/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@
define('CONSUMER_SECRET', get_option('social_connect_twitter_consumer_secret'));
define('OAUTH_CALLBACK', SOCIAL_CONNECT_PLUGIN_URL . '/twitter/callback.php');

if(CONSUMER_KEY != '' && CONSUMER_SECRET != '') {
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* Get temporary credentials. */
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
/* If last connection failed don't display authorization link. */
switch ($connection->http_code) {
case 200:
if (CONSUMER_KEY != '' && CONSUMER_SECRET != '') {
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);

/* Get temporary credentials. */
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
/* If last connection failed don't display authorization link. */
switch ($connection->http_code) {
case 200:
/* Build authorize URL and redirect user to Twitter. */
$url = $connection->getAuthorizeURL($token);
wp_redirect($url);
break;
default:
default:
/* Show notification if something went wrong. */
echo 'Could not connect to Twitter. Refresh the page or try again later.';
}

exit();

}
}

exit();
}
10 changes: 5 additions & 5 deletions ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ function sc_render_login_form_social_connect( $args = NULL ) {
<?php do_action ('social_connect_pre_form'); ?>
<?php if( $facebook_enabled ) :
echo apply_filters('social_connect_login_facebook','<a href="javascript:void(0);" title="Facebook" class="social_connect_login_facebook"><img alt="Facebook" src="'.$images_url.'facebook_32.png" /></a>');
endif; ?>
endif; ?>
<?php if( $twitter_enabled ) :
echo apply_filters('social_connect_login_twitter','<a href="javascript:void(0);" title="Twitter" class="social_connect_login_twitter"><img alt="Twitter" src="'.$images_url.'twitter_32.png" /></a>');
endif; ?>
endif; ?>
<?php if( $google_enabled ) :
echo apply_filters('social_connect_login_google','<a href="javascript:void(0);" title="Google" class="social_connect_login_google"><img alt="Google" src="'.$images_url.'google_32.png" /></a>');
endif; ?>
endif; ?>
<?php if( $yahoo_enabled ) :
echo apply_filters('social_connect_login_yahoo','<a href="javascript:void(0);" title="Yahoo" class="social_connect_login_yahoo"><img alt="Yahoo" src="'.$images_url.'yahoo_32.png" /></a>');
endif; ?>
endif; ?>
<?php if( $wordpress_enabled ) :
echo apply_filters('social_connect_login_wordpress','<a href="javascript:void(0);" title="WordPress.com" class="social_connect_login_wordpress"><img alt="WordPress.com" src="'.$images_url.'wordpress_32.png" /></a>');
endif; ?>
endif; ?>
<?php do_action ('social_connect_post_form'); ?>
</div></p>

Expand Down
64 changes: 32 additions & 32 deletions wordpress/connect.php
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
<?php

require_once(dirname(dirname(__FILE__)) . '/openid/openid.php');
require_once(dirname(dirname(__FILE__)) . '/utils.php' );

try {
if(!isset($_GET['openid_mode'])) {
if (!isset($_GET['openid_mode'])) {
$openid = new LightOpenID;
$openid->identity = urldecode($_GET['wordpress_blog_url']);
$openid->required = array('namePerson', 'namePerson/friendly', 'contact/email');
header('Location: ' . $openid->authUrl());
} elseif($_GET['openid_mode'] == 'cancel') {
?>
<html>
?>
<html>
<body>
<p><?php _e( 'You have cancelled this login. Please close this window and try again.', 'social-connect' ); ?></p>
</body>
</html>
<?php
</html>
<?php
} else {
$openid = new LightOpenID;
if($openid->validate()) {
if ($openid->validate()) {
$wordpress_id = $openid->identity;
$attributes = $openid->getAttributes();
$email = isset($attributes['contact/email']) ? $attributes['contact/email'] : '';
$name = isset($attributes['namePerson']) ? $attributes['namePerson'] : '';
$signature = social_connect_generate_signature($wordpress_id);
if($email == '') {
if ($email == '') {
?>
<html>
<body>
<p><?php _e( 'You need to share your email address when prompted at wordpress.com. Please close this window and try again.', 'social-connect' ); ?></p>
</body>
<body>
<p><?php _e( 'You need to share your email address when prompted at wordpress.com. Please close this window and try again.', 'social-connect' ); ?></p>
</body>
</html>
<?php
die();
die();
}
do_action( 'social_connect_before_register_wordpress', $wordpress_id, $signature );
?>
<html>
<head>
<script>
function init() {
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'wordpress',
'social_connect_signature' : '<?php echo $signature ?>',
'social_connect_openid_identity' : '<?php echo $wordpress_id ?>',
'social_connect_email' : '<?php echo $email ?>',
'social_connect_name' : '<?php echo $name ?>'
});
window.close();
?>
<html>
<head>
<script>
function init() {
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'wordpress',
'social_connect_signature' : '<?php echo $signature ?>',
'social_connect_openid_identity' : '<?php echo $wordpress_id ?>',
'social_connect_email' : '<?php echo $email ?>',
'social_connect_name' : '<?php echo $name ?>'
});
window.close();
}
</script>
</head>
<body onload="init();"></body>
</html>
<?php
}
}
</script>
</head>
<body onload="init();">
</body>
</html>
<?php
}
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
?>
Loading

0 comments on commit 6874f19

Please sign in to comment.