0 )
powerpress_save_settings($NewSettings);
}
function powerpress_strip_redirect_urls($url)
{
$Settings = powerpress_get_settings('powerpress_general');
for( $x = 1; $x <= 3; $x++ )
{
$field = sprintf('redirect%d', $x);
if( !empty($Settings[$field]) )
{
$redirect_no_http = str_replace('http://', '', $Settings[$field]);
if( substr($redirect_no_http, -1, 1) != '/' )
$redirect_no_http .= '/';
$url = str_replace($redirect_no_http, '', $url);
}
}
return $url;
}
function powerpress_admin_jquery_init()
{
$Settings = false; // Important, never remove this
$Settings = get_option('powerpress_general');
$Error = false;
$Programs = false;
$Step = 1;
$action = (isset($_GET['action'])?$_GET['action']: (isset($_POST['action'])?$_POST['action']:false) );
if( !$action )
return;
$DeleteFile = false;
switch($action)
{
case 'powerpress-jquery-stats': {
// Make sure users have permission to access this
if( !empty($Settings['use_caps']) && !current_user_can('view_podcast_stats') )
{
powerpress_admin_jquery_header( __('Blubrry Media Statistics', 'powerpress') );
?>
0 && (empty($userLastPodcast) || $userLastPodcast == '!nodefault') && $Settings['network_mode'] == '1') {
$blubrryProgramKeyword = '!selectPodcast';
}
if(!empty($userLastPodcast) && $userLastPodcast != '!nodefault' && $Settings['network_mode'] == '1') {
$blubrryProgramKeyword = $userLastPodcast;
}
if(!empty($_GET['blubrryProgramKeyword'])) {
$blubrryProgramKeyword = $_GET['blubrryProgramKeyword'];
}
if( !empty($_GET['blubrryProgramKeyword']) && !empty($_GET['remSel']) && $_GET['remSel'] == 'true' ) {
update_user_meta(get_current_user_id(), 'pp_default_podcast', $blubrryProgramKeyword);
$userLastPodcast = $blubrryProgramKeyword;
}
if( isset($_GET['remSel']) && $_GET['remSel'] == 'false') {
update_user_meta(get_current_user_id(), 'pp_default_podcast', '!nodefault');
$userLastPodcast = '!nodefault';
}
if( $DeleteFile )
{
$json_data = false;
$api_url_array = powerpress_get_api_array();
foreach( $api_url_array as $index => $api_url )
{
$req_url = sprintf('%s/media/%s/%s?format=json', rtrim($api_url, '/'), $Settings['blubrry_program_keyword'], $DeleteFile );
$req_url = sprintf('%s/media/%s/%s?format=json', rtrim($api_url, '/'), $blubrryProgramKeyword , $DeleteFile );
$req_url .= (defined('POWERPRESS_BLUBRRY_API_QSA')?'&'. POWERPRESS_BLUBRRY_API_QSA:'');
$json_data = powerpress_remote_fopen($req_url, $Settings['blubrry_auth'], array(), 10, 'DELETE');
if( !$json_data && $api_url == 'https://api.blubrry.com/' ) { // Lets force cURL and see if that helps...
$json_data = powerpress_remote_fopen($req_url, $Settings['blubrry_auth'], array(), 10, 'DELETE', true); // Only give this 2 seconds to return results
}
if( $json_data != false )
break;
}
$results = powerpress_json_decode($json_data);
if( isset($results['text']) )
$Msg = $results['text'];
else if( isset($results['error']) )
$Msg = $results['error'];
else
$Msg = __('An unknown error occurred deleting media file.', 'powerpress');
}
$json_data = false;
$json_data_programs = false;
$api_url_array = powerpress_get_api_array();
foreach( $api_url_array as $index => $api_url )
{
$req_url = sprintf('%s/media/%s/index.json?quota=true&published=true', rtrim($api_url, '/'), $blubrryProgramKeyword );
$req_url .= (defined('POWERPRESS_BLUBRRY_API_QSA')?'&'. POWERPRESS_BLUBRRY_API_QSA:'');
$req_url_programs = sprintf('%s/service/index.json', rtrim($api_url, '/') );
$req_url_programs .= (defined('POWERPRESS_BLUBRRY_API_QSA')?'?'. POWERPRESS_BLUBRRY_API_QSA:'');
$json_data = powerpress_remote_fopen($req_url, $Settings['blubrry_auth']);
$json_data_programs = powerpress_remote_fopen($req_url_programs, $Settings['blubrry_auth']);
if( !$json_data && $api_url == 'https://api.blubrry.com/' ) { // Lets force cURL and see if that helps...
$json_data = powerpress_remote_fopen($req_url, $Settings['blubrry_auth'], array(), 15, false, true);
}
else if(!$json_data_programs && $api_url == 'https://api.blubrry.com/') {
$json_data_programs = powerpress_remote_fopen($req_url, $Settings['blubrry_auth'], array(), 15, false, true);
}
if( $json_data != false )
break;
}
$results = powerpress_json_decode($json_data);
$results_programs = powerpress_json_decode($json_data_programs);
if( isset($results_programs['error']) )
{
$Error = $results_programs['error'];
if( strstr($Error, __('currently not available', 'powerpress') ) )
{
$Error = __('Unable to find podcasts for this account.', 'powerpress');
$Error .= '
';
$Error .= 'Verify that the email address you enter here matches the email address you used when you listed your podcast on blubrry.com.';
}
else if( preg_match('/No programs found.*media hosting/i', $results_programs['error']) )
{
$Error .= '
';
$Error .= 'Service may take a few minutes to activate.';
}
}
else if( !is_array($results_programs) )
{
$Error = $json_data_programs;
}
else {
// Get all the programs for this user...
foreach ($results_programs as $null => $row) {
$Programs[$row['program_keyword']] = $row['program_title'];
}
}
if( $Error ) {
powerpress_page_message_add_notice($Error, 'inline', false);
}
$FeedSlug = sanitize_title($_GET['podcast-feed']);
powerpress_admin_jquery_header( __('Select Media', 'powerpress'), true );
?>
$api_url )
{
$req_url = sprintf('%s/service/index.json', rtrim($api_url, '/') );
$req_url .= (defined('POWERPRESS_BLUBRRY_API_QSA')?'?'. POWERPRESS_BLUBRRY_API_QSA:'');
$json_data = powerpress_remote_fopen($req_url, $auth);
if( !$json_data && $api_url == 'https://api.blubrry.com/' ) { // Lets force cURL and see if that helps...
$json_data = powerpress_remote_fopen($req_url, $auth, array(), 15, false, true);
}
if( $json_data != false )
break;
}
if( $json_data )
{
$results = powerpress_json_decode($json_data);
if( isset($results['error']) )
{
$Error = $results['error'];
if( strstr($Error, __('currently not available', 'powerpress') ) )
{
$Error = __('Unable to find podcasts for this account.', 'powerpress');
$Error .= '
';
$Error .= 'Verify that the email address you enter here matches the email address you used when you listed your podcast on blubrry.com.';
}
else if( preg_match('/No programs found.*media hosting/i', $results['error']) )
{
$Error .= '
';
$Error .= 'Service may take a few minutes to activate.';
}
}
else if( !is_array($results) )
{
$Error = $json_data;
}
else
{
// Get all the programs for this user...
foreach( $results as $null => $row )
{
$Programs[ $row['program_keyword'] ] = $row['program_title'];
if( $row['hosting'] === true || $row['hosting'] == 'true' )
$ProgramHosting[ $row['program_keyword'] ] = true;
else
$ProgramHosting[ $row['program_keyword'] ] = false;
}
if( count($Programs) > 0 )
{
$SaveSettings['blubrry_auth'] = $auth;
if( !empty($SaveSettings['blubrry_program_keyword']) )
{
powerpress_add_blubrry_redirect($SaveSettings['blubrry_program_keyword']);
if ($SaveSettings['blubrry_program_keyword'] != 'no_default') {
$SaveSettings['blubrry_hosting'] = $ProgramHosting[$SaveSettings['blubrry_program_keyword']];
if (!is_bool($SaveSettings['blubrry_hosting'])) {
if ($SaveSettings['blubrry_hosting'] === 'false' || empty($SaveSettings['blubrry_hosting']))
$SaveSettings['blubrry_hosting'] = false;
}
}
$Save = true;
$Close = true;
}
else if( isset($SaveSettings['blubrry_program_keyword']) ) // Present but empty
{
$Error = __('You must select a program to continue.', 'powerpress');
}
else if( count($Programs) == 1 )
{
foreach( $Programs as $keyword => $title ) {
break;
}
$SaveSettings['blubrry_program_keyword'] = $keyword;
$SaveSettings['blubrry_hosting'] = $ProgramHosting[ $keyword ];
if( !is_bool($SaveSettings['blubrry_hosting']) )
{
if( $SaveSettings['blubrry_hosting'] === 'false' || empty($SaveSettings['blubrry_hosting']) )
$SaveSettings['blubrry_hosting'] = false;
}
powerpress_add_blubrry_redirect($keyword);
$Close = true;
$Save = true;
}
else
{
$Error = __('Please select your podcast program to continue.', 'powerpress');
$Step = 2;
$Settings['blubrry_username'] = $SaveSettings['blubrry_username'];
}
}
else
{
$Error = __('No podcasts for this account are listed on blubrry.com.', 'powerpress');
}
}
}
else
{
global $g_powerpress_remote_error, $g_powerpress_remote_errorno;
//$Error = ''. __('Error', 'powerpress') .'
';
if( !empty($g_powerpress_remote_errorno) && $g_powerpress_remote_errorno == 401 )
$Error .= ''. __('Incorrect sign-in email address or password.', 'powerpress') .'
'. __('Verify your account settings then try again.', 'powerpress') .'
';
else if( !empty($g_powerpress_remote_error) )
$Error .= ''.$g_powerpress_remote_error .'
';
else
$Error .= ''.__('Authentication failed.', 'powerpress') .'
';
}
if( $Error )
{
$Error .= ''. __('Click Here For Help','powerpress') .'
';
}
}
if( $Save )
$SaveSettings['network_mode'] = (isset($SaveSettings['network_mode'])) ? 1 : 0;
powerpress_save_settings($SaveSettings);
// Clear cached statistics
delete_option('powerpress_stats');
if( $Error )
powerpress_page_message_add_notice( $Error, 'inline', false );
if( $Close )
{
powerpress_admin_jquery_header( __('Blubrry Services', 'powerpress') );
powerpress_page_message_print();
?>
; ?>/images/no.png)
" onclick="self.parent.tb_remove(); return false;" target="_top">
";
echo "";
$style = (!empty($_GET['style']) && $_GET['style'] == 'modern') ? 'modern' : 'classic';
$shape = (!empty($_GET['shape']) && $_GET['shape'] == 'squared') ? '-sq' : '';
$css = plugins_url('css/subscribe.css', __FILE__);
echo "";
echo '';
echo "";
echo "