Esempio n. 1
0
function powerpress_admin_players_init()
{
    wp_enqueue_style('wp-mediaelement');
    wp_enqueue_script('wp-mediaelement');
    $Settings = false;
    // Important, never remove this
    $Step = 1;
    $action = isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : false);
    //$type = (isset($_GET['type'])?$_GET['type']: (isset($_POST['type'])?$_POST['type']:'audio') );
    if (!$action) {
        return;
    }
    switch ($action) {
        case 'powerpress-select-player':
            $SaveSettings = array();
            //$SaveSettings = $_POST['Player'];
            if (isset($_POST['Player'])) {
                $SaveSettings = $_POST['Player'];
            }
            if (isset($_POST['VideoPlayer'])) {
                $SaveSettings += $_POST['VideoPlayer'];
            }
            powerpress_save_settings($SaveSettings, 'powerpress_general');
            powerpress_page_message_add_notice(__('Player activated successfully.', 'powerpress'));
            break;
        case 'powerpress-audio-player':
            $SaveSettings = $_POST['Player'];
            powerpress_save_settings($SaveSettings, 'powerpress_audio-player');
            powerpress_page_message_add_notice(__('Audio Player settings saved successfully.', 'powerpress'));
            break;
    }
}
function powerpress_admin_players_init()
{
    //wp_enqueue_script('jquery');
    //echo "powerpres player init";
    wp_enqueue_style('mediaelement');
    wp_enqueue_style('wp-mediaelement');
    wp_enqueue_script('mediaelement');
    // wp_enqueue_script( 'wp-mediaelement' );
    wp_enqueue_script('powerpress-mejs', powerpress_get_root_url() . 'powerpress-mejs.js');
    $Settings = false;
    // Important, never remove this
    $Step = 1;
    $action = isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : false);
    //$type = (isset($_GET['type'])?$_GET['type']: (isset($_POST['type'])?$_POST['type']:'audio') );
    if (!$action) {
        return;
    }
    switch ($action) {
        case 'powerpress-select-player':
            $SaveSettings = array();
            //$SaveSettings = $_POST['Player'];
            if (isset($_POST['Player'])) {
                $SaveSettings = $_POST['Player'];
            }
            if (isset($_POST['VideoPlayer'])) {
                $SaveSettings += $_POST['VideoPlayer'];
            }
            powerpress_save_settings($SaveSettings, 'powerpress_general');
            powerpress_page_message_add_notice(__('Player activated successfully.', 'powerpress'));
            break;
        case 'powerpress-audio-player':
            $SaveSettings = $_POST['Player'];
            powerpress_save_settings($SaveSettings, 'powerpress_audio-player');
            powerpress_page_message_add_notice(__('Audio Player settings saved successfully.', 'powerpress'));
            break;
        case 'powerpress-flashmp3-maxi':
            $SaveSettings = $_POST['Player'];
            powerpress_save_settings($SaveSettings, 'powerpress_flashmp3-maxi');
            powerpress_page_message_add_notice(__('Flash Mp3 Maxi settings saved successfully.', 'powerpress'));
            break;
        case 'powerpress-audioplay':
            $SaveSettings = $_POST['Player'];
            powerpress_save_settings($SaveSettings, 'powerpress_audioplay');
            powerpress_page_message_add_notice(__('AudioPlay settings saved successfully.', 'powerpress'));
            break;
            //TODO: PowerPress 5.0
            //case 'powerpress-mediaelement':
            //{
            //	$SaveSettings = $_POST['Player'];
            //	powerpress_save_settings($SaveSettings, 'powerpress_mediaelement');
            //	powerpress_page_message_add_notice( __('MediaElement.js settings saved successfully.', 'powerpress') );
            //}; break;
    }
}
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'));
                ?>
<h2><?php 
                echo __('Blubrry Media Statistics', 'powerpress');
                ?>
</h2>
<p><?php 
                echo __('You do not have sufficient permission to manage options.', 'powerpress');
                ?>
</p>
<p style="text-align: center;"><a href="#" onclick="self.parent.tb_remove();"><?php 
                echo __('Close', 'powerpress');
                ?>
</a></p>
<?php 
                powerpress_admin_jquery_footer();
                exit;
            } else {
                if (!current_user_can('edit_posts')) {
                    powerpress_admin_jquery_header(__('Blubrry Media Statistics', 'powerpress'));
                    powerpress_page_message_add_notice(__('You do not have sufficient permission to view media statistics.', 'powerpress'));
                    powerpress_page_message_print();
                    powerpress_admin_jquery_footer();
                    exit;
                }
            }
            $StatsCached = get_option('powerpress_stats');
            powerpress_admin_jquery_header(__('Blubrry Media Statistics', 'powerpress'));
            ?>
<h2><?php 
            echo __('Blubrry Media Statistics', 'powerpress');
            ?>
</h2>
<?php 
            echo $StatsCached['content'];
            powerpress_admin_jquery_footer();
            exit;
            break;
        case 'powerpress-jquery-media-disable':
            if (!current_user_can('edit_posts')) {
                powerpress_admin_jquery_header('Uploader');
                powerpress_page_message_add_notice(__('You do not have sufficient permission to disable this option.', 'powerpress'));
                powerpress_page_message_print();
                powerpress_admin_jquery_footer();
                exit;
            }
            check_admin_referer('powerpress-jquery-media-disable');
            $DisableSetting = array();
            $DisableSetting['no_media_url_folder'] = 1;
            powerpress_save_settings($DisableSetting);
            powerpress_admin_jquery_header(__('Select Media', 'powerpress'));
            ?>
<h2><?php 
            echo __('Select Media', 'powerpress');
            ?>
</h2>
<p><?php 
            echo __('Blubrry Media Hosting icon will no longer be displayed when editing posts and pages.', 'powerpress');
            ?>
</p>
<p style="text-align: center;"><a href="#" onclick="self.parent.tb_remove();"><?php 
            echo __('Close', 'powerpress');
            ?>
</a></p>
<?php 
            powerpress_admin_jquery_footer();
            exit;
            // No break here, let this fall thru..
        // No break here, let this fall thru..
        case 'powerpress-jquery-media-delete':
            if (!current_user_can('edit_posts')) {
                powerpress_admin_jquery_header('Uploader');
                powerpress_page_message_add_notice(__('You do not have sufficient permission to upload media.', 'powerpress'));
                powerpress_page_message_print();
                powerpress_admin_jquery_footer();
                exit;
            }
            check_admin_referer('powerpress-jquery-media-delete');
            $DeleteFile = $_GET['delete'];
            // No break here, let this fall thru..
        // No break here, let this fall thru..
        case 'powerpress-jquery-media':
            if (!current_user_can('edit_posts')) {
                powerpress_admin_jquery_header(__('Select Media', 'powerpress'));
                ?>
<h2><?php 
                echo __('Select Media', 'powerpress');
                ?>
</h2>
<p><?php 
                echo __('You do not have sufficient permission to manage options.', 'powerpress');
                ?>
</p>
<p style="text-align: center;"><a href="#" onclick="self.parent.tb_remove();"><?php 
                echo __('Close', 'powerpress');
                ?>
</a></p>
<?php 
                powerpress_admin_jquery_footer();
                exit;
            }
            if (empty($Settings['blubrry_auth']) || empty($Settings['blubrry_hosting']) || $Settings['blubrry_hosting'] === 'false') {
                powerpress_admin_jquery_header(__('Select Media', 'powerpress'));
                ?>
<h2><?php 
                echo __('Select Media', 'powerpress');
                ?>
</h2>
<p><?php 
                echo __('Wait a sec! This feature is only available to Blubrry Media Podcast Hosting customers.', 'powerpress');
                if (!isset($Settings['blubrry_auth'])) {
                    echo ' ' . sprintf(__('Join our community to get free podcast statistics and access to other valuable %s.', 'powerpress'), '<a href="http://create.blubrry.com/resources/" target="_blank">' . __('services', 'powerpress') . '</a>');
                }
                ?>
</p>
<p><?php 
                echo sprintf(__('Our %s integrated with PowerPress making podcast publishing simple. Check out the %s on our exciting three-step publishing system!', 'powerpress'), '<a href="http://create.blubrry.com/resources/podcast-media-hosting/" target="_blank">' . __('Podcast Media Hosting', 'powerpress') . '</a>', '<a href="http://create.blubrry.com/resources/podcast-media-hosting/blubrry-on-site-podcast-hosting-demo/" target="_blank">' . __('video', 'powerpress') . '</a>');
                ?>
   </p>
	 <p><a href="<?php 
                echo wp_nonce_url("admin.php?action=powerpress-jquery-media-disable", 'powerpress-jquery-media-disable');
                ?>
&amp;KeepThis=true&amp;TB_iframe=true&amp;modal=true" onclick="return confirm('<?php 
                echo __('Remove the Blubrry Media Hosting icon from the Media URL field?', 'powerpress');
                ?>
');"><?php 
                echo __('Do not show this icon next to the Media URL field', 'powerpress');
                ?>
</a></p>
<p style="text-align: center;"><a href="#" onclick="self.parent.tb_remove();"><?php 
                echo __('Close', 'powerpress');
                ?>
</a></p>
<?php 
                powerpress_admin_jquery_footer();
                exit;
            }
            $Msg = false;
            if ($DeleteFile) {
                $json_data = false;
                $api_url_array = powerpress_get_api_array();
                while (list($index, $api_url) = each($api_url_array)) {
                    $req_url = sprintf('%s/media/%s/%s?format=json', rtrim($api_url, '/'), $Settings['blubrry_program_keyword'], $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 != 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;
            $api_url_array = powerpress_get_api_array();
            while (list($index, $api_url) = each($api_url_array)) {
                $req_url = sprintf('%s/media/%s/index.json?quota=true&published=true', rtrim($api_url, '/'), $Settings['blubrry_program_keyword']);
                $req_url .= defined('POWERPRESS_BLUBRRY_API_QSA') ? '&' . POWERPRESS_BLUBRRY_API_QSA : '';
                $json_data = powerpress_remote_fopen($req_url, $Settings['blubrry_auth']);
                if ($json_data != false) {
                    break;
                }
            }
            $results = powerpress_json_decode($json_data);
            $FeedSlug = $_GET['podcast-feed'];
            powerpress_admin_jquery_header(__('Select Media', 'powerpress'), true);
            ?>
<script language="JavaScript" type="text/javascript"><!--

function SelectMedia(File)
{
	self.parent.document.getElementById('powerpress_url_<?php 
            echo $FeedSlug;
            ?>
').value=File;
	self.parent.document.getElementById('powerpress_hosting_<?php 
            echo $FeedSlug;
            ?>
').value='1';
	self.parent.document.getElementById('powerpress_url_<?php 
            echo $FeedSlug;
            ?>
').readOnly=true;
	self.parent.document.getElementById('powerpress_hosting_note_<?php 
            echo $FeedSlug;
            ?>
').style.display='block';
	if( self.parent.powerpress_update_for_video )
		self.parent.powerpress_update_for_video(File, '<?php 
            echo $FeedSlug;
            ?>
');
	self.parent.tb_remove();
}
function SelectURL(url)
{
	self.parent.document.getElementById('powerpress_url_<?php 
            echo $FeedSlug;
            ?>
').value=url;
	self.parent.document.getElementById('powerpress_hosting_<?php 
            echo $FeedSlug;
            ?>
').value='0';
	self.parent.document.getElementById('powerpress_url_<?php 
            echo $FeedSlug;
            ?>
').readOnly=false;
	self.parent.document.getElementById('powerpress_hosting_note_<?php 
            echo $FeedSlug;
            ?>
').style.display='none';
	if( self.parent.powerpress_update_for_video )
		self.parent.powerpress_update_for_video(url, '<?php 
            echo $FeedSlug;
            ?>
');
	self.parent.tb_remove();
}
function DeleteMedia(File)
{
	return confirm('<?php 
            echo __('Delete', 'powerpress');
            ?>
: '+File+'\n\n<?php 
            echo __('Are you sure you want to delete this media file?', 'powerpress');
            ?>
');
}
//-->
</script>
		<div id="media-header">
			<h2><?php 
            echo __('Select Media', 'powerpress');
            ?>
</h2>
			<?php 
            if (!empty($results['quota']['expires'])) {
                $message = '';
                if (!empty($results['quota']['expires']['expired'])) {
                    $message = '<p>' . sprintf(__('Media hosting service expired on %s.', 'powerpress'), $results['quota']['expires']['readable_date']) . '</p>';
                } else {
                    $message = '<p>' . sprintf(__('Media hosting service will expire on %s.', 'powerpress'), $results['quota']['expires']['readable_date']) . '</p>';
                }
                $message .= '<p style="text-align: center;"><strong><a href="' . $results['quota']['expires']['renew_link'] . '" target="_blank" style="text-decoration: underline;">' . __('Renew Media Hosting Service', 'powerpress') . '</a></strong></p>';
                powerpress_page_message_add_notice($message);
                powerpress_page_message_print();
            } else {
                if (empty($results)) {
                    // Handle the error here.
                    $message = '<h3>' . __('Error', 'powerpress') . '</h3>';
                    global $g_powerpress_remote_error, $g_powerpress_remote_errorno;
                    if (!empty($g_powerpress_remote_errorno) && $g_powerpress_remote_errorno == 401) {
                        $message .= '<p>' . __('Incorrect sign-in email address or password.', 'powerpress') . '</p><p>' . __('Verify your account entered under Services and Statistics settings then try again.', 'powerpress') . '</p>';
                    } else {
                        if (!empty($g_powerpress_remote_error)) {
                            $message .= '<p>' . $g_powerpress_remote_error . '</p>';
                        } else {
                            $message .= '<p>' . __('Unable to connect to service.', 'powerpress') . '</p>';
                        }
                    }
                    // Print an erro here
                    powerpress_page_message_add_notice($message);
                    powerpress_page_message_print();
                }
            }
            if ($Msg) {
                echo '<p>' . $Msg . '</p>';
            }
            ?>
			<div class="media-upload-link"><a href="<?php 
            echo admin_url() . wp_nonce_url("admin.php?action=powerpress-jquery-upload", 'powerpress-jquery-upload');
            ?>
&podcast-feed=<?php 
            echo $FeedSlug;
            ?>
&keepThis=true&TB_iframe=true&height=350&width=530&modal=true" class="thickbox"><?php 
            echo __('Upload Media File', 'powerpress');
            ?>
</a></div>
			<p><?php 
            echo __('Select from media files uploaded to blubrry.com', 'powerpress');
            ?>
:</p>
		</div>
	<div id="media-items-container">
		<div id="media-items">
<?php 
            $QuotaData = false;
            if (isset($results['error'])) {
                echo $results['error'];
            } else {
                if (is_array($results)) {
                    $PublishedList = false;
                    while (list($index, $data) = each($results)) {
                        if ($index === 'quota') {
                            $QuotaData = $data;
                            continue;
                        }
                        if ($PublishedList == false && !empty($data['published'])) {
                            ?>
<div id="media-published-title">
	<?php 
                            echo __('Media Published within the past 30 days', 'powerpress');
                            ?>
:
</div>
<?php 
                            $PublishedList = true;
                        }
                        ?>
<div class="media-item <?php 
                        echo empty($data['published']) ? 'media-unpublished' : 'media-published';
                        ?>
">
	<strong class="media-name"><?php 
                        echo htmlspecialchars($data['name']);
                        ?>
</strong>
	<cite><?php 
                        echo powerpress_byte_size($data['length']);
                        ?>
</cite>
	<?php 
                        if (!empty($data['published'])) {
                            ?>
	<div class="media-published-date">&middot; <?php 
                            echo __('Published on', 'powerpress');
                            ?>
 <?php 
                            echo date(get_option('date_format'), $data['last_modified']);
                            ?>
</div>
	<?php 
                        }
                        ?>
	<div class="media-item-links">
		<?php 
                        if (!empty($data['published']) && !empty($data['url'])) {
                            ?>
			<a href="#" onclick="SelectURL('<?php 
                            echo $data['url'];
                            ?>
'); return false;"><?php 
                            echo __('Select', 'powerpress');
                            ?>
</a>
		<?php 
                        } else {
                            ?>
			<?php 
                            if (function_exists('curl_init')) {
                                ?>
				<a href="<?php 
                                echo admin_url() . wp_nonce_url("admin.php?action=powerpress-jquery-media-delete", 'powerpress-jquery-media-delete');
                                ?>
&amp;podcast-feed=<?php 
                                echo $FeedSlug;
                                ?>
&amp;delete=<?php 
                                echo urlencode($data['name']);
                                ?>
" onclick="return DeleteMedia('<?php 
                                echo $data['name'];
                                ?>
');"><?php 
                                echo __('Delete', 'powerpress');
                                ?>
</a> | 
			<?php 
                            }
                            ?>
			<a href="#" onclick="SelectMedia('<?php 
                            echo $data['name'];
                            ?>
'); return false;"><?php 
                            echo __('Select', 'powerpress');
                            ?>
</a>
		<?php 
                        }
                        ?>
	</div> 
</div>
<?php 
                    }
                }
            }
            ?>
		</div>
	</div>
	<div id="media-footer">
		<div class="media-upload-link"><a href="<?php 
            echo admin_url() . wp_nonce_url("admin.php?action=powerpress-jquery-upload", 'powerpress-jquery-upload');
            ?>
&podcast-feed=<?php 
            echo $FeedSlug;
            ?>
&keepThis=true&TB_iframe=true&height=350&width=530&modal=true" class="thickbox"><?php 
            echo __('Upload Media File', 'powerpress');
            ?>
</a></div>
		<?php 
            if ($QuotaData) {
                $NextDate = strtotime($QuotaData['published']['next_date']);
                ?>
			<?php 
                if ($QuotaData['unpublished']['available'] != $QuotaData['unpublished']['total']) {
                    //echo '<p>';
                    //echo sprintf( __('You have uploaded %s (%s available) of your %s upload limit.', 'powerpress'),
                    //	'<em>'. powerpress_byte_size($QuotaData['unpublished']['used']) .'</em>',
                    //	'<em>'. powerpress_byte_size($QuotaData['unpublished']['available']) .'</em>',
                    //	'<em>'. powerpress_byte_size($QuotaData['unpublished']['total']) .'</em>' );
                    //echo '</p>';
                }
                if ($QuotaData['published']['status'] == 'OK') {
                    ?>
			<p><?php 
                    if ($QuotaData['published']['available'] > 0) {
                        echo sprintf(__('Publishing space available: %s of (%s %%) of %s/month quota.', 'powerpress'), '<em>' . powerpress_byte_size($QuotaData['published']['available']) . '</em>', '<em>' . round($QuotaData['published']['available'] / $QuotaData['published']['total'] * 100) . '</em>', '<em>' . str_replace('.0', '', powerpress_byte_size($QuotaData['published']['total'])) . '</em>');
                        //echo sprintf( __('You have %s available (%s published in the last 30 days) of your %s publish limit.', 'powerpress'),
                        //	'<em>'. powerpress_byte_size($QuotaData['published']['available']) .'</em>',
                        //	'<em>'. powerpress_byte_size($QuotaData['published']['total']-$QuotaData['published']['available']) .'</em>',
                        //	'<em>'. powerpress_byte_size($QuotaData['published']['total']) .'</em>' );
                    } else {
                        if ($QuotaData['published']['available'] == 0) {
                        } else {
                            echo sprintf(__('You have %s publish space available.', 'powerpress'), '<em>' . powerpress_byte_size($QuotaData['published']['total']) . '</em>');
                        }
                    }
                    ?>
			</p>
			<p>
			<?php 
                    echo sprintf(__('No-Fault Hosting: You may upload a media file up to %s in size and be within the No-Fault maximum (25%% more than your %s quota).', 'powerpress'), powerpress_byte_size($QuotaData['published']['no_fault_maximum']), str_replace('.0', '', powerpress_byte_size($QuotaData['published']['total'])));
                    echo ' ';
                    echo '<a href="http://create.blubrry.com/resources/podcast-media-hosting/no-fault/" target="_blank">' . __('Learn More', 'powerpress') . '</a>';
                    ?>
			</p>
			<p><?php 
                    if ($QuotaData['published']['available'] != $QuotaData['published']['total']) {
                        echo sprintf(__('Your quota will reset on %s.', 'powerpress'), date('m/d/Y', $NextDate));
                    }
                    ?>
			</p>
			<?php 
                } else {
                    if ($QuotaData['published']['status'] == 'UNLIMITED') {
                        echo '<p>';
                        echo __('Publishing Space Available: Unlimited (Professional Hosting)', 'powerpress');
                        echo '<p>';
                    } else {
                        echo '<p>';
                        echo __('Publishing Space Available: Account has expired', 'powerpress');
                        echo '<p>';
                    }
                }
                ?>
		<?php 
            }
            ?>
		<p style="text-align: center;"><a href="#" onclick="self.parent.tb_remove();"><?php 
            echo __('Close', 'powerpress');
            ?>
</a></p>
	</div>
	
<?php 
            powerpress_admin_jquery_footer(true);
            exit;
            break;
        case 'powerpress-jquery-account-save':
            if (!current_user_can(POWERPRESS_CAPABILITY_MANAGE_OPTIONS)) {
                powerpress_admin_jquery_header('Blubrry Services Integration', 'powerpress');
                powerpress_page_message_add_notice(__('You do not have sufficient permission to manage options.', 'powerpress'));
                powerpress_page_message_print();
                powerpress_admin_jquery_footer();
                exit;
            }
            check_admin_referer('powerpress-jquery-account');
            $Password = $_POST['Password'];
            $SaveSettings = $_POST['Settings'];
            $Password = powerpress_stripslashes($Password);
            $SaveSettings = powerpress_stripslashes($SaveSettings);
            $Save = false;
            $Close = false;
            if (!empty($_POST['Remove'])) {
                $SaveSettings['blubrry_username'] = '';
                $SaveSettings['blubrry_auth'] = '';
                $SaveSettings['blubrry_program_keyword'] = '';
                $SaveSettings['blubrry_hosting'] = false;
                $Close = true;
                $Save = true;
            } else {
                $Programs = array();
                $ProgramHosting = array();
                // Anytime we change the password we need to test it...
                $auth = base64_encode($SaveSettings['blubrry_username'] . ':' . $Password);
                $json_data = false;
                $api_url_array = powerpress_get_api_array();
                while (list($index, $api_url) = each($api_url_array)) {
                    $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 != 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 .= '<br /><span style="font-weight: normal; font-size: 12px;">';
                            $Error .= 'Verify that the email address you enter here matches the email address you used when you listed your podcast on blubrry.com.</span>';
                        } else {
                            if (preg_match('/No programs found.*media hosting/i', $results['error'])) {
                                $Error .= '<br/><span style="font-weight: normal; font-size: 12px;">';
                                $Error .= 'Service may take a few minutes to activate.</span>';
                            }
                        }
                    } else {
                        if (!is_array($results)) {
                            $Error = $json_data;
                        } else {
                            // Get all the programs for this user...
                            while (list($null, $row) = each($results)) {
                                $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']);
                                    $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'])) {
                                        $Error = __('You must select a program to continue.', 'powerpress');
                                    } else {
                                        if (count($Programs) == 1) {
                                            list($keyword, $title) = each($Programs);
                                            $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 = '<h3>'. __('Error', 'powerpress') .'</h3>';
                    if (!empty($g_powerpress_remote_errorno) && $g_powerpress_remote_errorno == 401) {
                        $Error .= '<p>' . __('Incorrect sign-in email address or password.', 'powerpress') . '</p><p>' . __('Verify your account settings then try again.', 'powerpress') . '</p>';
                    } else {
                        if (!empty($g_powerpress_remote_error)) {
                            $Error .= '<p>' . $g_powerpress_remote_error . '</p>';
                        } else {
                            $Error .= '<p>' . __('Authentication failed.', 'powerpress') . '</p>';
                        }
                    }
                }
                if ($Error) {
                    $Error .= '<p style="text-align: center;"><a href="http://create.blubrry.com/resources/powerpress/powerpress-settings/services-stats/" target="_blank">' . __('Click Here For Help', 'powerpress') . '</a></p>';
                }
            }
            if ($Save) {
                powerpress_save_settings($SaveSettings);
            }
            // Clear cached statistics
            delete_option('powerpress_stats');
            if ($Error) {
                powerpress_page_message_add_notice($Error);
            }
            if ($Close) {
                powerpress_admin_jquery_header(__('Blubrry Services Integration', 'powerpress'));
                powerpress_page_message_print();
                ?>
<p style="text-align: right; position: absolute; top: 5px; right: 5px; margin: 0; padding:0;"><a href="#" onclick="self.parent.tb_remove(); return false;" title="<?php 
                echo __('Close', 'powerpress');
                ?>
"><img src="<?php 
                echo admin_url();
                ?>
/images/no.png" alt="<?php 
                echo __('Close', 'powerpress');
                ?>
" /></a></p>
<h2><?php 
                echo __('Blubrry Services Integration', 'powerpress');
                ?>
</h2>
<p style="text-align: center;"><strong><?php 
                echo __('Settings Saved Successfully!', 'powerpress');
                ?>
</strong></p>
<p style="text-align: center;">
	<a href="<?php 
                echo admin_url("admin.php?page=powerpress/powerpressadmin_basic.php");
                ?>
" onclick="self.parent.tb_remove(); return false;" target="_top"><?php 
                echo __('Close', 'powerpress');
                ?>
</a>
</p>
<script type="text/javascript"><!--

jQuery(document).ready(function($) {
	// Upload loading, check the parent window for #blubrry_stats_settings div
	if( jQuery('#blubrry_stats_settings',parent.document).length )
	{
		jQuery('#blubrry_stats_settings',parent.document).html('');
	}
});

// --></script>
<?php 
                powerpress_admin_jquery_footer();
                exit;
            }
            // no break here, let the next case catch it...
        // no break here, let the next case catch it...
        case 'powerpress-jquery-account':
            if (!current_user_can(POWERPRESS_CAPABILITY_MANAGE_OPTIONS)) {
                powerpress_admin_jquery_header(__('Blubrry Services Integration', 'powerpress'));
                powerpress_page_message_add_notice(__('You do not have sufficient permission to manage options.', 'powerpress'));
                powerpress_page_message_print();
                powerpress_admin_jquery_footer();
                exit;
            }
            if (!ini_get('allow_url_fopen') && !function_exists('curl_init')) {
                powerpress_admin_jquery_header(__('Blubrry Services Integration', 'powerpress'));
                powerpress_page_message_add_notice(__('Your server must either have the php.ini setting \'allow_url_fopen\' enabled or have the PHP cURL library installed in order to continue.', 'powerpress'));
                powerpress_page_message_print();
                powerpress_admin_jquery_footer();
                exit;
            }
            check_admin_referer('powerpress-jquery-account');
            if (!$Settings) {
                $Settings = get_option('powerpress_general');
            }
            if (empty($Settings['blubrry_username'])) {
                $Settings['blubrry_username'] = '';
            }
            if (empty($Settings['blubrry_hosting']) || $Settings['blubrry_hosting'] === 'false') {
                $Settings['blubrry_hosting'] = false;
            }
            if (empty($Settings['blubrry_program_keyword'])) {
                $Settings['blubrry_program_keyword'] = '';
            }
            if ($Programs == false) {
                $Programs = array();
            }
            powerpress_admin_jquery_header(__('Blubrry Services Integration', 'powerpress'));
            powerpress_page_message_print();
            ?>
<form action="<?php 
            echo admin_url('admin.php');
            ?>
" enctype="multipart/form-data" method="post">
<?php 
            wp_nonce_field('powerpress-jquery-account');
            ?>
<input type="hidden" name="action" value="powerpress-jquery-account-save" />
<div id="accountinfo">
	<h2><?php 
            echo __('Blubrry Services Integration', 'powerpress');
            ?>
</h2>
<?php 
            if ($Step == 1) {
                ?>
	<p>
		<label for="blubrry_username"><?php 
                echo __('Blubrry User Name (Email)', 'powerpress');
                ?>
</label>
		<input type="text" id="blubrry_username" name="Settings[blubrry_username]" value="<?php 
                echo $Settings['blubrry_username'];
                ?>
" />
	</p>
	<p id="password_row">
		<label for="password_password"><?php 
                echo __('Blubrry Password', 'powerpress');
                ?>
</label>
		<input type="password" id="password_password" name="Password" value="" />
	</p>
<?php 
            } else {
                ?>
	<input type="hidden" name="Settings[blubrry_username]" value="<?php 
                echo htmlspecialchars($Settings['blubrry_username']);
                ?>
" />
	<input type="hidden" name="Password" value="<?php 
                echo htmlspecialchars($Password);
                ?>
" />
	<!-- <input type="hidden" name="Settings[blubrry_hosting]" value="<?php 
                echo $Settings['blubrry_hosting'];
                ?>
" /> -->
	<p>
		<label for="blubrry_program_keyword"><?php 
                echo __('Select Blubrry Program', 'powerpress');
                ?>
</label>
<select id="blubrry_program_keyword" name="Settings[blubrry_program_keyword]">
<option value=""><?php 
                echo __('Select Program', 'powerpress');
                ?>
</option>
<?php 
                while (list($value, $desc) = each($Programs)) {
                    echo "\t<option value=\"{$value}\"" . ($Settings['blubrry_program_keyword'] == $value ? ' selected' : '') . ">{$desc}</option>\n";
                }
                ?>
</select>
	</p>
<?php 
            }
            ?>
	<p>
		<input type="submit" name="Save" value="<?php 
            echo __('Save', 'powerpress');
            ?>
" />
		<input type="button" name="Cancel" value="<?php 
            echo __('Cancel', 'powerpress');
            ?>
" onclick="self.parent.tb_remove();" />
		<input type="submit" name="Remove" value="Remove" style="float: right;" onclick="return confirm('<?php 
            echo __('Remove Blubrry Services Integration, are you sure?', 'powerpress');
            ?>
');" />
	</p>
</div>
</form>
<?php 
            powerpress_admin_jquery_footer();
            exit;
            break;
        case 'powerpress-jquery-upload':
            if (!current_user_can('edit_posts')) {
                powerpress_admin_jquery_header(__('Uploader', 'powerpress'));
                powerpress_page_message_add_notice(__('You do not have sufficient permission to upload media.', 'powerpress'));
                powerpress_page_message_print();
                powerpress_admin_jquery_footer();
                exit;
            }
            check_admin_referer('powerpress-jquery-upload');
            $RedirectURL = false;
            $Error = false;
            if (!$Settings) {
                $Settings = get_option('powerpress_general');
            }
            if (empty($Settings['blubrry_hosting']) || $Settings['blubrry_hosting'] === 'false') {
                $Settings['blubrry_hosting'] = false;
            }
            if (empty($Settings['blubrry_program_keyword'])) {
                $Settings['blubrry_program_keyword'] = '';
            }
            if (empty($Settings['blubrry_auth'])) {
                $Settings['blubrry_auth'] = '';
            }
            if (empty($Settings['blubrry_hosting'])) {
                $Error = __('This feature is available to Blubrry Hosting users only.', 'powerpress');
            }
            if ($Error == false) {
                $json_data = false;
                $api_url_array = powerpress_get_api_array();
                while (list($index, $api_url) = each($api_url_array)) {
                    $req_url = sprintf('%s/media/%s/upload_session.json', rtrim($api_url, '/'), $Settings['blubrry_program_keyword']);
                    $req_url .= defined('POWERPRESS_BLUBRRY_API_QSA') ? '?' . POWERPRESS_BLUBRRY_API_QSA : '';
                    $json_data = powerpress_remote_fopen($req_url, $Settings['blubrry_auth']);
                    if ($json_data != false) {
                        break;
                    }
                }
                $results = powerpress_json_decode($json_data);
                // We need to obtain an upload session for this user...
                if (isset($results['error']) && strlen($results['error']) > 1) {
                    $Error = $results['error'];
                    if (strstr($Error, 'currently not available')) {
                        $Error = __('Unable to find podcasts for this account.', 'powerpress');
                    }
                } else {
                    if ($results === $json_data) {
                        $Error = $json_data;
                    } else {
                        if (!is_array($results) || $results == false) {
                            $Error = $json_data;
                        } else {
                            if (isset($results['url']) && !empty($results['url'])) {
                                $RedirectURL = $results['url'];
                            }
                        }
                    }
                }
            }
            if ($Error == false && $RedirectURL) {
                $RedirectURL .= '&ReturnURL=';
                $RedirectURL .= urlencode(admin_url("admin.php?action=powerpress-jquery-upload-complete"));
                header("Location: {$RedirectURL}");
                exit;
            } else {
                if ($Error == false) {
                    global $g_powerpress_remote_error, $g_powerpress_remote_errorno;
                    if (!empty($g_powerpress_remote_errorno) && $g_powerpress_remote_errorno == 401) {
                        $Error = '<p>' . __('Incorrect sign-in email address or password.', 'powerpress') . '</p><p>' . __('Verify your account entered under Services and Statistics settings then try again.', 'powerpress') . '</p>';
                    } else {
                        if (!empty($g_powerpress_remote_error)) {
                            $Error = '<p>' . $g_powerpress_remote_error . '</p>';
                        } else {
                            $Error = '<p>' . __('Unable to obtain upload session.', 'powerpress') . '</p>';
                        }
                    }
                }
            }
            powerpress_admin_jquery_header(__('Uploader', 'powerpress'));
            echo '<h2>' . __('Uploader', 'powerpress') . '</h2>';
            echo '<p>';
            echo $Error;
            echo '</p>';
            ?>
			<p style="text-align: center;"><a href="#" onclick="self.parent.tb_remove();"><?php 
            echo __('Close', 'powerpress');
            ?>
</a></p>
			<?php 
            powerpress_admin_jquery_footer();
            exit;
            break;
        case 'powerpress-jquery-upload-complete':
            if (!current_user_can('edit_posts')) {
                powerpress_admin_jquery_header('Uploader');
                powerpress_page_message_add_notice(__('You do not have sufficient permission to upload media.', 'powerpress'));
                powerpress_page_message_print();
                powerpress_admin_jquery_footer();
                exit;
            }
            $File = isset($_GET['File']) ? $_GET['File'] : false;
            $Message = isset($_GET['Message']) ? $_GET['Message'] : false;
            powerpress_admin_jquery_header(__('Upload Complete', 'powerpress'));
            echo '<h2>' . __('Uploader', 'powerpress') . '</h2>';
            echo '<p>';
            if ($File) {
                echo __('File', 'powerpress') . ': ';
                echo $File;
                echo ' - ';
            }
            echo $Message;
            echo '</p>';
            ?>
			<p style="text-align: center;"><a href="#" onclick="self.parent.tb_remove();"><?php 
            echo __('Close', 'powerpress');
            ?>
</a></p>
			<?php 
            if ($Message == '') {
                ?>
<script language="JavaScript" type="text/javascript"><!--
<?php 
                if ($File != '') {
                    ?>
self.parent.SelectMedia('<?php 
                    echo $File;
                    ?>
'); <?php 
                }
                ?>
self.parent.tb_remove();
//-->
</script>
<?php 
            }
            powerpress_admin_jquery_footer();
            exit;
            break;
    }
}
Esempio n. 4
0
function powerpress_admin_import_podcasting_settings()
{
    $Changes = false;
    $General = get_option('powerpress_general');
    if (!$General) {
        $General = array();
        $Changes = true;
        $General['process_podpress'] = 0;
        $General['display_player'] = 1;
        $General['player_function'] = 1;
        $General['podcast_link'] = 1;
    }
    $pod_player_location = get_option('pod_player_location');
    if ($pod_player_location == 'top') {
        $General['display_player'] = 2;
        // display above posts
        $Changes = true;
    }
    $pod_audio_width = get_option('pod_audio_width');
    if (is_int((int) $pod_audio_width) && $pod_audio_width > 100) {
        $General['player_width_audio'] = $pod_audio_width;
        $Changes = true;
    }
    $pod_player_width = get_option('pod_player_width');
    if (is_int((int) $pod_player_width) && $pod_player_width > 100) {
        $General['player_width'] = $pod_player_width;
        $Changes = true;
    }
    $pod_player_height = get_option('pod_player_height');
    if (is_int((int) $pod_player_height) && $pod_player_height > 100) {
        $General['player_height'] = $pod_player_height;
        $Changes = true;
    }
    if ($Changes == true) {
        // save these imported general settings
        powerpress_save_settings($General, 'powerpress_general');
    }
    $FeedChanges = false;
    // Feed settings:
    $FeedSettings = get_option('powerpress_feed');
    if (!$FeedSettings) {
        $FeedSettings = array();
        $FeedChanges = true;
    }
    $pod_itunes_summary = get_option('pod_itunes_summary');
    if ($pod_itunes_summary) {
        $FeedSettings['itunes_summary'] = stripslashes($pod_itunes_summary);
        $FeedChanges = true;
    }
    $pod_itunes_image = get_option('pod_itunes_image');
    if ($pod_itunes_image) {
        $FeedSettings['itunes_image'] = $pod_itunes_image;
        $FeedChanges = true;
    }
    $iTunesCategories = powerpress_itunes_categories(true);
    for ($x = 1; $x <= 3; $x++) {
        $pod_itunes_cat = get_option('pod_itunes_cat' . $x);
        $find = str_replace('&amp;', '&', $pod_itunes_cat);
        $CatDesc = str_replace('||', ' > ', $find);
        $CatKey = array_search($CatDesc, $iTunesCategories);
        if ($CatKey) {
            $FeedSettings['itunes_cat_' . $x] = $CatKey;
            $FeedChanges = true;
        }
    }
    $pod_itunes_ownername = get_option('pod_itunes_ownername');
    if ($pod_itunes_ownername) {
        $FeedSettings['itunes_talent_name'] = stripslashes($pod_itunes_ownername);
        $FeedChanges = true;
    }
    $pod_itunes_owneremail = get_option('pod_itunes_owneremail');
    if ($pod_itunes_owneremail) {
        $FeedSettings['email'] = $pod_itunes_owneremail;
        $FeedChanges = true;
    }
    $rss_language = get_option('rss_language');
    if ($rss_language) {
        $FeedSettings['rss_language'] = $rss_language;
        $FeedChanges = true;
    }
    $pod_tagline = get_option('pod_tagline');
    if ($pod_tagline) {
        $FeedSettings['itunes_subtitle'] = stripslashes($pod_tagline);
        $FeedChanges = true;
    }
    $pod_itunes_explicit = get_option('pod_itunes_explicit');
    if ($pod_itunes_explicit == 'yes') {
        $FeedSettings['itunes_explicit'] = 1;
        $FeedChanges = true;
    } else {
        if ($pod_itunes_explicit == 'clean') {
            $FeedSettings['itunes_explicit'] = 2;
            $FeedChanges = true;
        }
    }
    if ($FeedChanges) {
        // save these imported feed settings
        powerpress_save_settings($FeedSettings, 'powerpress_feed');
    }
    return $Changes || $FeedChanges;
}
 function import_program_info($channel, $overwrite = false, $download_itunes_image = false)
 {
     $Feed = get_option('powerpress_feed_podcast');
     if (empty($Feed)) {
         $Feed = get_option('powerpress_feed');
     }
     $NewSettings = array();
     $matches = array();
     $program_title = false;
     if (preg_match('|<title>(.*?)</title>|is', $channel, $matches)) {
         $program_title = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['title'])) {
             $NewSettings['title'] = $program_title;
         }
     }
     // language
     $language = false;
     if (preg_match('|<language>(.*?)</language>|is', $channel, $matches)) {
         $language = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['rss_language'])) {
             $NewSettings['rss_language'] = $language;
         }
     }
     // copyright
     $copyright = false;
     if (preg_match('|<copyright>(.*?)</copyright>|is', $channel, $matches)) {
         $copyright = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['copyright'])) {
             $NewSettings['copyright'] = $copyright;
         }
     }
     // description
     $description = false;
     if (preg_match('|<description>(.*?)</description>|is', $channel, $matches)) {
         $description = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['description'])) {
             $NewSettings['description'] = $description;
         }
     }
     // itunes:subtitle
     $itunes_subtitle = false;
     if (preg_match('|<itunes:subtitle>(.*?)</itunes:subtitle>|is', $channel, $matches)) {
         $itunes_subtitle = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['itunes_subtitle'])) {
             $NewSettings['itunes_subtitle'] = $itunes_subtitle;
         }
     }
     // itunes:summary
     $itunes_summary = false;
     if (preg_match('|<itunes:summary>(.*?)</itunes:summary>|is', $channel, $matches)) {
         $itunes_summary = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['itunes_summary'])) {
             $NewSettings['itunes_summary'] = $itunes_summary;
         }
     }
     // itunes:email
     $itunes_email = false;
     if (preg_match('|<itunes:email>(.*?)</itunes:email>|is', $channel, $matches)) {
         $itunes_email = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['email'])) {
             $NewSettings['email'] = $itunes_email;
         }
     }
     // itunes:author
     $itunes_talent_name = false;
     if (preg_match('|<itunes:author>(.*?)</itunes:author>|is', $channel, $matches)) {
         $itunes_talent_name = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['itunes_talent_name'])) {
             $NewSettings['itunes_talent_name'] = $itunes_talent_name;
         }
     }
     // itunes:explicit
     if (preg_match('|<itunes:explicit>(.*?)</itunes:explicit>|is', $channel, $explicit)) {
         $explicit_array = array('yes' => 1, 'clean' => 2);
         // No need to save 'no'
         $value = strtolower(trim($explicit[1]));
         if (!empty($explicit_array[$value])) {
             if ($overwrite || empty($Feed['itunes_explicit'])) {
                 $NewSettings['itunes_explicit'] = $explicit_array[$value];
             }
         }
     }
     // itunes:image
     $itunes_image = '';
     if (preg_match('/<itunes:image.*href="(.*?)".*(\\/>|>.*<\\/itunes:image>)/is', $channel, $image)) {
         $itunes_image = html_entity_decode(trim($image[1]));
         // Now we need to download and save the image locally...
         // download the image then save it locally...
         if ($download_itunes_image) {
             $upload_path = false;
             $upload_url = false;
             $UploadArray = wp_upload_dir();
             if (false === $UploadArray['error']) {
                 $upload_path = $UploadArray['basedir'] . '/powerpress/';
                 $upload_url = $UploadArray['baseurl'] . '/powerpress/';
                 $filename = str_replace(" ", "_", basename($itunes_image));
                 if (file_exists($upload_path . $filename)) {
                     $filenameParts = pathinfo($filename);
                     if (!empty($filenameParts['extension'])) {
                         do {
                             $filename_no_ext = substr($filenameParts['basename'], 0, (strlen($filenameParts['extension']) + 1) * -1);
                             $filename = sprintf('%s-%03d.%s', $filename_no_ext, rand(0, 999), $filenameParts['extension']);
                         } while (file_exists($upload_path . $filename));
                     }
                 }
                 $image_data = wp_remote_fopen($itunes_image);
                 if (!empty($image_data)) {
                     file_put_contents($upload_path . $filename, $image_data);
                     $NewSettings['itunes_image'] = $upload_url . $filename;
                     $NewSettings['rss2_image'] = $itunes_image;
                 }
             }
         } else {
             if ($overwrite || empty($Feed['itunes_image'])) {
                 $NewSettings['itunes_image'] = $itunes_image;
                 $NewSettings['rss2_image'] = $itunes_image;
             }
         }
     }
     if (preg_match('|<itunes:author>(.*?)</itunes:author>|is', $channel, $matches)) {
         $itunes_talent_name = $this->_sanatize_tag_value($matches[1]);
         if ($overwrite || empty($Feed['itunes_talent_name'])) {
             $NewSettings['itunes_talent_name'] = $itunes_talent_name;
         }
     }
     // itunes:category (up to 3)
     $itunes_categories = false;
     if (preg_match_all('|<itunes:category.*text="(.*?)"|is', $channel, $matches)) {
         $pos = 1;
         $itunes_categories = $matches[1];
         $Categories = powerpress_itunes_categories();
         $Categories = array_map('strtolower', $Categories);
         $cats_by_title = array_flip($Categories);
         $FoundCategories = array();
         while (list($index, $category) = each($itunes_categories)) {
             $category = str_replace('&amp;', '&', $category);
             $category = strtolower($category);
             if (!empty($cats_by_title[$category])) {
                 $FoundCategories[] = $cats_by_title[$category];
             }
         }
         // Now walk trouigh found categories and stack them correctly...
         // this logic rebuilds the categorires in the correct order no matter what method the service stacked them
         $FinalCats = array(1 => '', 2 => '', 3 => '');
         $last_category_index = 1;
         while (list($index, $cat_id) = each($FoundCategories)) {
             if (!empty($FinalCats[$last_category_index])) {
                 if (intval(substr($FinalCats[$last_category_index], 3)) > 0) {
                     $last_category_index++;
                 } else {
                     if (intval(substr($FinalCats[$last_category_index], 0, 2)) != intval(substr($cat_id, 0, 2))) {
                         $last_category_index++;
                     }
                 }
                 // else we can overwrite this category with subcategory
             }
             if ($last_category_index > 3) {
                 break;
             }
             // We are at the max cats available...
             $FinalCats[$last_category_index] = $cat_id;
         }
         while (list($field_no, $cat_id) = each($FinalCats)) {
             if (empty($cat_id)) {
                 continue;
             }
             $field = sprintf('itunes_cat_%d', $field_no);
             if ($overwrite || empty($Feed[$field])) {
                 $NewSettings[$field] = $cat_id;
             }
         }
     }
     if (!empty($NewSettings)) {
         // Save here..
         if (get_option('powerpress_feed_podcast')) {
             // If the settings were moved to the podcast channels feature...
             powerpress_save_settings($NewSettings, 'powerpress_feed_podcast');
             // save a copy here if that is the case.
         } else {
             powerpress_save_settings($NewSettings, 'powerpress_feed');
         }
         echo '<hr />';
         echo '<p><strong>' . __('Program information imported', 'powerpress') . '</strong></p>';
         echo '<ul class="ul-disc">';
         while (list($field, $value) = each($NewSettings)) {
             if ($field == 'rss2_image') {
                 continue;
             }
             echo '<li>';
             switch ($field) {
                 case 'title':
                     echo __('Feed Title (Show Title)', 'powerpress');
                     break;
                 case 'rss_language':
                     echo __(' Feed Language', 'powerpress');
                     break;
                 case 'description':
                     echo __('Feed Description', 'powerpress');
                     break;
                 case 'copyright':
                     echo __('Copyright', 'powerpress');
                     break;
                 case 'itunes_talent_name':
                     echo __('iTunes Author Name', 'powerpress');
                     break;
                 case 'itunes_summary':
                     echo __('iTunes Program Summary', 'powerpress');
                     break;
                 case 'itunes_subtitle':
                     echo __('iTunes Program Subtitle', 'powerpress');
                     break;
                 case 'itunes_image':
                     echo __('iTunes Image', 'powerpress');
                     break;
                 case 'itunes_explicit':
                     echo __('iTunes Explicit', 'powerpress');
                     break;
                 case 'email':
                     echo __('iTunes Email', 'powerpress');
                     break;
                 case 'itunes_cat_1':
                     echo __('iTunes Category', 'powerpress');
                     break;
                 case 'itunes_cat_2':
                     echo __('iTunes Category 2', 'powerpress');
                     break;
                 case 'itunes_cat_3':
                     echo __('iTunes Category 3', 'powerpress');
                     break;
                 default:
                     echo $field . ': ' . htmlspecialchars($value);
                     break;
             }
             echo '</li>';
         }
         echo '</ul>';
     }
 }