feed_getCategory();
$this->tempFileSystemPath = ABSPATH.get_option('upload_path').'/podpress_temp';
$this->tempFileURLPath = get_settings('siteurl').'/'.get_option('upload_path').'/podpress_temp';
// load up podPress general config
$this->settings = podPress_get_option('podPress_config');
// make sure things look current, if not run the settings checker
if(!is_array($this->settings) || PODPRESS_VERSION > $this->settings['lastChecked']) {
$this->checkSettings();
}
if(is_object($GLOBALS['wp_rewrite'])
&& is_array($GLOBALS['wp_object_cache'])
&& is_array($GLOBALS['wp_object_cache']['cache'])
&& is_array($GLOBALS['wp_object_cache']['cache']['options'])
&& is_array($GLOBALS['wp_object_cache']['cache']['options']['alloptions'])
&& is_array($GLOBALS['wp_object_cache']['cache']['options']['alloptions']['rewrite_rules'])
&& !strpos($GLOBALS['wp_object_cache']['cache']['options']['alloptions']['rewrite_rules'], 'playlist.xspf')
) {
$GLOBALS['wp_rewrite']->flush_rules();
}
}
/*************************************************************/
/* Handle all the default values for a new install of plugin */
/*************************************************************/
function activate() {
GLOBAL $wpdb;
$current = get_option('podPress_version');
if(!$current) {
$current = 0;
}
if(function_exists('get_role')) {
$ps_role = get_role('premium_subscriber');
if(!$ps_role) {
add_role('premium_subscriber', 'Premium Subscriber', $caps);
$ps_role = get_role('premium_subscriber');
}
$ps_role = get_role('premium_subscriber');
if(!$ps_role->has_cap('premium_content')) {
$ps_role->add_cap('premium_content');
}
if(!$ps_role->has_cap('read')) {
$ps_role->add_cap('read');
}
$role = get_role('administrator');
if(!$role->has_cap('premium_content')) {
$role->add_cap('premium_content');
}
}
// Create stats table
$create_table = "CREATE TABLE ".$wpdb->prefix."podpress_statcounts (".
"postID int(11) NOT NULL default '0',".
"media varchar(255) NOT NULL,".
"total int(11) default '1',".
"feed int(11) default '0',".
"web int(11) default '0',".
"play int(11) default '0',".
"PRIMARY KEY (media)) TYPE=MyISAM;";
podPress_maybe_create_table($wpdb->prefix."podpress_statcounts", $create_table);
// Create stats table
$create_table = "CREATE TABLE ".$wpdb->prefix."podpress_stats (".
"id int(11) unsigned NOT NULL auto_increment,".
"postID int(11) NOT NULL default '0',".
"media varchar(255) NOT NULL default '',".
"method varchar(50) NOT NULL default '',".
"remote_ip varchar(15) NOT NULL default '',".
"country varchar(50) NOT NULL default '',".
"language VARCHAR(5) NOT NULL default '',".
"domain varchar(255) NOT NULL default '',".
"referer varchar(255) NOT NULL default '',".
"resource varchar(255) NOT NULL default '',".
"user_agent varchar(255) NOT NULL default '',".
"platform varchar(50) NOT NULL default '',".
"browser varchar(50) NOT NULL default '',".
"version varchar(15) NOT NULL default '',".
"dt int(10) unsigned NOT NULL default '0',".
"UNIQUE KEY id (id)) TYPE=MyISAM;";
podPress_maybe_create_table($wpdb->prefix."podpress_stats", $create_table);
if(function_exists('wp_cache_flush')) {
wp_cache_flush();
}
if($current == 0) {
$current = PODPRESS_VERSION;
add_option('podPress_version', $current);
}
$this->checkSettings();
}
function checkSettings() {
GLOBAL $wp_object_cache, $wp_rewrite;
if(!is_array($this->settings)) {
$this->settings = podPress_get_option('podPress_config');
if(!is_array($this->settings)) {
$this->settings = array();
}
}
$this->settings['lastChecked'] = PODPRESS_VERSION;
// Make sure some standard values are set.
$x = get_option('rss_language');
if(!$x || empty($x))
{
add_option('rss_language', 'en_us');
}
$x = get_option('rss_image');
if(!$x || empty($x))
{
podPress_update_option('rss_image', podPress_url().'images/powered_by_podpress.jpg');
}
if($this->settings['compatibilityChecks']['themeTested'] !== true) {
$this->settings['compatibilityChecks']['themeTested'] = false;
}
if($this->settings['compatibilityChecks']['wp_head'] !== true) {
$this->settings['compatibilityChecks']['wp_head'] = false;
}
if($this->settings['compatibilityChecks']['wp_footer'] !== true) {
$this->settings['compatibilityChecks']['wp_footer'] = false;
}
if(!is_bool($this->settings['enableStats'])) {
if($this->settings['enableStats']== 'true') {
$this->settings['enableStats'] = true;
} else {
$this->settings['enableStats'] = false;
}
}
if(!is_bool($this->settings['enableStats'])) {
if($this->settings['enableStats']== 'true') {
$this->settings['enableStats'] = true;
} else {
$this->settings['enableStats'] = false;
}
}
if(!$this->settings['statMethod'] || empty($this->settings['statMethod']) || $this->settings['statMethod'] == 'htaccess')
{
$this->settings['statMethod'] = 'permalinks';
}
if(!$this->settings['statLogging'] || empty($this->settings['statLogging']))
{
$this->settings['statLogging'] = 'Counts';
}
if(empty($this->settings['enable3rdPartyStats'])) {
$this->settings['enable3rdPartyStats'] = 'No';
}
if(!is_bool($this->settings['enableBlubrryStats'])) {
if($this->settings['enableBlubrryStats']== 'true') {
$this->settings['enableBlubrryStats'] = true;
} else {
$this->settings['enableBlubrryStats'] = false;
}
}
if(!$this->settings['rss_copyright'] || empty($this->settings['rss_copyright']))
{
$this->settings['rss_copyright'] = '2006-2007';
}
if(podPress_WPVersionCheck('2.0.0')) {
if(!is_bool($this->settings['enablePremiumContent'])) {
if($this->settings['enablePremiumContent']== 'true') {
$this->settings['enablePremiumContent'] = true;
} else {
$this->settings['enablePremiumContent'] = false;
}
}
} else {
$this->settings['enablePremiumContent'] = false;
}
if(empty($this->settings['premiumMethod'])) {
$this->settings['premiumMethod'] = 'Digest';
}
if(!defined('PODPRESS_PREMIUM_METHOD')) {
define('PODPRESS_PREMIUM_METHOD', $this->settings['premiumMethod']);
}
if(!is_bool($this->settings['enableTorrentCasting'])) {
if($this->settings['enableTorrentCasting']== 'true') {
$this->settings['enableTorrentCasting'] = true;
} else {
$this->settings['enableTorrentCasting'] = false;
}
}
if(empty($this->settings['podcastFeedURL'])) {
if(podPress_WPVersionCheck('2.1')) {
$this->settings['podcastFeedURL'] = get_settings('siteurl').'/?feed=podcast';
} else {
$this->settings['podcastFeedURL'] = get_settings('siteurl').'/?feed=rss2';
}
}
if(empty($this->settings['mediaWebPath'])) {
$this->settings['mediaWebPath'] = get_settings('siteurl').'/wp-content/uploads';
}
unset($this->settings['autoDetectedMediaFilePath']);
if(!file_exists($this->settings['mediaFilePath'])) {
$this->settings['autoDetectedMediaFilePath'] = str_replace(get_settings('siteurl'), '', $this->settings['mediaWebPath']);
$this->settings['autoDetectedMediaFilePath'] = ABSPATH.$this->settings['autoDetectedMediaFilePath'];
$this->settings['autoDetectedMediaFilePath'] = str_replace('\\\\', '\\', $this->settings['autoDetectedMediaFilePath']);
$this->settings['autoDetectedMediaFilePath'] = str_replace('//', '/', $this->settings['autoDetectedMediaFilePath']);
$this->settings['autoDetectedMediaFilePath'] = str_replace('//', '/', $this->settings['autoDetectedMediaFilePath']);
if(!file_exists($this->settings['autoDetectedMediaFilePath'])) {
$this->settings['autoDetectedMediaFilePath'] .= ' (Auto Detection Failed.)';
}
}
if(empty($this->settings['maxMediaFiles']) || $this->settings['maxMediaFiles'] < 1) {
$this->settings['maxMediaFiles'] = 5;
}
if(!$this->settings['contentBeforeMore'] || empty($this->settings['contentBeforeMore']))
{
$this->settings['contentBeforeMore'] = 'yes';
}
if(!$this->settings['contentLocation'] || empty($this->settings['contentLocation']))
{
$this->settings['contentLocation'] = 'end';
}
if(!$this->settings['contentImage'] || empty($this->settings['contentImage']))
{
$this->settings['contentImage'] = 'button';
}
if(!$this->settings['contentPlayer'] || empty($this->settings['contentPlayer']))
{
$this->settings['contentPlayer'] = 'both';
}
if(empty($this->settings['videoPreviewImage'])) {
$this->settings['videoPreviewImage'] = podPress_url().'images/vpreview_center.png';
}
if(!is_bool($this->settings['disableVideoPreview'])) {
if($this->settings['disableVideoPreview']== 'true') {
$this->settings['disableVideoPreview'] = true;
} else {
$this->settings['disableVideoPreview'] = false;
}
}
if(!$this->settings['contentDownload'] || empty($this->settings['contentDownload']))
{
$this->settings['contentDownload'] = 'enabled';
}
if(!$this->settings['contentDownloadText'] || empty($this->settings['contentDownloadText']))
{
$this->settings['contentDownloadText'] = 'enabled';
}
if(!$this->settings['contentDownloadStats'] || empty($this->settings['contentDownloadStats']))
{
$this->settings['contentDownloadStats'] = 'enabled';
}
if(!$this->settings['contentDuration'] || empty($this->settings['contentDuration']))
{
$this->settings['contentDuration'] = 'enabled';
}
if(!is_bool($this->settings['contentAutoDisplayPlayer'])) {
if($this->settings['contentAutoDisplayPlayer'] == 'false') {
$this->settings['contentAutoDisplayPlayer'] = false;
} else {
$this->settings['contentAutoDisplayPlayer'] = true;
}
}
if(!is_bool($this->settings['enableFooter'])) {
if($this->settings['enableFooter']== 'false') {
$this->settings['enableFooter'] = false;
} else {
$this->settings['enableFooter'] = true;
}
}
if($this->settings['player']['bg'] == '') {
$this->resetPlayerSettings();
}
if(empty($this->settings['iTunes']['summary'])) {
$this->settings['iTunes']['summary'] = stripslashes(get_option('blogdescription'));
} else {
$this->settings['iTunes']['summary'] = stripslashes($this->settings['iTunes']['summary']);
}
$this->settings['iTunes']['keywords'] = stripslashes($this->settings['iTunes']['keywords']);
$this->settings['iTunes']['subtitle'] = stripslashes($this->settings['iTunes']['subtitle']);
$this->settings['iTunes']['author'] = stripslashes($this->settings['iTunes']['author']);
$this->settings['iTunes']['FeedID'] = stripslashes($this->settings['iTunes']['FeedID']);
$this->settings['iTunes']['FeedID'] = str_replace(' ', '', $this->settings['iTunes']['FeedID']);
if(!empty($this->settings['iTunes']['FeedID']) && !is_numeric($this->settings['iTunes']['FeedID'])) {
$this->settings['iTunes']['FeedID'] = settype($this->settings['iTunes']['FeedID'], 'double');
}
if(empty($this->settings['iTunes']['explicit'])) {
$this->settings['iTunes']['explicit'] = 'No';
}
if(empty($this->settings['iTunes']['image'])) {
$x = get_option('rss_image');
if(isset($x) && $x != podPress_url().'images/powered_by_podpress.jpg') {
$this->settings['iTunes']['image'] = $x;
} else {
$this->settings['iTunes']['image'] = podPress_url().'images/powered_by_podpress_large.jpg';
}
}
if(empty($this->settings['iTunes']['new-feed-url'])) {
$this->settings['iTunes']['new-feed-url'] = 'Disable';
}
podPress_update_option('podPress_config', $this->settings);
if(is_object($wp_rewrite)
&& is_array($wp_object_cache)
&& is_array($wp_object_cache['cache'])
&& is_array($wp_object_cache['cache']['options'])
&& is_array($wp_object_cache['cache']['options']['alloptions'])
&& is_array($wp_object_cache['cache']['options']['alloptions']['rewrite_rules'])
&& !strpos($wp_object_cache['cache']['options']['alloptions']['rewrite_rules'], 'playlist.xspf')
) {
$wp_rewrite->flush_rules();
}
}
function deactivate() {
// at the moment I have nothing I would want to clean up
}
function iTunesLink() {
return '
';
}
function resetPlayerSettings() {
$result['bg'] = '#F8F8F8';
$result['leftbg'] = '#F8F8F8';
$result['text'] = '#666666';
$result['leftbg'] = '#EEEEEE';
$result['lefticon'] = '#666666';
$result['rightbg'] = '#CCCCCC';
$result['rightbghover'] = '#999999';
$result['righticon'] = '#666666';
$result['righticonhover'] = '#FFFFFF';
$result['slider'] = '#666666';
$result['track'] = '#FFFFFF';
$result['loader'] = '#9FFFB8';
$result['border'] = '#666666';
$result['listen_wrapper'] = 'off';
$this->settings['player'] = $result;
return $result;
}
function convertPodcastFileNameToValidWebPath($filename){
if(strpos(substr($filename, 0, 10), '://')) {
$url = $filename;
} else {
if(substr($filename, 0,1) == '/') {
$baseurl = strtolower(strtok($_SERVER['SERVER_PROTOCOL'], '/')).'://'.$_SERVER['HTTP_HOST'].$this->settings['mediaWebPath'];
} elseif(strpos(substr($this->settings['mediaWebPath'], 0, 10), '://')) {
$baseurl = $this->settings['mediaWebPath'];
} else {
$baseurl = get_settings('siteurl').$this->settings['mediaWebPath'];
}
if(substr($filename, -1, 1) != '/')
{
$baseurl .= '/';
}
$url = $baseurl.$filename;
}
return $url;
}
function convertPodcastFileNameToWebPath($postID, $mediaNum, $filename = '', $method = false){
$url = $this->convertPodcastFileNameToValidWebPath($filename);
if($method != false) {
if($this->settings['enableStats']) {
$filename_part = podPress_getFileName($url);
if($this->settings['statMethod'] == 'download.mp3') {
$url = podPress_url().'download.mp3?'.$method.'='.$postID.'/'.$mediaNum.'/'.$filename_part;
} else {
$url = get_settings('siteurl').'/podpress_trac/'.$method.'/'.$postID.'/'.$mediaNum.'/'.$filename_part;
}
} elseif($this->settings['enable3rdPartyStats'] == 'Podtrac') {
$url = str_replace(array('ftp://', 'http://', 'https://'), '', $url);
$url = $this->podtrac_url.$url;
} elseif($this->settings['enable3rdPartyStats'] == 'BluBrry' && !empty($this->settings['statBluBrryProgramKeyword'])) {
$url = $this->blubrry_url.$this->settings['statBluBrryProgramKeyword'].'/'.$url;
}
}
$url = str_replace(' ', '%20', $url);
return $url;
}
function convertPodcastFileNameToSystemPath($filename = ''){
if(!strpos(substr($filename, 0, 10), '://')) {
$filename = $this->settings['mediaFilePath'].'/'.$filename;
if(file_exists($filename))
{
return $filename;
}
}
return false;
}
function checkWritableTempFileDir($showErrors = true) {
/* check, if user-upload path is set */
$this->uploadPath = ABSPATH.get_option('upload_path');
if (file_exists($this->tempFileSystemPath)) {
if(is_writable($this->tempFileSystemPath)) {
return true;
} else {
if($showErrors) {
echo '
'.__('Your uploads/podpress_temp directory is not writable. Please set permissions as needed, and make sure configuration is correct.', 'podpress').'
Currently set to:'.get_option('upload_path')."/podpress_temp
'.__('Your WordPress upload directory does not exist. Please create it and make sure configuration is correct.', 'podpress').'
Currently set to:'.get_option('upload_path')."
'.__('Your WordPress upload directory is not writable. Please set permissions as needed, and make sure configuration is correct.', 'podpress').'
Currently set to:'.get_option('upload_path')."
'.__('Could not create uploads/podpress_temp directory. Please set permission of the following directory to 755 or 777:', 'podpress').''.get_option('upload_path')."/podpress_temp
podPress theme compatibility problem. Please check podPress->General Settings for more information.