File: /home/bt667/www/wp-content/plugins/wp_mvplayer/includes/aweber_api/request-access.php
<?php
include_once('../../../../../wp-load.php');
//$appID = '0d6203e1';
//$oauth_callback = rawurlencode(MV_PLAYER_URL.'/includes/aweber_api/request-access.php?processed=1');
if(isset($_GET['request-access']) && isset($_GET['vid']))
{
$appID = '0d6203e1';
$vid = $_GET['vid'];
$oauth_callback = rawurlencode(MV_PLAYER_URL.'includes/aweber_api/request-access.php?processed=1&vid='.$vid);
$awebr_access_point = "https://auth.aweber.com/1.0/oauth/authorize_app/{$appID}?oauth_callback={$oauth_callback}";
header('Location:'. $awebr_access_point);
}
if(isset($_GET['processed']) && isset($_GET['vid']))
{
/* Now process the request */
$vid=$_GET['vid'];
try
{
global $wpdb;
$auth = AWeberAPI::getDataFromAweberID($_GET['authorization_code']);
$aweber_data = array();
$aweber_data['consumerKey'] = $auth[0];
$aweber_data['consumerSecret'] = $auth[1];
$aweber_data['accessKey'] = $auth[2];
$aweber_data['accessSecret'] = $auth[3];
/* Now lets save this in database for future use */
$table_name = $wpdb->prefix . "mvplayer_video";
$desc = $wpdb->get_row( "SELECT * FROM $table_name where id='$vid'" );
if(!$desc)
{
$wpdb->insert( $table_name, array('AWeberAccessTokens' => serialize($aweber_data)) );
}
else
{
$wpdb->query( "update $table_name set AWeberAccessTokens = '".serialize($aweber_data)."' where id='$vid'" );
header('Location:'.get_option( 'siteurl' ) . '/wp-admin/admin.php?page=mv_player_add_video&id='.$vid.'&aweber-success=1');
}
}
catch(Exception $e)
{
/* Something went wrong!! */
header('Location:'.get_option( 'siteurl' ) . '/wp-admin/admin.php?page=mv_player_add_video&id='.$vid.'&aweber-error=1');
}
}